Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listMay 17, 2026 13:53M-RochatM-RochatError
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2026 14:000220,398,003207,906,0001,009,0002,113,536expected "403602732 ", got "diag bytes=267164586 lines=1000000 usd=199900 eur=0 other=800100 first=333225,333699,333076,0 txBeforeCur=499725 txBeforeUser=499717 s0={"transactions": [{"amount": 254, "to_user_id": 655, "canceled": false}, {"amount": 635,...
2May 17, 2026 14:000217,920,303207,766,0001,017,0002,113,536expected "405100255 ", got "diag bytes=267096289 lines=1000000 usd=199793 eur=0 other=800207 first=332965,333873,333162,0 txBeforeCur=499994 txBeforeUser=500399 s0={"transactions": [{"canceled": false, "to_user_id": 8315, "amount": 367}, {"amount": 151...
3May 17, 2026 14:000217,622,223207,742,0001,058,0002,113,536expected "404388527 ", got "diag bytes=267062249 lines=1000000 usd=200233 eur=0 other=799767 first=333716,332746,333538,0 txBeforeCur=500426 txBeforeUser=499836 s0={"user_id": 1047, "transactions": [{"canceled": false, "to_user_id": 7309, "amount": 785...