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 14:31M-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:310302,559,201292,559,0001,107,0002,113,536expected "403301693 ", got "diag2 bytes=267217664 lines=1000000 usd=199244 txRecords=1000000 txTotal=4500392 txUsd=897409 lenAvg=266 lenMax=558 txHist=100002,99882,100205,99702,100015,100133,99709,100403,100347,99602,0,0 topOrd=166639,165985,166703,167...
2May 17, 2026 14:310302,711,527292,597,0001,097,0002,113,536expected "404468818 ", got "diag2 bytes=267166719 lines=1000000 usd=200034 txRecords=1000000 txTotal=4500027 txUsd=900041 lenAvg=266 lenMax=558 txHist=100495,99745,100285,99883,99276,100064,99667,100428,99772,100385,0,0 topOrd=165922,166475,166079,1671...
3May 17, 2026 14:310302,610,742292,300,0001,040,0002,113,536expected "404062018 ", got "diag2 bytes=267117249 lines=1000000 usd=199470 txRecords=1000000 txTotal=4498914 txUsd=898265 lenAvg=266 lenMax=558 txHist=100217,100124,99809,100047,99976,99755,100113,100019,99919,100021,0,0 topOrd=166925,166485,166501,167...