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 01:34M-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 01:340221,603,943208,778,0001,093,0002,113,536expected "403310825 ", got "diag bytes=267047207 lines=1000000 usd=200013 eur=0 other=799987 first=333330,332953,333717,0 txBeforeCur=500059 txBeforeUser=500222 s0={"currency": "USD", "transactions": [{"amount": 418, "to_user_id": 8618, "canceled": fal...
2May 17, 2026 01:340219,117,999208,611,0001,012,0002,113,536expected "404498810 ", got "diag bytes=267039013 lines=1000000 usd=199900 eur=0 other=800100 first=333364,333650,332986,0 txBeforeCur=499423 txBeforeUser=499859 s0={"user_id": 7908, "currency": "USD", "transactions": [{"canceled": false, "amount": 475,...
3May 17, 2026 01:340218,682,945208,892,0001,045,0002,113,536expected "406530443 ", got "diag bytes=267240881 lines=1000000 usd=200817 eur=0 other=799183 first=333166,333651,333183,0 txBeforeCur=499684 txBeforeUser=499604 s0={"currency": "USD", "user_id": 735, "transactions": [{"amount": 331, "to_user_id": 4900}...