QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65591#693. Hard Times for Your DataQingyuAC ✓1614ms8424kbC++233.1kb2022-12-02 10:40:462022-12-02 10:40:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-02 10:40:52]
  • 评测
  • 测评结果:AC
  • 用时:1614ms
  • 内存:8424kb
  • [2022-12-02 10:40:46]
  • 提交

answer

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = 500;

int x[N][N], y[N][N];
int f[N];

int n, m;

int vis[N];
int p[N];

int tt = 0;

auto ch = [] (int i, int j, int delta) {
  x[i][j] += delta, x[j][i] += delta;
  y[i][j] -= delta, y[j][i] -= delta;
};

int ptr[N];

int s = -1;

int dfs(int v, int cur){
  vis[v] = tt;
  for (int i = 0; i < n; i++) {
    if ((x[v][i] >= cur && f[i] >= cur && i != s) || (x[v][i] >= cur && i == s && f[i] >= 2 * cur)) {
      f[i] -= cur;
      ch(v, i, -cur);
      return cur;
    }
  }
  for (int i = 0; i < n; i++) {
    if (x[v][i] >= cur) {
      for (int j = 0; j < n; j++) {
        if (x[v][i] < cur) break;
        if (y[i][j] >= cur && vis[j] < tt) {
          ch(v, i, -cur);
          ch(i, j, cur);
          int go = dfs(j, cur);
          if (go) {
            return go;
          }
          ch(v, i, cur);
          ch(i, j, -cur);
        }
      }
    }
  }
  return 0;
}

struct triple {
  int u, v, go;
};

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> f[i];
    p[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int a, b, cap;
    cin >> a >> b >> cap;
    a--, b--;
    x[a][b] = x[b][a] = cap;
  }
  vector <pair <int, int> > ee;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      //x[i][j] = x[j][i] = rnd() % 10;
      //int c = rnd() % (x[i][j] + 1);
      //f[i] += c, f[j] += c;
      ee.push_back({i, j});
    }
  }
  shuffle(ee.begin(), ee.end(), rnd);
  for (auto c : ee) {
    int i = c.first, j = c.second;
      if (f[i] && f[j]) {
        int grab = min(x[i][j], min(f[i], f[j]));
        f[i] -= grab, f[j] -= grab;
        ch(i, j, -grab);
      }
  }
  while (true) {
    vector <int> ord;
    for (int i = 0; i < n; i++) if (f[i]) ord.push_back(i);
    shuffle(ord.begin(), ord.end(), rnd);
    if (ord.empty()) break;
    int i = ord[0];
    s = i;
    for (int lg = (1 << 20); lg > 0; lg /= 2) {
      if (f[i] < lg) continue;
      tt++;
      while (int x = dfs(i, lg)) {
        f[i] -= x;
        if (f[i] < lg) break;
        tt++;
      }
    }
  }
  vector <triple> e;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (y[i][j]) {
        e.push_back({i + 1, j + 1, y[i][j]});
      }
    }
  }
  cout << e.size() << '\n';
  for (auto c : e) {
    cout << c.u << ' ' << c.v << ' ' << c.go << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3528kb

input:

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

output:

3
1 4 1
1 5 2
2 3 1

result:

ok OK

Test #2:

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

input:

10 30
5 6 1 3 5 4 2 5 3 6
1 2 1
1 4 1
1 7 1
1 8 1
1 10 1
2 3 1
2 5 1
2 6 1
2 8 1
2 10 1
4 5 1
4 10 1
5 6 1
5 8 1
5 9 1
6 8 1
6 9 1
7 10 1
8 10 1
9 10 1
6 7 1
3 9 1
4 7 1
7 9 1
3 4 1
3 7 1
8 9 1
3 8 1
6 10 1
3 5 1

output:

20
1 2 1
1 4 1
1 7 1
1 8 1
1 10 1
2 3 1
2 5 1
2 6 1
2 8 1
2 10 1
4 5 1
4 10 1
5 6 1
5 8 1
5 9 1
6 7 1
6 10 1
8 9 1
8 10 1
9 10 1

result:

ok OK

Test #3:

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

input:

500 1500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 285 1
2 478 1
3 455 1
4 247 1
5 24 1
6 259 1
7 334 1
8 199 1
9 479 1
10 27 1
11 98 1
12 377 1
13 313 1
14 411 1
15 463 1
16 154 1
17 62 1
18 309 1
19 482 1
20 87 1
21 159 1
22 305 1
23 326 1
25 32 1
26 437 1
28 90 1
29 405 1
30 223 1
31 51 1
33 358 1
34 162 1
35 210 1
36 42 1
37 138 1
38 429 1...

result:

ok OK

Test #4:

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

input:

30 100
5 5 7 2 7 6 1 4 1 3 5 3 3 5 5 3 4 4 2 7 5 2 4 6 4 5 2 2 5 3
1 4 1
1 8 1
1 12 1
1 21 1
1 26 1
2 5 1
2 8 1
2 14 1
2 24 1
2 29 1
3 5 1
3 13 1
3 15 1
3 17 1
3 19 1
3 20 1
3 23 1
4 11 1
5 7 1
5 14 1
5 20 1
5 24 1
5 26 1
6 10 1
6 17 1
6 24 1
6 25 1
6 27 1
6 28 1
8 17 1
8 22 1
9 20 1
10 24 1
10 29 1...

output:

60
1 4 1
1 8 1
1 12 1
1 21 1
1 26 1
2 5 1
2 13 1
2 14 1
2 15 1
2 29 1
3 5 1
3 6 1
3 15 1
3 17 1
3 20 1
3 27 1
3 28 1
4 11 1
5 7 1
5 14 1
5 23 1
5 24 1
5 26 1
6 10 1
6 17 1
6 20 1
6 24 1
6 27 1
8 17 1
8 22 1
8 24 1
9 20 1
10 24 1
10 29 1
11 13 1
11 19 1
11 24 1
11 30 1
12 14 1
12 21 1
13 26 1
14 16 1...

result:

ok OK

Test #5:

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

input:

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

output:

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

result:

ok OK

Test #6:

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

input:

20 50
5 2 3 3 4 5 2 2 1 5 8 6 5 3 3 5 3 5 4 6
1 6 1
1 10 1
1 13 1
1 19 1
1 20 1
2 15 1
2 18 1
3 8 1
3 18 1
3 20 1
4 10 1
4 11 1
4 16 1
5 10 1
5 11 1
5 14 1
5 20 1
6 11 1
6 13 1
6 17 1
6 19 1
7 18 1
7 19 1
8 12 1
9 11 1
10 14 1
10 17 1
11 12 1
11 13 1
11 16 1
11 20 1
12 13 1
12 15 1
12 16 1
12 17 1
1...

output:

40
1 6 1
1 10 1
1 13 1
1 19 1
1 20 1
2 15 1
2 18 1
3 8 1
3 13 1
3 20 1
4 10 1
4 11 1
4 16 1
5 6 1
5 10 1
5 14 1
5 20 1
6 11 1
6 17 1
6 19 1
7 18 1
7 19 1
8 12 1
9 11 1
10 14 1
10 17 1
11 12 1
11 13 1
11 16 1
11 18 1
11 20 1
12 13 1
12 15 1
12 16 1
12 17 1
13 19 1
14 18 1
15 16 1
16 20 1
18 20 1

result:

ok OK

Test #7:

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

input:

50 200
5 1 4 2 5 5 4 3 3 2 4 3 2 8 2 8 3 2 5 3 5 2 5 2 4 3 2 3 2 2 2 5 3 1 3 3 6 2 2 1 4 2 4 1 2 6 2 2 3 2
1 3 1
1 18 1
1 25 1
1 31 1
1 37 1
2 17 1
3 13 1
3 14 1
3 17 1
4 21 1
4 38 1
5 32 1
5 35 1
5 43 1
5 45 1
5 49 1
6 16 1
6 19 1
6 21 1
6 37 1
6 41 1
7 21 1
7 36 1
7 39 1
7 42 1
8 16 1
8 29 1
8 37 ...

output:

80
1 9 1
1 22 1
1 25 1
1 31 1
1 37 1
2 16 1
3 13 1
3 14 1
3 26 1
3 31 1
4 14 1
4 50 1
5 9 1
5 23 1
5 37 1
5 43 1
5 45 1
6 16 1
6 21 1
6 37 1
6 38 1
6 41 1
7 24 1
7 36 1
7 39 1
7 42 1
8 16 1
8 37 1
8 47 1
9 11 1
10 14 1
10 34 1
11 22 1
11 43 1
11 46 1
12 15 1
12 21 1
12 41 1
13 16 1
14 20 1
14 29 1
1...

result:

ok OK

Test #8:

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

input:

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

output:

250
1 77 1
2 259 1
3 244 1
4 352 1
5 424 1
6 122 1
7 410 1
8 372 1
9 297 1
10 114 1
11 276 1
12 229 1
13 403 1
14 177 1
15 402 1
16 199 1
17 76 1
18 208 1
19 223 1
20 131 1
21 91 1
22 309 1
23 236 1
24 358 1
25 246 1
26 176 1
27 116 1
28 253 1
29 115 1
30 128 1
31 65 1
32 56 1
33 408 1
34 71 1
35 16...

result:

ok OK

Test #9:

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

input:

500 1500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 67 1
2 234 1
3 65 1
4 11 1
5 494 1
6 421 1
7 195 1
8 281 1
9 44 1
10 213 1
12 410 1
13 268 1
14 167 1
15 63 1
16 55 1
17 208 1
18 130 1
19 414 1
20 95 1
21 462 1
22 240 1
23 139 1
24 360 1
25 138 1
26 152 1
27 387 1
28 318 1
29 469 1
30 241 1
31 454 1
32 39 1
33 489 1
34 355 1
35 363 1
36 338 ...

result:

ok OK

Test #10:

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

input:

500 1400
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 476 1
2 371 1
3 45 1
4 347 1
5 17 1
6 111 1
7 201 1
8 280 1
9 206 1
10 276 1
11 241 1
12 163 1
13 375 1
14 215 1
15 428 1
16 247 1
18 197 1
19 391 1
20 307 1
21 108 1
22 437 1
23 34 1
24 384 1
25 383 1
26 116 1
27 439 1
28 409 1
29 325 1
30 486 1
31 89 1
32 420 1
33 305 1
35 396 1
36 172 1
37 ...

result:

ok OK

Test #11:

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

input:

500 1400
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 175 1
2 423 1
3 304 1
4 419 1
5 83 1
6 279 1
7 74 1
8 361 1
9 145 1
10 484 1
11 180 1
12 116 1
13 111 1
14 184 1
15 147 1
16 130 1
17 370 1
18 472 1
19 70 1
20 271 1
21 478 1
22 262 1
23 350 1
24 450 1
25 231 1
26 374 1
27 435 1
28 426 1
29 473 1
30 273 1
31 464 1
32 439 1
33 275 1
34 448 1
35...

result:

ok OK

Test #12:

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

input:

500 4500
6 8 4 11 6 9 11 3 6 3 9 13 5 7 7 8 14 8 12 6 6 6 9 9 11 4 8 11 10 7 8 5 7 3 6 7 6 10 6 8 11 7 4 7 7 11 8 7 8 10 5 7 11 11 5 5 11 7 8 12 14 10 8 8 4 8 8 8 10 11 3 6 7 9 6 9 5 4 8 8 7 10 11 9 4 6 5 12 9 5 10 3 7 8 11 9 11 9 10 7 11 8 9 9 8 7 9 8 10 5 7 5 10 12 9 16 9 7 9 11 8 7 9 6 9 10 7 8 5...

output:

2000
1 47 1
1 107 1
1 164 1
1 165 1
1 398 1
1 455 1
2 6 1
2 89 1
2 181 1
2 213 1
2 358 1
2 426 1
2 432 1
2 446 1
3 18 1
3 42 1
3 123 1
3 448 1
4 29 1
4 50 1
4 109 1
4 164 1
4 165 1
4 184 1
4 194 1
4 198 1
4 246 1
4 261 1
4 335 1
5 69 1
5 138 1
5 263 1
5 271 1
5 310 1
5 392 1
6 56 1
6 59 1
6 80 1
6 1...

result:

ok OK

Test #13:

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

input:

500 8000
22 32 20 22 24 24 25 27 33 25 33 29 19 28 33 32 33 29 22 26 28 37 30 28 22 28 28 30 25 32 31 30 24 25 27 25 37 31 28 25 32 32 28 28 25 23 24 29 33 22 34 32 28 31 27 25 22 43 31 22 32 27 30 32 32 25 30 27 28 22 28 26 25 34 24 30 35 29 21 30 30 25 28 28 26 25 38 35 22 28 24 34 18 34 24 22 32 ...

output:

7000
1 14 1
1 36 1
1 84 1
1 133 1
1 149 1
1 189 1
1 219 1
1 228 1
1 229 1
1 236 1
1 238 1
1 242 1
1 247 1
1 253 1
1 260 1
1 301 1
1 308 1
1 314 1
1 326 1
1 372 1
1 377 1
1 396 1
2 18 1
2 19 1
2 21 1
2 42 1
2 74 1
2 80 1
2 83 1
2 103 1
2 111 1
2 126 1
2 161 1
2 189 1
2 247 1
2 259 1
2 272 1
2 279 1
2...

result:

ok OK

Test #14:

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

input:

500 9000
35 32 42 35 48 26 34 23 31 33 29 38 33 39 34 33 38 29 23 41 34 34 31 30 35 24 31 32 28 33 25 24 25 37 20 30 36 44 38 31 27 33 33 26 36 25 27 20 35 33 30 33 25 30 25 37 22 24 28 30 34 26 45 31 30 43 29 33 36 29 28 21 36 29 30 37 32 31 38 34 35 37 29 30 29 35 29 33 41 29 34 40 33 35 25 31 29 ...

output:

8000
1 22 1
1 30 1
1 36 1
1 39 1
1 62 1
1 65 1
1 70 1
1 76 1
1 102 1
1 105 1
1 125 1
1 133 1
1 141 1
1 155 1
1 166 1
1 172 1
1 176 1
1 197 1
1 213 1
1 231 1
1 237 1
1 312 1
1 313 1
1 317 1
1 337 1
1 338 1
1 343 1
1 350 1
1 389 1
1 396 1
1 397 1
1 406 1
1 417 1
1 486 1
1 493 1
2 12 1
2 34 1
2 41 1
2 ...

result:

ok OK

Test #15:

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

input:

500 1500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 240 1
2 181 1
3 9 1
4 316 1
5 397 1
6 479 1
7 120 1
8 260 1
10 136 1
11 149 1
12 442 1
13 279 1
14 432 1
15 410 1
16 25 1
17 343 1
18 165 1
19 92 1
20 312 1
21 67 1
22 80 1
23 83 1
24 89 1
26 43 1
27 317 1
28 262 1
29 437 1
30 138 1
31 384 1
32 45 1
33 382 1
34 127 1
35 119 1
36 215 1
37 53 1
...

result:

ok OK

Test #16:

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

input:

100 1000
3 6 3 4 7 3 3 2 5 5 2 4 4 5 2 3 3 1 3 3 6 4 7 3 5 2 3 7 2 4 6 4 4 3 6 2 3 7 3 4 3 2 2 3 6 1 4 3 6 5 4 6 2 7 2 1 2 2 6 5 4 5 5 7 7 7 2 3 5 2 5 2 4 1 6 2 6 8 5 2 4 4 4 7 6 2 5 5 4 4 2 2 4 8 6 5 1 3 4 4
1 13 1
1 28 1
1 77 1
2 9 1
2 14 1
2 38 1
2 75 1
2 98 1
2 100 1
3 58 1
3 68 1
3 96 1
4 69 1
...

output:

200
1 5 1
1 13 1
1 95 1
2 9 1
2 43 1
2 50 1
2 55 1
2 75 1
2 93 1
3 5 1
3 66 1
3 99 1
4 9 1
4 49 1
4 85 1
4 94 1
5 12 1
5 23 1
5 37 1
5 53 1
5 78 1
6 41 1
6 60 1
6 89 1
7 32 1
7 35 1
7 84 1
8 14 1
8 87 1
9 39 1
9 40 1
9 60 1
10 28 1
10 34 1
10 49 1
10 65 1
10 79 1
11 34 1
11 85 1
12 32 1
12 84 1
12 1...

result:

ok OK

Test #17:

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

input:

200 5000
13 10 8 5 12 6 15 9 12 12 10 8 9 9 12 14 10 13 4 9 6 13 15 12 6 15 5 8 13 6 10 11 5 11 10 13 10 7 10 8 14 12 17 10 9 11 13 6 9 8 8 11 11 11 8 11 19 9 12 11 12 7 11 12 7 7 5 4 6 6 11 11 7 10 13 10 13 11 17 7 14 5 12 11 14 6 9 8 11 12 14 6 10 11 11 11 17 7 14 15 6 5 6 6 11 16 5 8 4 8 8 6 11 1...

output:

1000
1 15 1
1 26 1
1 35 1
1 42 1
1 75 1
1 88 1
1 105 1
1 114 1
1 129 1
1 153 1
1 160 1
1 162 1
1 196 1
2 9 1
2 11 1
2 33 1
2 130 1
2 134 1
2 137 1
2 144 1
2 148 1
2 179 1
2 191 1
3 51 1
3 57 1
3 72 1
3 97 1
3 140 1
3 152 1
3 190 1
3 192 1
4 15 1
4 27 1
4 36 1
4 57 1
4 119 1
5 25 1
5 47 1
5 70 1
5 78...

result:

ok OK

Test #18:

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

input:

300 30000
67 70 83 76 68 63 62 58 62 69 60 80 64 73 74 60 66 52 69 64 68 71 74 68 62 67 62 72 75 83 73 67 73 70 69 70 73 70 78 72 62 79 66 78 76 50 67 73 61 67 77 83 66 65 59 64 75 66 63 75 65 62 51 64 68 70 80 60 50 58 69 51 63 72 79 57 72 73 70 58 68 76 69 72 63 63 66 79 63 58 62 68 65 60 67 70 67...

output:

10000
1 5 1
1 10 1
1 30 1
1 32 1
1 35 1
1 42 1
1 48 1
1 51 1
1 57 1
1 59 1
1 61 1
1 63 1
1 64 1
1 71 1
1 78 1
1 84 1
1 90 1
1 92 1
1 97 1
1 100 1
1 101 1
1 103 1
1 106 1
1 108 1
1 109 1
1 115 1
1 118 1
1 119 1
1 131 1
1 135 1
1 136 1
1 138 1
1 142 1
1 143 1
1 145 1
1 151 1
1 157 1
1 168 1
1 181 1
1 ...

result:

ok OK

Test #19:

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

input:

400 500
3 1 1 4 4 2 2 3 4 1 6 2 1 4 1 2 1 3 2 1 1 6 4 2 2 3 3 2 3 3 4 3 2 2 2 1 1 3 1 1 2 2 1 3 2 1 1 2 2 3 2 4 1 1 3 2 1 2 1 2 1 1 2 2 1 2 3 4 1 2 1 1 4 3 2 3 2 2 1 2 1 1 1 2 1 1 1 4 1 1 3 1 2 2 2 3 1 3 1 2 3 5 1 2 1 3 2 2 2 2 2 2 1 4 2 1 1 2 2 1 2 1 2 3 2 1 3 2 3 1 3 3 3 3 1 4 2 1 2 3 1 1 3 1 2 1 ...

output:

400
1 73 1
1 89 1
1 282 1
2 114 1
3 25 1
4 212 1
4 230 1
4 272 1
4 370 1
5 76 1
5 84 1
5 279 1
5 395 1
6 11 1
6 182 1
7 34 1
7 381 1
8 59 1
8 176 1
8 315 1
9 39 1
9 76 1
9 318 1
9 383 1
10 163 1
11 119 1
11 163 1
11 184 1
11 190 1
11 388 1
12 209 1
12 322 1
13 14 1
14 34 1
14 87 1
14 162 1
15 52 1
1...

result:

ok OK

Test #20:

score: 0
Accepted
time: 27ms
memory: 6172kb

input:

500 124750
3 4 6 4 6 6 7 5 9 5 7 3 5 3 4 2 7 3 5 5 4 4 2 3 6 3 7 8 6 4 4 5 3 5 6 5 6 6 4 3 5 6 5 5 7 5 3 5 6 7 3 5 8 3 7 5 5 4 3 2 6 6 7 2 7 4 7 2 4 7 6 6 4 5 4 5 4 2 6 4 3 7 4 6 8 5 4 2 4 7 3 5 4 7 4 4 5 4 8 4 7 3 3 5 4 2 7 4 9 8 4 4 4 7 5 4 5 4 4 5 4 9 6 2 3 5 2 4 5 9 7 3 5 2 2 3 8 2 5 4 3 7 4 6 3...

output:

1200
1 147 1
1 316 1
1 319 1
2 45 1
2 125 1
2 287 1
2 340 1
3 4 1
3 208 1
3 237 1
3 339 1
3 353 1
3 409 1
4 228 1
4 232 1
4 260 1
5 15 1
5 109 1
5 126 1
5 243 1
5 368 1
5 444 1
6 190 1
6 277 1
6 300 1
6 340 1
6 411 1
6 474 1
7 34 1
7 46 1
7 54 1
7 122 1
7 146 1
7 201 1
7 251 1
8 153 1
8 311 1
8 394 ...

result:

ok OK

Test #21:

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

input:

500 124750
6 5 5 4 4 5 6 7 3 3 8 4 6 5 12 6 8 7 5 8 10 8 5 6 5 7 4 6 7 1 4 4 7 3 7 6 4 9 7 4 11 8 6 7 8 6 10 2 7 5 5 7 7 14 7 5 7 6 9 5 6 3 6 6 6 7 7 3 4 7 8 6 5 5 4 8 6 8 12 4 6 9 5 7 6 5 5 7 5 5 3 9 8 6 7 5 2 6 6 7 5 6 4 5 5 3 7 5 7 4 9 7 4 5 9 6 7 4 4 4 4 9 10 6 11 4 4 2 4 4 3 5 4 3 3 6 5 6 6 8 6...

output:

1500
1 206 1
1 207 1
1 227 1
1 259 1
1 297 1
1 440 1
2 95 1
2 161 1
2 228 1
2 264 1
2 276 1
3 111 1
3 314 1
3 326 1
3 381 1
3 442 1
4 41 1
4 73 1
4 354 1
4 402 1
5 146 1
5 317 1
5 424 1
5 482 1
6 39 1
6 242 1
6 274 1
6 287 1
6 432 1
7 15 1
7 59 1
7 199 1
7 246 1
7 290 1
7 436 1
8 10 1
8 300 1
8 348 ...

result:

ok OK

Test #22:

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

input:

500 124750
9 9 6 6 8 7 6 5 10 5 11 10 5 3 4 9 10 4 8 11 5 7 6 8 6 4 6 13 8 10 8 6 7 9 5 4 10 7 3 6 7 5 5 9 5 7 9 8 7 11 11 4 14 8 11 5 6 5 4 6 8 8 6 5 5 9 12 10 9 10 7 8 9 10 5 4 13 13 4 5 7 7 5 5 4 6 7 7 7 6 10 6 5 6 6 9 9 5 7 7 7 10 6 7 9 7 5 9 2 7 6 11 3 5 6 6 9 10 5 8 4 7 4 11 6 4 5 3 6 6 6 3 11...

output:

1700
1 54 1
1 97 1
1 160 1
1 206 1
1 307 1
1 376 1
1 390 1
1 426 1
1 441 1
2 31 1
2 37 1
2 208 1
2 233 1
2 247 1
2 357 1
2 358 1
2 407 1
2 410 1
3 68 1
3 115 1
3 185 1
3 270 1
3 297 1
3 375 1
4 17 1
4 194 1
4 334 1
4 415 1
4 437 1
4 473 1
5 14 1
5 76 1
5 140 1
5 175 1
5 250 1
5 300 1
5 354 1
5 465 1...

result:

ok OK

Test #23:

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

input:

500 124750
8 8 11 7 9 9 8 8 7 8 12 9 8 9 10 11 6 7 11 12 12 9 7 9 9 5 7 8 2 7 12 9 8 7 8 8 8 11 9 9 11 14 5 8 4 13 11 9 6 12 11 7 5 6 6 8 6 12 10 13 9 11 9 7 8 12 12 7 7 10 6 15 8 9 6 10 8 11 15 7 12 10 13 11 11 7 11 6 9 13 6 6 11 9 7 7 10 12 6 8 8 12 11 11 11 9 12 13 4 6 9 11 9 14 14 10 5 9 14 7 6 ...

output:

2300
1 137 1
1 187 1
1 213 1
1 345 1
1 363 1
1 367 1
1 415 1
1 431 1
2 77 1
2 80 1
2 138 1
2 222 1
2 258 1
2 322 1
2 459 1
2 485 1
3 12 1
3 13 1
3 16 1
3 83 1
3 87 1
3 115 1
3 199 1
3 332 1
3 370 1
3 446 1
3 492 1
4 143 1
4 161 1
4 171 1
4 214 1
4 251 1
4 269 1
4 408 1
5 107 1
5 183 1
5 188 1
5 308 ...

result:

ok OK

Test #24:

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

input:

500 124750
176 179 173 181 174 176 181 180 163 164 172 195 184 169 184 183 194 169 160 181 198 171 169 188 176 175 159 186 187 175 165 182 189 183 176 172 185 186 184 190 200 173 165 173 164 163 180 168 188 188 175 193 194 184 186 172 181 175 186 187 165 181 189 176 160 174 169 171 183 175 183 161 1...

output:

44151
1 2 1
1 3 1
1 11 1
1 12 1
1 14 1
1 16 1
1 19 1
1 25 1
1 27 1
1 28 1
1 29 1
1 33 1
1 34 1
1 37 1
1 39 1
1 48 1
1 49 1
1 50 1
1 52 1
1 54 1
1 60 1
1 64 1
1 68 1
1 70 1
1 71 1
1 73 1
1 75 1
1 80 1
1 83 1
1 85 1
1 87 1
1 89 1
1 95 1
1 96 1
1 98 1
1 99 1
1 101 1
1 103 1
1 104 1
1 105 1
1 113 1
1 11...

result:

ok OK

Test #25:

score: 0
Accepted
time: 36ms
memory: 8264kb

input:

500 124750
347 346 369 352 345 337 356 350 356 354 341 356 356 358 356 349 351 343 345 355 348 364 352 356 350 342 353 339 359 354 372 360 366 343 351 337 349 361 348 367 338 363 345 354 359 345 354 348 346 345 360 353 338 349 344 368 349 344 351 348 342 364 362 329 353 356 362 343 347 352 347 346 3...

output:

88184
1 2 1
1 3 1
1 4 1
1 5 1
1 6 1
1 7 1
1 8 1
1 9 1
1 10 1
1 11 1
1 12 1
1 13 1
1 14 1
1 15 1
1 16 1
1 17 1
1 18 1
1 19 1
1 20 1
1 21 1
1 22 1
1 24 1
1 25 1
1 26 1
1 29 1
1 31 1
1 32 1
1 36 1
1 40 1
1 42 1
1 45 1
1 49 1
1 51 1
1 53 1
1 58 1
1 62 1
1 64 1
1 65 1
1 66 1
1 72 1
1 75 1
1 76 1
1 77 1
1...

result:

ok OK

Test #26:

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

input:

1 0
0

output:

0

result:

ok OK

Test #27:

score: 0
Accepted
time: 32ms
memory: 7608kb

input:

500 93511
228 252 255 233 246 214 246 241 247 249 254 249 252 227 260 253 260 268 254 244 238 266 242 253 249 268 254 225 250 244 233 229 241 243 260 257 236 246 272 288 231 241 265 242 238 243 241 245 247 245 245 264 266 243 238 257 247 262 270 228 233 255 250 238 254 263 255 250 247 231 245 254 26...

output:

46907
1 3 1
1 4 1
1 5 2
1 7 1
1 12 2
1 13 1
1 16 2
1 19 2
1 21 2
1 22 2
1 24 1
1 31 1
1 32 1
1 33 1
1 36 1
1 37 2
1 39 1
1 41 1
1 42 1
1 43 1
1 47 1
1 49 1
1 51 1
1 52 1
1 58 1
1 60 1
1 62 2
1 65 2
1 81 2
1 82 2
1 83 2
1 84 2
1 85 1
1 87 1
1 91 1
1 95 2
1 99 1
1 100 1
1 103 1
1 105 1
1 106 2
1 108 1...

result:

ok OK

Test #28:

score: 0
Accepted
time: 31ms
memory: 8412kb

input:

500 124750
733 754 732 741 753 768 745 752 735 774 749 745 767 744 737 767 749 750 772 744 756 760 728 744 755 736 746 741 744 747 760 755 753 737 764 743 742 759 737 750 749 770 746 756 758 754 742 742 762 738 760 745 732 746 753 743 744 777 769 761 749 735 728 752 742 742 746 742 758 757 740 770 7...

output:

93711
1 2 2
1 3 3
1 4 3
1 5 1
1 6 1
1 7 2
1 8 2
1 9 2
1 10 1
1 11 2
1 12 2
1 14 2
1 15 2
1 16 3
1 17 2
1 18 2
1 20 1
1 21 2
1 23 2
1 24 3
1 25 1
1 26 2
1 27 2
1 28 1
1 29 2
1 31 1
1 33 1
1 34 2
1 35 1
1 37 3
1 38 2
1 40 1
1 41 2
1 42 3
1 45 1
1 46 3
1 47 2
1 48 2
1 49 1
1 50 3
1 51 2
1 52 2
1 55 2
1...

result:

ok OK

Test #29:

score: 0
Accepted
time: 34ms
memory: 8316kb

input:

500 124750
989 1032 998 988 1012 1009 1024 1022 988 1006 1029 1013 999 1028 985 1018 974 957 1001 1002 984 997 1024 970 996 1043 996 1015 992 986 983 966 1000 1018 978 973 988 1005 984 974 997 967 984 965 989 981 1010 987 1023 960 1002 1019 1025 1012 1002 1046 1007 1019 1032 990 965 1007 975 962 102...

output:

99952
1 2 4
1 3 2
1 4 2
1 5 1
1 6 3
1 7 2
1 8 2
1 9 3
1 10 2
1 12 2
1 13 2
1 14 3
1 15 1
1 16 2
1 17 1
1 18 2
1 20 4
1 25 2
1 26 3
1 27 2
1 28 2
1 29 3
1 31 4
1 32 2
1 33 2
1 34 3
1 36 4
1 38 2
1 39 3
1 41 4
1 42 3
1 43 1
1 44 2
1 46 2
1 48 3
1 50 2
1 52 2
1 53 4
1 54 3
1 57 3
1 58 3
1 59 1
1 60 2
1...

result:

ok OK

Test #30:

score: 0
Accepted
time: 39ms
memory: 8416kb

input:

500 104092
498 488 489 514 476 506 512 479 481 468 516 509 476 537 479 498 513 493 517 507 498 475 516 503 480 508 468 520 497 518 476 524 483 520 536 508 522 477 489 482 492 528 494 486 507 511 481 502 486 522 498 505 504 507 494 504 513 509 470 522 495 498 492 519 532 529 485 481 512 483 487 520 5...

output:

69494
1 3 3
1 4 3
1 6 1
1 9 2
1 11 1
1 13 2
1 15 1
1 16 1
1 20 1
1 21 2
1 22 3
1 24 1
1 25 2
1 26 1
1 27 1
1 31 3
1 32 1
1 34 1
1 36 1
1 37 2
1 42 1
1 47 3
1 48 3
1 49 3
1 51 1
1 52 1
1 53 3
1 56 1
1 61 3
1 62 2
1 64 2
1 66 2
1 69 1
1 71 1
1 72 1
1 73 2
1 77 1
1 79 3
1 80 1
1 83 1
1 87 2
1 88 2
1 91...

result:

ok OK

Test #31:

score: 0
Accepted
time: 20ms
memory: 7624kb

input:

500 110890
522 485 507 512 492 496 472 517 508 530 493 484 468 493 473 508 521 493 502 527 523 497 455 510 466 503 516 459 502 498 499 479 512 487 514 514 479 506 489 463 515 517 522 494 535 504 481 525 515 495 488 507 496 489 495 482 485 523 515 499 500 527 474 502 493 488 476 464 469 508 493 510 4...

output:

55517
1 2 1
1 5 4
1 9 1
1 10 2
1 13 2
1 16 2
1 17 1
1 18 2
1 20 2
1 23 3
1 26 3
1 27 2
1 28 2
1 29 1
1 30 3
1 32 2
1 33 3
1 37 3
1 40 2
1 41 1
1 43 1
1 44 2
1 46 1
1 48 2
1 49 3
1 51 1
1 52 3
1 53 2
1 54 3
1 56 3
1 58 4
1 59 2
1 60 3
1 61 2
1 62 1
1 63 2
1 69 3
1 70 3
1 72 2
1 74 3
1 76 1
1 77 2
1 7...

result:

ok OK

Test #32:

score: 0
Accepted
time: 123ms
memory: 8348kb

input:

500 124750
998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 9...

output:

99959
1 2 2
1 3 3
1 4 2
1 5 2
1 6 3
1 7 3
1 8 3
1 9 2
1 10 2
1 11 2
1 12 2
1 13 2
1 14 2
1 15 3
1 16 2
1 17 3
1 18 2
1 19 2
1 20 2
1 21 2
1 22 2
1 23 3
1 24 1
1 25 3
1 26 2
1 27 2
1 28 2
1 29 3
1 30 3
1 31 2
1 32 2
1 33 2
1 34 2
1 35 2
1 36 2
1 37 1
1 38 2
1 39 3
1 40 3
1 41 3
1 42 3
1 43 3
1 44 2
1...

result:

ok OK

Test #33:

score: 0
Accepted
time: 1614ms
memory: 7628kb

input:

500 124750
252889 255529 243016 255430 261844 245011 259101 253197 243666 249639 246098 253370 266006 245667 245715 244189 252380 251515 247190 247805 250077 247286 248169 240596 250036 247222 251517 264594 257846 234620 254052 243612 250944 248254 252225 262739 253024 254425 249527 243222 250721 24...

output:

62690
1 2 1808
1 3 1155
1 4 1296
1 5 581
1 6 1410
1 7 197
1 8 1491
1 9 529
1 10 1024
1 11 512
1 12 1659
1 13 558
1 15 975
1 16 1249
1 17 778
1 18 1072
1 19 256
1 21 1347
1 22 128
1 25 1301
1 26 783
1 27 1666
1 29 1887
1 30 839
1 32 938
1 35 1292
1 37 961
1 38 12
1 39 516
1 40 753
1 42 233
1 43 385
1...

result:

ok OK

Test #34:

score: 0
Accepted
time: 63ms
memory: 8368kb

input:

500 124750
449593 449569 449616 449586 449608 449597 449608 449617 449596 449638 449586 449614 449599 449587 449613 449605 449617 449614 449602 449622 449609 449571 449577 449624 449598 449571 449608 449578 449607 449590 449599 449612 449580 449575 449586 449574 449613 449610 449577 449586 449579 44...

output:

124750
1 2 903
1 3 900
1 4 900
1 5 901
1 6 901
1 7 903
1 8 903
1 9 902
1 10 901
1 11 900
1 12 900
1 13 902
1 14 901
1 15 901
1 16 902
1 17 900
1 18 901
1 19 900
1 20 901
1 21 903
1 22 903
1 23 901
1 24 902
1 25 900
1 26 902
1 27 901
1 28 903
1 29 901
1 30 901
1 31 900
1 32 902
1 33 902
1 34 900
1 35...

result:

ok OK

Test #35:

score: 0
Accepted
time: 129ms
memory: 8344kb

input:

500 124750
1490 1491 1491 1483 1493 1488 1486 1487 1487 1489 1490 1490 1490 1491 1488 1491 1491 1489 1490 1489 1493 1488 1487 1487 1492 1491 1492 1483 1480 1492 1488 1490 1489 1485 1489 1490 1494 1493 1488 1490 1492 1490 1491 1485 1489 1480 1490 1492 1487 1489 1486 1490 1486 1487 1490 1492 1488 1493...

output:

107010
1 2 3
1 3 4
1 4 4
1 5 4
1 6 3
1 7 4
1 8 3
1 9 4
1 10 4
1 11 4
1 12 3
1 13 4
1 14 4
1 15 3
1 16 4
1 17 3
1 18 3
1 19 4
1 20 1
1 21 4
1 22 1
1 23 3
1 24 2
1 25 3
1 26 3
1 27 3
1 28 3
1 31 4
1 32 3
1 33 4
1 34 3
1 35 4
1 36 4
1 37 3
1 39 4
1 40 4
1 41 3
1 42 3
1 43 4
1 45 4
1 46 3
1 47 4
1 48 4
...

result:

ok OK

Test #36:

score: 0
Accepted
time: 45ms
memory: 8268kb

input:

500 124750
1374 1380 1370 1369 1367 1374 1359 1367 1363 1392 1372 1346 1367 1385 1367 1362 1366 1365 1370 1385 1376 1371 1353 1393 1365 1378 1370 1355 1363 1380 1369 1375 1369 1373 1388 1364 1383 1378 1383 1377 1374 1378 1377 1380 1387 1373 1370 1371 1374 1360 1358 1381 1375 1385 1370 1373 1369 1378...

output:

105734
1 2 4
1 3 3
1 4 3
1 5 3
1 6 3
1 7 4
1 8 2
1 9 3
1 10 4
1 11 3
1 12 1
1 13 4
1 14 4
1 16 3
1 18 3
1 19 3
1 21 2
1 22 3
1 23 3
1 24 4
1 25 4
1 26 3
1 27 3
1 29 3
1 30 4
1 31 3
1 32 3
1 33 2
1 34 4
1 35 4
1 36 4
1 37 4
1 38 2
1 39 3
1 40 4
1 41 3
1 42 3
1 43 2
1 45 4
1 46 3
1 47 4
1 48 3
1 49 3
...

result:

ok OK

Test #37:

score: 0
Accepted
time: 52ms
memory: 8352kb

input:

500 124750
14862 14860 14841 14845 14847 14829 14830 14843 14855 14860 14843 14849 14856 14849 14851 14854 14853 14850 14831 14850 14832 14843 14851 14820 14828 14835 14857 14844 14860 14845 14852 14836 14853 14842 14847 14863 14828 14838 14839 14849 14847 14849 14852 14836 14835 14850 14839 14833 1...

output:

123062
1 2 30
1 3 31
1 4 31
1 5 30
1 6 29
1 7 30
1 8 31
1 9 31
1 10 31
1 11 31
1 12 30
1 13 30
1 14 30
1 15 30
1 16 31
1 17 30
1 18 30
1 19 31
1 20 30
1 21 31
1 22 30
1 23 31
1 24 31
1 25 31
1 26 30
1 27 29
1 28 31
1 29 30
1 30 30
1 31 31
1 32 30
1 33 31
1 34 30
1 35 30
1 36 30
1 37 30
1 38 30
1 39 ...

result:

ok OK

Test #38:

score: 0
Accepted
time: 80ms
memory: 8420kb

input:

500 124750
14970 14968 14968 14969 14970 14969 14969 14970 14970 14970 14969 14970 14970 14970 14970 14970 14969 14970 14969 14970 14970 14970 14969 14970 14970 14970 14970 14970 14969 14970 14970 14969 14969 14970 14969 14970 14970 14968 14970 14970 14969 14970 14970 14970 14969 14970 14970 14970 1...

output:

120961
1 2 30
1 3 32
1 4 32
1 5 30
1 6 32
1 7 30
1 8 32
1 9 32
1 10 32
1 11 30
1 12 32
1 13 32
1 14 30
1 15 31
1 16 32
1 17 31
1 18 31
1 19 32
1 20 31
1 21 32
1 22 32
1 23 31
1 24 30
1 25 32
1 26 30
1 27 30
1 28 31
1 29 31
1 30 31
1 31 30
1 32 32
1 33 30
1 34 32
1 35 32
1 36 30
1 37 32
1 38 32
1 39 ...

result:

ok OK

Test #39:

score: 0
Accepted
time: 35ms
memory: 7572kb

input:

500 114257
387 364 374 392 369 372 365 372 380 371 375 388 378 371 377 373 366 380 374 362 372 371 366 358 378 389 378 360 380 376 369 378 374 363 372 384 361 364 375 381 371 368 382 383 373 389 365 357 379 358 344 379 369 367 378 376 382 372 378 362 371 374 361 371 384 391 364 376 372 370 383 378 3...

output:

49080
1 3 2
1 6 1
1 10 1
1 12 1
1 15 2
1 17 1
1 19 1
1 20 1
1 23 1
1 28 2
1 29 1
1 34 1
1 41 3
1 43 3
1 44 2
1 48 3
1 49 1
1 50 1
1 52 3
1 53 1
1 60 2
1 65 3
1 68 1
1 70 3
1 71 3
1 74 1
1 76 3
1 82 2
1 83 1
1 86 3
1 87 3
1 88 2
1 89 3
1 90 3
1 91 2
1 92 1
1 101 2
1 102 2
1 105 1
1 106 2
1 108 3
1 10...

result:

ok OK

Test #40:

score: 0
Accepted
time: 94ms
memory: 8204kb

input:

500 124750
1488 1485 1492 1493 1490 1489 1482 1495 1486 1482 1479 1486 1490 1490 1487 1489 1484 1487 1493 1490 1486 1489 1491 1494 1491 1485 1490 1482 1485 1491 1488 1488 1488 1488 1488 1487 1484 1486 1486 1483 1489 1491 1490 1486 1490 1485 1485 1489 1492 1489 1488 1489 1491 1487 1487 1487 1491 1491...

output:

107039
1 2 3
1 3 3
1 4 3
1 5 3
1 6 3
1 7 3
1 8 4
1 9 3
1 10 3
1 11 3
1 12 2
1 13 3
1 14 4
1 15 3
1 16 4
1 17 4
1 18 3
1 19 4
1 20 3
1 21 1
1 22 3
1 23 3
1 24 4
1 26 4
1 28 4
1 29 3
1 30 4
1 31 3
1 32 4
1 33 3
1 35 3
1 36 4
1 37 3
1 38 3
1 39 4
1 40 3
1 41 4
1 42 4
1 43 3
1 44 3
1 46 3
1 47 4
1 48 4
...

result:

ok OK

Test #41:

score: 0
Accepted
time: 87ms
memory: 8204kb

input:

500 124750
1489 1492 1491 1485 1490 1490 1487 1487 1488 1492 1489 1487 1488 1491 1488 1490 1486 1487 1490 1488 1493 1485 1485 1486 1487 1493 1486 1494 1483 1490 1493 1491 1492 1491 1491 1488 1489 1491 1487 1491 1491 1491 1488 1486 1488 1491 1493 1491 1483 1491 1487 1490 1489 1491 1489 1490 1491 1491...

output:

107033
1 2 4
1 3 4
1 4 3
1 5 3
1 6 3
1 7 4
1 8 3
1 9 4
1 10 3
1 11 4
1 12 3
1 13 4
1 14 3
1 15 2
1 16 3
1 17 2
1 18 3
1 19 4
1 20 4
1 21 4
1 23 2
1 24 3
1 25 1
1 26 1
1 27 3
1 28 3
1 29 3
1 30 3
1 31 4
1 32 1
1 33 4
1 34 4
1 35 3
1 36 2
1 37 4
1 38 4
1 39 3
1 40 4
1 41 3
1 42 1
1 43 3
1 46 3
1 48 3
...

result:

ok OK

Test #42:

score: 0
Accepted
time: 83ms
memory: 8288kb

input:

500 124750
4238117 4262284 4290935 4320891 4240110 4319111 4268307 4239303 4212959 4269182 4278289 4229143 4256508 4292763 4307952 4295643 4262663 4317763 4307141 4305875 4279249 4257100 4307968 4255606 4282654 4194421 4250479 4286031 4251648 4263126 4309087 4231518 4246623 4241153 4285256 4262092 4...

output:

124750
1 2 9621
1 3 9512
1 4 9191
1 5 5564
1 6 8182
1 7 8396
1 8 9944
1 9 8849
1 10 7530
1 11 8915
1 12 8129
1 13 4900
1 14 8043
1 15 8415
1 16 9751
1 17 9555
1 18 7838
1 19 8178
1 20 9094
1 21 8609
1 22 8519
1 23 9864
1 24 8129
1 25 9493
1 26 8567
1 27 9955
1 28 7390
1 29 9586
1 30 6713
1 31 7789
1...

result:

ok OK

Test #43:

score: 0
Accepted
time: 87ms
memory: 8424kb

input:

500 124750
3270752 3406208 3336140 3318852 3193241 3377251 3268856 3263877 3283306 3309608 3394677 3273425 3300385 3222003 3228209 3366078 3367603 3374843 3257915 3308319 3341540 3255608 3277939 3375558 3327128 3323671 3273432 3300132 3310094 3343160 3374260 3327771 3277600 3267769 3337235 3361960 3...

output:

124733
1 2 9434
1 3 375
1 4 3082
1 5 9642
1 6 8356
1 7 4031
1 8 7505
1 9 9216
1 10 9997
1 11 9066
1 12 1607
1 13 6554
1 14 5451
1 15 4934
1 16 7734
1 17 6825
1 18 5772
1 19 6244
1 20 8378
1 21 6026
1 22 8441
1 23 9968
1 24 7578
1 25 8208
1 26 8443
1 27 1961
1 28 9511
1 29 7285
1 30 7717
1 31 5972
1 ...

result:

ok OK

Test #44:

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

input:

10 13
1 1 1 1 1 1 1 1 1 1
1 2 1
1 3 1
2 3 1
3 4 1
3 5 1
4 5 1
5 6 1
5 7 1
6 7 1
7 8 2
8 9 1
7 10 1
9 10 1

output:

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

result:

ok OK

Test #45:

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

input:

100 148
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 3 1
2 3 1
3 4 1
3 5 1
4 5 1
5 6 1
5 7 1
6 7 1
7 8 1
7 9 1
8 9 1
9 10 1
9 11 1
10 11 ...

output:

50
1 2 1
3 4 1
5 6 1
7 8 1
9 10 1
11 12 1
13 14 1
15 16 1
17 18 1
19 20 1
21 22 1
23 24 1
25 26 1
27 28 1
29 30 1
31 32 1
33 34 1
35 36 1
37 38 1
39 40 1
41 42 1
43 44 1
45 46 1
47 48 1
49 50 1
51 52 1
53 54 1
55 56 1
57 58 1
59 60 1
61 62 1
63 64 1
65 66 1
67 68 1
69 70 1
71 72 1
73 74 1
75 76 1
77...

result:

ok OK

Test #46:

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

input:

500 848
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 2 1
3 4 1
5 6 1
7 8 1
9 10 1
11 12 1
13 498 1
14 15 1
16 17 1
18 19 1
20 21 1
22 23 1
24 25 1
26 27 1
28 29 1
30 226 1
31 33 1
32 62 1
34 35 1
36 37 1
38 39 1
40 41 1
42 43 1
44 107 1
45 46 1
47 48 1
49 50 1
51 52 1
53 55 1
54 210 1
56 325 1
57 58 1
59 60 1
61 63 1
64 65 1
66 67 1
68 69 1
70 7...

result:

ok OK

Test #47:

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

input:

500 1243
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 3 1
2 121 1
4 5 1
6 129 1
7 9 1
8 448 1
10 11 1
12 361 1
13 15 1
14 252 1
16 82 1
17 19 1
18 369 1
20 174 1
21 56 1
22 23 1
24 25 1
26 68 1
27 28 1
29 354 1
30 31 1
32 33 1
34 35 1
36 37 1
38 39 1
40 183 1
41 70 1
42 43 1
44 45 1
46 47 1
48 205 1
49 203 1
50 289 1
51 53 1
52 427 1
54 55 1
57 5...

result:

ok OK

Test #48:

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

input:

500 1738
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 3 1
2 372 1
4 325 1
5 7 1
6 171 1
8 160 1
9 324 1
10 297 1
11 438 1
12 13 1
14 15 1
16 17 1
18 142 1
19 40 1
20 21 1
22 122 1
23 452 1
24 118 1
25 238 1
26 138 1
27 52 1
28 488 1
29 30 1
31 480 1
32 234 1
33 35 1
34 145 1
36 411 1
37 168 1
38 358 1
39 41 1
42 467 1
43 203 1
44 45 1
46 236 1
47...

result:

ok OK

Test #49:

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

input:

100 222
13 7 6 9 11 12 2 3 14 11 5 4 8 7 8 7 5 3 4 9 2 6 1 4 2 4 7 5 4 4 7 2 2 2 3 9 1 3 1 3 2 2 6 4 5 6 2 3 7 2 6 6 3 3 2 3 3 8 6 2 2 3 1 3 2 2 3 3 4 3 2 4 4 3 2 3 4 3 4 2 2 5 2 3 4 1 3 2 3 1 2 3 2 1 1 1 1 1 2 2
1 2 1
2 3 1
3 4 1
1 5 2
2 5 1
3 5 1
4 5 1
1 6 2
2 6 1
5 6 1
1 7 1
3 7 1
1 8 1
4 8 1
5 8...

output:

193
1 2 1
1 5 2
1 6 2
1 7 1
1 8 1
1 10 1
1 12 1
1 13 1
1 35 1
1 45 2
2 3 1
2 5 1
2 6 1
2 10 1
2 24 1
2 83 1
3 4 1
3 5 1
3 7 1
3 29 1
3 31 1
4 5 1
4 8 1
4 10 1
4 11 2
4 21 1
4 35 1
4 60 1
5 6 1
5 8 1
5 12 1
5 20 1
5 24 1
5 26 1
6 9 1
6 27 1
6 29 1
6 38 1
6 42 1
6 46 1
6 79 1
6 84 1
9 10 1
9 11 1
9 13...

result:

ok OK

Test #50:

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

input:

500 851
1 2 3 2 3 3 5 3 4 3 3 9 2 2 2 1 6 7 4 1 4 3 7 2 2 3 2 4 4 4 3 6 5 1 1 3 1 10 1 1 3 3 6 3 3 3 6 4 6 1 2 2 1 4 11 4 4 2 2 6 1 8 2 7 4 3 5 2 2 1 2 2 3 2 1 2 2 3 5 10 7 3 4 2 6 5 12 4 3 1 5 4 3 2 4 7 3 2 9 2 2 4 3 3 1 4 4 10 2 1 3 5 6 2 2 9 2 1 2 2 5 3 1 6 8 1 4 1 3 2 3 9 2 3 5 5 7 2 2 4 1 2 2 4...

output:

757
1 2 1
2 3 1
3 4 1
3 5 1
4 5 1
5 6 1
6 7 1
6 8 1
7 8 1
7 9 2
7 10 1
8 9 1
9 10 1
10 11 1
11 12 1
11 17 1
12 13 1
12 15 1
12 17 1
12 18 1
12 19 2
12 26 2
13 14 1
14 16 1
15 19 1
17 18 1
17 23 2
17 25 1
18 20 1
18 21 1
18 22 1
18 24 1
18 28 1
19 26 1
21 22 1
21 23 1
21 29 1
22 24 1
23 28 1
23 30 1
...

result:

ok OK

Test #51:

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

input:

500 1466
5 3 5 6 3 8 7 5 13 5 4 1 1 12 5 9 9 5 5 8 18 1 4 11 19 5 1 3 5 12 6 2 3 15 4 2 3 11 5 1 4 5 7 21 12 3 3 4 7 6 3 9 12 6 11 3 7 22 5 3 3 24 3 2 3 25 2 2 2 5 22 5 7 15 4 7 19 4 4 17 3 9 25 30 3 4 4 5 3 20 2 5 4 8 2 21 1 15 9 4 15 15 1 13 18 5 6 6 10 6 4 8 2 3 6 10 2 5 4 10 2 4 16 6 5 3 3 33 2 ...

output:

1372
1 2 1
1 3 2
1 6 2
2 3 1
2 10 1
3 4 1
3 6 1
4 5 1
4 6 1
4 7 1
4 11 1
4 15 1
5 6 1
5 16 1
6 7 1
6 9 1
6 14 1
7 8 1
7 11 1
7 15 1
7 17 1
7 21 1
8 9 1
8 11 1
8 14 1
8 19 1
9 10 1
9 11 1
9 13 1
9 14 1
9 16 1
9 17 1
9 18 2
9 19 1
9 25 1
9 33 1
10 12 1
10 14 1
10 19 1
14 15 1
14 17 1
14 18 1
14 25 1
1...

result:

ok OK

Test #52:

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

input:

500 2838
13 6 5 10 6 9 9 2 7 16 9 11 11 3 8 12 12 4 4 9 6 8 10 4 2 2 13 7 4 5 2 3 5 3 3 7 17 8 8 3 9 6 3 5 7 6 5 8 7 10 4 3 6 8 5 4 3 5 6 13 6 10 3 15 2 2 2 2 2 2 6 3 22 18 25 6 3 1 31 4 10 11 25 12 32 16 29 5 3 6 2 2 3 4 6 14 13 3 2 4 8 4 11 18 2 4 7 7 15 18 3 4 7 3 1 3 5 2 3 2 6 7 10 12 10 10 3 4 ...

output:

1312
1 2 2
1 3 2
1 4 5
1 5 2
1 6 1
1 8 1
2 4 1
2 6 1
2 10 2
3 4 1
3 7 1
3 10 1
4 5 1
4 8 1
4 14 1
5 6 2
5 9 1
6 7 1
6 9 1
6 12 2
6 13 1
7 9 3
7 11 1
7 14 1
7 16 1
7 23 1
9 10 1
9 15 1
10 11 3
10 12 2
10 13 4
10 17 2
10 37 1
11 12 1
11 15 2
11 37 2
12 13 2
12 15 1
12 20 1
12 37 1
12 38 1
13 15 1
13 1...

result:

ok OK

Test #53:

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

input:

500 2195
11 5 8 9 8 8 4 10 9 10 7 2 3 9 12 6 1 12 1 2 9 13 3 7 13 8 14 2 5 6 4 17 3 9 2 3 5 14 4 23 6 20 2 4 3 16 19 2 6 3 5 3 21 5 18 3 4 9 9 2 5 4 4 3 14 4 3 2 3 5 3 5 6 2 7 3 1 1 2 5 2 10 8 7 21 17 4 3 4 8 3 1 4 10 4 3 3 6 2 5 17 2 3 4 2 2 2 7 16 3 5 21 6 4 5 3 6 3 2 4 18 21 18 14 9 2 13 12 15 2 ...

output:

1339
1 2 1
1 3 1
1 4 3
1 5 1
1 6 1
1 7 1
1 8 3
2 3 2
2 8 2
3 6 2
3 9 1
3 11 2
4 5 1
4 6 1
4 8 1
4 10 2
4 14 1
5 6 2
5 7 1
5 8 2
5 10 1
6 8 1
6 21 1
7 12 1
7 15 1
8 9 1
9 10 1
9 16 1
9 22 2
9 25 1
9 26 1
9 33 1
10 11 1
10 13 2
10 14 1
10 18 1
10 21 1
11 12 1
11 15 1
11 16 2
13 15 1
14 15 1
14 20 1
14...

result:

ok OK

Test #54:

score: 0
Accepted
time: 16ms
memory: 6168kb

input:

500 4891
45 20 26 21 19 26 23 14 35 9 29 6 36 32 35 48 19 8 40 48 41 6 47 12 4 38 42 25 45 13 15 12 13 48 14 33 10 13 30 58 26 73 8 5 15 10 27 15 25 11 11 10 18 7 14 9 62 70 9 9 15 9 54 38 11 39 33 29 13 10 10 52 35 14 5 16 17 10 35 8 18 20 26 9 10 50 39 39 67 11 66 8 17 10 113 15 39 25 16 16 15 10 ...

output:

3161
1 2 3
1 3 12
1 4 9
1 5 6
1 6 4
1 7 5
1 8 3
1 9 3
2 3 3
2 4 1
2 5 3
2 6 3
2 8 1
2 9 1
2 11 4
2 13 1
3 4 1
3 5 2
3 6 2
3 8 4
3 9 1
3 10 1
4 5 3
4 6 4
4 9 1
4 11 1
4 13 1
5 6 3
5 7 1
5 13 1
6 7 3
6 8 3
6 9 1
6 10 1
6 11 1
6 13 1
7 8 2
7 9 1
7 10 2
7 11 2
7 12 1
7 13 3
7 14 3
8 13 1
9 10 1
9 11 2
9...

result:

ok OK

Test #55:

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

input:

500 3939
42 20 39 23 38 26 19 10 43 33 23 9 39 13 53 6 53 69 16 64 33 32 31 18 11 12 11 17 16 10 63 9 14 11 40 37 58 14 44 11 62 26 21 47 44 36 56 14 62 24 48 61 48 10 61 12 16 53 10 25 15 60 10 55 12 9 14 28 15 55 22 35 21 36 12 52 8 11 32 10 11 11 48 59 11 21 8 52 34 12 36 13 48 12 20 83 10 55 24 ...

output:

3041
1 2 2
1 3 17
1 4 7
1 5 8
1 6 6
1 7 2
2 3 1
2 4 1
2 5 1
2 6 4
2 7 4
2 8 1
2 9 4
2 10 2
3 4 2
3 5 10
3 8 4
3 9 3
3 10 2
4 5 1
4 7 1
4 8 2
4 9 3
4 10 3
4 13 3
5 6 1
5 7 7
5 9 5
5 10 1
5 12 1
5 13 2
5 15 1
6 7 2
6 8 1
6 9 2
6 10 1
6 11 3
6 12 4
6 13 1
6 15 1
7 8 1
7 13 2
8 10 1
9 10 2
9 11 2
9 12 4...

result:

ok OK

Test #56:

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

input:

500 3031
31 16 25 28 12 32 38 40 18 18 12 47 37 18 17 13 50 48 14 50 12 13 66 31 13 32 51 14 48 34 25 44 9 29 39 26 16 23 40 32 7 14 7 43 13 52 14 8 36 22 17 30 57 10 34 27 24 24 37 23 24 18 21 25 32 12 21 26 14 11 59 14 13 36 37 72 13 30 43 8 31 13 12 10 44 31 16 41 50 51 9 10 11 14 77 20 61 34 88 ...

output:

2336
1 2 1
1 3 16
1 4 6
1 5 6
1 6 2
2 3 2
2 4 6
2 6 5
2 7 2
3 4 2
3 5 2
3 6 2
3 7 1
4 5 1
4 6 2
4 7 6
4 8 5
5 6 2
5 7 1
6 7 1
6 8 1
6 9 6
6 10 4
6 12 3
6 13 4
7 8 1
7 9 5
7 10 7
7 11 3
7 12 3
7 13 2
7 14 3
7 17 3
8 9 2
8 10 7
8 11 5
8 12 1
8 13 2
8 14 2
8 15 5
8 17 3
8 18 4
8 19 2
9 11 3
9 13 2
11 1...

result:

ok OK

Test #57:

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

input:

500 3011
23 18 21 26 29 26 28 23 12 23 29 28 22 7 24 11 33 9 35 39 66 13 34 10 28 41 17 18 12 41 18 16 9 9 7 53 13 79 19 11 12 11 80 61 54 23 13 11 15 24 17 12 23 22 9 83 11 63 15 14 23 8 10 47 22 59 29 48 46 30 37 15 46 23 12 14 13 24 13 18 47 14 16 10 45 18 33 44 16 41 19 23 38 11 31 59 41 47 13 6...

output:

2326
1 2 2
1 3 12
1 4 5
1 5 4
2 3 1
2 4 6
2 5 8
2 6 1
3 4 2
3 5 1
3 6 4
3 7 1
4 5 1
4 6 3
4 7 8
4 8 1
5 6 2
5 7 5
5 8 5
5 9 1
5 10 2
6 8 4
6 9 7
6 10 5
7 8 2
7 9 2
7 10 3
7 11 6
7 12 1
8 9 1
8 10 2
8 11 5
8 12 3
9 11 1
10 11 2
10 12 4
10 13 2
10 14 3
11 12 3
11 13 3
11 14 2
11 15 5
11 16 1
11 17 1
1...

result:

ok OK

Test #58:

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

input:

500 3014
31 12 20 32 24 24 21 21 22 25 29 29 50 13 46 27 16 19 11 42 9 54 75 28 26 18 53 20 13 12 25 47 16 12 12 48 21 46 19 12 58 15 71 13 47 9 17 55 55 46 43 10 25 20 46 15 39 44 14 41 11 8 6 8 30 11 22 39 25 49 13 30 8 46 37 46 47 50 11 11 22 19 13 29 12 20 8 15 17 8 14 25 60 14 12 13 11 52 52 23...

output:

2336
1 2 4
1 3 12
1 4 14
1 5 1
2 4 3
2 5 5
3 4 1
3 5 5
3 6 1
3 7 1
4 5 1
4 6 7
4 7 6
5 6 1
5 8 7
5 9 4
6 7 2
6 8 5
6 9 6
6 10 2
7 8 3
7 9 3
7 10 6
8 10 3
8 11 3
9 10 2
9 11 2
9 12 5
10 11 2
10 12 1
10 13 3
10 15 6
11 12 2
11 13 7
11 14 5
11 15 6
11 16 2
12 13 1
12 14 5
12 15 3
12 16 7
12 17 2
12 18 ...

result:

ok OK

Test #59:

score: 0
Accepted
time: 16ms
memory: 6240kb

input:

500 2873
21 15 24 26 29 31 31 37 27 14 10 30 20 24 9 26 21 36 31 51 32 21 11 55 13 57 13 68 11 19 11 14 55 17 9 34 28 13 21 12 11 17 46 18 56 50 39 11 13 8 15 29 42 40 16 34 51 24 21 32 32 53 11 33 35 49 15 26 23 9 40 26 9 18 15 13 15 49 13 42 36 10 8 11 43 24 10 13 28 14 11 39 14 55 18 13 52 11 13 ...

output:

2270
1 2 1
1 3 9
1 4 10
1 5 1
2 3 3
2 4 4
2 5 5
2 6 2
3 4 2
3 5 7
3 6 1
3 7 2
4 5 2
4 6 7
4 7 1
5 6 2
5 7 4
5 8 5
5 9 3
6 7 2
6 8 6
6 9 8
6 12 3
7 8 3
7 9 4
7 10 5
7 11 4
7 12 6
8 9 3
8 10 6
8 11 6
8 12 2
8 13 3
8 14 1
8 15 2
9 10 2
9 12 1
9 13 2
9 14 2
9 15 2
10 12 1
12 13 1
12 14 8
12 15 2
12 16 4...

result:

ok OK

Test #60:

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

input:

500 2837
28 13 30 26 31 30 36 32 12 28 26 33 18 11 40 37 14 15 29 10 25 45 32 13 12 37 44 40 11 16 44 8 68 16 25 14 36 22 69 61 25 41 29 18 9 10 12 14 21 53 17 15 20 14 12 11 14 51 42 14 27 52 30 27 17 11 19 38 15 12 61 12 57 15 91 21 10 15 21 12 10 10 13 91 11 27 37 30 14 22 12 33 15 16 56 22 7 21 ...

output:

2335
1 2 3
1 3 13
1 4 6
1 5 6
2 4 5
2 5 4
2 6 1
3 5 9
3 6 4
3 7 4
4 5 2
4 6 4
4 7 6
4 8 3
5 6 2
5 7 3
5 8 3
5 9 2
6 7 1
6 8 4
6 9 5
6 10 4
6 11 4
6 13 1
7 8 1
7 9 1
7 10 4
7 11 5
7 13 10
7 14 1
8 9 2
8 10 3
8 11 5
8 12 5
8 13 2
8 15 4
9 10 1
9 12 1
10 11 1
10 12 3
10 13 2
10 14 5
10 15 4
10 16 1
11 ...

result:

ok OK

Test #61:

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

input:

500 3273
25 18 19 27 18 26 26 17 28 30 31 35 29 30 16 13 19 25 35 31 30 25 55 16 12 38 40 33 15 19 16 27 16 35 36 44 16 50 13 27 14 23 15 28 27 23 25 13 15 41 43 23 19 14 6 13 14 58 62 85 15 14 14 14 18 81 27 16 14 13 64 21 21 24 40 37 18 40 14 59 11 10 9 13 35 10 37 54 16 27 13 15 69 12 30 18 16 10...

output:

2669
1 2 2
1 3 9
1 4 8
1 5 5
1 6 1
2 3 3
2 4 5
2 5 2
2 6 6
3 4 2
3 6 1
3 7 4
4 5 2
4 6 1
4 7 6
4 8 1
4 9 2
5 6 1
5 7 4
5 8 1
5 9 3
6 7 2
6 8 2
6 9 5
6 10 4
6 11 3
7 8 2
7 9 4
7 10 3
7 11 1
8 9 2
8 11 4
8 12 4
8 13 1
9 10 1
9 11 4
9 12 5
9 13 1
9 14 1
10 11 2
10 12 4
10 13 6
10 14 4
10 15 4
10 17 2
1...

result:

ok OK

Test #62:

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

input:

500 2800
13 9 13 15 20 16 29 23 29 37 26 11 25 8 9 26 18 21 19 20 23 33 22 39 52 11 8 7 54 10 52 40 36 16 32 11 10 38 10 30 17 15 18 5 7 8 30 7 53 20 12 52 5 13 37 5 11 12 11 8 30 11 26 8 11 5 6 37 47 24 33 20 27 32 30 29 28 17 9 19 14 18 12 13 45 55 36 29 11 34 33 22 15 12 39 8 27 8 4 22 25 8 12 8 ...

output:

2189
1 2 4
1 3 6
1 4 2
1 5 1
2 4 4
2 5 1
3 4 2
3 6 2
3 7 3
4 5 4
4 6 1
4 7 2
5 6 1
5 7 7
5 8 3
5 9 3
6 7 1
6 8 5
6 9 1
6 10 5
7 8 1
7 9 3
7 10 7
7 11 5
8 9 1
8 10 5
8 11 5
8 12 3
9 10 4
9 11 4
9 13 5
9 14 4
9 15 3
9 16 1
10 11 1
10 12 7
10 13 5
10 16 3
11 12 1
11 13 1
11 14 1
11 15 3
11 16 3
11 17 2...

result:

ok OK

Test #63:

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

input:

500 2381
17 9 17 15 14 19 22 22 19 23 22 17 17 21 16 14 19 21 13 25 18 26 17 25 18 22 29 23 20 23 19 18 21 16 19 25 23 18 23 12 12 23 21 19 20 19 21 15 16 25 23 23 21 24 24 23 20 3 24 28 27 16 25 11 24 20 18 21 26 25 27 22 14 19 22 20 17 24 17 21 23 22 15 30 28 22 27 8 11 18 26 24 13 21 25 20 5 24 2...

output:

1951
1 2 3
1 3 10
1 4 2
1 5 2
2 3 3
2 4 3
3 4 1
3 6 3
4 5 1
4 6 3
4 7 5
5 6 1
5 7 4
5 8 4
5 9 2
6 7 1
6 8 6
6 9 1
6 10 4
7 8 1
7 9 4
7 10 4
7 11 3
8 9 2
8 10 5
8 12 4
9 11 2
9 12 7
9 13 1
10 11 1
10 12 2
10 13 4
10 14 3
11 13 5
11 14 3
11 15 8
12 13 1
12 14 3
13 14 1
13 16 5
14 15 1
14 16 3
14 17 3
...

result:

ok OK

Test #64:

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

input:

500 1500
13 8 17 26 13 26 21 23 14 22 22 18 23 23 26 18 22 22 22 19 17 19 15 17 19 18 26 23 17 28 18 25 16 21 22 21 18 22 24 22 27 32 28 24 23 27 21 19 26 21 22 26 15 23 12 17 21 22 26 22 27 18 25 19 27 14 24 21 20 21 23 17 27 17 16 17 18 20 21 21 19 21 23 21 27 26 28 27 26 25 24 24 35 18 25 20 21 1...

output:

1408
1 3 5
1 4 8
2 3 2
2 4 6
3 4 1
3 5 3
3 6 6
4 6 7
4 7 4
5 6 1
5 7 5
5 8 4
6 7 2
6 8 9
6 9 1
7 8 1
7 9 5
7 10 4
8 9 1
8 10 4
8 11 4
9 10 2
9 11 3
9 12 2
10 11 1
10 12 8
10 13 3
11 12 1
11 13 5
11 14 8
12 13 1
12 14 2
12 15 4
13 14 1
13 15 9
13 16 4
14 15 2
14 16 6
14 17 4
15 16 1
15 17 5
15 18 5
1...

result:

ok OK

Test #65:

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

input:

500 1488
13 12 28 17 25 30 20 22 24 19 19 20 21 22 21 18 16 22 18 12 24 26 20 22 24 13 9 18 13 17 15 17 17 13 12 16 11 20 16 21 16 23 18 26 17 25 23 16 17 27 13 20 18 13 19 13 18 29 23 28 19 20 28 25 20 21 16 17 17 18 19 16 13 20 16 15 17 27 17 13 24 22 33 22 28 29 24 31 28 21 24 22 16 16 18 18 13 2...

output:

1390
1 2 2
1 3 8
1 4 3
2 3 1
2 4 5
2 5 4
3 4 1
3 5 9
3 6 9
4 5 1
4 6 4
4 7 3
5 7 5
5 8 6
6 7 1
6 8 6
6 9 10
7 8 1
7 9 7
7 10 3
8 10 5
8 11 4
9 10 2
9 11 4
9 12 1
10 11 2
10 12 4
10 13 3
11 12 2
11 13 6
11 14 1
12 13 1
12 14 7
12 15 5
13 14 4
13 16 7
14 15 1
14 16 5
14 17 4
15 16 1
15 17 5
15 18 9
16...

result:

ok OK

Test #66:

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

input:

500 1493
14 7 27 18 18 28 21 18 13 23 8 22 25 15 27 21 16 23 20 20 19 22 21 17 17 24 14 28 17 27 19 25 20 16 17 16 17 14 19 12 11 15 16 20 18 21 19 21 18 17 12 26 20 23 25 27 30 25 17 27 16 17 23 18 27 24 19 32 20 28 17 25 23 20 15 17 16 14 15 18 15 21 16 25 14 20 21 18 22 10 24 21 14 14 20 16 12 18...

output:

1403
1 3 12
1 4 2
2 4 5
2 5 2
3 4 3
3 5 4
3 6 8
4 6 7
4 7 1
5 6 2
5 7 6
5 8 4
6 7 3
6 8 5
6 9 3
7 8 1
7 9 1
7 10 9
8 9 2
8 10 5
8 11 1
9 10 1
9 12 6
10 11 2
10 12 1
10 13 5
11 12 2
11 13 1
11 14 2
12 13 1
12 14 5
12 15 7
13 14 1
13 15 9
13 16 8
14 16 3
14 17 4
15 17 3
15 18 8
16 17 2
16 18 6
16 19 2...

result:

ok OK

Test #67:

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

input:

500 1538
35 30 52 54 71 62 71 58 65 58 63 59 58 58 69 61 61 71 60 63 59 80 46 60 60 52 71 58 67 72 57 57 49 65 58 62 67 71 52 62 55 56 59 47 57 55 50 53 64 39 56 53 48 54 51 52 64 60 60 68 59 62 68 41 63 69 61 56 56 69 67 51 74 57 64 68 61 66 63 66 59 67 73 54 69 62 59 60 67 79 59 66 68 68 69 61 71 ...

output:

1532
1 2 4
1 3 19
1 4 12
2 3 2
2 4 9
2 5 15
3 4 3
3 5 14
3 6 14
4 5 3
4 6 16
4 7 11
5 6 2
5 7 18
5 8 19
6 7 4
6 8 15
6 9 11
7 8 4
7 9 17
7 10 17
8 9 2
8 10 9
8 11 9
9 10 3
9 11 20
9 12 12
10 11 4
10 12 13
10 13 12
11 12 4
11 13 15
11 14 11
12 13 4
12 14 11
12 15 15
13 14 4
13 15 14
13 16 9
14 15 3
1...

result:

ok OK

Test #68:

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

input:

500 1686
449 354 619 629 588 644 598 611 584 605 612 597 572 605 565 609 557 597 600 592 598 631 608 637 623 624 636 610 612 620 589 636 618 612 623 582 626 579 639 556 618 622 604 618 592 654 576 632 627 592 633 607 605 624 577 587 629 575 631 562 585 591 583 609 551 588 615 550 651 611 577 606 611...

output:

1675
1 2 29
1 3 279
1 4 141
2 3 31
2 4 144
2 5 150
3 4 31
3 5 131
3 6 147
4 5 30
4 6 149
4 7 134
5 6 31
5 7 124
5 8 122
6 7 30
6 8 154
6 9 133
7 8 30
7 9 133
7 10 147
8 9 30
8 10 124
8 11 151
9 10 31
9 11 143
9 12 114
10 11 29
10 12 142
10 13 132
11 12 30
11 13 130
11 14 129
12 13 31
12 14 154
12 15...

result:

ok OK

Test #69:

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

input:

500 1513
764 853 1520 1525 1534 1569 1583 1616 1615 1608 1617 1616 1590 1564 1544 1530 1551 1568 1590 1614 1588 1592 1596 1632 1653 1636 1664 1552 1641 1614 1703 1657 1676 1648 1580 1627 1598 1630 1636 1588 1650 1546 1617 1589 1627 1591 1648 1587 1610 1581 1561 1623 1564 1637 1572 1587 1558 1586 160...

output:

1511
1 2 81
1 3 683
2 3 80
2 4 692
3 4 81
3 5 676
4 5 80
4 6 672
5 6 80
5 7 698
6 7 80
6 8 737
7 8 80
7 9 725
8 9 80
8 10 719
9 10 80
9 11 730
10 11 80
10 12 729
11 12 80
11 13 727
12 13 81
12 14 726
13 14 81
13 15 701
14 15 81
14 16 676
15 16 82
15 17 680
16 17 80
16 18 692
17 18 81
17 19 710
18 19...

result:

ok OK

Test #70:

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

input:

500 2203
1303 1488 1966 2021 2004 1949 2018 2030 2028 2027 2061 2054 2011 2000 1968 1996 2021 1966 1983 2011 1976 1977 1990 1975 2006 1979 2061 2041 2030 2041 1979 2008 2000 2006 1991 2006 2041 1964 2002 2040 1992 2023 2022 1984 1963 1987 1965 1999 2016 1986 2042 2042 1996 2007 1952 2009 1976 2038 1...

output:

2123
1 2 502
1 3 509
1 4 292
2 3 498
2 4 247
2 5 241
3 4 501
3 5 236
3 6 222
4 5 500
4 6 229
4 7 252
5 6 501
5 7 265
5 8 261
6 7 501
6 8 258
6 9 238
7 8 502
7 9 243
7 10 255
8 9 501
8 10 241
8 11 267
9 10 503
9 11 273
9 12 270
10 11 501
10 12 293
10 13 234
11 12 501
11 13 287
11 14 232
12 13 500
12 ...

result:

ok OK

Test #71:

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

input:

500 905
4 4 6 6 5 8 6 6 6 5 6 6 6 6 6 7 7 8 6 7 7 6 9 7 8 7 8 6 8 8 8 7 7 6 6 7 6 6 5 5 4 7 4 9 5 7 5 7 5 11 6 9 7 5 6 7 4 8 8 9 8 7 5 4 6 6 5 8 4 6 5 4 6 6 5 6 5 7 5 9 5 8 7 10 7 8 6 7 7 8 8 5 6 4 6 5 8 6 9 6 9 5 6 5 4 6 4 6 4 5 4 8 4 8 5 5 5 6 4 6 5 7 9 6 9 7 5 9 4 7 7 6 9 5 6 5 5 6 5 6 4 7 6 8 8 ...

output:

836
1 2 2
1 3 2
2 3 2
3 4 2
4 5 2
4 6 2
5 6 3
6 7 2
6 8 1
7 8 3
7 9 1
8 9 2
9 10 2
9 11 1
10 11 2
10 12 1
11 12 2
11 13 1
12 13 2
12 14 1
13 14 2
13 15 1
14 15 2
14 16 1
15 16 2
15 17 1
16 17 2
16 18 2
17 18 2
17 19 2
18 19 2
18 20 2
19 20 2
20 21 2
20 22 1
21 22 2
21 23 3
22 23 2
22 24 1
23 24 2
23...

result:

ok OK

Test #72:

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

input:

500 2399
238 437 484 484 486 484 474 475 472 484 485 494 482 485 475 482 474 480 475 484 490 483 493 469 488 474 481 474 474 481 474 490 478 488 484 481 481 478 476 483 481 479 486 483 495 492 494 480 480 476 481 482 492 486 493 484 480 472 472 472 480 475 485 473 488 477 487 490 497 493 484 483 468...

output:

2231
1 2 200
1 3 38
2 3 201
2 4 36
3 4 200
3 5 45
4 5 201
4 6 47
5 6 199
5 7 41
6 7 200
6 8 38
7 8 200
7 9 33
8 9 199
8 10 38
9 10 200
9 11 40
10 11 201
10 12 45
11 12 200
11 13 44
12 13 203
12 14 46
13 14 200
13 15 35
14 15 200
14 16 39
15 16 202
15 17 38
16 17 200
16 18 41
17 18 203
17 19 33
18 19...

result:

ok OK

Test #73:

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

input:

500 4061
306 436 485 475 492 472 488 472 488 473 501 489 473 504 483 487 471 488 498 476 468 477 497 473 475 481 480 480 467 480 468 469 478 492 472 474 483 474 494 471 490 473 485 467 474 472 484 480 475 482 462 477 480 482 479 469 478 479 480 481 477 480 476 487 490 506 495 497 495 499 486 478 475...

output:

3830
1 2 201
1 3 42
1 4 30
1 5 26
1 6 7
2 3 200
2 4 11
2 5 9
2 6 11
2 7 4
3 4 200
3 5 7
3 6 10
3 7 17
3 8 9
4 5 200
4 6 6
4 7 9
4 8 8
4 9 11
5 6 200
5 7 13
5 8 4
5 9 16
5 10 17
6 7 201
6 8 9
6 9 10
6 10 7
6 11 11
7 8 199
7 9 6
7 10 15
7 11 16
7 12 8
8 9 201
8 10 10
8 11 8
8 12 16
8 13 8
9 10 200
9 1...

result:

ok OK

Test #74:

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

input:

500 5512
3242 1806 3415 3325 3330 3441 3433 3446 3481 3470 3328 3508 3444 3375 3413 3406 3372 3460 3354 3423 3435 3430 3463 3521 3381 3410 3526 3390 3502 3432 3566 3462 3416 3428 3491 3329 3414 3458 3427 3459 3365 3479 3510 3458 3523 3361 3466 3338 3438 3463 3421 3363 3462 3425 3431 3406 3514 3420 3...

output:

5468
1 2 170
1 3 1568
1 4 1024
1 5 480
2 3 171
2 4 455
2 5 496
2 6 514
3 4 171
3 5 486
3 6 501
3 7 518
4 5 171
4 6 514
4 7 487
4 8 503
5 6 170
5 7 526
5 8 495
5 9 506
6 7 171
6 8 531
6 9 524
6 10 516
7 8 171
7 9 531
7 10 526
7 11 503
8 9 170
8 10 514
8 11 498
8 12 564
9 10 170
9 11 531
9 12 506
9 13...

result:

ok OK

Test #75:

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

input:

500 145
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 9 0 0 0 0 0 0 ...

output:

45
27 117 1
27 134 1
27 140 1
27 172 1
27 217 1
27 263 1
27 287 1
27 355 1
27 481 1
117 134 1
117 140 1
117 172 1
117 217 1
117 263 1
117 287 1
117 355 1
117 481 1
134 140 1
134 172 1
134 217 1
134 263 1
134 287 1
134 355 1
134 481 1
140 172 1
140 217 1
140 263 1
140 287 1
140 355 1
140 481 1
172 21...

result:

ok OK

Test #76:

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

input:

500 5905
0 0 0 0 0 0 99 99 0 0 0 0 99 0 99 0 0 0 99 99 0 99 0 0 0 0 99 0 99 0 0 0 0 0 0 99 0 0 0 99 0 99 99 0 0 0 99 0 0 0 0 0 0 99 0 0 0 99 0 0 0 0 0 99 0 0 0 0 0 0 99 0 0 0 0 0 0 99 99 0 0 0 0 0 0 0 0 0 0 0 99 0 0 0 0 0 99 0 99 0 0 0 0 0 0 0 0 0 99 0 0 0 0 0 99 0 0 0 0 0 0 0 99 0 0 0 0 0 0 99 99 9...

output:

4909
7 8 1
7 13 1
7 15 1
7 19 1
7 20 1
7 22 1
7 27 1
7 29 1
7 36 1
7 40 1
7 42 1
7 43 1
7 47 1
7 54 1
7 58 1
7 64 1
7 71 1
7 78 1
7 79 1
7 91 1
7 97 1
7 99 1
7 109 1
7 115 1
7 123 1
7 130 1
7 131 1
7 132 1
7 135 1
7 138 1
7 143 1
7 145 1
7 150 1
7 153 1
7 156 1
7 159 1
7 161 1
7 172 1
7 179 1
7 181 ...

result:

ok OK

Test #77:

score: 0
Accepted
time: 20ms
memory: 6336kb

input:

500 54514
0 0 0 199 0 0 199 0 199 199 0 0 0 0 199 199 199 0 0 0 0 0 0 0 0 0 0 199 199 0 0 0 0 199 0 199 0 199 0 0 0 0 199 199 199 0 199 0 199 199 0 0 199 0 199 199 0 0 199 0 0 199 0 0 0 0 0 0 0 199 199 199 199 199 199 0 0 199 199 0 199 199 0 199 199 0 199 199 0 199 199 0 199 0 0 199 199 199 0 0 0 19...

output:

14330
4 7 1
4 9 1
4 10 1
4 15 1
4 16 1
4 17 1
4 28 2
4 29 2
4 36 2
4 38 1
4 43 1
4 44 1
4 50 1
4 53 2
4 56 1
4 59 3
4 62 1
4 70 1
4 72 1
4 73 1
4 78 2
4 79 2
4 81 3
4 85 1
4 87 1
4 88 1
4 90 2
4 91 1
4 93 1
4 104 1
4 105 1
4 106 1
4 109 3
4 110 1
4 111 1
4 113 1
4 114 2
4 116 1
4 120 2
4 130 1
4 131...

result:

ok OK

Test #78:

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

input:

500 7285
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...

output:

2447
1 18 1
1 76 2
1 79 1
1 104 1
1 158 1
1 185 1
1 209 1
1 211 1
1 369 1
2 10 1
2 36 1
2 39 1
2 172 1
2 179 1
2 211 1
2 249 1
2 282 1
2 344 1
2 353 1
3 66 1
3 107 1
3 206 1
3 223 1
3 283 1
3 320 1
3 402 1
3 414 1
3 419 1
3 421 1
4 25 1
4 31 2
4 171 1
4 193 1
4 290 1
4 340 1
4 341 1
4 364 1
4 408 1
...

result:

ok OK

Test #79:

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

input:

500 6087
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
1 485 1
2 346 1
3 55 1
4 437 1
5 478 1
6 167 1
7 298 1
8 421 1
9 227 1
10 187 1
11 328 1
12 415 1
13 152 1
14 371 1
15 305 1
16 420 1
17 317 1
18 323 1
19 406 1
20 92 1
21 476 1
22 147 1
23 145 1
24 459 1
25 306 1
26 416 1
27 461 1
28 361 1
29 392 1
30 33 1
31 324 1
32 300 1
34 277 1
35 254 1
36...

result:

ok OK