QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143303#4565. Rarest Insectsbashkort82.99 51ms3900kbC++203.8kb2023-08-21 01:30:462023-08-21 01:31:00

Judging History

你现在查看的是最新测评结果

  • [2023-08-21 01:31:00]
  • 评测
  • 测评结果:82.99
  • 用时:51ms
  • 内存:3900kb
  • [2023-08-21 01:30:46]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

mt19937 rnd(1337);

int min_cardinality(int N) {
    vector<int> a(N);
    iota(a.begin(), a.end(), 0);

    for (int t = 0; t < 3; ++t) {
        for (int i = 0; i < N; ++i) {
            swap(a[i], a[rnd() % N]);
        }
    }

    vector<int> leaders, inside(N);
    int maxSize = 0, T = 0, cntIn = 0, lastQueryT = 0;
    int queriesCnt[3]{};

    auto insert = [&](int x) -> void {
        if (inside[x]) {
            return;
        }
        cntIn += 1;
        move_inside(x);
        T += 1;
        queriesCnt[0] += 1;
        inside[x] = true;
    };

    auto erase = [&](int x) -> void {
        if (!inside[x]) {
            return;
        }
        cntIn -= 1;
        move_outside(x);
        T += 1;
        queriesCnt[1] += 1;
        inside[x] = false;
    };

    auto query = [&]() -> int {
        if (T == lastQueryT) {
            return maxSize;
        }
        lastQueryT = T;
        queriesCnt[2] += 1;
        return maxSize = press_button();
    };

    vector<int> others;

    for (int x : a) {
        insert(x);
        if (query() == 1) {
            leaders.push_back(x);
        } else {
            others.push_back(x);
            erase(x);
        }
    };


    int ans = N;
    if (size(leaders) > size(others)) {
        return 1;
    } else if (size(leaders) == 1) {
        return N;
    }

    if (size(leaders) < sqrt(N) / 1.2) {
        shuffle(leaders.begin(), leaders.end(), rnd);
        auto dfs = [&](auto dfs, vector<int> lead, vector<int> oth, int isFull) -> void {
            if (ans == 1) {
                return;
            }
            if (size(lead) == 1) {
                ans = min<int>(ans, 1 + size(oth));
                return;
            }
            if (size(lead) > size(oth)) {
                ans = 1;
                return;
            }
            int mid = size(lead) / 2;
            vector<int> leadLeft(lead.begin(), lead.begin() + mid);
            vector<int> leadRight(lead.begin() + mid, lead.end());
            vector<int> nxt[2];
            if (isFull) {
                for (int x: leadRight) {
                    erase(x);
                }
            } else {
                for (int x: leadLeft) {
                    insert(x);
                }
            }
            for (int x: oth) {
                insert(x);
                if (query() == 1) {
                    nxt[1].push_back(x);
                } else {
                    nxt[0].push_back(x);
                }
                erase(x);
            }
            dfs(dfs, leadLeft, nxt[0], true);
            dfs(dfs, leadRight, nxt[1], false);
        };

        dfs(dfs, leaders, others, true);
        return ans;
    } else {
        shuffle(others.begin(), others.end(), rnd);
        int lo = 1, hi = 2 + size(others) / size(leaders);
        while (lo + 1 < hi) {
            int mid = lo + hi >> 1;
            if (query() > mid) {
                for (int x : others) {
                    erase(x);
                }
            }
            bool yay = false;
            int left = size(others);
            for (int x : others) {
                insert(x);
                left -= 1;
                if (query() > mid) {
                    erase(x);
                }
                if (size(leaders) * mid == cntIn) {
                    yay = true;
                    break;
                } else if (size(leaders) * mid > cntIn + left) {
                    break;
                }
            }
            if (yay) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
}


Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 3808kb

input:

6
1
2
1
2
1
2
1
2
2
3

output:

8
0 5
8
2
8
0 4
8
2
8
1 4
8
0 0
8
2
8
0 2
8
2
8
1 2
8
0 1
8
2
8
0 3
8
2
8
1 3
8
2
8
0 3
8
2
8
0 4
8
2
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

2
1
2

output:

8
0 1
8
2
8
0 0
8
2
8
1 0
8
3 2

result:

ok 

Test #3:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
1
1

output:

8
0 1
8
2
8
0 0
8
2
8
3 1

result:

ok 

Test #4:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

3
1
1
2

output:

8
0 1
8
2
8
0 0
8
2
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #5:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

5
1
1
2
2
2
1
2
2

output:

8
0 1
8
2
8
0 3
8
2
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 0
8
2
8
1 0
8
2
8
0 2
8
2
8
0 0
8
2
8
3 2

result:

ok 

Test #6:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

8
1
2
1
1
2
2
2
2
1
2
3
3
3

output:

8
0 1
8
2
8
0 4
8
2
8
1 4
8
0 7
8
2
8
0 6
8
2
8
0 2
8
2
8
1 2
8
0 5
8
2
8
1 5
8
0 3
8
2
8
1 3
8
0 0
8
2
8
1 0
8
2
8
0 5
8
2
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #7:

score: 0
Accepted
time: 3ms
memory: 3756kb

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 24
8
2
8
0 127
8
2
8
1 127
8
0 49
8
2
8
1 49
8
0 4
8
2
8
1 4
8
0 146
8
2
8
1 146
8
0 70
8
2
8
1 70
8
0 171
8
2
8
1 171
8
0 137
8
2
8
1 137
8
0 98
8
2
8
1 98
8
0 22
8
2
8
1 22
8
0 38
8
2
8
1 38
8
0 135
8
2
8
1 135
8
0 39
8
2
8
1 39
8
0 194
8
2
8
1 194
8
0 169
8
2
8
1 169
8
0 9
8
2
8
1 9
8
0 131
8...

result:

ok 

Test #8:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 82
8
2
8
0 64
8
2
8
0 126
8
2
8
0 75
8
2
8
0 25
8
2
8
0 72
8
2
8
0 186
8
2
8
0 67
8
2
8
0 39
8
2
8
0 142
8
2
8
0 139
8
2
8
0 145
8
2
8
0 76
8
2
8
0 9
8
2
8
0 69
8
2
8
0 29
8
2
8
0 19
8
2
8
0 17
8
2
8
0 0
8
2
8
0 59
8
2
8
0 16
8
2
8
0 181
8
2
8
0 23
8
2
8
0 156
8
2
8
0 140
8
2
8
0 134
8
2
8
0 123...

result:

ok 

Test #9:

score: 0
Accepted
time: 6ms
memory: 3752kb

input:

200
1
2
1
1
1
1
1
1
2
2
1
1
1
2
1
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 82
8
2
8
0 64
8
2
8
1 64
8
0 126
8
2
8
0 75
8
2
8
0 25
8
2
8
0 72
8
2
8
0 186
8
2
8
0 67
8
2
8
0 39
8
2
8
1 39
8
0 142
8
2
8
1 142
8
0 139
8
2
8
0 145
8
2
8
0 76
8
2
8
0 9
8
2
8
1 9
8
0 69
8
2
8
0 29
8
2
8
0 19
8
2
8
1 19
8
0 17
8
2
8
0 0
8
2
8
1 0
8
0 59
8
2
8
1 59
8
0 16
8
2
8
0 181
8
2
8
1 18...

result:

ok 

Test #10:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

198
1
1
1
1
1
1
1
1
2
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 162
8
2
8
0 24
8
2
8
0 42
8
2
8
0 54
8
2
8
0 192
8
2
8
0 134
8
2
8
0 77
8
2
8
0 141
8
2
8
0 11
8
2
8
1 11
8
0 155
8
2
8
1 155
8
0 185
8
2
8
0 104
8
2
8
1 104
8
0 58
8
2
8
1 58
8
0 114
8
2
8
1 114
8
0 183
8
2
8
1 183
8
0 128
8
2
8
0 146
8
2
8
1 146
8
0 169
8
2
8
1 169
8
0 76
8
2
8
1 76
8
0 35
8
2...

result:

ok 

Test #11:

score: 0
Accepted
time: 7ms
memory: 3692kb

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 24
8
2
8
0 127
8
2
8
1 127
8
0 49
8
2
8
1 49
8
0 4
8
2
8
1 4
8
0 146
8
2
8
1 146
8
0 70
8
2
8
1 70
8
0 171
8
2
8
1 171
8
0 137
8
2
8
1 137
8
0 98
8
2
8
1 98
8
0 22
8
2
8
1 22
8
0 38
8
2
8
1 38
8
0 135
8
2
8
1 135
8
0 39
8
2
8
1 39
8
0 194
8
2
8
1 194
8
0 169
8
2
8
1 169
8
0 9
8
2
8
1 9
8
0 131
8...

result:

ok 

Test #12:

score: 0
Accepted
time: 3ms
memory: 3580kb

input:

197
1
2
1
1
2
1
1
2
2
2
1
1
2
1
1
2
1
1
1
2
2
2
2
1
2
1
1
2
1
2
1
1
1
1
1
2
1
1
1
1
2
1
1
2
2
2
1
1
2
2
1
2
2
1
2
2
2
1
1
1
2
2
2
2
2
1
2
2
2
2
2
2
1
1
2
2
1
1
2
1
1
2
2
2
1
2
1
1
2
1
1
1
1
2
2
1
2
2
2
2
1
2
2
1
2
2
1
1
1
1
1
1
2
2
1
2
2
2
1
1
1
1
1
2
2
1
1
2
1
2
2
1
1
2
2
1
2
2
2
2
1
1
2
1
2
2
1
1
...

output:

8
0 32
8
2
8
0 41
8
2
8
1 41
8
0 164
8
2
8
0 95
8
2
8
0 184
8
2
8
1 184
8
0 194
8
2
8
0 28
8
2
8
0 48
8
2
8
1 48
8
0 76
8
2
8
1 76
8
0 119
8
2
8
1 119
8
0 31
8
2
8
0 45
8
2
8
0 142
8
2
8
1 142
8
0 108
8
2
8
0 170
8
2
8
0 124
8
2
8
1 124
8
0 159
8
2
8
0 109
8
2
8
0 165
8
2
8
0 84
8
2
8
1 84
8
0 111
8...

result:

ok 

Test #13:

score: 0
Accepted
time: 3ms
memory: 3692kb

input:

197
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 32
8
2
8
0 41
8
2
8
0 164
8
2
8
0 95
8
2
8
0 184
8
2
8
1 184
8
0 194
8
2
8
1 194
8
0 28
8
2
8
1 28
8
0 48
8
2
8
1 48
8
0 76
8
2
8
1 76
8
0 119
8
2
8
1 119
8
0 31
8
2
8
1 31
8
0 45
8
2
8
1 45
8
0 142
8
2
8
1 142
8
0 108
8
2
8
1 108
8
0 170
8
2
8
1 170
8
0 124
8
2
8
1 124
8
0 159
8
2
8
1 159
8
0 1...

result:

ok 

Test #14:

score: 0
Accepted
time: 2ms
memory: 3808kb

input:

198
1
1
1
1
1
1
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 162
8
2
8
0 24
8
2
8
0 42
8
2
8
0 54
8
2
8
0 192
8
2
8
0 134
8
2
8
0 77
8
2
8
0 141
8
2
8
1 141
8
0 11
8
2
8
0 155
8
2
8
1 155
8
0 185
8
2
8
1 185
8
0 104
8
2
8
0 58
8
2
8
1 58
8
0 114
8
2
8
1 114
8
0 183
8
2
8
1 183
8
0 128
8
2
8
1 128
8
0 146
8
2
8
1 146
8
0 169
8
2
8
1 169
8
0 76
8
2
8
1 76
8...

result:

ok 

Test #15:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

200
1
2
2
1
1
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 82
8
2
8
0 64
8
2
8
1 64
8
0 126
8
2
8
1 126
8
0 75
8
2
8
0 25
8
2
8
0 72
8
2
8
0 186
8
2
8
1 186
8
0 67
8
2
8
1 67
8
0 39
8
2
8
1 39
8
0 142
8
2
8
0 139
8
2
8
1 139
8
0 145
8
2
8
1 145
8
0 76
8
2
8
1 76
8
0 9
8
2
8
1 9
8
0 69
8
2
8
1 69
8
0 29
8
2
8
1 29
8
0 19
8
2
8
1 19
8
0 17
8
2
8
1 17
8
0 ...

result:

ok 

Test #16:

score: 0
Accepted
time: 6ms
memory: 3588kb

input:

196
1
1
1
2
2
1
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 131
8
2
8
0 48
8
2
8
0 97
8
2
8
0 57
8
2
8
1 57
8
0 129
8
2
8
1 129
8
0 56
8
2
8
0 3
8
2
8
1 3
8
0 46
8
2
8
1 46
8
0 80
8
2
8
0 172
8
2
8
1 172
8
0 19
8
2
8
0 116
8
2
8
1 116
8
0 160
8
2
8
1 160
8
0 74
8
2
8
1 74
8
0 60
8
2
8
1 60
8
0 162
8
2
8
1 162
8
0 135
8
2
8
0 133
8
2
8
1 133
8
0 76
8
2
8
...

result:

ok 

Test #17:

score: 0
Accepted
time: 9ms
memory: 3692kb

input:

199
1
1
1
1
2
1
2
2
1
1
2
2
2
2
2
2
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 24
8
2
8
0 127
8
2
8
0 49
8
2
8
0 4
8
2
8
0 146
8
2
8
1 146
8
0 70
8
2
8
0 171
8
2
8
1 171
8
0 137
8
2
8
1 137
8
0 98
8
2
8
0 22
8
2
8
0 38
8
2
8
1 38
8
0 135
8
2
8
1 135
8
0 39
8
2
8
1 39
8
0 194
8
2
8
1 194
8
0 169
8
2
8
1 169
8
0 9
8
2
8
1 9
8
0 131
8
2
8
0 20
8
2
8
1 20
8
0 0
8
2
8
1 0
8
0 4...

result:

ok 

Test #18:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

196
1
1
1
2
1
1
2
1
2
2
1
2
2
1
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 131
8
2
8
0 48
8
2
8
0 97
8
2
8
0 57
8
2
8
1 57
8
0 129
8
2
8
0 56
8
2
8
0 3
8
2
8
1 3
8
0 46
8
2
8
0 80
8
2
8
1 80
8
0 172
8
2
8
1 172
8
0 19
8
2
8
0 116
8
2
8
1 116
8
0 160
8
2
8
1 160
8
0 74
8
2
8
0 60
8
2
8
0 162
8
2
8
1 162
8
0 135
8
2
8
0 133
8
2
8
1 133
8
0 76
8
2
8
1 76
8
0 109
8
2
8
1 1...

result:

ok 

Test #19:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

196
1
1
1
1
1
1
2
1
1
1
2
1
2
2
2
1
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 131
8
2
8
0 48
8
2
8
0 97
8
2
8
0 57
8
2
8
0 129
8
2
8
0 56
8
2
8
0 3
8
2
8
1 3
8
0 46
8
2
8
0 80
8
2
8
0 172
8
2
8
0 19
8
2
8
1 19
8
0 116
8
2
8
0 160
8
2
8
1 160
8
0 74
8
2
8
1 74
8
0 60
8
2
8
1 60
8
0 162
8
2
8
0 135
8
2
8
1 135
8
0 133
8
2
8
0 76
8
2
8
1 76
8
0 109
8
2
8
1 109
8
0 0
8
2
8
1 ...

result:

ok 

Test #20:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

196
1
1
1
1
1
1
1
2
2
1
1
2
1
2
2
2
1
1
1
1
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 131
8
2
8
0 48
8
2
8
0 97
8
2
8
0 57
8
2
8
0 129
8
2
8
0 56
8
2
8
0 3
8
2
8
0 46
8
2
8
1 46
8
0 80
8
2
8
1 80
8
0 172
8
2
8
0 19
8
2
8
0 116
8
2
8
1 116
8
0 160
8
2
8
0 74
8
2
8
1 74
8
0 60
8
2
8
1 60
8
0 162
8
2
8
1 162
8
0 135
8
2
8
0 133
8
2
8
0 76
8
2
8
0 109
8
2
8
0 0
8
2
8
1 0
8
0 155
8
2
...

result:

ok 

Test #21:

score: 0
Accepted
time: 6ms
memory: 3704kb

input:

200
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
2
2
2
1
1
1
1
1
1
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
1
1
2
1
2
2
1
1
1
2
2
2
2
2
1
1
1
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 82
8
2
8
0 64
8
2
8
0 126
8
2
8
0 75
8
2
8
0 25
8
2
8
0 72
8
2
8
0 186
8
2
8
0 67
8
2
8
0 39
8
2
8
0 142
8
2
8
0 139
8
2
8
0 145
8
2
8
1 145
8
0 76
8
2
8
0 9
8
2
8
0 69
8
2
8
0 29
8
2
8
0 19
8
2
8
0 17
8
2
8
0 0
8
2
8
0 59
8
2
8
1 59
8
0 16
8
2
8
0 181
8
2
8
1 181
8
0 23
8
2
8
1 23
8
0 156
8
2
8...

result:

ok 

Test #22:

score: 0
Accepted
time: 5ms
memory: 3684kb

input:

199
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
2
2
1
2
1
1
1
2
2
1
2
1
2
2
2
1
2
1
2
2
1
2
1
2
1
2
1
2
1
2
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
1
2
1
2
2
1
2
1
2
2
2
2
1
2
2
2
2
1
2
1
1
1
1
2
2
2
2
1
2
2
2
1
2
1
2
1
2
2
2
2
2
1
1
1
1
2
2
1
2
1
2
2
2
2
2
2
2
2
...

output:

8
0 24
8
2
8
0 127
8
2
8
0 49
8
2
8
0 4
8
2
8
0 146
8
2
8
0 70
8
2
8
0 171
8
2
8
0 137
8
2
8
1 137
8
0 98
8
2
8
0 22
8
2
8
0 38
8
2
8
0 135
8
2
8
0 39
8
2
8
0 194
8
2
8
0 169
8
2
8
0 9
8
2
8
0 131
8
2
8
1 131
8
0 20
8
2
8
0 0
8
2
8
0 47
8
2
8
0 196
8
2
8
0 118
8
2
8
0 61
8
2
8
0 185
8
2
8
0 51
8
2
8...

result:

ok 

Test #23:

score: 0
Accepted
time: 7ms
memory: 3684kb

input:

198
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
2
2
1
2
1
1
2
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
1
2
1
2
1
2
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
2
2
1
1
2
2
1
2
1
1
1
1
1
2
1
1
1
2
1
2
1
2
1
1
2
2
1
1
1
2
2
1
2
1
1
2
1
2
2
...

output:

8
0 162
8
2
8
0 24
8
2
8
0 42
8
2
8
0 54
8
2
8
0 192
8
2
8
0 134
8
2
8
0 77
8
2
8
0 141
8
2
8
0 11
8
2
8
0 155
8
2
8
0 185
8
2
8
0 104
8
2
8
0 58
8
2
8
0 114
8
2
8
0 183
8
2
8
0 128
8
2
8
0 146
8
2
8
0 169
8
2
8
0 76
8
2
8
0 35
8
2
8
0 18
8
2
8
0 97
8
2
8
0 67
8
2
8
0 91
8
2
8
1 91
8
0 186
8
2
8
0 7...

result:

ok 

Subtask #2:

score: 15
Accepted

Test #24:

score: 15
Accepted
time: 31ms
memory: 3748kb

input:

1000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 147
8
2
8
0 505
8
2
8
1 505
8
0 814
8
2
8
1 814
8
0 310
8
2
8
1 310
8
0 571
8
2
8
1 571
8
0 301
8
2
8
1 301
8
0 137
8
2
8
1 137
8
0 930
8
2
8
1 930
8
0 136
8
2
8
1 136
8
0 129
8
2
8
1 129
8
0 323
8
2
8
1 323
8
0 340
8
2
8
1 340
8
0 397
8
2
8
1 397
8
0 630
8
2
8
1 630
8
0 101
8
2
8
1 101
8
0 769
...

result:

ok 

Test #25:

score: 0
Accepted
time: 4ms
memory: 3692kb

input:

1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 147
8
2
8
0 505
8
2
8
0 814
8
2
8
0 310
8
2
8
0 571
8
2
8
0 301
8
2
8
0 137
8
2
8
0 930
8
2
8
0 136
8
2
8
0 129
8
2
8
0 323
8
2
8
0 340
8
2
8
0 397
8
2
8
0 630
8
2
8
0 101
8
2
8
0 769
8
2
8
0 219
8
2
8
0 635
8
2
8
0 560
8
2
8
0 118
8
2
8
0 20
8
2
8
0 254
8
2
8
0 665
8
2
8
0 693
8
2
8
0 673
8
2
8...

result:

ok 

Test #26:

score: 0
Accepted
time: 13ms
memory: 3828kb

input:

999
1
1
1
1
1
1
2
1
1
2
1
2
1
1
2
2
1
1
1
2
2
2
1
1
1
2
2
1
2
2
1
2
1
1
2
2
2
2
1
2
2
2
2
1
2
1
1
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
...

output:

8
0 612
8
2
8
0 68
8
2
8
0 772
8
2
8
0 865
8
2
8
0 419
8
2
8
0 812
8
2
8
0 414
8
2
8
1 414
8
0 27
8
2
8
0 606
8
2
8
0 876
8
2
8
1 876
8
0 524
8
2
8
0 168
8
2
8
1 168
8
0 21
8
2
8
0 660
8
2
8
0 721
8
2
8
1 721
8
0 842
8
2
8
1 842
8
0 299
8
2
8
0 869
8
2
8
0 618
8
2
8
0 750
8
2
8
1 750
8
0 849
8
2
8
1...

result:

ok 

Test #27:

score: 0
Accepted
time: 6ms
memory: 3700kb

input:

999
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
2
1
2
2
1
1
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 612
8
2
8
0 68
8
2
8
0 772
8
2
8
0 865
8
2
8
0 419
8
2
8
0 812
8
2
8
0 414
8
2
8
0 27
8
2
8
0 606
8
2
8
0 876
8
2
8
1 876
8
0 524
8
2
8
0 168
8
2
8
0 21
8
2
8
0 660
8
2
8
0 721
8
2
8
0 842
8
2
8
1 842
8
0 299
8
2
8
0 869
8
2
8
1 869
8
0 618
8
2
8
0 750
8
2
8
1 750
8
0 849
8
2
8
1 849
8
0 979
8
2...

result:

ok 

Test #28:

score: 0
Accepted
time: 5ms
memory: 3848kb

input:

996
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 355
8
2
8
0 125
8
2
8
1 125
8
0 447
8
2
8
1 447
8
0 314
8
2
8
1 314
8
0 221
8
2
8
1 221
8
0 210
8
2
8
1 210
8
0 884
8
2
8
1 884
8
0 336
8
2
8
1 336
8
0 675
8
2
8
1 675
8
0 562
8
2
8
1 562
8
0 184
8
2
8
1 184
8
0 866
8
2
8
1 866
8
0 919
8
2
8
1 919
8
0 783
8
2
8
1 783
8
0 653
8
2
8
1 653
8
0 630
...

result:

ok 

Test #29:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

995
1
1
1
2
2
1
2
1
2
1
2
1
2
2
1
2
2
1
2
2
1
2
1
2
1
2
2
1
2
1
1
1
1
1
1
2
1
2
2
1
2
2
2
1
2
2
1
2
2
1
2
2
2
1
1
2
2
2
1
2
1
1
2
1
2
2
2
1
2
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
2
2
2
1
1
1
1
2
1
1
2
2
2
2
2
2
1
2
1
1
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
1
2
1
1
1
2
1
2
1
2
2
2
1
1
1
2
2
1
2
2
2
1
1
...

output:

8
0 319
8
2
8
0 949
8
2
8
0 501
8
2
8
0 496
8
2
8
1 496
8
0 577
8
2
8
1 577
8
0 784
8
2
8
0 874
8
2
8
1 874
8
0 857
8
2
8
0 366
8
2
8
1 366
8
0 918
8
2
8
0 755
8
2
8
1 755
8
0 326
8
2
8
0 124
8
2
8
1 124
8
0 769
8
2
8
1 769
8
0 242
8
2
8
0 854
8
2
8
1 854
8
0 77
8
2
8
1 77
8
0 346
8
2
8
0 491
8
2
8
...

result:

ok 

Test #30:

score: 0
Accepted
time: 4ms
memory: 3596kb

input:

998
1
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 323
8
2
8
0 478
8
2
8
0 781
8
2
8
0 298
8
2
8
1 298
8
0 555
8
2
8
0 498
8
2
8
1 498
8
0 299
8
2
8
1 299
8
0 418
8
2
8
1 418
8
0 570
8
2
8
1 570
8
0 882
8
2
8
1 882
8
0 433
8
2
8
1 433
8
0 69
8
2
8
1 69
8
0 994
8
2
8
1 994
8
0 749
8
2
8
1 749
8
0 37
8
2
8
1 37
8
0 662
8
2
8
1 662
8
0 666
8
2
8
1 ...

result:

ok 

Test #31:

score: 0
Accepted
time: 17ms
memory: 3696kb

input:

998
1
1
1
1
1
1
1
1
2
2
2
1
1
1
1
2
1
2
1
2
2
2
1
1
1
2
1
2
2
1
1
2
2
1
1
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 323
8
2
8
0 478
8
2
8
0 781
8
2
8
0 298
8
2
8
0 555
8
2
8
0 498
8
2
8
0 299
8
2
8
0 418
8
2
8
0 570
8
2
8
1 570
8
0 882
8
2
8
1 882
8
0 433
8
2
8
1 433
8
0 69
8
2
8
0 994
8
2
8
0 749
8
2
8
0 37
8
2
8
0 662
8
2
8
1 662
8
0 666
8
2
8
0 496
8
2
8
1 496
8
0 255
8
2
8
0 292
8
2
8
1 292
8
0 790
8
2
8
...

result:

ok 

Test #32:

score: 0
Accepted
time: 25ms
memory: 3716kb

input:

1000
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 147
8
2
8
0 505
8
2
8
0 814
8
2
8
0 310
8
2
8
0 571
8
2
8
0 301
8
2
8
1 301
8
0 137
8
2
8
1 137
8
0 930
8
2
8
1 930
8
0 136
8
2
8
1 136
8
0 129
8
2
8
1 129
8
0 323
8
2
8
1 323
8
0 340
8
2
8
1 340
8
0 397
8
2
8
1 397
8
0 630
8
2
8
1 630
8
0 101
8
2
8
1 101
8
0 769
8
2
8
1 769
8
0 219
8
2
8
1 219
...

result:

ok 

Test #33:

score: 0
Accepted
time: 3ms
memory: 3732kb

input:

996
1
1
1
2
2
2
1
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 355
8
2
8
0 125
8
2
8
0 447
8
2
8
0 314
8
2
8
1 314
8
0 221
8
2
8
1 221
8
0 210
8
2
8
1 210
8
0 884
8
2
8
0 336
8
2
8
0 675
8
2
8
0 562
8
2
8
1 562
8
0 184
8
2
8
1 184
8
0 866
8
2
8
0 919
8
2
8
1 919
8
0 783
8
2
8
1 783
8
0 653
8
2
8
0 630
8
2
8
1 630
8
0 762
8
2
8
1 762
8
0 297
8
2
8
1 297
8
0 ...

result:

ok 

Test #34:

score: 0
Accepted
time: 15ms
memory: 3792kb

input:

1000
1
1
2
1
2
1
1
2
2
1
1
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 147
8
2
8
0 505
8
2
8
0 814
8
2
8
1 814
8
0 310
8
2
8
0 571
8
2
8
1 571
8
0 301
8
2
8
0 137
8
2
8
0 930
8
2
8
1 930
8
0 136
8
2
8
1 136
8
0 129
8
2
8
0 323
8
2
8
0 340
8
2
8
1 340
8
0 397
8
2
8
0 630
8
2
8
1 630
8
0 101
8
2
8
0 769
8
2
8
0 219
8
2
8
1 219
8
0 635
8
2
8
1 635
8
0 560
8
2
8
1 560
...

result:

ok 

Test #35:

score: 0
Accepted
time: 29ms
memory: 3612kb

input:

1000
1
1
1
2
2
1
2
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 147
8
2
8
0 505
8
2
8
0 814
8
2
8
0 310
8
2
8
1 310
8
0 571
8
2
8
1 571
8
0 301
8
2
8
0 137
8
2
8
1 137
8
0 930
8
2
8
1 930
8
0 136
8
2
8
0 129
8
2
8
1 129
8
0 323
8
2
8
0 340
8
2
8
1 340
8
0 397
8
2
8
0 630
8
2
8
1 630
8
0 101
8
2
8
0 769
8
2
8
1 769
8
0 219
8
2
8
1 219
8
0 635
8
2
8
1 635
8
0 ...

result:

ok 

Test #36:

score: 0
Accepted
time: 21ms
memory: 3560kb

input:

997
1
1
1
1
1
2
1
1
1
1
1
2
2
2
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 878
8
2
8
0 352
8
2
8
0 690
8
2
8
0 936
8
2
8
0 820
8
2
8
0 128
8
2
8
1 128
8
0 960
8
2
8
0 585
8
2
8
0 235
8
2
8
0 881
8
2
8
0 596
8
2
8
0 908
8
2
8
1 908
8
0 446
8
2
8
1 446
8
0 24
8
2
8
1 24
8
0 117
8
2
8
0 873
8
2
8
0 175
8
2
8
1 175
8
0 280
8
2
8
0 488
8
2
8
0 475
8
2
8
1 475
8
0 889
8
2
8
...

result:

ok 

Test #37:

score: 0
Accepted
time: 19ms
memory: 3624kb

input:

995
1
1
1
1
1
1
2
1
1
1
1
1
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 319
8
2
8
0 949
8
2
8
0 501
8
2
8
0 496
8
2
8
0 577
8
2
8
0 784
8
2
8
0 874
8
2
8
1 874
8
0 857
8
2
8
0 366
8
2
8
0 918
8
2
8
0 755
8
2
8
0 326
8
2
8
0 124
8
2
8
0 769
8
2
8
1 769
8
0 242
8
2
8
1 242
8
0 854
8
2
8
1 854
8
0 77
8
2
8
0 346
8
2
8
1 346
8
0 491
8
2
8
1 491
8
0 766
8
2
8
1 766
8
0 9...

result:

ok 

Test #38:

score: 0
Accepted
time: 4ms
memory: 3716kb

input:

997
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
2
1
2
1
2
1
1
2
1
1
2
2
2
1
1
1
1
1
2
1
1
2
1
2
2
1
2
1
2
1
2
1
2
2
1
2
2
2
2
2
2
1
2
1
2
1
1
2
2
2
2
2
2
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
...

output:

8
0 878
8
2
8
0 352
8
2
8
0 690
8
2
8
0 936
8
2
8
0 820
8
2
8
0 128
8
2
8
0 960
8
2
8
0 585
8
2
8
0 235
8
2
8
0 881
8
2
8
0 596
8
2
8
0 908
8
2
8
0 446
8
2
8
1 446
8
0 24
8
2
8
0 117
8
2
8
1 117
8
0 873
8
2
8
0 175
8
2
8
1 175
8
0 280
8
2
8
0 488
8
2
8
1 488
8
0 475
8
2
8
0 889
8
2
8
1 889
8
0 54
8
...

result:

ok 

Test #39:

score: 0
Accepted
time: 8ms
memory: 3808kb

input:

997
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
2
1
1
1
2
1
2
1
1
1
1
1
2
1
2
1
2
1
2
2
1
2
1
2
2
1
1
2
2
2
2
1
2
2
2
1
2
1
1
1
1
1
1
1
2
2
2
2
2
1
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
1
1
1
2
2
1
1
1
2
2
1
1
2
1
2
2
...

output:

8
0 878
8
2
8
0 352
8
2
8
0 690
8
2
8
0 936
8
2
8
0 820
8
2
8
0 128
8
2
8
0 960
8
2
8
0 585
8
2
8
0 235
8
2
8
0 881
8
2
8
0 596
8
2
8
1 596
8
0 908
8
2
8
0 446
8
2
8
0 24
8
2
8
0 117
8
2
8
0 873
8
2
8
0 175
8
2
8
0 280
8
2
8
0 488
8
2
8
0 475
8
2
8
0 889
8
2
8
0 54
8
2
8
0 356
8
2
8
0 197
8
2
8
0 49...

result:

ok 

Test #40:

score: 0
Accepted
time: 9ms
memory: 3696kb

input:

996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
2
1
1
2
1
1
1
1
2
2
2
1
1
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
2
1
1
2
1
1
2
1
1
...

output:

8
0 355
8
2
8
0 125
8
2
8
0 447
8
2
8
0 314
8
2
8
0 221
8
2
8
0 210
8
2
8
0 884
8
2
8
0 336
8
2
8
0 675
8
2
8
0 562
8
2
8
0 184
8
2
8
0 866
8
2
8
0 919
8
2
8
0 783
8
2
8
0 653
8
2
8
0 630
8
2
8
0 762
8
2
8
0 297
8
2
8
1 297
8
0 412
8
2
8
0 627
8
2
8
0 600
8
2
8
0 840
8
2
8
0 162
8
2
8
0 625
8
2
8
0 ...

result:

ok 

Test #41:

score: 0
Accepted
time: 10ms
memory: 3780kb

input:

995
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
2
1
1
2
1
2
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
2
1
1
2
1
1
1
2
2
2
1
1
1
1
2
1
1
1
1
1
2
2
1
2
1
1
...

output:

8
0 319
8
2
8
0 949
8
2
8
0 501
8
2
8
0 496
8
2
8
0 577
8
2
8
0 784
8
2
8
0 874
8
2
8
0 857
8
2
8
0 366
8
2
8
0 918
8
2
8
0 755
8
2
8
0 326
8
2
8
0 124
8
2
8
0 769
8
2
8
0 242
8
2
8
0 854
8
2
8
0 77
8
2
8
0 346
8
2
8
0 491
8
2
8
0 766
8
2
8
0 970
8
2
8
0 73
8
2
8
0 679
8
2
8
0 609
8
2
8
0 972
8
2
8
...

result:

ok 

Test #42:

score: 0
Accepted
time: 8ms
memory: 3696kb

input:

995
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
...

output:

8
0 319
8
2
8
0 949
8
2
8
0 501
8
2
8
0 496
8
2
8
0 577
8
2
8
0 784
8
2
8
0 874
8
2
8
0 857
8
2
8
0 366
8
2
8
0 918
8
2
8
0 755
8
2
8
0 326
8
2
8
0 124
8
2
8
0 769
8
2
8
0 242
8
2
8
0 854
8
2
8
0 77
8
2
8
0 346
8
2
8
0 491
8
2
8
0 766
8
2
8
0 970
8
2
8
0 73
8
2
8
0 679
8
2
8
0 609
8
2
8
0 972
8
2
8
...

result:

ok 

Subtask #3:

score: 57.99
Acceptable Answer

Test #43:

score: 75
Accepted
time: 1ms
memory: 3676kb

input:

2
1
2

output:

8
0 1
8
2
8
0 0
8
2
8
1 0
8
3 2

result:

ok 

Test #44:

score: 75
Accepted
time: 1ms
memory: 3812kb

input:

2
1
1

output:

8
0 1
8
2
8
0 0
8
2
8
3 1

result:

ok 

Test #45:

score: 75
Accepted
time: 1ms
memory: 3800kb

input:

3
1
1
2

output:

8
0 1
8
2
8
0 0
8
2
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #46:

score: 75
Accepted
time: 0ms
memory: 3752kb

input:

6
1
2
2
1
2
2
1
1
1
1

output:

8
0 5
8
2
8
0 4
8
2
8
1 4
8
0 0
8
2
8
1 0
8
0 2
8
2
8
0 1
8
2
8
1 1
8
0 3
8
2
8
1 3
8
1 5
8
0 4
8
2
8
1 4
8
0 0
8
2
8
1 0
8
0 1
8
2
8
1 1
8
0 3
8
2
8
1 3
8
3 1

result:

ok 

Test #47:

score: 75
Accepted
time: 1ms
memory: 3740kb

input:

10
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
1
2
1

output:

8
0 8
8
2
8
0 6
8
2
8
1 6
8
0 9
8
2
8
1 9
8
0 5
8
2
8
1 5
8
0 1
8
2
8
0 7
8
2
8
1 7
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
1 1
8
0 6
8
2
8
1 6
8
0 9
8
2
8
1 9
8
0 5
8
2
8
1 5
8
0 7
8
2
8
1 7
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
3 4

result:

ok 

Test #48:

score: 75
Accepted
time: 37ms
memory: 3852kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
1 316
8
0 1456
8
2
8
1 1456
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
1 15
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
1 918
8
0 405
8
2
8...

result:

ok 

Test #49:

score: 75
Accepted
time: 5ms
memory: 3844kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2
8
0 939
8
2
8
0 1741
8
2...

result:

ok 

Test #50:

score: 75
Accepted
time: 12ms
memory: 3716kb

input:

2000
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
2
1
1
2
2
1
2
1
2
1
2
2
2
1
1
2
2
1
1
2
2
1
1
1
2
2
2
2
2
1
1
1
2
2
1
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
1 1851
8
0 1323
8
2
8
...

result:

ok 

Test #51:

score: 61.86
Acceptable Answer
time: 23ms
memory: 3812kb

input:

2000
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
1
2
1
1
2
1
2
2
1
2
2
1
2
2
1
2
2
2
2
1
2
1
1
2
2
2
2
2
1
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
1 15
8
0 867
8
2
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
1 1323
8
0 1834
8
2...

result:

points 0.82480 points  0.82480

Test #52:

score: 75
Accepted
time: 13ms
memory: 3848kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
1 316
8
0 1456
8
2
8
1 1456
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
1 15
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
1 918
8
0 405
8
2
8...

result:

ok 

Test #53:

score: 75
Accepted
time: 3ms
memory: 3716kb

input:

2000
1
2
1
2
1
2
2
2
1
1
2
1
1
2
2
2
1
1
2
2
2
2
2
1
1
2
1
1
1
1
2
2
1
1
2
1
1
1
2
1
1
1
2
1
2
1
1
1
2
1
2
2
1
2
2
1
1
2
2
1
2
2
2
1
1
1
1
2
1
2
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
1
1
1
2
2
2
1
1
2
1
1
2
2
2
1
1
2
2
1
2
1
2
2
2
1
1
2
1
1
2
1
2
1
2
1
2
2
1
1
2
1
1
1
2
2
1
2
2
2
1
1
2
2
2
2
2
2
1
1
2
1
2
1...

output:

8
0 1410
8
2
8
0 316
8
2
8
1 316
8
0 1456
8
2
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
1 405
8
0 1050
8
2
8
1 1050
8
0 288
8
2
8
0 92
8
2...

result:

ok 

Test #54:

score: 73.98
Acceptable Answer
time: 23ms
memory: 3740kb

input:

2000
1
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
1 316
8
0 1456
8
2
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
1 15
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
1 405
8
0 1050
8
2
8
1 105...

result:

points 0.98640 points  0.98640

Test #55:

score: 57.99
Acceptable Answer
time: 17ms
memory: 3792kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
1
1
2
1
1
2
1
2
2
2
1
1
2
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
1
2
1
2
1
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
1 1918
8
0 1851
8
2
8
0 1323
8
2
8
1 1323
8
0 1834
8
2
8
1 18...

result:

points 0.77320 points  0.77320

Test #56:

score: 73.28
Acceptable Answer
time: 16ms
memory: 3900kb

input:

1998
1
1
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1610
8
2
8
0 785
8
2
8
0 778
8
2
8
0 10
8
2
8
1 10
8
0 1209
8
2
8
0 759
8
2
8
1 759
8
0 1331
8
2
8
0 1021
8
2
8
1 1021
8
0 566
8
2
8
1 566
8
0 802
8
2
8
1 802
8
0 906
8
2
8
1 906
8
0 937
8
2
8
1 937
8
0 63
8
2
8
1 63
8
0 1837
8
2
8
1 1837
8
0 631
8
2
8
1 631
8
0 991
8
2
8
1 991
8
0 123
8
2
8
1 1...

result:

points 0.97706666670 points  0.97706666670

Test #57:

score: 70.39
Acceptable Answer
time: 5ms
memory: 3732kb

input:

1999
1
1
2
2
1
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1482
8
2
8
0 782
8
2
8
0 1611
8
2
8
1 1611
8
0 364
8
2
8
1 364
8
0 1080
8
2
8
0 1070
8
2
8
1 1070
8
0 618
8
2
8
0 1911
8
2
8
1 1911
8
0 25
8
2
8
0 338
8
2
8
1 338
8
0 1295
8
2
8
1 1295
8
0 1336
8
2
8
1 1336
8
0 954
8
2
8
1 954
8
0 163
8
2
8
0 1235
8
2
8
1 1235
8
0 1640
8
2
8
1 1640
8
0 132
8
2
8...

result:

points 0.93853333330 points  0.93853333330

Test #58:

score: 68.13
Acceptable Answer
time: 10ms
memory: 3648kb

input:

1997
1
1
1
2
2
2
2
2
1
1
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 954
8
2
8
0 1742
8
2
8
0 1858
8
2
8
0 1112
8
2
8
1 1112
8
0 777
8
2
8
1 777
8
0 882
8
2
8
1 882
8
0 1442
8
2
8
1 1442
8
0 1520
8
2
8
1 1520
8
0 1300
8
2
8
0 1708
8
2
8
0 999
8
2
8
1 999
8
0 125
8
2
8
0 1396
8
2
8
0 51
8
2
8
1 51
8
0 647
8
2
8
1 647
8
0 503
8
2
8
1 503
8
0 1880
8
2
8
1 1880
8
0 7...

result:

points 0.90840 points  0.90840

Test #59:

score: 66.5
Acceptable Answer
time: 19ms
memory: 3836kb

input:

1998
1
1
2
1
1
2
2
2
1
1
2
1
1
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1610
8
2
8
0 785
8
2
8
0 778
8
2
8
1 778
8
0 10
8
2
8
0 1209
8
2
8
0 759
8
2
8
1 759
8
0 1331
8
2
8
1 1331
8
0 1021
8
2
8
1 1021
8
0 566
8
2
8
0 802
8
2
8
0 906
8
2
8
1 906
8
0 937
8
2
8
0 63
8
2
8
0 1837
8
2
8
1 1837
8
0 631
8
2
8
0 991
8
2
8
1 991
8
0 123
8
2
8
1 123
8
0 367
8
2
8
1 367
8
0 64...

result:

points 0.88666666670 points  0.88666666670

Test #60:

score: 64.97
Acceptable Answer
time: 38ms
memory: 3656kb

input:

1996
1
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1762
8
2
8
0 1036
8
2
8
0 1905
8
2
8
0 893
8
2
8
0 1125
8
2
8
0 879
8
2
8
1 879
8
0 1555
8
2
8
0 1474
8
2
8
0 348
8
2
8
0 422
8
2
8
0 1842
8
2
8
1 1842
8
0 290
8
2
8
1 290
8
0 1550
8
2
8
1 1550
8
0 1977
8
2
8
0 486
8
2
8
0 114
8
2
8
1 114
8
0 600
8
2
8
1 600
8
0 876
8
2
8
1 876
8
0 232
8
2
8
1 2...

result:

points 0.86626666670 points  0.86626666670

Test #61:

score: 61.73
Acceptable Answer
time: 28ms
memory: 3736kb

input:

2000
1
1
1
1
1
1
2
2
1
1
1
1
2
1
1
2
1
1
2
2
2
2
2
2
2
2
1
1
2
2
2
1
2
2
2
2
1
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
1 1050
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
1 1918
8
0 1851
8
2
8
1 1...

result:

points 0.82306666670 points  0.82306666670

Test #62:

score: 65.84
Acceptable Answer
time: 25ms
memory: 3836kb

input:

1998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
2
1
2
1
1
2
1
1
2
1
1
1
1
2
2
1
2
1
2
2
2
1
2
1
1
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
1
1
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2...

output:

8
0 1610
8
2
8
0 785
8
2
8
0 778
8
2
8
0 10
8
2
8
0 1209
8
2
8
0 759
8
2
8
0 1331
8
2
8
0 1021
8
2
8
0 566
8
2
8
0 802
8
2
8
0 906
8
2
8
0 937
8
2
8
0 63
8
2
8
0 1837
8
2
8
0 631
8
2
8
0 991
8
2
8
1 991
8
0 123
8
2
8
0 367
8
2
8
0 643
8
2
8
0 250
8
2
8
0 199
8
2
8
1 199
8
0 1973
8
2
8
1 1973
8
0 742...

result:

points 0.87786666670 points  0.87786666670

Test #63:

score: 72.22
Acceptable Answer
time: 33ms
memory: 3844kb

input:

2000
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
2
2
2
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
2
1
2
2
2
1
2
2
1
1
1
1
1
1
2
1
2
2
1
1
1
1
2
1
1
2
2
1
1
2
1
2
2
1
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
1
2
2
2
1
2
2
1
2
2
2
1
2
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
1
1
1
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
1 405
8
0 1050
8
2
8
0 288
8
2
8
1 288
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2...

result:

points 0.96293333330 points  0.96293333330

Test #64:

score: 71.89
Acceptable Answer
time: 9ms
memory: 3720kb

input:

1995
1
1
1
1
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
2
2
2
2
1
2
1
1
1
1
2
2
1
2
2
2
1
1
2
1
1
1
1
1
1
2
2
2
1
2
1
1
2
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
2
1
2
1
1
1
2
2
1
2
1
2
1
2
1
2
2
2
1
1
1
2
1
1
2
2
2
1
1
2
1
1
2
1
1
2
1
2
2...

output:

8
0 1625
8
2
8
0 97
8
2
8
0 439
8
2
8
0 1125
8
2
8
0 1939
8
2
8
0 1050
8
2
8
0 424
8
2
8
0 1875
8
2
8
0 1429
8
2
8
1 1429
8
0 779
8
2
8
0 1177
8
2
8
0 396
8
2
8
0 47
8
2
8
1 47
8
0 1865
8
2
8
0 1311
8
2
8
1 1311
8
0 628
8
2
8
0 307
8
2
8
0 523
8
2
8
0 1518
8
2
8
0 1208
8
2
8
0 1418
8
2
8
0 1600
8
2
...

result:

points 0.95853333330 points  0.95853333330

Test #65:

score: 75
Accepted
time: 23ms
memory: 3696kb

input:

1999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
2
1
1
2
1
1
2
1
1
1
1
2
1
1
2
2
1
1
1...

output:

8
0 1482
8
2
8
0 782
8
2
8
0 1611
8
2
8
0 364
8
2
8
0 1080
8
2
8
0 1070
8
2
8
0 618
8
2
8
0 1911
8
2
8
0 25
8
2
8
0 338
8
2
8
0 1295
8
2
8
0 1336
8
2
8
0 954
8
2
8
0 163
8
2
8
0 1235
8
2
8
0 1640
8
2
8
0 132
8
2
8
0 601
8
2
8
0 1273
8
2
8
0 1059
8
2
8
0 1203
8
2
8
0 1386
8
2
8
0 168
8
2
8
0 1921
8
2...

result:

ok 

Test #66:

score: 75
Accepted
time: 11ms
memory: 3872kb

input:

1998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1...

output:

8
0 1610
8
2
8
0 785
8
2
8
0 778
8
2
8
0 10
8
2
8
0 1209
8
2
8
0 759
8
2
8
0 1331
8
2
8
0 1021
8
2
8
0 566
8
2
8
0 802
8
2
8
0 906
8
2
8
0 937
8
2
8
0 63
8
2
8
0 1837
8
2
8
0 631
8
2
8
1 631
8
0 991
8
2
8
0 123
8
2
8
0 367
8
2
8
0 643
8
2
8
0 250
8
2
8
0 199
8
2
8
0 1973
8
2
8
0 742
8
2
8
0 1554
8
2...

result:

ok 

Test #67:

score: 75
Accepted
time: 4ms
memory: 3796kb

input:

1999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 1482
8
2
8
0 782
8
2
8
0 1611
8
2
8
0 364
8
2
8
0 1080
8
2
8
0 1070
8
2
8
0 618
8
2
8
0 1911
8
2
8
0 25
8
2
8
0 338
8
2
8
0 1295
8
2
8
0 1336
8
2
8
0 954
8
2
8
0 163
8
2
8
0 1235
8
2
8
0 1640
8
2
8
0 132
8
2
8
0 601
8
2
8
0 1273
8
2
8
0 1059
8
2
8
0 1203
8
2
8
0 1386
8
2
8
0 168
8
2
8
0 1921
8
2...

result:

ok 

Test #68:

score: 75
Accepted
time: 9ms
memory: 3780kb

input:

1979
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
2
1
1
2
1
1
2
1
1
2
2
1
2
2
2
1
1
2
2
1
2
1
2
1
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
2
1
1
2
1
1
1
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2...

output:

8
0 851
8
2
8
0 364
8
2
8
0 968
8
2
8
0 1305
8
2
8
0 1545
8
2
8
0 1148
8
2
8
0 636
8
2
8
0 1437
8
2
8
0 238
8
2
8
0 49
8
2
8
0 511
8
2
8
0 1467
8
2
8
0 931
8
2
8
1 931
8
0 1513
8
2
8
0 1106
8
2
8
0 1746
8
2
8
0 1548
8
2
8
0 1550
8
2
8
0 1500
8
2
8
1 1500
8
0 1298
8
2
8
0 485
8
2
8
0 897
8
2
8
0 652
...

result:

ok 

Test #69:

score: 75
Accepted
time: 7ms
memory: 3844kb

input:

1979
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
2
1
1
2
1
1
2
1
1
2
2
1
2
2
2
1
1
2
2
1
2
1
2
1
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
2
1
1
2
1
1
1
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2...

output:

8
0 851
8
2
8
0 364
8
2
8
0 968
8
2
8
0 1305
8
2
8
0 1545
8
2
8
0 1148
8
2
8
0 636
8
2
8
0 1437
8
2
8
0 238
8
2
8
0 49
8
2
8
0 511
8
2
8
0 1467
8
2
8
0 931
8
2
8
1 931
8
0 1513
8
2
8
0 1106
8
2
8
0 1746
8
2
8
0 1548
8
2
8
0 1550
8
2
8
0 1500
8
2
8
1 1500
8
0 1298
8
2
8
0 485
8
2
8
0 897
8
2
8
0 652
...

result:

ok 

Test #70:

score: 58
Acceptable Answer
time: 32ms
memory: 3868kb

input:

1979
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
1
1
1
2
2
1
2
1
2
2
1
1
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 851
8
2
8
0 364
8
2
8
0 968
8
2
8
0 1305
8
2
8
0 1545
8
2
8
0 1148
8
2
8
0 636
8
2
8
0 1437
8
2
8
1 1437
8
0 238
8
2
8
0 49
8
2
8
0 511
8
2
8
0 1467
8
2
8
1 1467
8
0 931
8
2
8
0 1513
8
2
8
0 1106
8
2
8
0 1746
8
2
8
1 1746
8
0 1548
8
2
8
1 1548
8
0 1550
8
2
8
0 1500
8
2
8
0 1298
8
2
8
0 485
8
2
8...

result:

points 0.77333333330 points  0.77333333330

Test #71:

score: 58
Acceptable Answer
time: 19ms
memory: 3856kb

input:

1979
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
1
1
1
2
2
1
2
1
2
2
1
1
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 851
8
2
8
0 364
8
2
8
0 968
8
2
8
0 1305
8
2
8
0 1545
8
2
8
0 1148
8
2
8
0 636
8
2
8
0 1437
8
2
8
1 1437
8
0 238
8
2
8
0 49
8
2
8
0 511
8
2
8
0 1467
8
2
8
1 1467
8
0 931
8
2
8
0 1513
8
2
8
0 1106
8
2
8
0 1746
8
2
8
1 1746
8
0 1548
8
2
8
1 1548
8
0 1550
8
2
8
0 1500
8
2
8
0 1298
8
2
8
0 485
8
2
8...

result:

points 0.77333333330 points  0.77333333330

Test #72:

score: 63.25
Acceptable Answer
time: 35ms
memory: 3688kb

input:

1981
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
2
1
2
1
2
1
1
1
1
2
2
2
1
1
1
2
1
2
1
2
2
2
2
2
2
1
1
2
2
2
1
1
1
2
2
2
2
2
1
2
2
2
1
2
2
1
1
2
1
2
2
2
2
1
2
1
2
1
2
1
2
2
2
1
1
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
1...

output:

8
0 1765
8
2
8
0 1032
8
2
8
0 1564
8
2
8
0 817
8
2
8
0 1079
8
2
8
0 1974
8
2
8
0 248
8
2
8
0 563
8
2
8
0 456
8
2
8
0 827
8
2
8
0 196
8
2
8
0 643
8
2
8
0 798
8
2
8
0 1225
8
2
8
0 1742
8
2
8
1 1742
8
0 295
8
2
8
0 1873
8
2
8
0 209
8
2
8
1 209
8
0 26
8
2
8
0 1902
8
2
8
0 1166
8
2
8
1 1166
8
0 22
8
2
8
...

result:

points 0.84333333330 points  0.84333333330

Test #73:

score: 62.18
Acceptable Answer
time: 51ms
memory: 3840kb

input:

1981
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
2
1
2
1
1
1
1
2
1
1
1
2
2
2
2
2
2
2
1
1
2
2
1
2
1
2
2
1
1
2
2
2
2
1
1
2
1
1
2
2
1
2
1
2
2
2
2
2
1
2
2
1
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
1
2
1
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1765
8
2
8
0 1032
8
2
8
1 1032
8
0 1564
8
2
8
0 817
8
2
8
0 1079
8
2
8
0 1974
8
2
8
1 1974
8
0 248
8
2
8
0 563
8
2
8
0 456
8
2
8
0 827
8
2
8
0 196
8
2
8
0 643
8
2
8
0 798
8
2
8
0 1225
8
2
8
0 1742
8
2
8
0 295
8
2
8
0 1873
8
2
8
0 209
8
2
8
0 26
8
2
8
1 26
8
0 1902
8
2
8
1 1902
8
0 1166
8
2
8
1 1...

result:

points 0.82906666670 points  0.82906666670

Test #74:

score: 69.49
Acceptable Answer
time: 23ms
memory: 3728kb

input:

1989
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
2
1
1
1
2
1
2
1
2
2
2
2
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
1
1
1
1
2
1
2
1
1
2
1
1
2
1
2
2
2
1
2
1
2
1
2
2
1
1
1
1
2
1
1
1
2
2
1
1
2
2
2
1
2
1
1
1
2
2
2
1
2
2
2
2
2
1
1
2
1
2
2
2
2
2
1
1
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2...

output:

8
0 1126
8
2
8
0 210
8
2
8
0 68
8
2
8
0 1492
8
2
8
0 1278
8
2
8
0 719
8
2
8
0 999
8
2
8
0 1337
8
2
8
0 977
8
2
8
0 516
8
2
8
0 1468
8
2
8
0 419
8
2
8
1 419
8
0 1095
8
2
8
0 1084
8
2
8
0 1359
8
2
8
0 929
8
2
8
0 1536
8
2
8
0 1944
8
2
8
0 669
8
2
8
0 890
8
2
8
0 1966
8
2
8
0 726
8
2
8
0 1476
8
2
8
0 1...

result:

points 0.92653333330 points  0.92653333330

Test #75:

score: 66.46
Acceptable Answer
time: 17ms
memory: 3724kb

input:

1989
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
2
1
1
1
2
1
2
1
2
2
2
2
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
1
1
1
1
2
1
2
1
1
2
1
1
2
1
2
2
2
1
2
1
2
1
2
2
1
1
1
1
2
1
1
1
2
2
1
1
2
2
2
1
2
1
1
1
2
2
2
1
2
2
2
2
2
1
1
2
1
2
2
2
2
2
1
1
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2...

output:

8
0 1126
8
2
8
0 210
8
2
8
0 68
8
2
8
0 1492
8
2
8
0 1278
8
2
8
0 719
8
2
8
0 999
8
2
8
0 1337
8
2
8
0 977
8
2
8
0 516
8
2
8
0 1468
8
2
8
0 419
8
2
8
1 419
8
0 1095
8
2
8
0 1084
8
2
8
0 1359
8
2
8
0 929
8
2
8
0 1536
8
2
8
0 1944
8
2
8
0 669
8
2
8
0 890
8
2
8
0 1966
8
2
8
0 726
8
2
8
0 1476
8
2
8
0 1...

result:

points 0.88613333330 points  0.88613333330

Test #76:

score: 75
Accepted
time: 14ms
memory: 3848kb

input:

1970
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
2
2
2
2
1
2
1
1
1
1
2
1
1
1
1
1
1
2
1
2
2
1
2
2
2
1
1
2
1
2
1
2
2
2
1
2
1
1
2
1
2
2
1
2
2
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2...

output:

8
0 409
8
2
8
0 1532
8
2
8
0 1206
8
2
8
0 662
8
2
8
0 216
8
2
8
0 1142
8
2
8
0 660
8
2
8
0 201
8
2
8
0 1296
8
2
8
0 1798
8
2
8
0 1602
8
2
8
0 493
8
2
8
0 1877
8
2
8
0 942
8
2
8
1 942
8
0 1902
8
2
8
0 1732
8
2
8
0 617
8
2
8
0 223
8
2
8
0 1320
8
2
8
1 1320
8
0 1211
8
2
8
0 452
8
2
8
1 452
8
0 458
8
2
...

result:

ok 

Test #77:

score: 75
Accepted
time: 13ms
memory: 3720kb

input:

1970
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
2
2
1
1
1
2
1
1
2
1
1
1
2
2
2
1
1
1
2
2
1
1
2
2
2
1
1
2
2
2
2
2
1
2
1
2
1
2
1
2
2
2
2
2
2
1
1
1
1
2
2
2
2
2
1
2
2
1
2
1
2
1
2
1
2
2
2
2
2
2
1
2
2
2
2
2
1
2
1
2
2
2
1
2
2
2
2
1
2
2
2
1
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2...

output:

8
0 409
8
2
8
0 1532
8
2
8
0 1206
8
2
8
0 662
8
2
8
0 216
8
2
8
0 1142
8
2
8
0 660
8
2
8
0 201
8
2
8
1 201
8
0 1296
8
2
8
0 1798
8
2
8
0 1602
8
2
8
0 493
8
2
8
0 1877
8
2
8
0 942
8
2
8
0 1902
8
2
8
1 1902
8
0 1732
8
2
8
0 617
8
2
8
1 617
8
0 223
8
2
8
0 1320
8
2
8
1 1320
8
0 1211
8
2
8
1 1211
8
0 45...

result:

ok 

Test #78:

score: 64.38
Acceptable Answer
time: 16ms
memory: 3780kb

input:

1980
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
2
1
2
1
2
1
2
2
2
1
2
2
1
1
1
1
2
1
2
1
1
1
2
1
2
2
2
2
1
1
1
1
1
2
2
1
2
1
2
1
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2...

output:

8
0 1269
8
2
8
0 1094
8
2
8
0 869
8
2
8
0 1389
8
2
8
1 1389
8
0 159
8
2
8
0 209
8
2
8
1 209
8
0 960
8
2
8
0 1261
8
2
8
0 1832
8
2
8
0 1661
8
2
8
0 1251
8
2
8
0 1536
8
2
8
0 1333
8
2
8
0 258
8
2
8
1 258
8
0 326
8
2
8
0 1405
8
2
8
0 769
8
2
8
1 769
8
0 705
8
2
8
0 589
8
2
8
0 582
8
2
8
0 1887
8
2
8
1 ...

result:

points 0.85840 points  0.85840

Test #79:

score: 62.4
Acceptable Answer
time: 14ms
memory: 3796kb

input:

1980
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
2
1
2
1
2
1
2
2
2
1
2
2
1
1
1
1
2
1
2
1
1
1
2
1
2
2
2
2
1
1
1
1
1
2
2
1
2
1
2
1
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2...

output:

8
0 1269
8
2
8
0 1094
8
2
8
0 869
8
2
8
0 1389
8
2
8
1 1389
8
0 159
8
2
8
0 209
8
2
8
1 209
8
0 960
8
2
8
0 1261
8
2
8
0 1832
8
2
8
0 1661
8
2
8
0 1251
8
2
8
0 1536
8
2
8
0 1333
8
2
8
0 258
8
2
8
1 258
8
0 326
8
2
8
0 1405
8
2
8
0 769
8
2
8
1 769
8
0 705
8
2
8
0 589
8
2
8
0 582
8
2
8
0 1887
8
2
8
1 ...

result:

points 0.8320 points  0.8320

Test #80:

score: 75
Accepted
time: 20ms
memory: 3868kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
2
1
1
1
2
2
1
2
2
2
1
2
1
1
2
1
1
1
1
1
2
1
1
2
1
1
2
1
1
1
2
1
2
2
1
1
2
1
2
2
1
2
2
2
2
1
2
1
1
1
2
1
2
2
1
1
2
2
2
1
2
1
1
2
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
1
1
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
1 288
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2...

result:

ok 

Test #81:

score: 75
Accepted
time: 16ms
memory: 3816kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
2
1
1
1
2
2
1
2
2
2
1
2
1
1
2
1
1
1
1
1
2
1
1
2
1
1
2
1
1
1
2
1
2
2
1
1
2
1
2
2
1
2
2
2
2
1
2
1
1
1
2
1
2
2
1
1
2
2
2
1
2
1
1
2
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
1
1
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
1 288
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2...

result:

ok 

Test #82:

score: 75
Accepted
time: 17ms
memory: 3792kb

input:

2000
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
2
1
2
1
2
1
1
2
2
1
1
2
2
1
2
1
2
1
2
1
1
2
1
2
2
2
2
2
2
1
2
1
1
1
2
1
2
2
2
2
2
1
1
1
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
0 1050
8
2
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2
8
0 939...

result:

ok 

Test #83:

score: 75
Accepted
time: 18ms
memory: 3712kb

input:

2000
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
2
2
1
2
1
1
1
2
1
2
1
1
2
1
2
1
2
2
2
2
2
2
2
2
1
2
1
1
1
2
1
1
1
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
1
2
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
1 1050
8
0 288
8
2
8
0 92
8
2
8
0 1918
8
2
8
0 1851
8
2
8
0 1323
8
2
8
0 1834
8
2
8
1 18...

result:

ok 

Test #84:

score: 75
Accepted
time: 7ms
memory: 3776kb

input:

540
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 5
8
2
8
0 438
8
2
8
1 438
8
0 174
8
2
8
1 174
8
0 504
8
2
8
1 504
8
0 236
8
2
8
1 236
8
0 173
8
2
8
0 224
8
2
8
1 224
8
0 334
8
2
8
1 334
8
0 234
8
2
8
1 234
8
0 528
8
2
8
1 528
8
0 415
8
2
8
1 415
8
0 166
8
2
8
1 166
8
0 113
8
2
8
1 113
8
0 128
8
2
8
1 128
8
0 478
8
2
8
1 478
8
0 507
8
2
8
1 50...

result:

ok 

Test #85:

score: 75
Accepted
time: 13ms
memory: 3880kb

input:

1834
1
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1483
8
2
8
0 1043
8
2
8
1 1043
8
0 1300
8
2
8
1 1300
8
0 1635
8
2
8
1 1635
8
0 1824
8
2
8
0 888
8
2
8
1 888
8
0 649
8
2
8
1 649
8
0 613
8
2
8
0 99
8
2
8
1 99
8
0 1607
8
2
8
0 1472
8
2
8
1 1472
8
0 1049
8
2
8
1 1049
8
0 524
8
2
8
1 524
8
0 210
8
2
8
1 210
8
0 811
8
2
8
1 811
8
0 206
8
2
8
1 206
8...

result:

ok 

Test #86:

score: 75
Accepted
time: 12ms
memory: 3860kb

input:

2000
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
1 316
8
0 1456
8
2
8
1 1456
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
1 15
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
1 918
8
0 405
8
2
8
1 405
8
...

result:

ok 

Test #87:

score: 75
Accepted
time: 14ms
memory: 3716kb

input:

2000
1
1
1
1
2
1
1
1
1
2
2
1
1
2
2
1
2
2
1
1
1
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
2
1
2
1
2
1
2
2
1
2
2
1
1
1
2
1
2
2
1
1
2
2
2
1
2
2
1
2
1
1
2
2
2
1
2
2
2
1
2
1
2
2
1
2
2
1
1
1
2
2
1
1
2
1
1
2
2
2
1
2
1
1
2
2
1
1
1
2
1
2
1
2
1
2
2
1
1
1
2
1
2
2
1
1
1
2
1
2
1
1
2
2
1
1
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
1
1
1...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
0 558
8
2
8
1 558
8
0 1743
8
2
8
0 1356
8
2
8
0 1971
8
2
8
0 1882
8
2
8
0 15
8
2
8
1 15
8
0 867
8
2
8
1 867
8
0 1339
8
2
8
0 1883
8
2
8
0 918
8
2
8
1 918
8
0 405
8
2
8
1 405
8
0 1050
8
2
8
0 288
8
2
8
1 288
8
0 92
8
2
8
1 92
8
0 1918
8
2
8
0 1851
...

result:

ok 

Test #88:

score: 75
Accepted
time: 6ms
memory: 3868kb

input:

2000
1
1
2
2
1
2
2
2
2
1
1
2
2
1
1
2
1
1
2
2
2
2
1
2
2
2
1
2
2
2
2
1
1
2
2
2
1
2
1
2
1
2
1
1
2
1
1
2
2
2
1
2
1
1
2
2
1
1
1
2
1
1
2
1
2
2
1
1
1
2
1
1
1
2
1
2
1
1
2
1
1
2
2
2
1
1
2
2
1
2
2
1
1
1
2
1
2
2
1
1
2
2
2
1
2
1
2
1
2
1
1
2
2
2
1
2
1
1
2
2
2
1
2
1
2
2
1
1
2
2
2
2
2
2
1
1
1
2
1
1
1
1
2
1
1
2
2
2...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
1 1456
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
1 1356
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
0 867
8
2
8
0 1339
8
2
8
1 1339
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
0 405
8
2
8
0 1050
8
2
8
1 1050
8
0 288
8
2
8
0 92...

result:

ok 

Test #89:

score: 75
Accepted
time: 2ms
memory: 3776kb

input:

2000
1
1
1
2
1
2
1
2
2
2
1
1
2
1
2
1
2
2
2
2
1
2
1
2
2
2
2
1
1
1
1
1
1
1
2
2
1
1
1
1
1
2
1
1
2
1
1
2
1
1
1
2
2
1
1
1
1
1
2
1
1
1
1
2
1
1
2
2
2
2
2
1
1
2
1
2
1
2
2
2
2
2
1
2
1
2
2
1
2
1
1
1
1
2
2
2
2
2
1
2
1
1
1
1
2
1
1
2
2
1
1
2
1
2
1
2
1
2
1
1
1
2
2
1
1
1
2
1
1
2
2
2
2
1
1
2
1
2
2
1
1
2
2
2
1
1
2
1...

output:

8
0 1410
8
2
8
0 316
8
2
8
0 1456
8
2
8
0 1894
8
2
8
1 1894
8
0 558
8
2
8
0 1743
8
2
8
1 1743
8
0 1356
8
2
8
0 1971
8
2
8
1 1971
8
0 1882
8
2
8
1 1882
8
0 15
8
2
8
1 15
8
0 867
8
2
8
0 1339
8
2
8
0 1883
8
2
8
1 1883
8
0 918
8
2
8
0 405
8
2
8
1 405
8
0 1050
8
2
8
0 288
8
2
8
1 288
8
0 92
8
2
8
1 92
8...

result:

ok