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
Date AuthorLanguageStatus Score
Apr 9, 2026 06:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:41olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:40olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:37olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:37olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:36olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:35olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:33olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:32olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:32olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:31olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:30olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:30olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:26olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:24olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:22olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:21olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:20olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:20olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:19olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:19olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:16olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:16olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:15olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:14olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:14olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:13olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:11olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:09olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:05olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:04olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:04olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:03olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:03olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:59olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:58olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:58olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:57olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:57olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:56olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:54olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:52olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:51olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:51olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:48olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:48olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:47olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:47olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:46olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:46olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:43olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:43olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:41olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:40olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:38olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:37olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:36olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:35olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:35olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:32olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:31olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:30olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:30olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:29olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:24olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:23olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:21olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:21olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:19olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:18olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:17olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:15olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:15olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:14olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:14olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:12olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:09olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:09olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 05:05olliecrowolliecrowCPPg++13.3.0Error