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 08:38olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:37olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:34olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:33olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:33olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:32olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:31olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:31olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:12olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:11olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:07olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:07olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:06olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:05olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:04olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:02olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:02olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:01olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 08:01olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:59olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:58olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:57olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:56olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:56olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:55olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:51olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:50olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:50olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:49olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:48olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:47olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:45olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:45olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:44olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:43olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:42olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:41olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:40olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:39olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:38olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:38olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:36olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:36olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:34olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:33olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:33olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:32olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:31olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:30olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:28olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:28olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:27olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:25olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:23olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:22olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:22olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:21olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:19olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:19olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:17olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:17olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:16olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:16olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:14olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:13olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:12olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:11olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:11olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:10olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:08olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:06olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:05olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:05olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:03olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:02olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:01olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:00olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 07:00olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:59olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:57olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:55olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:54olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:54olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:53olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:51olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:49olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:49olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:48olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:48olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:47olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:46olliecrowolliecrowCPPg++13.3.0Error
Apr 9, 2026 06:43olliecrowolliecrowCPPg++13.3.0Error