QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#44082#4565. Rarest InsectsQingyu100 ✓62ms3904kbC++231.5kb2022-08-12 19:17:042022-08-13 12:26:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-13 12:26:51]
  • 评测
  • 测评结果:100
  • 用时:62ms
  • 内存:3904kb
  • [2022-08-12 19:17:04]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N) {
  int colors = 0;
  vector <int> insects;
  vector <int> order(N);
  iota(order.begin(),order.end(),0);
  
  mt19937 mt(715082022);
  shuffle(order.begin(),order.end(),mt);
  for (int x : order) {
    move_inside(x);
    if (press_button() == 1) {
      colors++;
    }
    else {
      move_outside(x);
      insects.push_back(x);
    }
  }
  
  int ans = 1;
  int rest = N - colors;
  vector <int> in, out;
  
  while (rest >= colors) {
    int mid = ans + (rest + colors + 1) / (2 * colors);
    
    shuffle(in.begin(),in.end(),mt);
    while ((int)in.size() > mid - ans) {
      int x = in.back();
      in.pop_back();
      insects.push_back(x);
      move_outside(x);
      
      if ((int)in.size() % colors == 0) {
        if (press_button() <= mid) {
          break;
        }
      }
    }
    
    shuffle(insects.begin(),insects.end(),mt);
    for (int x : insects) {
      if ((int)in.size() == colors * (mid - ans)) {
        out.push_back(x);
        continue;
      }
      move_inside(x);
      if ((int)in.size() >= mid - ans && press_button() > mid) {
        move_outside(x);
        out.push_back(x);
      }
      else {
        in.push_back(x);
      }
    }
    
    if ((int)in.size() == colors * (mid - ans)) {
      ans = mid;
      rest = out.size();
      insects = out;
      in.clear();
      out.clear();
    }
    else {
      rest = in.size();
      out.clear();
      insects.clear();
    }
  }
  
  return ans;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

6
1
2
1
1
2
2
2
3

output:

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

result:

ok 

Test #2:

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

input:

2
1
2

output:

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

result:

ok 

Test #3:

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

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: 2ms
memory: 3844kb

input:

3
1
1
2

output:

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

result:

ok 

Test #5:

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

input:

5
1
2
2
1
2
2

output:

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

result:

ok 

Test #6:

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

input:

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

output:

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

result:

ok 

Test #7:

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

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 140
8
2
8
0 149
8
2
8
1 149
8
0 104
8
2
8
1 104
8
0 137
8
2
8
1 137
8
0 110
8
2
8
1 110
8
0 76
8
2
8
1 76
8
0 8
8
2
8
1 8
8
0 83
8
2
8
1 83
8
0 101
8
2
8
1 101
8
0 68
8
2
8
1 68
8
0 20
8
2
8
1 20
8
0 146
8
2
8
1 146
8
0 187
8
2
8
1 187
8
0 93
8
2
8
1 93
8
0 147
8
2
8
1 147
8
0 87
8
2
8
1 87
8
0 ...

result:

ok 

Test #8:

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

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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
0 135
8
2
8
0 133
8
2
8
0 51
8
2
8
0 186
8
2
8
0 92
8
2
8
0 163
8
2
8
0 87
8
2
8
0 53
8
2
8
0 88
8
2
8
0 62
8
2
8
0 167
8
2
8
0 40
8
2
8
0 123
8
2
8
0 84
8
2
8
0 58
8
2
8
0 39
8
2
8
0 153
8
2
8
0...

result:

ok 

Test #9:

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

input:

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

output:

8
0 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
1 171
8
0 135
8
2
8
0 133
8
2
8
0 51
8
2
8
1 51
8
0 186
8
2
8
1 186
8
0 92
8
2
8
1 92
8
0 163
8
2
8
0 87
8
2
8
1 87
8
0 53
8
2
8
1 53
8
0 88
8
2
8
0 62
8
2
8
1 62
8
0 167
8
2
8
1 167
8
0 4...

result:

ok 

Test #10:

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

input:

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

output:

8
0 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
1 136
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
0 135
8
2
8
0 133
8
2
8
0 51
8
2
8
0 186
8
2
8
1 186
8
0 92
8
2
8
1 92
8
0 163
8
2
8
0 87
8
2
8
1 87
8
0 53
8
2
8
1 53
8
0 88
8
2
8
1 88
8
0 62
8
2
8
1 62
8
0 167
8
2
8
1 167
8
0 40
8
2
8...

result:

ok 

Test #11:

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

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
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 140
8
2
8
0 149
8
2
8
1 149
8
0 104
8
2
8
1 104
8
0 137
8
2
8
1 137
8
0 110
8
2
8
1 110
8
0 76
8
2
8
1 76
8
0 8
8
2
8
1 8
8
0 83
8
2
8
1 83
8
0 101
8
2
8
1 101
8
0 68
8
2
8
1 68
8
0 20
8
2
8
1 20
8
0 146
8
2
8
1 146
8
0 187
8
2
8
1 187
8
0 93
8
2
8
1 93
8
0 147
8
2
8
1 147
8
0 87
8
2
8
1 87
8
0 ...

result:

ok 

Test #12:

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

input:

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

output:

8
0 140
8
2
8
0 149
8
2
8
0 104
8
2
8
0 137
8
2
8
1 137
8
0 110
8
2
8
1 110
8
0 76
8
2
8
1 76
8
0 8
8
2
8
0 83
8
2
8
1 83
8
0 101
8
2
8
0 68
8
2
8
1 68
8
0 20
8
2
8
1 20
8
0 146
8
2
8
0 187
8
2
8
1 187
8
0 93
8
2
8
0 147
8
2
8
1 147
8
0 87
8
2
8
1 87
8
0 12
8
2
8
1 12
8
0 89
8
2
8
1 89
8
0 57
8
2
8
...

result:

ok 

Test #13:

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

input:

197
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 140
8
2
8
0 149
8
2
8
0 104
8
2
8
0 137
8
2
8
1 137
8
0 110
8
2
8
1 110
8
0 76
8
2
8
0 8
8
2
8
1 8
8
0 83
8
2
8
1 83
8
0 101
8
2
8
1 101
8
0 68
8
2
8
1 68
8
0 20
8
2
8
1 20
8
0 146
8
2
8
1 146
8
0 187
8
2
8
1 187
8
0 93
8
2
8
1 93
8
0 147
8
2
8
1 147
8
0 87
8
2
8
1 87
8
0 12
8
2
8
1 12
8
0 89
8
...

result:

ok 

Test #14:

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

input:

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

output:

8
0 10
8
2
8
0 148
8
2
8
0 70
8
2
8
1 70
8
0 136
8
2
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
1 103
8
0 44
8
2
8
0 171
8
2
8
1 171
8
0 135
8
2
8
1 135
8
0 133
8
2
8
1 133
8
0 51
8
2
8
1 51
8
0 186
8
2
8
0 92
8
2
8
0 163
8
2
8
1 163
8
0 87
8
2
8
0 53
8
2
8
1 53
8
0 88
8
2
8
1 88
8
0 62
8
2
8
1 62
8
0 167
...

result:

ok 

Test #15:

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

input:

200
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 61
8
2
8
1 61
8
0 103
8
2
8
1 103
8
0 44
8
2
8
1 44
8
0 171
8
2
8
0 135
8
2
8
1 135
8
0 133
8
2
8
1 133
8
0 51
8
2
8
1 51
8
0 186
8
2
8
1 186
8
0 92
8
2
8
1 92
8
0 163
8
2
8
1 163
8
0 87
8
2
8
1 87
8
0 53
8
2
8
1 53
8
0 88
8
2
8
1 8...

result:

ok 

Test #16:

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

input:

196
1
1
1
1
2
2
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 61
8
2
8
1 61
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
1 171
8
0 135
8
2
8
1 135
8
0 133
8
2
8
1 133
8
0 51
8
2
8
1 51
8
0 186
8
2
8
0 92
8
2
8
1 92
8
0 163
8
2
8
1 163
8
0 87
8
2
8
1 87
8
0 53
8
2
8
1 53
8
0 88
8
2
8
1 88
8
0 62
8
2
8
...

result:

ok 

Test #17:

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

input:

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

output:

8
0 140
8
2
8
0 149
8
2
8
0 104
8
2
8
0 137
8
2
8
0 110
8
2
8
0 76
8
2
8
0 8
8
2
8
0 83
8
2
8
0 101
8
2
8
0 68
8
2
8
1 68
8
0 20
8
2
8
0 146
8
2
8
1 146
8
0 187
8
2
8
1 187
8
0 93
8
2
8
1 93
8
0 147
8
2
8
1 147
8
0 87
8
2
8
1 87
8
0 12
8
2
8
1 12
8
0 89
8
2
8
1 89
8
0 57
8
2
8
1 57
8
0 161
8
2
8
1 1...

result:

ok 

Test #18:

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

input:

196
1
1
1
2
2
1
1
1
2
2
2
2
1
1
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
1 136
8
0 42
8
2
8
1 42
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
1 171
8
0 135
8
2
8
1 135
8
0 133
8
2
8
1 133
8
0 51
8
2
8
1 51
8
0 186
8
2
8
0 92
8
2
8
0 163
8
2
8
1 163
8
0 87
8
2
8
0 53
8
2
8
1 53
8
0 88
8
2
8
0 62
8
2
8
1 62
8
0 167
8
2
8
1...

result:

ok 

Test #19:

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

input:

196
1
1
1
1
2
1
1
2
2
1
2
1
2
2
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
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
2
2
2
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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
1 44
8
0 171
8
2
8
1 171
8
0 135
8
2
8
0 133
8
2
8
1 133
8
0 51
8
2
8
0 186
8
2
8
1 186
8
0 92
8
2
8
1 92
8
0 163
8
2
8
1 163
8
0 87
8
2
8
0 53
8
2
8
1 53
8
0 88
8
2
8
1 88
8
0 62
8
2
8
1 62
8
0 167
8...

result:

ok 

Test #20:

score: 0
Accepted
time: 11ms
memory: 3812kb

input:

196
1
1
1
1
1
1
2
1
1
2
2
1
2
1
2
2
1
1
1
1
1
2
2
2
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
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
1 103
8
0 44
8
2
8
0 171
8
2
8
0 135
8
2
8
1 135
8
0 133
8
2
8
1 133
8
0 51
8
2
8
0 186
8
2
8
1 186
8
0 92
8
2
8
0 163
8
2
8
1 163
8
0 87
8
2
8
1 87
8
0 53
8
2
8
0 88
8
2
8
0 62
8
2
8
0 167
8
2
8
0 40
8
2
8
0 123
8
2
8...

result:

ok 

Test #21:

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

input:

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

output:

8
0 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
1 44
8
0 171
8
2
8
0 135
8
2
8
0 133
8
2
8
1 133
8
0 51
8
2
8
1 51
8
0 186
8
2
8
0 92
8
2
8
0 163
8
2
8
0 87
8
2
8
0 53
8
2
8
0 88
8
2
8
0 62
8
2
8
0 167
8
2
8
1 167
8
0 40
8
2
8
1 40
8
0 123
8
2
8
0 84
8
2
...

result:

ok 

Test #22:

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

input:

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

output:

8
0 140
8
2
8
0 149
8
2
8
0 104
8
2
8
0 137
8
2
8
0 110
8
2
8
0 76
8
2
8
0 8
8
2
8
0 83
8
2
8
0 101
8
2
8
0 68
8
2
8
0 20
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
0 147
8
2
8
0 87
8
2
8
0 12
8
2
8
0 89
8
2
8
1 89
8
0 57
8
2
8
0 161
8
2
8
0 196
8
2
8
0 41
8
2
8
0 85
8
2
8
1 85
8
0 59
8
2
8
0 90
8
2
8...

result:

ok 

Test #23:

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

input:

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

output:

8
0 10
8
2
8
0 148
8
2
8
0 70
8
2
8
0 136
8
2
8
0 42
8
2
8
0 61
8
2
8
0 103
8
2
8
0 44
8
2
8
0 171
8
2
8
0 135
8
2
8
0 133
8
2
8
0 51
8
2
8
0 186
8
2
8
1 186
8
0 92
8
2
8
0 163
8
2
8
0 87
8
2
8
0 53
8
2
8
0 88
8
2
8
0 62
8
2
8
1 62
8
0 167
8
2
8
0 40
8
2
8
0 123
8
2
8
0 84
8
2
8
0 58
8
2
8
1 58
8
0 ...

result:

ok 

Subtask #2:

score: 15
Accepted

Test #24:

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

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 10
8
2
8
0 943
8
2
8
1 943
8
0 206
8
2
8
1 206
8
0 136
8
2
8
1 136
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 207
8
2
8
1 207
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2...

result:

ok 

Test #25:

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

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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
0 363
8
2
8
0 207
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 268
8
2
8
0 254
8
2
8
0 88
8
2
8
0 62
8
2
8
0 856
8
2
8
0 277
8
2
8
0 357
8
2
8
0 235
8
2
8
0 982
8
2
8
0 762
8
2
8
0 ...

result:

ok 

Test #26:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
1 137
8
0 566
8
2
8
1 566
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
1 565
8
0 475
8
2
8
1 475
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
1 857
8
0 203
8
2
8
0 41
8
2
8
...

result:

ok 

Test #27:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
1 337
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
1 8
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
1 187
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 857
8
2
8
0 203
8
2
8
1 203
8
0 41
8
2
8
0 ...

result:

ok 

Test #28:

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

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 10
8
2
8
0 943
8
2
8
1 943
8
0 206
8
2
8
1 206
8
0 136
8
2
8
1 136
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 207
8
2
8
1 207
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2...

result:

ok 

Test #29:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
1 646
8
0 8
8
2
8
1 8
8
0 83
8
2
8
1 83
8
0 257
8
2
8
1 257
8
0 565
8
2
8
0 475
8
2
8
1 475
8
0 146
8
2
8
1 146
8
0 187
8
2
8
1 187
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
1 255
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
0 ...

result:

ok 

Test #30:

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

input:

998
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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 207
8
2
8
1 207
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
1 268
8
0 254
8
2
8
1...

result:

ok 

Test #31:

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

input:

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

output:

8
0 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
0 207
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 268
8
2
8
0 254
8
2
8
1 254
8
0 88
8
2
8
0 62
8
2
8
1 62
8
0 856
8
2
8
1 856
8
0 277
8
2
8
0 357
8
2
8
0 235
8
...

result:

ok 

Test #32:

score: 0
Accepted
time: 12ms
memory: 3896kb

input:

1000
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
1 206
8
0 136
8
2
8
1 136
8
0 42
8
2
8
0 363
8
2
8
1 363
8
0 207
8
2
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
1 268
8
0 254
8
2
8
...

result:

ok 

Test #33:

score: 0
Accepted
time: 24ms
memory: 3832kb

input:

996
1
1
1
1
1
2
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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
0 363
8
2
8
1 363
8
0 207
8
2
8
0 256
8
2
8
0 564
8
2
8
1 564
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
1 268
8
0 254
8
2
8
1 254
8
0 88
8
2
8
1 88
8
0 62
8...

result:

ok 

Test #34:

score: 0
Accepted
time: 42ms
memory: 3852kb

input:

1000
1
1
1
2
2
1
2
2
2
1
2
1
1
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
1 136
8
0 42
8
2
8
1 42
8
0 363
8
2
8
0 207
8
2
8
1 207
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
0 254
8
2
8
1 254
8
0 88
8
2
8
1 88
8
0 62
8
...

result:

ok 

Test #35:

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

input:

1000
1
1
1
1
2
2
1
1
1
1
2
2
1
2
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 207
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
1 268
8
0 254
8
2
8
0 88
8
2
8
1 88
8
0 62
8
2
8
1 62
8
0 856...

result:

ok 

Test #36:

score: 0
Accepted
time: 24ms
memory: 3708kb

input:

997
1
1
1
1
1
1
1
2
2
1
1
1
1
2
2
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
1 83
8
0 257
8
2
8
1 257
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
1 93
8
0 411
8
2
8
1 411
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
1 89
8
0 470
8
2
8
1 470
8
0 857
8
2
8
0 203
8
2
8
1 203
...

result:

ok 

Test #37:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
1 137
8
0 566
8
2
8
1 566
8
0 646
8
2
8
1 646
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
1 565
8
0 475
8
2
8
0 146
8
2
8
1 146
8
0 187
8
2
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
1 255
8
0 89
8
2
8
1 89
8
0 470
8
2
8
0 857
8
2
8
...

result:

ok 

Test #38:

score: 0
Accepted
time: 22ms
memory: 3708kb

input:

997
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
2
2
2
2
2
1
2
1
2
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
1
2
1
2
2
2
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
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 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
1 257
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
1 93
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
1 255
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
0 203
8
2
8
0 41
8
2
8
0 416
8
2...

result:

ok 

Test #39:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
1 857
8
0 203
8
2
8
0 41
8
2
8
0 416
8
2
8
0 983
8
2
8
...

result:

ok 

Test #40:

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

input:

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

output:

8
0 10
8
2
8
0 943
8
2
8
0 206
8
2
8
0 136
8
2
8
0 42
8
2
8
0 363
8
2
8
0 207
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 268
8
2
8
0 254
8
2
8
1 254
8
0 88
8
2
8
0 62
8
2
8
1 62
8
0 856
8
2
8
0 277
8
2
8
1 277
8
0 357
8
2
8
0 235
8
2
8
0 9...

result:

ok 

Test #41:

score: 0
Accepted
time: 23ms
memory: 3760kb

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
0 203
8
2
8
0 41
8
2
8
0 416
8
2
8
0 983
8
2
8
0 763
8
2
8
1 76...

result:

ok 

Test #42:

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

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 137
8
2
8
0 566
8
2
8
0 646
8
2
8
0 8
8
2
8
0 83
8
2
8
0 257
8
2
8
0 565
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 93
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 857
8
2
8
0 203
8
2
8
0 41
8
2
8
0 416
8
2
8
0 983
8
2
8
0 763
8
2
8
1 76...

result:

ok 

Subtask #3:

score: 75
Accepted

Test #43:

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

input:

2
1
2

output:

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

result:

ok 

Test #44:

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

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: 3ms
memory: 3680kb

input:

3
1
1
2

output:

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

result:

ok 

Test #46:

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

input:

6
1
2
2
2
2
1
3
3
3

output:

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

result:

ok 

Test #47:

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

input:

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

output:

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

result:

ok 

Test #48:

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

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 10
8
2
8
0 1173
8
2
8
1 1173
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1...

result:

ok 

Test #49:

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

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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
0 1631
8
2
8
0 1683
8
2
8
0 7...

result:

ok 

Test #50:

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

input:

2000
1
1
1
1
2
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
1
2
1
1
2
2
2
1
1
2
1
2
2
2
1
1
2
1
2
2
2
1
2
1
1
2
1
1
2
2
1
2
2
1
2
2
1
2
2
2
2
2
2
1
2
2
2
2
1
2
2
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
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
1
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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
...

result:

ok 

Test #51:

score: 75
Accepted
time: 53ms
memory: 3756kb

input:

2000
1
1
1
2
2
1
1
1
1
1
2
1
1
1
1
2
1
2
2
1
1
2
1
2
2
1
2
1
1
1
1
1
2
2
2
2
1
2
2
2
1
1
2
1
1
1
2
2
1
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
1
2
2
1
2
2
2
2
1
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
1
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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
1 62
8
0 1952
8
2
8
0 277...

result:

ok 

Test #52:

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

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 10
8
2
8
0 1173
8
2
8
1 1173
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1...

result:

ok 

Test #53:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
1 256
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
1...

result:

ok 

Test #54:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
1 1971
8
0 1307
8...

result:

ok 

Test #55:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
1 277
8
0 1701
8
...

result:

ok 

Test #56:

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

input:

1998
1
2
2
1
2
2
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 10
8
2
8
0 1173
8
2
8
1 1173
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
1 564
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
1 ...

result:

ok 

Test #57:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
1 1924
8
0 566
8
2
8
1 566
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
1 257
8
0 1066
8
2
8
1 1066
8
0 475
8
2
8
0 1994
8
2
8
1 1994
8
0 187
8
2
8
0 1032
8
2
8
1 1032
8
0 411
8
2
8
1 411
8
0 540
8
2
8
1 540
8
0 255
8
2
8
1 255
8
0 89
8
2
8
...

result:

ok 

Test #58:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
1 1924
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
1 1209
8
0 1412
8
2
8
1 1412
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 1994
8
2
8
1 1994
8
0 187
8
2
8
0 1032
8
2
8
1 1032
8
0 411
8
2
8
1 411
8
0 540
8
2
8
1 540
8
0 255
8
2
8
1 255
8
0 89
8
2
8
0 470
8...

result:

ok 

Test #59:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
...

result:

ok 

Test #60:

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

input:

1996
1
1
2
1
1
1
1
2
2
1
1
2
2
2
1
1
2
1
2
2
2
2
1
1
2
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
0 62
8
2
8
1 62
8
0 1...

result:

ok 

Test #61:

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

input:

2000
1
1
1
1
1
1
1
1
2
2
1
1
1
1
2
2
1
1
2
1
2
2
2
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
1 62
8
0 1952
8
2
8
0 277
8
2
8
1 ...

result:

ok 

Test #62:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
1 533
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
1 1952
8
0 277
8
2
8
0 1701
8
2
8
1 1701
8
0 1...

result:

ok 

Test #63:

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

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
1 1701
8
0 1631
8
2
...

result:

ok 

Test #64:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 1994
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 1953
8
2
8
0 203
8
2
8
1 203
8
0 1299
8
2
8
0 416
8
2
...

result:

ok 

Test #65:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
1 1012
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 1994
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
0 203
8
2
8
0 1299
8
2
8
0 416
8
2
8
0 983...

result:

ok 

Test #66:

score: 75
Accepted
time: 21ms
memory: 3724kb

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
0 1631
8
2
8
0 1683
8
2
8
0 7...

result:

ok 

Test #67:

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

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 1994
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
0 203
8
2
8
0 1299
8
2
8
0 416
8
2
8
0 983
8
2
8
0 ...

result:

ok 

Test #68:

score: 75
Accepted
time: 21ms
memory: 3828kb

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
1 258
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
1 1032
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 1953
8
2
8
0 203
8
2
8
0 1299
...

result:

ok 

Test #69:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
1 258
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
1 1032
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 1953
8
2
8
0 203
8
2
8
0 1299
...

result:

ok 

Test #70:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
1 1012
8
0 1209
8
2
8
0 1412
8
2
8
1 1412
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
0 203
8
2
8
0 1299
8
2
8
1...

result:

ok 

Test #71:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
1 1012
8
0 1209
8
2
8
0 1412
8
2
8
1 1412
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
1 1953
8
0 203
8
2
8
0 129...

result:

ok 

Test #72:

score: 75
Accepted
time: 54ms
memory: 3764kb

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
1 258
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
1 1032
8
0 411
8
2
8
0 540
8
2
8
1 540
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 1953
8
2
8
0 203
8
2
8
0 1299
...

result:

ok 

Test #73:

score: 75
Accepted
time: 49ms
memory: 3756kb

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
1 566
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
1 255
8
0 89
8
2
8
0 470
8
2
8
1 470
8
0 1953
8
2
8
1 1953
8
0 203
8
2
8
0 1299
...

result:

ok 

Test #74:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
0 203
8
2
8
0 1299
8
2
8
1 1299
8
0 416
8
2
8
1 416
...

result:

ok 

Test #75:

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

input:

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

output:

8
0 140
8
2
8
0 337
8
2
8
0 258
8
2
8
0 1924
8
2
8
0 566
8
2
8
0 1012
8
2
8
0 1209
8
2
8
0 1412
8
2
8
0 257
8
2
8
0 1066
8
2
8
0 475
8
2
8
0 146
8
2
8
0 187
8
2
8
0 1032
8
2
8
0 411
8
2
8
0 540
8
2
8
0 255
8
2
8
0 89
8
2
8
0 470
8
2
8
0 1953
8
2
8
0 203
8
2
8
0 1299
8
2
8
1 1299
8
0 416
8
2
8
1 416
...

result:

ok 

Test #76:

score: 75
Accepted
time: 30ms
memory: 3832kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
1 135
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
1 489
8
0 951
8
2
8
0 268
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
0 1631
8
2
8
1...

result:

ok 

Test #77:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 268
8
2
8
1 268
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
1 1701
8
0 1631
8
2
8
...

result:

ok 

Test #78:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
...

result:

ok 

Test #79:

score: 75
Accepted
time: 15ms
memory: 3856kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
...

result:

ok 

Test #80:

score: 75
Accepted
time: 43ms
memory: 3724kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
0 1631
8
2
8
1 1631
...

result:

ok 

Test #81:

score: 75
Accepted
time: 24ms
memory: 3904kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
0 1631
8
2
8
1 1631
...

result:

ok 

Test #82:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
1 186
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
1 277
8
0 1701
8...

result:

ok 

Test #83:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
0 256
8
2
8
0 564
8
2
8
1 564
8
0 135
8
2
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8
2
8
0 1952
8
2
8
0 277
8
2
8
0 1701
8
2
8
1 1701
8
0 16...

result:

ok 

Test #84:

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

input:

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

output:

8
0 10
8
2
8
0 336
8
2
8
1 336
8
0 206
8
2
8
1 206
8
0 136
8
2
8
1 136
8
0 42
8
2
8
0 363
8
2
8
1 363
8
0 207
8
2
8
0 256
8
2
8
1 256
8
0 171
8
2
8
1 171
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 499
8
2
8
1 499
8
0 268
8
2
8
1 268
8
0 25...

result:

ok 

Test #85:

score: 75
Accepted
time: 21ms
memory: 3864kb

input:

1834
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 268
8
2
8
1 268
8
...

result:

ok 

Test #86:

score: 75
Accepted
time: 28ms
memory: 3840kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
1 1173
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
...

result:

ok 

Test #87:

score: 75
Accepted
time: 28ms
memory: 3840kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
0 256
8
2
8
1 256
8
0 564
8
2
8
1 564
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
1 533
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
1 951
8
0 1971
8
2
8
0 1307
8
2
8
0 11...

result:

ok 

Test #88:

score: 75
Accepted
time: 36ms
memory: 3832kb

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
0 1142
8
2
8
1 1142
8
0 42
8
2
8
0 363
8
2
8
0 1208
8
2
8
1 1208
8
0 256
8
2
8
0 564
8
2
8
0 135
8
2
8
0 474
8
2
8
0 533
8
2
8
0 186
8
2
8
0 489
8
2
8
0 951
8
2
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
1 1307
8
0 1163
8
2
8
1 1163
8
0 62
8
2
8
0 1952
8
2
8
1 1952
8
...

result:

ok 

Test #89:

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

input:

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

output:

8
0 10
8
2
8
0 1173
8
2
8
0 206
8
2
8
1 206
8
0 1142
8
2
8
0 42
8
2
8
1 42
8
0 363
8
2
8
1 363
8
0 1208
8
2
8
0 256
8
2
8
1 256
8
0 564
8
2
8
0 135
8
2
8
1 135
8
0 474
8
2
8
1 474
8
0 533
8
2
8
0 186
8
2
8
1 186
8
0 489
8
2
8
1 489
8
0 951
8
2
8
0 1971
8
2
8
1 1971
8
0 1307
8
2
8
0 1163
8
2
8
0 62
8...

result:

ok