Submission details
Task:Sum of ones
Sender:aalto26em_008
Submission time:2026-09-28 16:36:14 +0300
Language:C++ (C++23)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails
#150.00 sdetails
#160.00 sdetails
#170.00 sdetails
#180.00 sdetails
#190.00 sdetails
#200.00 sdetails
#210.00 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:7:9: warning: unused variable 'm' [-Wunused-variable]
    7 |     int m = 0;
      |         ^

Code

#include "iostream"
#include "map"

int main() {
    int n;
    std::cin >> n;
    int m = 0;
    long total = 0;
    std::map<long, int> dict;
    for (long i = 1; i <= n ; i++) {
        long num = i;
        int subtot = 0;
        while(num > 0) {
            if (dict.at(num)) {
                subtot += dict.at(num);
                break;
            }
            subtot += (num % 2);
            num /= 2;
        }
        dict.insert_or_assign(i, subtot);
        total += subtot;
    }
    std::cout << total << std::endl;
}

Test details

Test 1

Verdict:

input
1

correct output
1

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 2

Verdict:

input
2

correct output
2

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 3

Verdict:

input
3

correct output
4

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 4

Verdict:

input
4

correct output
5

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 5

Verdict:

input
5

correct output
7

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 6

Verdict:

input
6

correct output
9

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 7

Verdict:

input
7

correct output
12

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 8

Verdict:

input
8

correct output
13

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 9

Verdict:

input
9

correct output
15

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 10

Verdict:

input
10

correct output
17

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 11

Verdict:

input
303021765044187

correct output
7250167017244884

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 12

Verdict:

input
390977392667778

correct output
9400236781929604

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 13

Verdict:

input
670904313808571

correct output
16399391652009372

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 14

Verdict:

input
704275111916256

correct output
17252936460583174

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 15

Verdict:

input
799807335176164

correct output
19646099779305746

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 16

Verdict:

input
852012055430877

correct output
21005540865890493

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 17

Verdict:

input
901305628563213

correct output
22232965316761961

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 18

Verdict:

input
917427461591619

correct output
22650112032503064

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 19

Verdict:

input
981787468874797

correct output
24322274256024775

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 20

Verdict:

input
1000000000000000

correct output
24784747400675348

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Test 21

Verdict:

input
989898989898989

correct output
24531282955144033

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at