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
Sep 5, 2021 12:24Andrey TsvetkovAndrey TsvetkovGOgo1.17Success8,835+24.32 RP
Sep 2, 2021 05:42Ilya AniskovetsIlya AniskovetsCPPg++9.3.0Success591,502+16.91 RP
Aug 30, 2021 13:42Mikhail SmetannikovMikhail SmetannikovGOgo1.17Error
Aug 30, 2021 13:41Mikhail SmetannikovMikhail SmetannikovGOgo1.17Success120,478+0.06 RP
Aug 30, 2021 13:40Mikhail SmetannikovMikhail SmetannikovGOgo1.17Error
Aug 30, 2021 13:39Mikhail SmetannikovMikhail SmetannikovGOgo1.17Error
Aug 30, 2021 13:32Mikhail SmetannikovMikhail SmetannikovGOgo1.17Success120,568+62.72 RP
Aug 30, 2021 13:29Mikhail SmetannikovMikhail SmetannikovGOgo1.17Success519,127
Aug 30, 2021 13:17Mikhail SmetannikovMikhail SmetannikovGOgo1.17Success494,435+20.23 RP
Aug 21, 2021 17:40Yuriy LyfenkoYuriy LyfenkoCPPg++9.3.0Success3,908
Aug 21, 2021 17:39Yuriy LyfenkoYuriy LyfenkoCPPclang++10.0.0Success4,468
Jun 27, 2021 08:49gchebanovgchebanovCPPError
Jun 27, 2021 08:34gchebanovgchebanovCPPError
Jun 27, 2021 07:38gchebanovgchebanovCPPSuccess549,526+18.20 RP
Jun 25, 2021 09:32alex3dalex3dCPPSuccess63,878
Jun 25, 2021 09:28alex3dalex3dCPPSuccess64,330
Jun 24, 2021 21:26alex3dalex3dCPPSuccess64,074
Jun 24, 2021 21:24alex3dalex3dCPPSuccess62,925
Jun 24, 2021 21:21alex3dalex3dCPPSuccess62,120
Jun 24, 2021 21:20alex3dalex3dCPPSuccess63,749
Jun 24, 2021 21:14alex3dalex3dCPPSuccess64,024
Jun 24, 2021 20:45alex3dalex3dCPPSuccess64,004
Jun 24, 2021 20:44alex3dalex3dCPPSuccess64,040
Jun 24, 2021 20:44alex3dalex3dCPPSuccess64,089
Jun 24, 2021 20:44alex3dalex3dCPPSuccess64,199
Jun 24, 2021 20:41alex3dalex3dCPPSuccess63,977
Jun 24, 2021 20:41alex3dalex3dCPPSuccess63,906
Jun 24, 2021 20:41alex3dalex3dCPPSuccess63,950
Jun 24, 2021 20:39alex3dalex3dCPPSuccess64,371
Jun 24, 2021 20:37alex3dalex3dCPPSuccess64,385
Jun 24, 2021 20:36alex3dalex3dCPPSuccess63,936
Jun 24, 2021 20:29alex3dalex3dCPPSuccess63,720
Jun 24, 2021 20:28alex3dalex3dCPPSuccess64,785
Jun 24, 2021 20:27alex3dalex3dCPPSuccess64,225
Jun 24, 2021 20:25alex3dalex3dCPPSuccess63,953
Jun 24, 2021 20:23alex3dalex3dCPPSuccess64,482
Jun 24, 2021 20:02alex3dalex3dCPPSuccess63,862
Jun 24, 2021 20:01alex3dalex3dCPPSuccess64,002
Jun 24, 2021 20:01alex3dalex3dCPPSuccess63,918
Jun 24, 2021 20:00alex3dalex3dCPPSuccess63,900
Jun 24, 2021 19:55alex3dalex3dCPPSuccess64,323
Jun 23, 2021 19:46alex3dalex3dCPPSuccess62,674
Jun 23, 2021 19:43alex3dalex3dCPPSuccess61,981
Jun 22, 2021 17:54alex3dalex3dCPPSuccess62,226
Jun 22, 2021 17:51alex3dalex3dCPPSuccess62,494
Jun 22, 2021 12:49alex3dalex3dCPPSuccess61,988
Jun 22, 2021 11:59alex3dalex3dCPPSuccess62,496
Jun 22, 2021 10:49alex3dalex3dCPPSuccess62,206
Jun 22, 2021 10:18alex3dalex3dCPPSuccess62,147
Jun 22, 2021 10:17alex3dalex3dCPPError
Jun 22, 2021 10:17alex3dalex3dCPPSuccess63,324
Jun 22, 2021 10:15alex3dalex3dCPPError
Jun 22, 2021 10:11alex3dalex3dCPPSuccess63,323
Jun 22, 2021 10:10alex3dalex3dCPPSuccess63,696
Jun 22, 2021 09:32alex3dalex3dCPPSuccess63,372
Jun 22, 2021 09:31alex3dalex3dCPPSuccess63,931
Jun 22, 2021 09:28alex3dalex3dCPPSuccess63,024
Jun 22, 2021 09:19alex3dalex3dCPPSuccess62,145
Jun 22, 2021 06:55alex3dalex3dCPPSuccess62,298
Jun 22, 2021 06:48alex3dalex3dCPPSuccess63,046
Jun 22, 2021 06:44alex3dalex3dCPPSuccess62,882
Jun 22, 2021 06:42alex3dalex3dCPPError
Jun 22, 2021 06:39alex3dalex3dCPPSuccess63,607
Jun 22, 2021 06:32alex3dalex3dCPPSuccess62,212
Jun 22, 2021 06:26alex3dalex3dCPPSuccess62,518
Jun 22, 2021 06:22alex3dalex3dCPPSuccess62,581
Jun 22, 2021 06:19alex3dalex3dCPPSuccess62,539
Jun 22, 2021 06:16alex3dalex3dCPPSuccess62,461
Jun 22, 2021 06:15alex3dalex3dCPPError
Jun 22, 2021 06:03alex3dalex3dCPPError
Jun 22, 2021 05:57alex3dalex3dCPPError
Jun 22, 2021 05:56alex3dalex3dCPPError
Jun 22, 2021 05:54alex3dalex3dCPPError
Jun 22, 2021 05:52alex3dalex3dCPPError
Jun 22, 2021 05:48alex3dalex3dCPPError
Jun 22, 2021 05:44alex3dalex3dCPPError
Jun 22, 2021 05:41alex3dalex3dCPPSuccess53,158
Jun 21, 2021 20:48alex3dalex3dCPPError
Jun 21, 2021 20:35alex3dalex3dCPPError
Jun 21, 2021 20:14alex3dalex3dCPPSuccess53,455
Jun 20, 2021 20:29alex3dalex3dCPPSuccess53,405
Jun 20, 2021 20:25alex3dalex3dCPPSuccess52,726
Jun 20, 2021 18:50Sergey StreminSergey StreminRUSTSuccess5,876+102.26 RP
Jun 20, 2021 18:49Sergey StreminSergey StreminRUSTSuccess8,005
Jun 20, 2021 18:46Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:43Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:41Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:40Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:39Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:37Sergey StreminSergey StreminRUSTSuccess6,058+2.72 RP
Jun 20, 2021 18:24Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:20Sergey StreminSergey StreminRUSTSuccess6,063+56.68 RP
Jun 20, 2021 18:19Sergey StreminSergey StreminRUSTSuccess8,093
Jun 20, 2021 18:13Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:11Sergey StreminSergey StreminRUSTError
Jun 20, 2021 18:09Sergey StreminSergey StreminRUSTError
Jun 20, 2021 17:13alex3dalex3dCPPSuccess52,250
Jun 20, 2021 15:05Andrey TsvetkovAndrey TsvetkovGOError
Jun 20, 2021 15:04Andrey TsvetkovAndrey TsvetkovGOError
Jun 20, 2021 15:01Andrey TsvetkovAndrey TsvetkovGOError