QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#794762#4565. Rarest Insects_8_8_100 ✓27ms4404kbC++231.9kb2024-11-30 15:55:002024-11-30 15:55:01

Judging History

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

  • [2024-11-30 15:55:01]
  • 评测
  • 测评结果:100
  • 用时:27ms
  • 内存:4404kb
  • [2024-11-30 15:55:00]
  • 提交

answer

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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, u;
vector<int> p;
set<int> cur, lef;
void add(int i) {
    cur.insert(i);
    i = p[i];
    move_inside(i);
}
void del(int i) {
    if(cur.count(i)) {
        cur.erase(i);
        i = p[i];
        move_outside(i);
    }
}
int l , r;
bool check(int mid) {
    if(mid * u > n) return false;
    int col = 0, sz = (int)cur.size();
    int val = (int)lef.size() + (int)cur.size();
    set<int> nf = lef;
    vector<int> t;
    for(int i : lef) t.push_back(i);
    
    shuffle(t.begin(), t.end(), rng);
    for(int i : t) {
        if(sz == mid * u) break;
        add(i); 
        sz++;
        if(col <= val - mid * u && press_button() > mid) {
            del(i);
            nf.erase(i);
            sz--;
        }
    }
    if(sz == mid * u) {
        l = mid;
        if(r - l <= 1) return 1;
        set<int> nv;
        for(int i : lef) {
            if(!cur.count(i)) { 
                nv.insert(i);
            }
        }
        lef.swap(nv);   
        return 1;   
    }
    r = mid;
    if(r - l <= 1) return 0;
    for(auto i : nf) {
        del(i);
    }
    lef.swap(nf);
    return false;
}
int min_cardinality(int NN) {
    n = NN;
    for(int i = 0; i < n; i++) {
        p.push_back(i);
        lef.insert(i);
    }
    shuffle(p.begin(), p.end(), rng);
    for(int i = 0; i < n; i++) {
        add(i);
        if(press_button() == 2) {
            del(i);
        } else {
            lef.erase(i);
        }
    }
    u = (int)cur.size();
    if(u == 1) return n;
    if(u == n) return 1;
    l = 1, r = n / u + 1;
    while(r - l > 1) {
        int mid = (l + r) >> 1;
        if(check(mid)) {
            // l = mid;
        } else {
            // r = mid;
        }
    }
    return l;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

6
1
1
1
2
2
2
2
3
2

output:

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

result:

ok 

Test #2:

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

input:

2
1
2

output:

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

result:

ok 

Test #3:

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

input:

2
1
1

output:

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

result:

ok 

Test #4:

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

input:

3
1
2
1

output:

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

result:

ok 

Test #5:

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

input:

5
1
2
2
1
2
2
2

output:

8
0 3
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 1
8
2
8
0 0
8
2
8
3 2

result:

ok 

Test #6:

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

input:

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

output:

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

result:

ok 

Test #7:

score: 10
Accepted
time: 2ms
memory: 4116kb

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 157
8
2
8
0 140
8
2
8
1 140
8
0 74
8
2
8
1 74
8
0 148
8
2
8
1 148
8
0 176
8
2
8
1 176
8
0 99
8
2
8
1 99
8
0 159
8
2
8
1 159
8
0 11
8
2
8
1 11
8
0 80
8
2
8
1 80
8
0 45
8
2
8
1 45
8
0 103
8
2
8
1 103
8
0 105
8
2
8
1 105
8
0 187
8
2
8
1 187
8
0 127
8
2
8
1 127
8
0 98
8
2
8
1 98
8
0 188
8
2
8
1 188
...

result:

ok 

Test #8:

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

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 192
8
2
8
0 62
8
2
8
0 89
8
2
8
0 48
8
2
8
0 195
8
2
8
0 139
8
2
8
0 161
8
2
8
0 176
8
2
8
0 16
8
2
8
0 42
8
2
8
0 164
8
2
8
0 168
8
2
8
0 22
8
2
8
0 193
8
2
8
0 131
8
2
8
0 32
8
2
8
0 184
8
2
8
0 163
8
2
8
0 24
8
2
8
0 33
8
2
8
0 6
8
2
8
0 58
8
2
8
0 167
8
2
8
0 88
8
2
8
0 111
8
2
8
0 46
8
2
8
...

result:

ok 

Test #9:

score: 10
Accepted
time: 2ms
memory: 4104kb

input:

200
1
1
1
1
1
1
1
1
1
2
1
1
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
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
...

output:

8
0 67
8
2
8
0 163
8
2
8
0 145
8
2
8
0 80
8
2
8
0 47
8
2
8
0 9
8
2
8
0 101
8
2
8
0 38
8
2
8
0 42
8
2
8
0 5
8
2
8
1 5
8
0 126
8
2
8
0 195
8
2
8
0 41
8
2
8
1 41
8
0 158
8
2
8
1 158
8
0 155
8
2
8
0 141
8
2
8
0 130
8
2
8
1 130
8
0 185
8
2
8
1 185
8
0 45
8
2
8
1 45
8
0 187
8
2
8
1 187
8
0 153
8
2
8
1 153...

result:

ok 

Test #10:

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

input:

198
1
1
1
2
2
1
2
1
1
1
2
1
1
1
2
1
2
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 50
8
2
8
0 69
8
2
8
0 115
8
2
8
0 24
8
2
8
1 24
8
0 91
8
2
8
1 91
8
0 7
8
2
8
0 32
8
2
8
1 32
8
0 54
8
2
8
0 0
8
2
8
0 34
8
2
8
0 27
8
2
8
1 27
8
0 178
8
2
8
0 66
8
2
8
0 114
8
2
8
0 92
8
2
8
1 92
8
0 145
8
2
8
0 170
8
2
8
1 170
8
0 185
8
2
8
0 195
8
2
8
0 160
8
2
8
1 160
8
0 144
8
2
8
1 144
8
0...

result:

ok 

Test #11:

score: 10
Accepted
time: 3ms
memory: 3848kb

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 26
8
2
8
0 162
8
2
8
1 162
8
0 39
8
2
8
1 39
8
0 21
8
2
8
1 21
8
0 178
8
2
8
1 178
8
0 195
8
2
8
1 195
8
0 156
8
2
8
1 156
8
0 14
8
2
8
1 14
8
0 122
8
2
8
1 122
8
0 19
8
2
8
1 19
8
0 48
8
2
8
1 48
8
0 29
8
2
8
1 29
8
0 78
8
2
8
1 78
8
0 84
8
2
8
1 84
8
0 114
8
2
8
1 114
8
0 18
8
2
8
1 18
8
0 177...

result:

ok 

Test #12:

score: 10
Accepted
time: 2ms
memory: 4116kb

input:

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

output:

8
0 161
8
2
8
0 65
8
2
8
1 65
8
0 186
8
2
8
0 147
8
2
8
1 147
8
0 17
8
2
8
1 17
8
0 120
8
2
8
1 120
8
0 122
8
2
8
1 122
8
0 145
8
2
8
1 145
8
0 66
8
2
8
0 89
8
2
8
1 89
8
0 59
8
2
8
1 59
8
0 100
8
2
8
1 100
8
0 135
8
2
8
1 135
8
0 172
8
2
8
0 116
8
2
8
0 13
8
2
8
0 24
8
2
8
0 184
8
2
8
1 184
8
0 19
...

result:

ok 

Test #13:

score: 10
Accepted
time: 3ms
memory: 4092kb

input:

197
1
2
1
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
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
...

output:

8
0 143
8
2
8
0 5
8
2
8
1 5
8
0 82
8
2
8
0 161
8
2
8
1 161
8
0 163
8
2
8
0 178
8
2
8
1 178
8
0 134
8
2
8
1 134
8
0 19
8
2
8
1 19
8
0 3
8
2
8
1 3
8
0 117
8
2
8
1 117
8
0 30
8
2
8
0 169
8
2
8
1 169
8
0 24
8
2
8
1 24
8
0 94
8
2
8
1 94
8
0 60
8
2
8
1 60
8
0 31
8
2
8
1 31
8
0 110
8
2
8
1 110
8
0 186
8
2
...

result:

ok 

Test #14:

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

input:

198
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
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
...

output:

8
0 118
8
2
8
0 76
8
2
8
0 6
8
2
8
0 55
8
2
8
0 74
8
2
8
0 3
8
2
8
0 89
8
2
8
0 27
8
2
8
1 27
8
0 141
8
2
8
0 156
8
2
8
0 155
8
2
8
0 181
8
2
8
0 34
8
2
8
1 34
8
0 57
8
2
8
1 57
8
0 66
8
2
8
0 1
8
2
8
1 1
8
0 61
8
2
8
1 61
8
0 123
8
2
8
1 123
8
0 145
8
2
8
0 150
8
2
8
1 150
8
0 130
8
2
8
1 130
8
0 5...

result:

ok 

Test #15:

score: 10
Accepted
time: 3ms
memory: 3900kb

input:

200
1
2
1
2
2
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
2
2
2
2
2
2
...

output:

8
0 159
8
2
8
0 21
8
2
8
1 21
8
0 4
8
2
8
0 122
8
2
8
1 122
8
0 197
8
2
8
1 197
8
0 1
8
2
8
1 1
8
0 117
8
2
8
0 80
8
2
8
1 80
8
0 144
8
2
8
0 113
8
2
8
0 42
8
2
8
1 42
8
0 64
8
2
8
1 64
8
0 147
8
2
8
1 147
8
0 115
8
2
8
1 115
8
0 88
8
2
8
1 88
8
0 188
8
2
8
1 188
8
0 87
8
2
8
1 87
8
0 141
8
2
8
1 14...

result:

ok 

Test #16:

score: 10
Accepted
time: 3ms
memory: 3876kb

input:

196
1
1
1
1
1
2
2
1
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
...

output:

8
0 159
8
2
8
0 47
8
2
8
0 31
8
2
8
0 36
8
2
8
0 45
8
2
8
0 153
8
2
8
1 153
8
0 1
8
2
8
1 1
8
0 147
8
2
8
0 76
8
2
8
0 120
8
2
8
1 120
8
0 54
8
2
8
1 54
8
0 33
8
2
8
1 33
8
0 119
8
2
8
1 119
8
0 126
8
2
8
1 126
8
0 167
8
2
8
1 167
8
0 144
8
2
8
1 144
8
0 12
8
2
8
1 12
8
0 65
8
2
8
1 65
8
0 100
8
2
8...

result:

ok 

Test #17:

score: 10
Accepted
time: 3ms
memory: 4132kb

input:

199
1
1
1
1
1
2
1
1
2
2
2
2
2
2
2
1
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
2
2
2
2
2
2
2
2
2
...

output:

8
0 16
8
2
8
0 183
8
2
8
0 80
8
2
8
0 43
8
2
8
0 74
8
2
8
0 29
8
2
8
1 29
8
0 13
8
2
8
0 31
8
2
8
0 61
8
2
8
1 61
8
0 174
8
2
8
1 174
8
0 71
8
2
8
1 71
8
0 100
8
2
8
1 100
8
0 132
8
2
8
1 132
8
0 85
8
2
8
1 85
8
0 173
8
2
8
1 173
8
0 93
8
2
8
0 81
8
2
8
1 81
8
0 154
8
2
8
0 106
8
2
8
1 106
8
0 4
8
2...

result:

ok 

Test #18:

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

input:

196
1
1
1
1
2
2
1
1
1
2
1
2
1
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
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
...

output:

8
0 42
8
2
8
0 126
8
2
8
0 144
8
2
8
0 135
8
2
8
0 10
8
2
8
1 10
8
0 8
8
2
8
1 8
8
0 188
8
2
8
0 129
8
2
8
0 161
8
2
8
0 190
8
2
8
1 190
8
0 179
8
2
8
0 194
8
2
8
1 194
8
0 12
8
2
8
0 123
8
2
8
1 123
8
0 136
8
2
8
1 136
8
0 192
8
2
8
1 192
8
0 148
8
2
8
1 148
8
0 17
8
2
8
1 17
8
0 130
8
2
8
1 130
8
...

result:

ok 

Test #19:

score: 10
Accepted
time: 4ms
memory: 4136kb

input:

196
1
1
1
1
2
1
2
1
2
1
1
1
2
2
2
1
2
2
1
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 15
8
2
8
0 41
8
2
8
0 70
8
2
8
0 150
8
2
8
0 125
8
2
8
1 125
8
0 60
8
2
8
0 135
8
2
8
1 135
8
0 172
8
2
8
0 101
8
2
8
1 101
8
0 71
8
2
8
0 116
8
2
8
0 126
8
2
8
0 9
8
2
8
1 9
8
0 146
8
2
8
1 146
8
0 109
8
2
8
1 109
8
0 182
8
2
8
0 96
8
2
8
1 96
8
0 163
8
2
8
1 163
8
0 89
8
2
8
0 132
8
2
8
1 132
...

result:

ok 

Test #20:

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

input:

196
1
1
1
1
1
2
1
1
2
2
2
1
1
2
2
1
1
1
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
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
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
...

output:

8
0 15
8
2
8
0 107
8
2
8
0 150
8
2
8
0 95
8
2
8
0 28
8
2
8
0 32
8
2
8
1 32
8
0 126
8
2
8
0 113
8
2
8
0 93
8
2
8
1 93
8
0 71
8
2
8
1 71
8
0 146
8
2
8
1 146
8
0 116
8
2
8
0 38
8
2
8
0 168
8
2
8
1 168
8
0 119
8
2
8
1 119
8
0 109
8
2
8
0 142
8
2
8
0 21
8
2
8
0 120
8
2
8
1 120
8
0 34
8
2
8
1 34
8
0 147
8...

result:

ok 

Test #21:

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

input:

200
1
1
1
1
1
2
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
2
2
1
1
2
1
2
2
2
1
2
1
2
1
2
1
2
2
1
2
2
2
2
2
1
2
2
1
1
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
1
2
1
2
2
2
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
1
2
2
2
2
2
2
2
2
2
2
2
2
2
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
2
2
2
...

output:

8
0 183
8
2
8
0 171
8
2
8
0 83
8
2
8
0 71
8
2
8
0 60
8
2
8
0 163
8
2
8
1 163
8
0 160
8
2
8
0 144
8
2
8
0 176
8
2
8
0 34
8
2
8
0 157
8
2
8
1 157
8
0 126
8
2
8
0 170
8
2
8
1 170
8
0 45
8
2
8
0 136
8
2
8
0 117
8
2
8
0 59
8
2
8
0 199
8
2
8
1 199
8
0 55
8
2
8
0 198
8
2
8
0 137
8
2
8
0 108
8
2
8
0 110
8
2...

result:

ok 

Test #22:

score: 10
Accepted
time: 2ms
memory: 3844kb

input:

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

output:

8
0 130
8
2
8
0 2
8
2
8
0 26
8
2
8
0 134
8
2
8
0 184
8
2
8
0 7
8
2
8
0 97
8
2
8
0 50
8
2
8
0 20
8
2
8
0 177
8
2
8
0 28
8
2
8
0 65
8
2
8
0 188
8
2
8
0 11
8
2
8
0 16
8
2
8
0 19
8
2
8
0 197
8
2
8
1 197
8
0 12
8
2
8
0 1
8
2
8
0 180
8
2
8
0 100
8
2
8
0 53
8
2
8
0 59
8
2
8
1 59
8
0 54
8
2
8
1 54
8
0 31
8
...

result:

ok 

Test #23:

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

input:

198
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
2
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
1
1
1
2
1
2
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
1
2
2
2
1
2
1
1
2
1
1
1
1
2
1
1
2
1
1
1
2
1
1
2
1
1
1
1
2
2
2
1
2
1
1
2
2
1
1
2
1
1
1
1
1
2
2
1
1
2
1
1
2
2
2
1
1
2
1
1
2
2
2
...

output:

8
0 47
8
2
8
0 99
8
2
8
0 28
8
2
8
0 80
8
2
8
0 168
8
2
8
0 187
8
2
8
1 187
8
0 96
8
2
8
0 133
8
2
8
0 132
8
2
8
0 157
8
2
8
0 10
8
2
8
0 57
8
2
8
0 167
8
2
8
0 97
8
2
8
0 131
8
2
8
0 155
8
2
8
0 150
8
2
8
0 71
8
2
8
0 109
8
2
8
0 12
8
2
8
0 48
8
2
8
0 69
8
2
8
0 182
8
2
8
0 146
8
2
8
0 125
8
2
8
0 ...

result:

ok 

Subtask #2:

score: 15
Accepted

Test #24:

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

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 771
8
2
8
0 3
8
2
8
1 3
8
0 414
8
2
8
1 414
8
0 219
8
2
8
1 219
8
0 598
8
2
8
1 598
8
0 397
8
2
8
1 397
8
0 406
8
2
8
1 406
8
0 720
8
2
8
1 720
8
0 491
8
2
8
1 491
8
0 835
8
2
8
1 835
8
0 601
8
2
8
1 601
8
0 535
8
2
8
1 535
8
0 891
8
2
8
1 891
8
0 151
8
2
8
1 151
8
0 943
8
2
8
1 943
8
0 663
8
2
...

result:

ok 

Test #25:

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

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 296
8
2
8
0 227
8
2
8
0 611
8
2
8
0 492
8
2
8
0 228
8
2
8
0 894
8
2
8
0 665
8
2
8
0 698
8
2
8
0 356
8
2
8
0 621
8
2
8
0 673
8
2
8
0 168
8
2
8
0 150
8
2
8
0 840
8
2
8
0 223
8
2
8
0 419
8
2
8
0 662
8
2
8
0 38
8
2
8
0 19
8
2
8
0 336
8
2
8
0 154
8
2
8
0 866
8
2
8
0 96
8
2
8
0 44
8
2
8
0 807
8
2
8
0 ...

result:

ok 

Test #26:

score: 15
Accepted
time: 3ms
memory: 4244kb

input:

999
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
2
2
1
1
2
2
1
1
2
2
2
2
2
1
2
1
1
1
1
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
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
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
...

output:

8
0 800
8
2
8
0 751
8
2
8
0 865
8
2
8
1 865
8
0 280
8
2
8
0 787
8
2
8
0 736
8
2
8
0 186
8
2
8
0 227
8
2
8
1 227
8
0 580
8
2
8
0 522
8
2
8
0 49
8
2
8
1 49
8
0 407
8
2
8
0 756
8
2
8
0 44
8
2
8
0 718
8
2
8
0 219
8
2
8
1 219
8
0 122
8
2
8
0 640
8
2
8
0 105
8
2
8
0 482
8
2
8
1 482
8
0 569
8
2
8
1 569
8
0...

result:

ok 

Test #27:

score: 15
Accepted
time: 4ms
memory: 4000kb

input:

999
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
1
1
2
1
2
1
1
1
2
2
2
2
1
1
2
2
2
2
2
1
2
1
2
2
2
1
2
1
2
2
1
2
2
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
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
...

output:

8
0 492
8
2
8
0 218
8
2
8
0 473
8
2
8
0 385
8
2
8
0 169
8
2
8
0 205
8
2
8
0 975
8
2
8
0 553
8
2
8
0 142
8
2
8
0 220
8
2
8
0 678
8
2
8
1 678
8
0 393
8
2
8
0 93
8
2
8
0 790
8
2
8
1 790
8
0 766
8
2
8
0 855
8
2
8
1 855
8
0 419
8
2
8
0 185
8
2
8
0 346
8
2
8
1 346
8
0 206
8
2
8
0 959
8
2
8
1 959
8
0 86
8
...

result:

ok 

Test #28:

score: 15
Accepted
time: 8ms
memory: 3988kb

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 914
8
2
8
0 635
8
2
8
1 635
8
0 424
8
2
8
1 424
8
0 236
8
2
8
1 236
8
0 239
8
2
8
1 239
8
0 631
8
2
8
1 631
8
0 650
8
2
8
1 650
8
0 992
8
2
8
1 992
8
0 887
8
2
8
1 887
8
0 610
8
2
8
1 610
8
0 659
8
2
8
1 659
8
0 578
8
2
8
1 578
8
0 483
8
2
8
1 483
8
0 993
8
2
8
1 993
8
0 257
8
2
8
1 257
8
0 454
...

result:

ok 

Test #29:

score: 15
Accepted
time: 6ms
memory: 4124kb

input:

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

output:

8
0 396
8
2
8
0 51
8
2
8
0 918
8
2
8
0 778
8
2
8
1 778
8
0 478
8
2
8
0 64
8
2
8
0 363
8
2
8
0 262
8
2
8
1 262
8
0 523
8
2
8
1 523
8
0 410
8
2
8
0 817
8
2
8
1 817
8
0 805
8
2
8
0 231
8
2
8
0 708
8
2
8
1 708
8
0 52
8
2
8
1 52
8
0 151
8
2
8
0 76
8
2
8
1 76
8
0 336
8
2
8
0 544
8
2
8
0 756
8
2
8
1 756
8
...

result:

ok 

Test #30:

score: 15
Accepted
time: 9ms
memory: 3936kb

input:

998
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 911
8
2
8
0 311
8
2
8
0 879
8
2
8
1 879
8
0 599
8
2
8
1 599
8
0 810
8
2
8
1 810
8
0 376
8
2
8
1 376
8
0 147
8
2
8
0 947
8
2
8
0 958
8
2
8
1 958
8
0 855
8
2
8
1 855
8
0 455
8
2
8
1 455
8
0 952
8
2
8
1 952
8
0 718
8
2
8
1 718
8
0 539
8
2
8
1 539
8
0 104
8
2
8
1 104
8
0 915
8
2
8
1 915
8
0 944
8
2
...

result:

ok 

Test #31:

score: 15
Accepted
time: 3ms
memory: 3936kb

input:

998
1
1
1
1
1
1
1
1
1
1
2
2
1
1
2
2
2
1
1
1
1
1
2
1
1
2
2
1
2
1
1
2
2
2
2
1
1
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
1
2
2
2
2
2
1
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
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
...

output:

8
0 194
8
2
8
0 343
8
2
8
0 51
8
2
8
0 701
8
2
8
0 927
8
2
8
0 656
8
2
8
0 748
8
2
8
0 700
8
2
8
0 703
8
2
8
0 493
8
2
8
0 238
8
2
8
1 238
8
0 505
8
2
8
1 505
8
0 996
8
2
8
0 962
8
2
8
0 573
8
2
8
1 573
8
0 393
8
2
8
1 393
8
0 244
8
2
8
1 244
8
0 524
8
2
8
0 73
8
2
8
0 454
8
2
8
0 926
8
2
8
0 741
8
...

result:

ok 

Test #32:

score: 15
Accepted
time: 4ms
memory: 4244kb

input:

1000
1
1
1
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
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 269
8
2
8
0 450
8
2
8
0 339
8
2
8
0 67
8
2
8
1 67
8
0 604
8
2
8
1 604
8
0 85
8
2
8
0 162
8
2
8
1 162
8
0 656
8
2
8
1 656
8
0 128
8
2
8
1 128
8
0 960
8
2
8
1 960
8
0 568
8
2
8
1 568
8
0 382
8
2
8
0 100
8
2
8
1 100
8
0 687
8
2
8
1 687
8
0 824
8
2
8
1 824
8
0 400
8
2
8
1 400
8
0 295
8
2
8
1 295
8
0...

result:

ok 

Test #33:

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

input:

996
1
1
1
1
2
2
2
1
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
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
...

output:

8
0 226
8
2
8
0 14
8
2
8
0 548
8
2
8
0 566
8
2
8
0 378
8
2
8
1 378
8
0 124
8
2
8
1 124
8
0 333
8
2
8
1 333
8
0 119
8
2
8
0 771
8
2
8
1 771
8
0 351
8
2
8
1 351
8
0 222
8
2
8
1 222
8
0 499
8
2
8
1 499
8
0 682
8
2
8
1 682
8
0 440
8
2
8
0 492
8
2
8
1 492
8
0 99
8
2
8
1 99
8
0 873
8
2
8
1 873
8
0 239
8
2...

result:

ok 

Test #34:

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

input:

1000
1
1
1
2
1
1
2
2
1
2
1
2
2
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...

output:

8
0 354
8
2
8
0 22
8
2
8
0 453
8
2
8
0 838
8
2
8
1 838
8
0 856
8
2
8
0 357
8
2
8
0 958
8
2
8
1 958
8
0 5
8
2
8
1 5
8
0 727
8
2
8
0 83
8
2
8
1 83
8
0 961
8
2
8
0 689
8
2
8
1 689
8
0 230
8
2
8
1 230
8
0 679
8
2
8
1 679
8
0 284
8
2
8
0 843
8
2
8
1 843
8
0 909
8
2
8
0 999
8
2
8
0 789
8
2
8
1 789
8
0 659...

result:

ok 

Test #35:

score: 15
Accepted
time: 8ms
memory: 4024kb

input:

1000
1
1
1
1
2
1
1
1
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 923
8
2
8
0 406
8
2
8
0 95
8
2
8
0 892
8
2
8
0 595
8
2
8
1 595
8
0 329
8
2
8
0 362
8
2
8
0 879
8
2
8
0 779
8
2
8
1 779
8
0 264
8
2
8
0 34
8
2
8
0 842
8
2
8
1 842
8
0 614
8
2
8
1 614
8
0 959
8
2
8
1 959
8
0 187
8
2
8
1 187
8
0 473
8
2
8
0 294
8
2
8
1 294
8
0 349
8
2
8
1 349
8
0 228
8
2
8
0 567
8
...

result:

ok 

Test #36:

score: 15
Accepted
time: 3ms
memory: 4016kb

input:

997
1
2
1
1
1
1
2
2
1
1
2
1
1
1
2
2
1
2
2
1
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
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
...

output:

8
0 320
8
2
8
0 180
8
2
8
1 180
8
0 90
8
2
8
0 712
8
2
8
0 914
8
2
8
0 281
8
2
8
0 821
8
2
8
1 821
8
0 453
8
2
8
1 453
8
0 83
8
2
8
0 545
8
2
8
0 331
8
2
8
1 331
8
0 274
8
2
8
0 178
8
2
8
0 161
8
2
8
0 318
8
2
8
1 318
8
0 388
8
2
8
1 388
8
0 474
8
2
8
0 566
8
2
8
1 566
8
0 405
8
2
8
1 405
8
0 936
8
...

result:

ok 

Test #37:

score: 15
Accepted
time: 6ms
memory: 4240kb

input:

995
1
1
1
1
1
1
2
2
1
1
1
2
2
1
1
1
1
2
2
1
1
1
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
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
2
2
2
2
2
2
2
2
2
2
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 785
8
2
8
0 17
8
2
8
0 605
8
2
8
0 54
8
2
8
0 194
8
2
8
0 274
8
2
8
0 29
8
2
8
1 29
8
0 533
8
2
8
1 533
8
0 783
8
2
8
0 624
8
2
8
0 123
8
2
8
0 371
8
2
8
1 371
8
0 581
8
2
8
1 581
8
0 611
8
2
8
0 32
8
2
8
0 888
8
2
8
0 319
8
2
8
0 743
8
2
8
1 743
8
0 492
8
2
8
1 492
8
0 470
8
2
8
0 599
8
2
8
0 8...

result:

ok 

Test #38:

score: 15
Accepted
time: 3ms
memory: 4232kb

input:

997
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
2
1
1
1
2
2
2
1
2
1
1
2
2
2
2
2
2
1
1
1
1
2
2
1
1
2
1
1
1
1
1
1
2
2
2
2
1
1
2
2
2
2
2
2
1
1
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
2
2
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
1
2
2
2
2
2
2
1
2
1
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
...

output:

8
0 765
8
2
8
0 851
8
2
8
0 774
8
2
8
0 898
8
2
8
0 161
8
2
8
0 742
8
2
8
0 523
8
2
8
0 748
8
2
8
0 848
8
2
8
0 101
8
2
8
0 667
8
2
8
1 667
8
0 316
8
2
8
1 316
8
0 277
8
2
8
0 827
8
2
8
0 212
8
2
8
0 333
8
2
8
1 333
8
0 907
8
2
8
0 797
8
2
8
1 797
8
0 379
8
2
8
0 867
8
2
8
0 683
8
2
8
0 318
8
2
8
1 ...

result:

ok 

Test #39:

score: 15
Accepted
time: 4ms
memory: 3984kb

input:

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

output:

8
0 100
8
2
8
0 31
8
2
8
0 22
8
2
8
0 525
8
2
8
0 156
8
2
8
0 30
8
2
8
1 30
8
0 187
8
2
8
0 495
8
2
8
0 345
8
2
8
0 655
8
2
8
0 630
8
2
8
0 678
8
2
8
0 316
8
2
8
0 235
8
2
8
0 222
8
2
8
1 222
8
0 86
8
2
8
0 213
8
2
8
1 213
8
0 515
8
2
8
0 971
8
2
8
0 648
8
2
8
1 648
8
0 464
8
2
8
1 464
8
0 417
8
2
8...

result:

ok 

Test #40:

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

input:

996
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
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
2
1
2
2
1
1
1
2
2
1
1
2
1
1
1
2
1
1
1
2
2
1
1
2
1
2
1
1
1
1
2
1
1
1
1
1
1
1
2
2
2
2
1
1
1
2
2
1
2
1
1
1
2
1
1
1
1
1
1
2
1
1
2
2
2
1
1
2
2
1
2
2
1
1
1
1
2
1
2
2
1
2
1
1
1
1
2
2
2
2
1
2
2
1
1
1
2
2
1
1
2
...

output:

8
0 565
8
2
8
0 374
8
2
8
0 719
8
2
8
0 299
8
2
8
0 327
8
2
8
0 359
8
2
8
0 744
8
2
8
0 100
8
2
8
0 906
8
2
8
0 274
8
2
8
0 970
8
2
8
0 400
8
2
8
1 400
8
0 727
8
2
8
0 863
8
2
8
0 123
8
2
8
0 883
8
2
8
0 454
8
2
8
0 339
8
2
8
0 842
8
2
8
0 989
8
2
8
0 900
8
2
8
0 457
8
2
8
0 888
8
2
8
0 995
8
2
8
0 ...

result:

ok 

Test #41:

score: 15
Accepted
time: 7ms
memory: 3976kb

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
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
2
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
2
2
1
1
1
2
1
1
1
2
1
1
1
2
2
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
1
2
1
...

output:

8
0 202
8
2
8
0 399
8
2
8
0 483
8
2
8
0 567
8
2
8
0 422
8
2
8
0 371
8
2
8
0 659
8
2
8
0 303
8
2
8
0 447
8
2
8
0 80
8
2
8
0 194
8
2
8
0 328
8
2
8
0 284
8
2
8
0 969
8
2
8
0 420
8
2
8
0 289
8
2
8
0 915
8
2
8
0 580
8
2
8
0 439
8
2
8
0 798
8
2
8
0 449
8
2
8
0 31
8
2
8
0 698
8
2
8
0 662
8
2
8
0 271
8
2
8
...

result:

ok 

Test #42:

score: 15
Accepted
time: 3ms
memory: 3840kb

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
2
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
1
1
1
1
1
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
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
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
...

output:

8
0 106
8
2
8
0 356
8
2
8
0 104
8
2
8
0 808
8
2
8
0 28
8
2
8
0 215
8
2
8
0 886
8
2
8
0 692
8
2
8
0 432
8
2
8
0 881
8
2
8
0 349
8
2
8
0 578
8
2
8
0 695
8
2
8
0 357
8
2
8
0 134
8
2
8
0 475
8
2
8
0 271
8
2
8
0 476
8
2
8
0 342
8
2
8
0 648
8
2
8
0 171
8
2
8
0 750
8
2
8
0 736
8
2
8
0 214
8
2
8
0 994
8
2
8...

result:

ok 

Subtask #3:

score: 75
Accepted

Test #43:

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

input:

2
1
2

output:

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

result:

ok 

Test #44:

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

input:

2
1
1

output:

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

result:

ok 

Test #45:

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

input:

3
1
2
1

output:

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

result:

ok 

Test #46:

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

input:

6
1
1
2
2
2
2
2
3
3
3

output:

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

result:

ok 

Test #47:

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

input:

10
1
1
2
2
2
2
2
2
2
2
2
2
3
3
4
4
5
6

output:

8
0 6
8
2
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 5
8
2
8
1 5
8
0 0
8
2
8
1 0
8
0 9
8
2
8
1 9
8
0 3
8
2
8
1 3
8
0 8
8
2
8
1 8
8
0 4
8
2
8
0 2
8
2
8
0 9
8
2
8
0 3
8
2
8
0 8
8
2
8
0 7
8
2
8
0 0
8
2
8
0 5
8
2
8
1 5
8
3 4

result:

ok 

Test #48:

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

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 567
8
2
8
0 1485
8
2
8
1 1485
8
0 43
8
2
8
1 43
8
0 1728
8
2
8
1 1728
8
0 1985
8
2
8
1 1985
8
0 1659
8
2
8
1 1659
8
0 142
8
2
8
1 142
8
0 1665
8
2
8
1 1665
8
0 454
8
2
8
1 454
8
0 1334
8
2
8
1 1334
8
0 1909
8
2
8
1 1909
8
0 377
8
2
8
1 377
8
0 876
8
2
8
1 876
8
0 383
8
2
8
1 383
8
0 403
8
2
8
1 ...

result:

ok 

Test #49:

score: 75
Accepted
time: 8ms
memory: 3928kb

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 1425
8
2
8
0 1936
8
2
8
0 144
8
2
8
0 1944
8
2
8
0 138
8
2
8
0 1204
8
2
8
0 1926
8
2
8
0 822
8
2
8
0 1293
8
2
8
0 1518
8
2
8
0 300
8
2
8
0 1314
8
2
8
0 729
8
2
8
0 107
8
2
8
0 561
8
2
8
0 1810
8
2
8
0 691
8
2
8
0 1662
8
2
8
0 702
8
2
8
0 252
8
2
8
0 118
8
2
8
0 84
8
2
8
0 1460
8
2
8
0 1426
8
2
8...

result:

ok 

Test #50:

score: 75
Accepted
time: 8ms
memory: 4236kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
2
2
2
2
2
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
1
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
1
2
2
2
2
1
2
1
2
2
2
2
1
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
1...

output:

8
0 907
8
2
8
0 1425
8
2
8
0 1947
8
2
8
0 511
8
2
8
0 1017
8
2
8
0 18
8
2
8
0 204
8
2
8
0 605
8
2
8
0 1520
8
2
8
0 1165
8
2
8
0 859
8
2
8
0 599
8
2
8
1 599
8
0 1781
8
2
8
0 1154
8
2
8
0 472
8
2
8
1 472
8
0 1477
8
2
8
0 260
8
2
8
1 260
8
0 1741
8
2
8
1 1741
8
0 1456
8
2
8
0 1115
8
2
8
0 1364
8
2
8
0 ...

result:

ok 

Test #51:

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

input:

2000
1
1
1
1
1
2
1
1
1
2
1
1
2
2
1
1
1
1
2
1
2
1
2
1
1
1
1
2
2
2
1
2
2
1
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
1
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
1
2
2
2
2
2
2
2
2
2
2
2
1
1
1
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
1...

output:

8
0 886
8
2
8
0 892
8
2
8
0 49
8
2
8
0 106
8
2
8
0 607
8
2
8
0 927
8
2
8
1 927
8
0 1091
8
2
8
0 613
8
2
8
0 1185
8
2
8
0 273
8
2
8
1 273
8
0 840
8
2
8
0 1546
8
2
8
0 401
8
2
8
1 401
8
0 1451
8
2
8
1 1451
8
0 549
8
2
8
0 1270
8
2
8
0 1323
8
2
8
0 76
8
2
8
0 1388
8
2
8
1 1388
8
0 1769
8
2
8
0 642
8
2
...

result:

ok 

Test #52:

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

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
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...

output:

8
0 1103
8
2
8
0 56
8
2
8
1 56
8
0 1341
8
2
8
1 1341
8
0 462
8
2
8
1 462
8
0 547
8
2
8
1 547
8
0 1972
8
2
8
1 1972
8
0 1548
8
2
8
1 1548
8
0 1129
8
2
8
1 1129
8
0 1826
8
2
8
1 1826
8
0 1241
8
2
8
1 1241
8
0 1236
8
2
8
1 1236
8
0 291
8
2
8
1 291
8
0 1022
8
2
8
1 1022
8
0 1066
8
2
8
1 1066
8
0 510
8
2...

result:

ok 

Test #53:

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

input:

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

output:

8
0 1229
8
2
8
0 1681
8
2
8
0 916
8
2
8
0 523
8
2
8
1 523
8
0 1298
8
2
8
1 1298
8
0 874
8
2
8
0 1050
8
2
8
1 1050
8
0 1622
8
2
8
0 1551
8
2
8
1 1551
8
0 1389
8
2
8
0 304
8
2
8
0 1553
8
2
8
1 1553
8
0 322
8
2
8
1 322
8
0 1172
8
2
8
0 1923
8
2
8
1 1923
8
0 179
8
2
8
0 911
8
2
8
1 911
8
0 1277
8
2
8
1 ...

result:

ok 

Test #54:

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

input:

2000
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
2...

output:

8
0 291
8
2
8
0 1197
8
2
8
0 661
8
2
8
0 648
8
2
8
0 1353
8
2
8
1 1353
8
0 1116
8
2
8
1 1116
8
0 1187
8
2
8
1 1187
8
0 1824
8
2
8
1 1824
8
0 1717
8
2
8
1 1717
8
0 1497
8
2
8
1 1497
8
0 1655
8
2
8
1 1655
8
0 158
8
2
8
1 158
8
0 1063
8
2
8
1 1063
8
0 1429
8
2
8
1 1429
8
0 338
8
2
8
1 338
8
0 1963
8
2
...

result:

ok 

Test #55:

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

input:

2000
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
2
2
1
2
2
2
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
2
1
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
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 958
8
2
8
0 1820
8
2
8
0 320
8
2
8
0 148
8
2
8
0 518
8
2
8
0 134
8
2
8
0 823
8
2
8
0 984
8
2
8
0 808
8
2
8
0 1318
8
2
8
1 1318
8
0 650
8
2
8
0 464
8
2
8
0 1785
8
2
8
0 1153
8
2
8
0 881
8
2
8
0 1006
8
2
8
1 1006
8
0 47
8
2
8
0 520
8
2
8
0 928
8
2
8
0 1714
8
2
8
0 1770
8
2
8
0 105
8
2
8
1 105
8
0 ...

result:

ok 

Test #56:

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

input:

1998
1
1
2
2
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 1418
8
2
8
0 1637
8
2
8
0 732
8
2
8
1 732
8
0 1449
8
2
8
1 1449
8
0 1710
8
2
8
0 1023
8
2
8
0 205
8
2
8
1 205
8
0 719
8
2
8
1 719
8
0 900
8
2
8
1 900
8
0 376
8
2
8
0 521
8
2
8
1 521
8
0 528
8
2
8
1 528
8
0 1193
8
2
8
1 1193
8
0 1865
8
2
8
1 1865
8
0 493
8
2
8
1 493
8
0 163
8
2
8
1 163
8
0 1161
8...

result:

ok 

Test #57:

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

input:

1999
1
1
1
2
1
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...

output:

8
0 341
8
2
8
0 1830
8
2
8
0 107
8
2
8
0 752
8
2
8
1 752
8
0 553
8
2
8
0 736
8
2
8
0 829
8
2
8
0 1490
8
2
8
0 399
8
2
8
1 399
8
0 335
8
2
8
0 40
8
2
8
1 40
8
0 1361
8
2
8
1 1361
8
0 1462
8
2
8
1 1462
8
0 532
8
2
8
1 532
8
0 15
8
2
8
1 15
8
0 1255
8
2
8
1 1255
8
0 1169
8
2
8
1 1169
8
0 1893
8
2
8
1 1...

result:

ok 

Test #58:

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

input:

1997
1
1
1
1
2
1
1
1
2
1
2
2
2
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
2
2
2
2...

output:

8
0 1863
8
2
8
0 1954
8
2
8
0 705
8
2
8
0 970
8
2
8
0 1204
8
2
8
1 1204
8
0 1665
8
2
8
0 703
8
2
8
0 128
8
2
8
0 426
8
2
8
1 426
8
0 252
8
2
8
0 1263
8
2
8
1 1263
8
0 1011
8
2
8
1 1011
8
0 744
8
2
8
1 744
8
0 937
8
2
8
1 937
8
0 59
8
2
8
1 59
8
0 1971
8
2
8
1 1971
8
0 1725
8
2
8
1 1725
8
0 1751
8
2
...

result:

ok 

Test #59:

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

input:

1998
1
1
1
1
2
1
2
1
2
2
2
1
2
2
2
1
2
1
2
2
2
2
1
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...

output:

8
0 311
8
2
8
0 443
8
2
8
0 1255
8
2
8
0 971
8
2
8
0 434
8
2
8
1 434
8
0 742
8
2
8
0 24
8
2
8
1 24
8
0 1468
8
2
8
0 1346
8
2
8
1 1346
8
0 1224
8
2
8
1 1224
8
0 587
8
2
8
1 587
8
0 1960
8
2
8
0 276
8
2
8
1 276
8
0 1417
8
2
8
1 1417
8
0 1684
8
2
8
1 1684
8
0 1989
8
2
8
0 110
8
2
8
1 110
8
0 1906
8
2
8...

result:

ok 

Test #60:

score: 75
Accepted
time: 10ms
memory: 4096kb

input:

1996
1
1
1
1
2
2
1
2
1
1
2
1
1
2
2
2
2
1
2
1
1
1
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
2
2
2
2
2
2
2
2
2...

output:

8
0 1533
8
2
8
0 466
8
2
8
0 1110
8
2
8
0 1414
8
2
8
0 1070
8
2
8
1 1070
8
0 106
8
2
8
1 106
8
0 1641
8
2
8
0 1348
8
2
8
1 1348
8
0 402
8
2
8
0 1032
8
2
8
0 1210
8
2
8
1 1210
8
0 1808
8
2
8
0 1350
8
2
8
0 477
8
2
8
1 477
8
0 1045
8
2
8
1 1045
8
0 85
8
2
8
1 85
8
0 648
8
2
8
1 648
8
0 899
8
2
8
0 101...

result:

ok 

Test #61:

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

input:

2000
1
1
2
1
2
1
1
1
1
2
2
2
2
1
2
2
2
1
1
2
1
1
1
2
2
2
1
2
2
1
1
2
2
1
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
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...

output:

8
0 511
8
2
8
0 1488
8
2
8
0 553
8
2
8
1 553
8
0 701
8
2
8
0 413
8
2
8
1 413
8
0 1074
8
2
8
0 1463
8
2
8
0 713
8
2
8
0 886
8
2
8
0 769
8
2
8
1 769
8
0 1027
8
2
8
1 1027
8
0 1651
8
2
8
1 1651
8
0 1072
8
2
8
1 1072
8
0 1036
8
2
8
0 1532
8
2
8
1 1532
8
0 797
8
2
8
1 797
8
0 1560
8
2
8
1 1560
8
0 207
8
...

result:

ok 

Test #62:

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

input:

1998
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
2
2
1
1
1
1
1
2
1
2
2
2
1
1
2
2
2
2
2
1
1
1
2
2
1
2
2
2
1
1
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
1
2
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
1
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 656
8
2
8
0 111
8
2
8
0 943
8
2
8
0 1334
8
2
8
0 1306
8
2
8
0 42
8
2
8
0 1482
8
2
8
0 1984
8
2
8
0 1505
8
2
8
0 373
8
2
8
1 373
8
0 1275
8
2
8
0 67
8
2
8
0 829
8
2
8
0 1861
8
2
8
0 1872
8
2
8
1 1872
8
0 1629
8
2
8
0 148
8
2
8
1 148
8
0 859
8
2
8
0 639
8
2
8
0 1396
8
2
8
1 1396
8
0 1704
8
2
8
0 1...

result:

ok 

Test #63:

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

input:

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

output:

8
0 1983
8
2
8
0 1420
8
2
8
0 1649
8
2
8
0 1818
8
2
8
0 1096
8
2
8
0 1672
8
2
8
1 1672
8
0 410
8
2
8
1 410
8
0 1120
8
2
8
0 1943
8
2
8
0 414
8
2
8
0 544
8
2
8
0 352
8
2
8
0 737
8
2
8
0 1945
8
2
8
0 1874
8
2
8
0 514
8
2
8
0 1581
8
2
8
1 1581
8
0 166
8
2
8
0 493
8
2
8
0 624
8
2
8
1 624
8
0 1132
8
2
8
...

result:

ok 

Test #64:

score: 75
Accepted
time: 27ms
memory: 4104kb

input:

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

output:

8
0 1362
8
2
8
0 1725
8
2
8
0 61
8
2
8
0 1355
8
2
8
0 1471
8
2
8
0 16
8
2
8
0 1628
8
2
8
0 1352
8
2
8
0 1300
8
2
8
0 249
8
2
8
0 910
8
2
8
0 401
8
2
8
0 308
8
2
8
0 1032
8
2
8
0 367
8
2
8
0 1828
8
2
8
1 1828
8
0 844
8
2
8
1 844
8
0 1086
8
2
8
0 1084
8
2
8
1 1084
8
0 861
8
2
8
0 318
8
2
8
0 1047
8
2
...

result:

ok 

Test #65:

score: 75
Accepted
time: 10ms
memory: 4312kb

input:

1999
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
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
2
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
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
2
1
2
1
1
1
2
2
1
1
1
1
1
2
2
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1...

output:

8
0 309
8
2
8
0 6
8
2
8
0 454
8
2
8
0 281
8
2
8
0 820
8
2
8
0 1965
8
2
8
0 1202
8
2
8
0 1114
8
2
8
0 1982
8
2
8
0 1498
8
2
8
0 1504
8
2
8
0 187
8
2
8
0 627
8
2
8
0 1035
8
2
8
0 740
8
2
8
0 356
8
2
8
0 1180
8
2
8
0 1577
8
2
8
0 1593
8
2
8
0 13
8
2
8
0 1446
8
2
8
1 1446
8
0 346
8
2
8
0 1768
8
2
8
0 44...

result:

ok 

Test #66:

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

input:

1998
1
1
1
1
1
1
1
1
1
1
1
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
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
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
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
2
1
1
1
1
2...

output:

8
0 285
8
2
8
0 674
8
2
8
0 1693
8
2
8
0 1993
8
2
8
0 793
8
2
8
0 231
8
2
8
0 754
8
2
8
0 1262
8
2
8
0 1
8
2
8
0 1476
8
2
8
0 1496
8
2
8
0 1746
8
2
8
0 1898
8
2
8
0 113
8
2
8
0 1130
8
2
8
0 42
8
2
8
0 1938
8
2
8
0 120
8
2
8
0 1417
8
2
8
0 886
8
2
8
0 1550
8
2
8
0 504
8
2
8
0 405
8
2
8
0 468
8
2
8
0 ...

result:

ok 

Test #67:

score: 75
Accepted
time: 8ms
memory: 3916kb

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
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
2
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...

output:

8
0 307
8
2
8
0 4
8
2
8
0 656
8
2
8
0 1427
8
2
8
0 1075
8
2
8
0 1595
8
2
8
0 1815
8
2
8
0 1539
8
2
8
0 791
8
2
8
0 1501
8
2
8
0 1549
8
2
8
0 1952
8
2
8
0 1527
8
2
8
0 1288
8
2
8
0 1526
8
2
8
0 966
8
2
8
0 460
8
2
8
0 1692
8
2
8
0 481
8
2
8
0 605
8
2
8
0 893
8
2
8
0 1669
8
2
8
0 498
8
2
8
0 1534
8
2
...

result:

ok 

Test #68:

score: 75
Accepted
time: 19ms
memory: 4148kb

input:

1979
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
2
1
2
1
1
2
1
2
1
1
1
2
1
2
1
1
1
1
1
2
1
2
2
2
1
2
2
2
1
1
2
1
2
1
2
1
1
2
1
1
2
2
1
2
2
2
2
2
2
1
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
1
1
1
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
1
2
1
2
2...

output:

8
0 1033
8
2
8
0 1234
8
2
8
0 1084
8
2
8
0 23
8
2
8
0 1515
8
2
8
0 367
8
2
8
0 800
8
2
8
0 338
8
2
8
0 1438
8
2
8
1 1438
8
0 1902
8
2
8
0 859
8
2
8
1 859
8
0 647
8
2
8
0 890
8
2
8
0 841
8
2
8
0 342
8
2
8
0 1223
8
2
8
1 1223
8
0 1430
8
2
8
1 1430
8
0 691
8
2
8
0 1399
8
2
8
1 1399
8
0 621
8
2
8
0 587
...

result:

ok 

Test #69:

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

input:

1979
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
2
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
1
2
2
1
2
2
1
1
1
2
2
2
1
1
1
2
2
1
2
2
1
1
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
1
1
2
2
2
1
2
2
1
2
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
1
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
1
2
2
2
2
2
2...

output:

8
0 395
8
2
8
0 24
8
2
8
0 972
8
2
8
0 1828
8
2
8
0 1487
8
2
8
0 1006
8
2
8
0 33
8
2
8
0 1435
8
2
8
0 1300
8
2
8
0 1921
8
2
8
1 1921
8
0 828
8
2
8
1 828
8
0 371
8
2
8
0 55
8
2
8
0 228
8
2
8
0 462
8
2
8
0 1551
8
2
8
1 1551
8
0 450
8
2
8
0 1317
8
2
8
1 1317
8
0 1387
8
2
8
0 1429
8
2
8
0 1469
8
2
8
0 1...

result:

ok 

Test #70:

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

input:

1979
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
2
2
2
1
2
2
1
1
2
2
1
1
2
2
2
1
2
1
2
2
1
2
2
2
2
2
2
1
1
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
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
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 541
8
2
8
0 628
8
2
8
1 628
8
0 1032
8
2
8
0 1486
8
2
8
0 1588
8
2
8
0 539
8
2
8
1 539
8
0 603
8
2
8
0 1654
8
2
8
0 281
8
2
8
0 1557
8
2
8
1 1557
8
0 1435
8
2
8
0 1658
8
2
8
0 228
8
2
8
0 1387
8
2
8
0 647
8
2
8
0 1408
8
2
8
0 1954
8
2
8
0 1206
8
2
8
1 1206
8
0 1172
8
2
8
0 615
8
2
8
0 31
8
2
8
1...

result:

ok 

Test #71:

score: 75
Accepted
time: 8ms
memory: 4388kb

input:

1979
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
2
1
1
2
1
2
2
1
2
1
2
1
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
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
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
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
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1145
8
2
8
0 1857
8
2
8
0 343
8
2
8
0 66
8
2
8
0 1240
8
2
8
0 694
8
2
8
0 1125
8
2
8
0 1080
8
2
8
0 730
8
2
8
0 1910
8
2
8
0 1977
8
2
8
0 1741
8
2
8
1 1741
8
0 476
8
2
8
0 505
8
2
8
1 505
8
0 1298
8
2
8
1 1298
8
0 1104
8
2
8
0 1475
8
2
8
1 1475
8
0 919
8
2
8
0 1816
8
2
8
0 1515
8
2
8
1 1515
8
0 ...

result:

ok 

Test #72:

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

input:

1981
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
2
1
1
1
2
1
2
1
2
1
2
1
2
1
1
1
1
1
2
2
2
1
2
2
1
1
1
2
2
1
1
2
1
2
2
2
2
2
2
1
1
2
1
2
1
2
2
2
2
1
2
1
2
1
2
2
2
2
2
2
1
2
2
2
1
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
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1859
8
2
8
0 559
8
2
8
0 974
8
2
8
1 974
8
0 1010
8
2
8
0 1370
8
2
8
0 1957
8
2
8
0 906
8
2
8
0 405
8
2
8
0 401
8
2
8
0 1167
8
2
8
0 1730
8
2
8
0 1399
8
2
8
0 1974
8
2
8
0 530
8
2
8
0 665
8
2
8
0 162
8
2
8
0 805
8
2
8
0 1649
8
2
8
0 205
8
2
8
1 205
8
0 496
8
2
8
0 629
8
2
8
0 1477
8
2
8
0 1406
8...

result:

ok 

Test #73:

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

input:

1981
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
2
1
1
2
2
1
1
2
1
2
2
2
1
1
2
1
1
1
1
1
1
1
2
2
2
1
2
2
2
1
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
1
1
1
2
1
1
2
2
2
2
1
1
2
2
1
2
2
2
1
2
2
2
2
1
1
1
1
2
2
2
1
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
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1676
8
2
8
0 446
8
2
8
0 876
8
2
8
0 616
8
2
8
0 1403
8
2
8
0 534
8
2
8
0 7
8
2
8
0 1350
8
2
8
0 560
8
2
8
0 60
8
2
8
0 1836
8
2
8
0 1949
8
2
8
1 1949
8
0 1281
8
2
8
0 658
8
2
8
0 700
8
2
8
0 246
8
2
8
1 246
8
0 1068
8
2
8
0 109
8
2
8
1 109
8
0 1856
8
2
8
0 1112
8
2
8
0 1420
8
2
8
0 794
8
2
8
0 ...

result:

ok 

Test #74:

score: 75
Accepted
time: 8ms
memory: 4064kb

input:

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

output:

8
0 586
8
2
8
0 1453
8
2
8
0 778
8
2
8
0 392
8
2
8
0 1671
8
2
8
0 343
8
2
8
0 44
8
2
8
1 44
8
0 1079
8
2
8
0 1540
8
2
8
0 176
8
2
8
0 716
8
2
8
0 93
8
2
8
0 766
8
2
8
0 389
8
2
8
0 1702
8
2
8
0 1840
8
2
8
0 1678
8
2
8
0 181
8
2
8
0 402
8
2
8
1 402
8
0 138
8
2
8
0 418
8
2
8
1 418
8
0 37
8
2
8
0 509
8...

result:

ok 

Test #75:

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

input:

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

output:

8
0 1130
8
2
8
0 362
8
2
8
0 619
8
2
8
0 214
8
2
8
0 1775
8
2
8
0 1043
8
2
8
0 1855
8
2
8
1 1855
8
0 665
8
2
8
0 1343
8
2
8
0 1621
8
2
8
0 1887
8
2
8
0 1160
8
2
8
0 950
8
2
8
0 1249
8
2
8
0 102
8
2
8
0 1276
8
2
8
1 1276
8
0 493
8
2
8
0 201
8
2
8
1 201
8
0 1251
8
2
8
0 1741
8
2
8
0 696
8
2
8
1 696
8
...

result:

ok 

Test #76:

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

input:

1970
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
1
1
2
1
1
1
2
1
2
1
1
1
2
1
1
1
2
2
1
2
2
1
2
1
1
1
1
1
1
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
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
1
2
2
2
2
2
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
1
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2...

output:

8
0 1396
8
2
8
0 1844
8
2
8
0 930
8
2
8
0 867
8
2
8
0 1330
8
2
8
0 1375
8
2
8
0 156
8
2
8
0 766
8
2
8
0 72
8
2
8
0 1442
8
2
8
0 1492
8
2
8
0 310
8
2
8
1 310
8
0 943
8
2
8
0 1685
8
2
8
0 885
8
2
8
0 1231
8
2
8
0 1743
8
2
8
0 1494
8
2
8
1 1494
8
0 1420
8
2
8
0 1904
8
2
8
0 118
8
2
8
0 1849
8
2
8
1 184...

result:

ok 

Test #77:

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

input:

1970
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
2
2
2
2
2
1
1
1
2
1
1
1
2
2
1
1
1
2
1
2
1
2
1
1
1
2
2
2
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
1
1
1
2
2
1
2
2
2
2
1
2
2
2
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
1
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2...

output:

8
0 714
8
2
8
0 943
8
2
8
0 284
8
2
8
0 1079
8
2
8
0 1595
8
2
8
0 361
8
2
8
0 1251
8
2
8
0 1486
8
2
8
0 1222
8
2
8
0 1147
8
2
8
0 1118
8
2
8
0 1492
8
2
8
0 773
8
2
8
0 707
8
2
8
0 607
8
2
8
0 1416
8
2
8
0 134
8
2
8
1 134
8
0 561
8
2
8
1 561
8
0 635
8
2
8
0 170
8
2
8
0 190
8
2
8
0 875
8
2
8
0 422
8
2...

result:

ok 

Test #78:

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

input:

1980
1
1
1
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
1
1
2
2
2
1
2
1
1
1
1
1
1
1
1
2
1
2
2
2
1
2
2
2
2
2
1
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2...

output:

8
0 1338
8
2
8
0 992
8
2
8
0 317
8
2
8
0 985
8
2
8
0 1448
8
2
8
0 1196
8
2
8
0 925
8
2
8
1 925
8
0 1079
8
2
8
0 496
8
2
8
0 1162
8
2
8
1 1162
8
0 692
8
2
8
0 261
8
2
8
0 1345
8
2
8
0 562
8
2
8
0 1794
8
2
8
1 1794
8
0 77
8
2
8
0 1916
8
2
8
0 328
8
2
8
0 785
8
2
8
1 785
8
0 1460
8
2
8
0 947
8
2
8
0 58...

result:

ok 

Test #79:

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

input:

1980
1
1
1
1
2
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
2
1
1
1
2
1
1
1
1
1
2
2
1
2
2
2
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
2
2
2
2
2
2
1
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
1
2
2
2
1
2
1
2
2
2
2
2
2
1
2
2
2
2
1
1
2
1
2
1
2
1
2
2
1
2
2
2
2
1
2
2
2
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1501
8
2
8
0 622
8
2
8
0 199
8
2
8
0 441
8
2
8
0 1497
8
2
8
1 1497
8
0 556
8
2
8
0 1208
8
2
8
1 1208
8
0 974
8
2
8
0 1002
8
2
8
0 1383
8
2
8
1 1383
8
0 1256
8
2
8
0 1803
8
2
8
0 158
8
2
8
0 1482
8
2
8
0 129
8
2
8
0 731
8
2
8
0 1242
8
2
8
0 398
8
2
8
0 1977
8
2
8
0 1410
8
2
8
0 177
8
2
8
0 1351
8...

result:

ok 

Test #80:

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

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
2
1
1
1
1
2
1
2
1
2
1
1
2
2
2
1
2
1
2
1
1
1
2
2
2
2
1
2
1
1
2
1
2
2
1
1
2
1
1
1
2
2
1
1
1
2
1
1
2
2
2
2
2
1
1
1
1
2
2
1
2
1
1
1
2
1
1
2
1
1
1
1
1
2
2
2
2
2
1
2
2
1
1
2
1
2
1
1
2
1
2
2
2
1
2
2
2
1
1
2
2
2
1
2
1
2
2
2
1
1
2
1
2
1
2
2
2
1
1
2
2
2
2...

output:

8
0 814
8
2
8
0 1324
8
2
8
0 124
8
2
8
0 19
8
2
8
0 441
8
2
8
0 942
8
2
8
0 912
8
2
8
0 1054
8
2
8
0 162
8
2
8
0 1518
8
2
8
0 1100
8
2
8
0 1547
8
2
8
0 1459
8
2
8
0 925
8
2
8
0 668
8
2
8
0 1766
8
2
8
0 1015
8
2
8
0 506
8
2
8
0 401
8
2
8
0 1976
8
2
8
0 1353
8
2
8
0 157
8
2
8
0 39
8
2
8
0 1134
8
2
8
0...

result:

ok 

Test #81:

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

input:

2000
1
1
1
1
1
1
2
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
2
1
1
1
2
1
2
1
1
1
2
1
2
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
2
2
1
2
1
2
1
1
2
1
2
2
2
1
1
2
2
1
2
1
2
2
2
1
2
1
1
2
2
1
1
2
1
2
1
1
2
2
2
2
1
1
2
2
2
2
2
1
1
2
2
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
2
2
2...

output:

8
0 254
8
2
8
0 1532
8
2
8
0 1151
8
2
8
0 144
8
2
8
0 1617
8
2
8
0 1531
8
2
8
0 1032
8
2
8
1 1032
8
0 479
8
2
8
1 479
8
0 671
8
2
8
0 1050
8
2
8
0 765
8
2
8
0 1656
8
2
8
0 1791
8
2
8
0 790
8
2
8
0 1463
8
2
8
0 50
8
2
8
0 1845
8
2
8
0 1016
8
2
8
0 534
8
2
8
0 434
8
2
8
0 897
8
2
8
0 77
8
2
8
0 1817
8...

result:

ok 

Test #82:

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

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
2
1
2
1
2
1
2
1
1
1
1
1
2
2
1
1
2
1
2
2
2
2
1
2
1
2
2
2
1
2
2
1
1
1
2
2
2
2
2
2
2
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
1
1
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
1
1
2
2
2
1
2
2
2
2
2
2
2
1
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 1176
8
2
8
0 1194
8
2
8
0 1381
8
2
8
0 1330
8
2
8
0 216
8
2
8
0 668
8
2
8
0 383
8
2
8
0 1223
8
2
8
0 511
8
2
8
0 663
8
2
8
0 255
8
2
8
0 1474
8
2
8
0 205
8
2
8
0 365
8
2
8
0 1094
8
2
8
0 962
8
2
8
0 1589
8
2
8
0 1482
8
2
8
0 551
8
2
8
0 1062
8
2
8
1 1062
8
0 625
8
2
8
1 625
8
0 1445
8
2
8
0 863
...

result:

ok 

Test #83:

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

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
2
1
1
1
1
2
1
2
1
1
1
1
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
1
1
2
2
1
1
1
1
1
2
2
2
2
2
1
2
1
1
2
1
2
2
2
1
2
2
2
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
1
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
2
2
2...

output:

8
0 709
8
2
8
0 1980
8
2
8
0 1396
8
2
8
0 524
8
2
8
0 931
8
2
8
0 370
8
2
8
0 635
8
2
8
0 579
8
2
8
0 1020
8
2
8
0 1009
8
2
8
0 246
8
2
8
0 567
8
2
8
0 1782
8
2
8
0 404
8
2
8
0 1674
8
2
8
0 437
8
2
8
0 25
8
2
8
0 1982
8
2
8
1 1982
8
0 916
8
2
8
0 1557
8
2
8
0 772
8
2
8
0 756
8
2
8
1 756
8
0 1776
8
2...

result:

ok 

Test #84:

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

input:

540
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 247
8
2
8
0 258
8
2
8
1 258
8
0 94
8
2
8
1 94
8
0 82
8
2
8
0 63
8
2
8
1 63
8
0 153
8
2
8
1 153
8
0 428
8
2
8
1 428
8
0 345
8
2
8
1 345
8
0 489
8
2
8
1 489
8
0 59
8
2
8
1 59
8
0 137
8
2
8
1 137
8
0 68
8
2
8
1 68
8
0 369
8
2
8
0 491
8
2
8
1 491
8
0 158
8
2
8
1 158
8
0 145
8
2
8
1 145
8
0 31
8
2
8
...

result:

ok 

Test #85:

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

input:

1834
1
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
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...

output:

8
0 182
8
2
8
0 353
8
2
8
1 353
8
0 566
8
2
8
0 514
8
2
8
1 514
8
0 1431
8
2
8
1 1431
8
0 276
8
2
8
1 276
8
0 480
8
2
8
1 480
8
0 877
8
2
8
1 877
8
0 183
8
2
8
1 183
8
0 45
8
2
8
1 45
8
0 1448
8
2
8
0 981
8
2
8
1 981
8
0 1149
8
2
8
1 1149
8
0 796
8
2
8
1 796
8
0 852
8
2
8
1 852
8
0 590
8
2
8
1 590
8...

result:

ok 

Test #86:

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

input:

2000
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
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 721
8
2
8
0 1529
8
2
8
1 1529
8
0 1162
8
2
8
1 1162
8
0 1726
8
2
8
0 1804
8
2
8
1 1804
8
0 766
8
2
8
1 766
8
0 1354
8
2
8
1 1354
8
0 660
8
2
8
1 660
8
0 1401
8
2
8
1 1401
8
0 1434
8
2
8
1 1434
8
0 1848
8
2
8
1 1848
8
0 456
8
2
8
1 456
8
0 1527
8
2
8
1 1527
8
0 242
8
2
8
1 242
8
0 412
8
2
8
1 412...

result:

ok 

Test #87:

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

input:

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

output:

8
0 1306
8
2
8
0 247
8
2
8
0 98
8
2
8
1 98
8
0 148
8
2
8
1 148
8
0 210
8
2
8
1 210
8
0 604
8
2
8
1 604
8
0 1862
8
2
8
0 1284
8
2
8
0 1536
8
2
8
0 1586
8
2
8
0 226
8
2
8
1 226
8
0 769
8
2
8
1 769
8
0 1453
8
2
8
0 1427
8
2
8
0 1075
8
2
8
0 333
8
2
8
1 333
8
0 938
8
2
8
1 938
8
0 437
8
2
8
1 437
8
0 17...

result:

ok 

Test #88:

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

input:

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

output:

8
0 1465
8
2
8
0 64
8
2
8
0 1246
8
2
8
1 1246
8
0 1612
8
2
8
1 1612
8
0 864
8
2
8
0 1080
8
2
8
1 1080
8
0 361
8
2
8
0 1840
8
2
8
1 1840
8
0 1997
8
2
8
1 1997
8
0 999
8
2
8
1 999
8
0 312
8
2
8
0 1582
8
2
8
1 1582
8
0 1457
8
2
8
1 1457
8
0 1963
8
2
8
1 1963
8
0 422
8
2
8
0 687
8
2
8
0 214
8
2
8
0 321
...

result:

ok 

Test #89:

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

input:

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

output:

8
0 414
8
2
8
0 235
8
2
8
1 235
8
0 1489
8
2
8
0 995
8
2
8
0 1358
8
2
8
0 1741
8
2
8
1 1741
8
0 288
8
2
8
1 288
8
0 602
8
2
8
0 1435
8
2
8
0 1976
8
2
8
1 1976
8
0 1853
8
2
8
1 1853
8
0 926
8
2
8
0 589
8
2
8
0 1490
8
2
8
0 612
8
2
8
0 1650
8
2
8
1 1650
8
0 1617
8
2
8
1 1617
8
0 1101
8
2
8
0 193
8
2
8...

result:

ok