QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#44083#4564. Digital CircuitQingyu100 ✓237ms40320kbC++233.7kb2022-08-12 19:27:572022-08-12 19:46:24

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-12 19:46:24]
  • 评测
  • 测评结果:100
  • 用时:237ms
  • 内存:40320kb
  • [2022-08-12 19:27:57]
  • 提交

answer

// O(N + M + Q log M)

#include "circuit.h"

#include <functional>
#include <utility>
#include <vector>

const int kMod = 1000002022;

int N;

struct SegTree {
 private:
  int n;
  struct Node {
    int val[2];
    bool lazy;
    Node(int v0=0, int v1=0) {
      val[0] = v0;
      val[1] = v1;
      lazy = false;
    }

    Node operator + (const Node &other) {
      return Node((val[0] + other.val[0]) % kMod,
                  (val[1] + other.val[1]) % kMod);
    }
  };
  std::vector<Node> nodes;

  inline void toggle(int idx) {
    std::swap(nodes[idx].val[0], nodes[idx].val[1]);
    nodes[idx].lazy = !nodes[idx].lazy;
  }

  inline void pull(int idx, int l, int r) {
    int mid = (l + r) >> 1;
    nodes[idx] = nodes[idx + 1] + nodes[idx + (mid - l) * 2];
  }

  inline void push(int idx, int l, int r) {
    if (!nodes[idx].lazy) return;
    int mid = (l + r) >> 1;
    toggle(idx + 1);
    toggle(idx + (mid - l) * 2);
    nodes[idx].lazy = false;
  }

  void build(int idx, int l, int r, const std::vector<std::pair<int, int>> &v) {
    if (l + 1 == r) {
      nodes[idx] = Node(v[l].first, v[l].second);
      return;
    }
    int mid = (l + r) >> 1;
    build(idx + 1, l, mid, v);
    build(idx + (mid - l) * 2, mid, r, v);
    pull(idx, l, r);
  }

  void update(int idx, int l, int r, int ll, int rr) {
    if (l >= rr || r <= ll) {
      return;
    }
    if (l >= ll && r <= rr) {
      return toggle(idx);
    }
    push(idx, l, r);
    int mid = (l + r) >> 1;
    update(idx + 1, l, mid, ll, rr);
    update(idx + (mid - l) * 2, mid, r, ll, rr);
    pull(idx, l, r);
  }

 public:
  void init(const std::vector<std::pair<int, int>> &v) {
    n = static_cast<int>(v.size());
    nodes.resize(2 * n - 1);
    build(0, 0, n, v);
  }

  void update(int l, int r) {
    update(0, 0, n, l, r);
  }

  int query() {
    return nodes[0].val[1];
  }
} segtree;

void init(int _N, int M, std::vector<int> P, std::vector<int> A) {
  N = _N;
  std::vector<std::vector<int>> adj(N + M);
  for (int i = 1; i < N + M; ++i) {
    adj[P[i]].push_back(i);
  }

  std::vector<int> prod(N + M);
  std::function<int(int)> dfs_prod = [&](int u) {
    if (u >= N) {
      return prod[u] = 1;
    }
    prod[u] = static_cast<int>(adj[u].size());
    for (int v : adj[u]) {
      prod[u] = 1LL * prod[u] * dfs_prod(v) % kMod;
    }
    return prod[u];
  };
  dfs_prod(0);

  std::vector<int> contribution(M);
  std::function<void(int, int)> dfs_contrib = [&](int u, int product) {
    if (u >= N) {
      contribution[u - N] = product;
      return;
    }
    std::vector<int> prefix(adj[u].size()), suffix(adj[u].size());
    for (int i = 0; i < static_cast<int>(adj[u].size()); ++i) {
      prefix[i] = prod[adj[u][i]];
      if (i > 0) {
        prefix[i] = 1LL * prefix[i] * prefix[i - 1] % kMod;
      }
    }
    for (int i = static_cast<int>(adj[u].size()) - 1; i >= 0; --i) {
      suffix[i] = prod[adj[u][i]];
      if (i + 1 < static_cast<int>(adj[u].size())) {
        suffix[i] = 1LL * suffix[i] * suffix[i + 1] % kMod;
      }
    }
    for (int i = 0; i < static_cast<int>(adj[u].size()); ++i) {
      int next_product = product;
      if (i > 0) {
        next_product = 1LL * next_product * prefix[i - 1] % kMod;
      }
      if (i + 1 < static_cast<int>(adj[u].size())) {
        next_product = 1LL * next_product * suffix[i + 1] % kMod;
      }
      dfs_contrib(adj[u][i], next_product);
    }
  };
  dfs_contrib(0, 1);

  std::vector<std::pair<int, int>> v(M);
  for (int i = 0; i < M; ++i) {
    if (A[i]) {
      v[i].second = contribution[i];
    } else {
      v[i].first = contribution[i];
    }
  }
  segtree.init(v);
}

int count_ways(int L, int R) {
  segtree.update(L - N, R - N + 1);
  return segtree.query();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 2ms
memory: 3172kb

input:

1 2
-1 0 0
0 0
1 1
2 2
1 2
2 2
1 2
-1 -1
-2 -2

output:

1
2
0
1
1

result:

ok 7 lines

Test #2:

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

input:

1 1
-1 0
0
1 1
1 1
1 1
1 1
-1 -1
-2 -2

output:

1
0
1
0

result:

ok 6 lines

Test #3:

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

input:

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

output:

509
483
489
500
481

result:

ok 7 lines

Test #4:

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

input:

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

output:

4
40
428
262
237

result:

ok 7 lines

Test #5:

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

input:

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

output:

898
828
828
617
582

result:

ok 7 lines

Test #6:

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

input:

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

output:

535
494
500
498
509

result:

ok 7 lines

Test #7:

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

input:

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

output:

517
486
511
487
512

result:

ok 7 lines

Test #8:

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

input:

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

output:

501
500
499
500
501

result:

ok 7 lines

Subtask #2:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 1ms
memory: 3216kb

input:

1 2
-1 0 0
0 0
1 1
2 2
1 2
2 2
1 2
-1 -1
-2 -2

output:

1
2
0
1
1

result:

ok 7 lines

Test #10:

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

input:

255 256
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

52130940
785285606
585825652

result:

ok 5 lines

Test #11:

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

input:

511 512
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

655368480
979089518
133738288
486298234
70832346

result:

ok 7 lines

Test #12:

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

input:

511 512
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

640949026
225483138
810019272
225483138
640949026

result:

ok 7 lines

Test #13:

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

input:

511 512
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

655368480
457459326
408972838
872925214
486298234

result:

ok 7 lines

Test #14:

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

input:

726 727
-1 0 0 2 1 1 2 3 5 7 9 4 9 7 6 6 11 8 16 12 17 19 3 14 18 16 15 25 10 10 8 27 26 24 20 30 14 18 33 32 4 40 12 25 30 22 43 45 39 46 13 33 23 13 35 26 31 15 57 47 38 22 37 28 41 55 39 43 23 29 64 17 49 67 24 36 55 5 59 62 63 59 48 28 70 11 71 74 76 56 84 66 88 88 56 58 77 27 79 38 74 98 95 44 ...

output:

706880838
491517432

result:

ok 4 lines

Test #15:

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

input:

999 1000
-1 0 1 1 0 4 2 5 5 8 8 3 7 9 6 4 15 16 7 2 11 13 13 18 21 23 12 10 6 20 29 18 16 19 14 31 24 34 35 17 28 26 27 31 29 25 45 43 33 46 32 23 27 42 48 14 15 42 45 37 12 41 59 43 51 57 3 47 40 38 39 64 66 21 56 19 61 59 58 55 26 11 40 77 63 82 48 85 58 53 56 10 22 75 92 91 92 47 81 52 71 96 100 ...

output:

942041994
438937124
841357772
232099870
90068874

result:

ok 7 lines

Test #16:

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

input:

999 1000
-1 0 1 2 3 0 3 6 5 8 6 8 11 9 1 14 10 12 10 13 2 20 4 17 22 13 12 26 15 11 14 27 31 4 30 19 32 18 32 21 38 36 30 19 17 25 23 25 39 27 48 40 41 41 47 38 46 56 54 56 34 45 20 52 57 58 62 65 65 29 40 43 28 54 5 34 26 15 61 67 49 9 43 46 73 76 68 79 87 83 81 47 82 92 68 52 28 86 69 60 93 71 71 ...

output:

846777934
543886020
117265458
170290282
281705356

result:

ok 7 lines

Test #17:

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

input:

999 1000
-1 0 1 0 1 4 2 5 3 2 5 6 3 9 8 6 7 10 15 14 8 11 18 22 19 12 4 25 22 12 21 7 31 17 15 13 30 27 18 11 38 36 27 42 42 40 37 9 13 20 29 10 49 47 43 34 50 55 19 58 28 17 47 48 35 64 36 64 61 33 37 33 62 16 24 53 67 65 73 70 29 26 54 58 69 51 75 14 82 59 59 77 80 63 46 90 56 30 77 94 39 49 68 66...

output:

705376374
644042668
670552036

result:

ok 5 lines

Test #18:

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

input:

999 1000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

934163262
112313082
337041484
769464108
426960866

result:

ok 7 lines

Test #19:

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

input:

999 1000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

824177488
180713918
915259054
915239172
406741568

result:

ok 7 lines

Test #20:

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

input:

848 849
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

740267208
421935812
842353974
899432906
740267208

result:

ok 7 lines

Subtask #3:

score: 9
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #21:

score: 9
Accepted
time: 3ms
memory: 3232kb

input:

722 938
-1 0 0 0 3 4 0 0 4 2 8 6 6 0 0 12 0 9 12 4 10 18 18 16 6 7 25 6 6 19 27 22 2 11 19 10 14 9 35 16 25 23 25 6 39 14 23 44 36 2 49 11 47 43 32 37 27 23 34 6 43 21 0 32 28 64 12 2 49 49 56 14 70 67 67 27 18 24 75 39 13 53 27 71 77 69 0 32 19 88 66 15 90 71 74 94 28 86 63 80 89 0 69 65 3 104 56 1...

output:

759476520
986929966
529361200
22204736

result:

ok 6 lines

Test #22:

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

input:

807 483
-1 0 1 1 2 0 4 5 2 7 7 10 8 3 11 5 15 12 14 10 14 20 11 12 18 16 23 9 4 19 27 19 22 32 23 28 29 16 20 34 24 37 36 30 8 41 30 15 47 48 33 32 24 46 13 33 49 35 45 43 31 31 56 59 17 22 21 61 62 62 67 37 65 46 55 43 67 60 49 59 48 71 25 61 44 17 72 70 85 84 41 50 64 65 3 44 87 45 88 76 75 34 82 ...

output:

747493058
75435678
304852326
580470868
792077662

result:

ok 7 lines

Test #23:

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

input:

659 548
-1 0 1 2 2 4 5 0 1 7 4 9 3 7 10 8 14 16 15 18 10 2 9 15 13 16 24 7 22 10 8 26 29 17 22 33 0 36 9 21 26 33 26 37 14 41 31 1 37 47 23 36 43 32 42 49 20 23 54 52 56 60 48 44 44 43 29 62 55 66 59 27 64 22 13 66 75 51 60 64 46 70 60 77 8 62 52 77 55 72 77 59 70 68 74 15 91 84 61 3 33 83 74 86 36 ...

output:

738488400
740072304
96397334
825774292
597854808

result:

ok 7 lines

Test #24:

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

input:

1000 1000
-1 0 1 0 1 4 0 4 1 5 9 5 6 10 2 7 1 11 0 0 0 6 1 18 1 21 4 25 3 18 5 6 19 18 18 16 28 17 19 24 20 18 0 24 42 41 34 35 7 24 45 17 16 29 29 53 53 44 39 40 33 41 0 0 11 32 54 46 42 19 64 62 32 15 66 63 12 42 26 56 49 74 77 11 30 80 69 9 7 86 45 69 8 29 90 74 17 78 76 39 90 61 48 85 96 101 91 ...

output:

933758984
95006268
317881142
882413916
585663928

result:

ok 7 lines

Test #25:

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

input:

1000 1000
-1 0 1 1 2 0 0 6 6 8 8 8 9 11 7 11 14 16 16 7 14 7 20 19 7 20 20 25 17 18 12 27 29 32 11 29 17 8 37 7 7 18 31 42 40 40 29 41 14 46 48 40 32 35 18 41 54 32 43 32 57 57 32 37 45 64 56 47 54 62 41 50 34 47 48 37 36 63 25 12 45 65 46 33 37 49 25 86 86 65 64 84 86 64 25 85 41 51 41 71 87 92 75 ...

output:

814713862
179971074
530108958
172714996
724155456

result:

ok 7 lines

Test #26:

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

input:

1000 1000
-1 0 0 0 2 2 2 6 6 5 2 9 6 12 10 8 15 15 14 8 2 7 12 6 5 14 25 0 10 20 20 6 16 3 33 31 15 11 31 10 0 36 27 26 43 27 38 31 42 10 2 24 50 8 2 24 55 55 44 6 51 2 38 61 24 42 22 57 31 57 67 38 65 24 15 24 52 6 23 56 6 51 55 71 18 84 80 54 76 71 75 64 78 62 55 45 16 75 73 63 56 100 51 23 91 86 ...

output:

10265418
663812742
838804900
935588604
32034942

result:

ok 7 lines

Test #27:

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

input:

1000 1000
-1 0 0 1 0 3 2 6 1 0 6 10 0 12 12 3 14 6 13 9 0 16 15 13 20 12 16 0 15 18 26 18 23 20 21 27 18 13 33 18 32 18 39 16 39 29 33 46 3 27 36 35 33 27 23 35 13 49 13 12 48 57 35 43 10 12 57 40 53 15 38 59 20 29 23 60 23 76 23 40 79 66 74 56 77 27 40 40 59 58 31 86 89 65 69 93 70 59 85 56 79 93 9...

output:

726868562
458496628
699307100
591908584
227703358

result:

ok 7 lines

Test #28:

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

input:

1000 1000
-1 0 0 2 2 2 0 0 7 5 8 0 11 7 5 13 8 13 8 16 14 15 13 18 0 21 13 26 22 0 16 17 1 22 26 31 31 27 27 31 7 5 34 15 11 9 12 22 8 25 8 31 29 29 48 50 29 47 29 43 51 36 61 6 15 58 64 63 29 68 58 21 43 7 72 63 33 70 12 18 72 15 56 79 70 56 65 73 77 64 64 56 73 77 64 22 88 40 85 77 73 80 63 89 3 6...

output:

230025634
903738266
10382050
690967620
797613426

result:

ok 7 lines

Test #29:

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

input:

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

output:

489
507
492
510
490

result:

ok 7 lines

Test #30:

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

input:

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

output:

486
458
478
508
512

result:

ok 7 lines

Test #31:

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

input:

1000 1
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

1
0
1
0
1

result:

ok 7 lines

Test #32:

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

input:

999 1000
-1 0 1 0 2 1 3 5 6 2 7 6 10 9 8 5 4 16 4 11 13 13 7 9 19 24 14 11 19 26 15 18 24 32 29 28 18 22 25 3 35 21 20 40 33 17 35 31 29 37 46 50 49 17 10 45 27 49 39 30 57 42 47 52 56 60 20 58 53 36 62 31 41 59 54 21 47 54 32 36 14 39 74 40 65 38 12 56 73 77 23 58 42 12 76 60 95 87 95 86 71 86 65 9...

output:

952151020
443043678
464032544
372922164
106850846

result:

ok 7 lines

Test #33:

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

input:

499 999
-1 0 1 0 1 3 3 1 6 6 8 0 8 12 5 9 3 6 11 16 12 19 10 5 18 14 8 20 25 14 23 4 30 29 31 24 33 12 31 34 35 29 14 28 15 29 38 11 33 25 47 43 42 5 45 48 30 24 56 23 31 55 42 49 53 16 60 65 37 49 65 25 67 52 56 70 48 47 70 59 47 42 75 73 45 70 84 77 62 60 87 56 71 59 37 87 64 19 32 97 71 76 97 81 ...

output:

331823726
717282174
897711128
622871150
337192684

result:

ok 7 lines

Test #34:

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

input:

249 997
-1 0 1 1 0 3 1 4 2 6 3 8 8 2 10 5 10 0 17 9 19 10 17 10 19 18 18 15 21 26 17 30 25 29 26 0 31 26 35 17 39 18 40 35 39 42 30 22 25 35 17 48 49 26 43 37 54 40 2 50 46 52 47 51 52 39 43 44 61 43 0 29 66 36 70 7 26 62 42 68 25 66 65 68 52 69 69 42 84 70 36 52 82 35 93 54 69 30 82 70 84 70 84 91 ...

output:

552267427
469565478
651807128
810234086
287134027

result:

ok 7 lines

Test #35:

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

input:

4 889
-1 0 1 2 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 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...

output:

235989424
147865831
125587682
158611529
258762404

result:

ok 7 lines

Test #36:

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

input:

1000 1000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

588565178
31154578
152598054
815496242
903968456

result:

ok 7 lines

Test #37:

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

input:

1000 1000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

525
470
474
490
492

result:

ok 7 lines

Test #38:

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

input:

1000 1000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

525
474
526
475
521

result:

ok 7 lines

Test #39:

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

input:

719 408
-1 0 1 0 1 1 5 2 5 6 8 9 7 11 13 11 9 12 14 13 19 20 20 17 22 22 25 24 16 28 28 26 25 29 30 32 33 32 37 38 39 40 36 42 33 44 39 45 35 41 49 49 50 43 51 47 53 56 48 58 59 51 55 62 52 58 61 66 67 62 66 70 71 68 60 72 74 75 76 78 69 79 76 64 80 81 85 84 86 83 88 90 91 89 91 89 95 96 97 98 99 10...

output:

33301336
56907144
944497018
704115760
462015690

result:

ok 7 lines

Test #40:

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

input:

510 819
-1 0 0 1 3 3 2 1 4 0 0 5 0 0 13 2 6 15 11 3 4 2 0 6 2 13 15 22 15 23 10 21 3 24 18 17 17 24 4 3 29 40 16 11 10 28 33 38 39 10 38 28 51 41 50 4 3 56 7 44 44 13 9 49 51 23 39 42 23 40 60 1 63 62 55 62 70 55 64 58 50 34 23 80 71 14 71 56 48 79 8 38 28 92 62 61 73 8 46 16 93 56 100 67 23 92 104 ...

output:

216372980
926486360
572278876
442949060
582680282

result:

ok 7 lines

Test #41:

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

input:

363 882
-1 0 0 0 1 3 2 2 6 4 3 0 10 2 6 13 11 1 10 0 18 5 11 1 13 21 11 21 26 27 7 9 21 2 0 3 35 18 23 33 34 10 27 21 21 2 44 38 18 25 44 5 29 45 42 42 25 46 41 43 19 59 26 55 43 23 11 59 57 62 1 27 67 55 73 34 58 63 64 54 4 47 23 32 5 69 47 23 49 4 33 56 82 87 68 65 58 64 0 48 7 32 35 63 49 98 90 8...

output:

860608712
828138786
455393642
548429080
972077788

result:

ok 7 lines

Test #42:

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

input:

44 947
-1 0 1 1 2 1 1 0 1 3 9 1 9 7 5 2 15 10 16 2 14 2 13 15 3 3 11 26 25 27 26 27 28 32 28 29 33 28 25 38 32 39 37 42 0 0 0 1 0 1 1 1 1 1 1 1 2 0 2 2 2 2 0 0 2 1 3 2 1 2 3 3 2 3 2 2 1 3 4 4 2 4 2 1 4 4 4 2 3 2 4 5 0 0 4 2 2 6 4 5 4 1 2 7 1 7 2 3 6 4 7 3 5 3 2 3 1 4 6 3 6 7 4 1 1 0 2 2 3 4 4 2 5 7 ...

output:

319941708
871406470
716326204
656940502
100714900

result:

ok 7 lines

Subtask #4:

score: 4
Accepted

Test #43:

score: 4
Accepted
time: 92ms
memory: 7492kb

input:

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

output:

431985922
394586018
431985922
469385826
506785730
469385826
431985922
469385826
431985922
469385826
506785730
469385826
431985922
394586018
357186114
319786210
357186114
394586018
431985922
394586018
357186114
394586018
431985922
469385826
506785730
469385826
431985922
394586018
357186114
319786210
...

result:

ok 71356 lines

Test #44:

score: 0
Accepted
time: 103ms
memory: 12188kb

input:

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

output:

913758140
928668562
913758140
898847718
883937296
869026874
883937296
898847718
913758140
928668562
913758140
898847718
883937296
898847718
913758140
928668562
913758140
898847718
913758140
928668562
943578984
928668562
913758140
928668562
913758140
898847718
883937296
869026874
883937296
898847718
...

result:

ok 100002 lines

Test #45:

score: 0
Accepted
time: 114ms
memory: 12244kb

input:

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

output:

152530276
137619854
122709432
107799010
92888588
77978166
63067744
48157322
33246900
18336478
3426056
988517656
973607234
958696812
943786390
928875968
913965546
899055124
884144702
869234280
854323858
839413436
824503014
809592592
794682170
779771748
764861326
749950904
735040482
720130060
70521963...

result:

ok 100002 lines

Test #46:

score: 0
Accepted
time: 132ms
memory: 12132kb

input:

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

output:

14910422
29820844
44731266
59641688
74552110
89462532
104372954
119283376
134193798
149104220
164014642
178925064
193835486
208745908
223656330
238566752
253477174
268387596
283298018
298208440
313118862
328029284
342939706
357850128
372760550
387670972
402581394
417491816
432402238
447312660
462223...

result:

ok 100002 lines

Subtask #5:

score: 12
Accepted

Dependency #4:

100%
Accepted

Test #47:

score: 12
Accepted
time: 147ms
memory: 7516kb

input:

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

output:

105182172
904826008
249436868
17023698
882566410
487194958
692003610
262795534
589599284
280604666
916403034
926198420
674194478
705362276
937775446
700017356
700017356
485413318
981407456
376776886
750775926
498771984
502335264
158609568
953802938
851398612
916403034
392804378
552199380
996206
7765...

result:

ok 80874 lines

Test #48:

score: 0
Accepted
time: 183ms
memory: 12244kb

input:

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

output:

987306502
479348406
404796296
600639278
987306502
690101810
599635530
420710466
657269722
880926052
746732254
345154608
59849094
238774158
419706718
237770410
882933548
596624286
852108956
551893020
193039144
641355552
924653570
551893020
87662442
115475790
803362698
86658694
968381088
28020754
3888...

result:

ok 100002 lines

Test #49:

score: 0
Accepted
time: 198ms
memory: 12172kb

input:

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

output:

583721360
598631782
568810938
553900516
538990094
538990094
568810938
598631782
538990094
524079672
524079672
613542204
598631782
613542204
628452626
583721360
568810938
583721360
583721360
598631782
628452626
568810938
524079672
643363048
583721360
568810938
568810938
643363048
524079672
583721360
...

result:

ok 100002 lines

Test #50:

score: 0
Accepted
time: 175ms
memory: 12176kb

input:

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

output:

106587856
60852842
91677434
105584108
61856590
150315374
17125324
150315374
61856590
60852842
2214902
45942420
91677434
105584108
76767012
75763264
76767012
90673686
76767012
165225796
32035746
150315374
46946168
150315374
136408700
120494530
46946168
75763264
91677434
105584108
46946168
90673686
76...

result:

ok 100002 lines

Test #51:

score: 0
Accepted
time: 62ms
memory: 3520kb

input:

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

output:

134861748
303006848
798573570
283689758
183944440
847656262
381855142
500917550
807442148
728593854
936953068
441386346
490469038
570897266
262792734
966718670
362538052
996484272
15799340
362538052
45564942
500917550
866973352
600662868
828339172
858104774
907187466
817890660
590214356
303006848
27...

result:

ok 50568 lines

Test #52:

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

input:

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

output:

603631736
197613152
784946490
375602856
512420184
601415036
507986784
195396452
789379890
650345862
560242660
421208632
283282954
830552266
192071402
325563680
282174604
917330418
237677178
967369594
558025960
466814408
12973348
829443916
604740086
192071402
737124014
284391304
422316982
832768966
7...

result:

ok 100002 lines

Test #53:

score: 0
Accepted
time: 105ms
memory: 3504kb

input:

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

output:

148682326
148682326
784946490
466814408
148682326
784946490
784946490
148682326
148682326
512420184
739340714
57470774
57470774
57470774
421208632
830552266
148682326
194288102
512420184
830552266
512420184
512420184
239893878
921763818
876158042
558025960
148682326
876158042
194288102
512420184
421...

result:

ok 100002 lines

Test #54:

score: 0
Accepted
time: 108ms
memory: 3712kb

input:

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

output:

783838140
786054840
101968200
467922758
465706058
740449064
56362424
104184900
101968200
467922758
465706058
104184900
783838140
467922758
147573976
831660616
511311834
786054840
101968200
831660616
465706058
149790676
829443916
831660616
147573976
467922758
465706058
149790676
465706058
149790676
1...

result:

ok 100002 lines

Subtask #6:

score: 27
Accepted

Dependency #2:

100%
Accepted

Test #55:

score: 27
Accepted
time: 230ms
memory: 16848kb

input:

98261 98262
-1 0 0 1 2 2 4 5 3 8 6 6 1 10 13 10 9 5 12 11 18 17 20 4 18 19 24 11 26 27 24 29 17 29 25 34 7 7 13 21 16 9 23 38 33 25 28 21 37 48 40 46 43 38 49 27 41 22 42 39 58 36 56 32 42 61 22 30 36 47 68 67 59 66 58 23 3 52 39 44 12 8 51 26 74 76 81 65 53 19 59 90 20 83 54 90 77 37 70 67 68 48 73...

output:

732332002
281856764
14589944
411925198
494975700
394036962
773421578
775146066
4883078
260203704
903670862
346009340
587339956
274764376
460788066
389167006
366495594
540344200
552587736
827184842
811178920
435730860
31164648
948570022
596481960
285872536
249124126
542862090
457661798
194120298
6299...

result:

ok 95649 lines

Test #56:

score: 0
Accepted
time: 216ms
memory: 17176kb

input:

99999 100000
-1 0 0 2 3 4 3 2 1 8 5 10 7 4 5 9 8 16 9 13 14 1 19 17 14 23 7 18 21 27 12 23 24 16 33 30 17 12 26 33 25 28 34 27 29 15 29 43 6 47 18 50 31 37 41 54 50 30 28 6 38 43 21 60 44 49 42 57 56 61 52 59 54 45 68 64 41 49 73 76 61 78 74 82 63 24 26 67 51 72 66 80 58 78 81 83 74 64 39 69 86 40 1...

output:

72622774
140280672
444113672
653654534
485348608
926360358
561479232
355415686
583042702
802022654
493146084
587106804
366303974
382276586
391742780
559151938
835245020
689548220
574614466
21188546
715435886
518764646
584779752
164185398
894167282
821817624
781841448
817414648
513938644
781147460
10...

result:

ok 100002 lines

Test #57:

score: 0
Accepted
time: 182ms
memory: 17080kb

input:

99999 100000
-1 0 1 2 3 0 4 5 6 7 8 6 9 11 12 14 3 15 1 9 17 16 21 17 4 18 23 24 16 21 28 30 29 25 5 27 2 27 12 37 33 33 36 38 39 43 26 36 19 20 45 50 14 29 51 51 41 20 48 19 40 15 47 34 52 47 42 52 23 57 18 67 35 61 60 69 38 69 75 44 48 70 63 60 64 73 62 86 50 37 25 44 88 76 93 73 90 61 74 85 59 71...

output:

132550234
49841434
420216762
944477446
354015584
145957196
694152308
700008458
126083600
327246656
590848220
497848900
41929052
246281020
763801480
109944748
30115632
84586906
904451102
129806150
264667918
304538036
202591916
262101986
976281864
568757726
725412776
320997330
116863194
338182944
1876...

result:

ok 100002 lines

Test #58:

score: 0
Accepted
time: 168ms
memory: 17080kb

input:

99999 100000
-1 0 0 2 2 3 4 5 6 1 9 1 8 10 11 8 12 7 14 4 15 13 11 20 17 9 24 19 24 5 26 15 23 18 6 23 14 16 25 33 21 21 27 13 39 35 30 22 29 47 19 36 36 48 44 37 52 7 40 50 56 31 40 54 22 44 41 61 25 27 66 49 62 3 32 55 29 53 75 51 54 80 72 28 43 83 38 49 43 86 59 72 89 10 58 51 93 93 69 61 64 16 3...

output:

243156070
974196636
776446796
149211350
640051670
953877066
465384064
642116074
777398194
954130204
523722976
954130204
523722976
584379430
407900558
721376824
978957488
402537438
862279664
895791292
920269446
954130204
666943358
330451074
777049064
156036606
321814552
148006814
29866854
837452380
2...

result:

ok 81651 lines

Test #59:

score: 0
Accepted
time: 206ms
memory: 39056kb

input:

99999 100000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...

output:

564528107
714961305
219237221
445787017
493715457
333295075
673119103
58524427
2956429
318864001
295182981
597059449
824990283
940859709
403852445
89124159
779617469
227564407
394490083
785422525
179269047
418286597
476200727
737490423
163562677
273206323
876125757
352080987
260330951
288123723
4114...

result:

ok 100002 lines

Test #60:

score: 0
Accepted
time: 179ms
memory: 39148kb

input:

99999 100000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...

output:

721730437
688232759
721730437
17196154
450170436
416672730
516749870
183317034
294534124
259070468
825859032
390918964
825858824
725781892
292568098
592623080
692699957
192491239
525923713
27680880
127757708
94260206
459344390
359267350
259606096
926175434
160064594
317786664
19042202
452255996
2559...

result:

ok 100002 lines

Subtask #7:

score: 28
Accepted

Dependency #3:

100%
Accepted

Test #61:

score: 28
Accepted
time: 86ms
memory: 3452kb

input:

2996 2704
-1 0 0 1 1 4 0 1 5 8 5 7 1 12 7 6 12 16 12 7 6 8 4 6 10 21 4 15 27 0 22 12 6 4 16 33 32 18 29 16 32 13 26 18 14 2 12 46 17 1 32 33 26 9 4 39 11 38 51 12 16 48 4 26 13 54 38 46 67 53 67 61 49 17 46 59 70 0 50 29 3 79 6 59 54 82 79 82 39 83 47 62 71 77 93 88 40 85 72 39 61 83 81 89 13 70 44 ...

output:

196037954
353332532
474467362
266572792
133541752
53461032
660114606
850761148
477663050
123824756
363114082
872464786
443857902
566147860
425391966
615113190
557952372
492810162
46040422
829723178
734786500
77970070
304364056
421827402
410653676
699128748
604978864
33254594
555442082
407003562
1477...

result:

ok 71544 lines

Test #62:

score: 0
Accepted
time: 108ms
memory: 3484kb

input:

4101 2507
-1 0 1 2 3 4 4 6 0 7 9 3 8 12 2 11 1 14 7 12 13 10 10 16 21 11 23 25 8 17 18 26 26 16 28 33 27 5 30 33 18 39 20 14 38 37 31 44 20 23 32 48 40 46 51 19 19 45 42 51 57 34 42 25 49 53 36 32 5 56 61 35 22 67 61 65 63 66 50 64 45 71 48 64 81 60 46 13 81 39 58 82 56 90 74 40 69 80 91 38 87 87 10...

output:

342156814
358320976
299380146
839974750
282714570
572663224
932423420
915564092
246626128
128065380
48497606
815538528
361202348
405225742
772957038
994707834
363262654
887329976
513239066
616260340
788922184
497750772
727226928
934935564
210054120
641368152
238239100
88064884
891443850
41490334
440...

result:

ok 100002 lines

Test #63:

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

input:

3417 2851
-1 0 0 2 3 2 4 3 5 1 6 0 10 7 10 11 8 15 17 10 12 4 12 21 16 1 1 11 14 25 8 6 29 32 4 25 35 22 27 35 9 27 14 20 12 40 37 16 23 39 9 47 34 49 24 21 32 33 45 25 11 22 59 34 63 5 55 59 62 62 42 50 22 68 40 38 75 36 68 50 63 52 80 51 8 70 77 19 49 60 24 73 67 80 93 67 15 63 29 40 99 84 36 61 9...

output:

949396966
874968448
624106114
995585060
612947610
530575296
889329008
582844978
116445438
729012664
236198472
578094796
665076398
197563306
39452380
847421978
46418196
102636690
534804282
706965424
586908544
620678032
164289828
176852690
24801678
793047470
109834608
453170222
202347662
457211996
802...

result:

ok 100002 lines

Test #64:

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

input:

5000 5000
-1 0 0 0 2 4 0 5 3 8 2 8 0 2 3 9 8 4 0 17 3 0 3 3 1 4 4 22 4 12 8 2 0 32 7 26 31 19 0 12 11 30 27 27 18 37 27 26 40 0 33 49 16 26 35 0 38 43 28 12 42 29 13 22 59 52 63 43 55 59 0 62 56 2 21 28 29 31 46 47 25 31 81 30 55 59 56 19 38 18 78 72 55 12 24 57 57 81 49 89 6 31 4 28 87 4 38 16 30 4...

output:

702684770
390597720
202778292
801120394
868084796
54893850
481228024
637429104
514520830
312512126
915002006
20467224
22699228
417264510
948663292
897866430
844311774
570833840
328659144
831968810
469375508
423452052
861130186
991447920
178887194
444023618
180355518
899195596
742679406
689124750
991...

result:

ok 100002 lines

Test #65:

score: 0
Accepted
time: 100ms
memory: 3648kb

input:

5000 5000
-1 0 1 0 1 3 3 6 6 7 0 3 3 0 6 11 10 0 17 13 19 20 17 9 17 17 13 26 0 25 19 26 16 26 3 28 28 34 27 37 0 40 32 3 43 43 43 44 41 22 41 44 11 31 11 35 37 40 11 41 45 37 24 25 24 41 55 59 57 48 50 28 57 68 68 62 29 0 68 77 55 43 54 48 68 77 84 41 84 57 40 69 61 49 57 81 34 90 35 78 17 19 81 17...

output:

447289776
646874750
658125210
164310956
722088888
249171358
872822600
130820184
752341892
770508518
609352990
487798736
528888222
991677150
68196636
472210858
367095868
131578900
106170502
156809576
780653914
177684322
854404220
677532818
886854984
59947178
130589076
716462452
514452260
481703990
97...

result:

ok 100002 lines

Test #66:

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

input:

5000 5000
-1 0 1 0 3 0 5 6 0 8 9 8 8 10 5 9 9 11 13 3 0 19 19 12 11 2 23 7 23 0 9 21 29 25 24 16 8 33 26 33 32 39 17 3 5 15 40 8 44 40 29 23 9 15 50 29 53 52 29 27 51 1 32 52 40 62 60 63 48 28 40 52 50 45 69 31 4 48 59 26 62 46 60 66 40 19 85 51 50 51 44 40 60 61 32 28 72 68 80 23 83 72 60 61 94 52 ...

output:

755318398
257540976
384650572
553495018
4327480
179943872
851825334
81212098
340410528
120857714
86133342
916778448
83137086
910662818
824201794
664195982
558395598
112380044
476184664
581407734
420109388
6948194
481903016
955494080
146329262
303245554
778342116
528033092
446014496
291664534
6141869...

result:

ok 100002 lines

Test #67:

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

input:

5000 5000
-1 0 0 0 0 3 3 5 5 3 5 0 5 2 11 3 3 6 9 2 12 0 12 2 12 2 5 6 3 2 28 12 23 5 0 30 34 0 25 34 28 40 22 37 24 35 20 26 11 30 34 46 34 19 39 12 50 39 22 9 50 8 3 38 58 54 28 54 0 32 18 58 28 17 49 11 55 1 52 5 78 54 62 71 12 39 84 25 49 58 43 78 37 92 90 68 58 1 39 58 57 67 86 21 92 86 59 50 5...

output:

832307486
740328038
527847214
292448340
779760122
196703534
752023942
60342270
842040544
369078830
612995262
295326184
699904570
832362908
225910628
809737592
916408194
29359160
212555762
943941470
995298592
952943148
773525898
550787202
996730128
560825216
484406998
925830500
238371804
827565520
60...

result:

ok 100002 lines

Test #68:

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

input:

5000 5000
-1 0 1 0 3 3 4 1 0 5 4 3 5 3 0 11 15 15 3 13 6 11 15 18 9 4 1 25 13 3 3 29 0 30 33 8 13 4 4 29 18 30 36 3 40 37 11 36 35 45 29 43 12 28 30 36 45 47 14 47 32 48 12 45 42 43 11 25 26 15 54 33 55 25 36 27 3 43 14 51 64 76 14 39 82 76 40 18 60 76 3 42 91 82 28 23 29 65 44 39 90 54 33 8 90 99 8...

output:

676832532
723880944
828476384
288471576
890871264
659140978
239078078
632328938
509763372
966128560
320530292
169726780
116930050
729825552
362613402
679813866
566614026
720044826
881501004
74719406
211937424
506809646
399883564
506809646
798457938
148127534
674913066
247814996
107746532
753040352
2...

result:

ok 100002 lines

Test #69:

score: 0
Accepted
time: 95ms
memory: 3516kb

input:

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

output:

2572
2428
2574
2426
2574
2430
2571
2426
2572
2431
2570
2431
2572
2429
2572
2431
2573
2433
2566
2430
2569
2431
2570
2431
2571
2427
2569
2428
2570
2430
2571
2428
2575
2427
2571
2428
2570
2429
2571
2425
2569
2428
2572
2429
2572
2429
2573
2430
2572
2433
2568
2426
2575
2427
2572
2430
2569
2427
2573
2428
...

result:

ok 100002 lines

Test #70:

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

input:

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

output:

2546
2441
2486
2500
2547
2550
2430
2454
2441
2440
2428
2524
2452
2540
2563
2564
2567
2559
2544
2503
2520
2489
2517
2513
2517
2534
2536
2526
2503
2487
2535
2521
2530
2470
2490
2489
2492
2487
2478
2482
2487
2488
2465
2460
2513
2456
2459
2477
2450
2495
2456
2488
2505
2485
2539
2536
2531
2538
2543
2511
...

result:

ok 100002 lines

Test #71:

score: 0
Accepted
time: 69ms
memory: 4780kb

input:

5000 1
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok 100002 lines

Test #72:

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

input:

4999 5000
-1 0 1 1 3 3 5 5 6 4 0 6 11 2 4 13 8 9 10 16 15 18 21 14 17 8 19 11 18 26 7 12 25 32 13 31 16 36 35 20 15 28 30 42 41 32 29 39 9 28 27 50 21 30 48 12 52 51 41 31 14 33 47 27 37 61 38 57 58 47 66 67 29 60 68 72 50 42 46 78 39 80 80 59 52 44 71 53 87 67 88 74 72 78 61 63 43 53 96 46 95 51 2 ...

output:

185712424
852173202
452792620
896321130
463387692
746766918
945742658
917960730
307302914
442062894
907657888
266210426
398363276
549540584
920424330
93127916
156223542
370298526
577428992
982385444
555770526
733884588
258673154
712047852
921563180
548259118
671869486
371969294
242044262
485519450
7...

result:

ok 100002 lines

Test #73:

score: 0
Accepted
time: 89ms
memory: 3552kb

input:

2499 4999
-1 0 0 2 2 1 0 3 6 6 1 4 7 9 13 8 3 11 17 2 16 17 14 16 1 9 24 20 25 8 19 11 26 3 33 33 13 23 15 30 37 10 31 39 10 33 35 43 28 43 41 30 7 8 38 35 37 14 45 57 24 7 53 61 13 27 40 21 54 51 4 20 64 52 29 56 10 62 66 52 54 60 50 74 41 67 51 46 4 37 59 77 84 16 83 26 26 60 63 44 51 76 89 50 100...

output:

749049158
329533133
354665722
436894200
912012811
795672851
526563046
478517408
4734060
734031692
270568596
413794995
960553536
192061721
516317534
568603712
139645551
369474722
162553340
726267258
384284046
636829973
459354751
45489393
418462271
922191743
762635429
742090654
254539215
114248504
195...

result:

ok 100002 lines

Test #74:

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

input:

1249 4997
-1 0 1 0 3 1 3 3 0 3 7 6 5 10 11 1 8 1 8 18 9 15 11 3 4 18 25 15 16 21 23 17 29 28 29 32 33 17 6 18 5 16 12 25 8 15 38 25 26 6 15 8 11 29 22 27 16 50 51 33 50 23 52 56 25 21 1 49 60 23 56 50 17 19 48 50 39 44 74 28 56 64 65 27 81 79 28 40 33 80 83 75 61 48 21 86 94 86 81 61 48 21 83 49 39 ...

output:

895559298
656481036
75907001
438275602
68094591
314514958
339181521
592925659
486016762
239633871
555892758
521180897
436865234
89863288
271975833
644284788
80575564
877838946
348220458
58230232
134319001
896467402
117266738
163705856
850876828
15339294
632551371
23757576
647799595
105010473
7309545...

result:

ok 100002 lines

Test #75:

score: 0
Accepted
time: 97ms
memory: 3508kb

input:

22 4885
-1 0 0 0 1 4 4 3 3 8 8 6 5 2 12 13 7 6 5 11 15 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 2 0 2 0 1 2 1 1 1 0 0 0 2 2 1 1 2 2 0 2 2 2 0 0 2 2 0 2 1 2 0 2 2 ...

output:

695653183
966587479
561804569
722994321
560066730
793974552
734234636
390261150
869135141
763783920
261983968
661390571
184525364
558522009
423755527
698503792
839181335
927483091
690257252
191703734
23298817
670882120
256029199
372074831
919855599
383632698
357262056
231117423
490702357
959247880
8...

result:

ok 100002 lines

Test #76:

score: 0
Accepted
time: 102ms
memory: 4764kb

input:

5000 5000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

348091745
506488113
304111789
244930169
654850277
149148187
742128537
324004831
332817035
673026255
493816855
844485651
539281305
496130687
469012525
895805011
519751757
709554045
411609799
318966975
980356863
313355461
723220379
200254317
165017935
923347451
911169029
292370465
259979211
273349987
...

result:

ok 100002 lines

Test #77:

score: 0
Accepted
time: 106ms
memory: 4948kb

input:

5000 5000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

2473
2486
2523
2503
2493
2499
2508
2513
2454
2478
2459
2490
2446
2446
2459
2473
2468
2475
2469
2519
2504
2457
2511
2507
2476
2498
2468
2519
2488
2479
2452
2511
2478
2509
2487
2489
2473
2552
2482
2497
2459
2499
2500
2497
2510
2481
2495
2467
2461
2500
2495
2510
2466
2507
2503
2504
2515
2503
2440
2520
...

result:

ok 100002 lines

Test #78:

score: 0
Accepted
time: 86ms
memory: 4812kb

input:

5000 5000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

2557
2441
2554
2444
2555
2443
2554
2443
2555
2442
2554
2439
2558
2440
2561
2442
2557
2446
2556
2443
2558
2441
2559
2444
2557
2442
2560
2444
2559
2442
2557
2444
2557
2440
2558
2442
2555
2442
2555
2446
2552
2439
2555
2440
2557
2440
2560
2440
2556
2445
2554
2439
2556
2443
2559
2442
2556
2446
2553
2444
...

result:

ok 100002 lines

Test #79:

score: 0
Accepted
time: 127ms
memory: 3680kb

input:

4156 2237
-1 0 1 1 1 2 1 3 7 6 8 8 9 10 11 12 12 15 14 17 19 20 21 22 21 21 23 16 22 26 27 28 27 30 29 29 33 32 34 37 38 37 38 39 36 43 35 40 44 38 49 49 49 51 52 51 55 56 55 58 57 56 60 58 61 58 63 64 62 68 69 66 71 72 72 70 75 74 75 65 72 77 81 76 81 84 82 86 79 84 89 80 85 82 86 91 67 95 96 88 98...

output:

702983394
230215628
684085038
54823100
164631470
573108652
877031222
859201124
60736136
155085168
941493940
753576360
188006110
136895948
76349374
698678796
788085896
38888654
110879326
272549772
381624656
687352094
140563428
393212930
707033360
922070244
177288910
372458510
688691772
580834172
3881...

result:

ok 100002 lines

Test #80:

score: 0
Accepted
time: 146ms
memory: 3448kb

input:

2159 3457
-1 0 0 2 2 0 3 0 0 2 0 6 10 2 9 2 14 16 5 13 9 7 2 16 10 3 10 13 23 27 21 21 0 8 31 27 20 25 20 10 26 5 24 8 19 40 36 39 5 28 12 50 19 45 32 54 21 39 6 37 54 7 19 29 19 24 43 42 56 64 66 39 22 38 55 28 39 71 43 55 72 21 45 23 12 31 75 14 16 39 39 10 78 56 78 20 73 33 64 11 19 94 25 46 95 8...

output:

196070398
616805606
880697132
976081464
39969400
711496334
37816640
740726954
371308374
116859024
808125950
828616390
195606468
79943986
886143534
711444906
447405830
861671830
188321596
370572000
984961366
268655416
450751038
711512364
363406734
972819834
60000444
478278322
590579722
106891468
4443...

result:

ok 100002 lines

Test #81:

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

input:

1547 3725
-1 0 0 0 1 2 3 0 2 5 7 10 10 12 12 7 10 2 17 10 10 15 21 17 21 5 13 15 16 22 10 21 17 7 19 29 32 21 6 30 19 35 28 13 29 30 4 17 2 15 22 4 32 48 47 15 14 20 53 50 36 14 37 58 63 27 18 24 53 23 55 50 58 65 0 59 33 28 37 73 70 40 45 75 30 37 16 70 48 45 39 61 11 71 16 47 90 63 55 93 88 22 58 ...

output:

409966966
623474836
425662850
257254326
57717066
611498630
50836926
354078940
975918896
267032622
213491122
248898312
246324266
510962340
227635158
704559276
920811410
541699146
607318932
729631658
301620622
475508820
789013502
554248586
693887550
433422594
88931910
12425372
273460040
757889268
7474...

result:

ok 100002 lines

Test #82:

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

input:

100 4951
-1 0 0 1 2 1 1 6 5 7 7 5 1 12 5 10 2 15 4 6 3 14 0 10 18 4 19 19 6 15 4 13 10 21 27 15 21 6 15 28 29 40 10 5 41 15 15 39 43 15 46 50 40 51 42 50 2 56 51 46 46 50 59 56 50 56 50 62 56 51 62 40 65 34 64 60 65 60 19 76 28 65 74 65 12 78 81 84 60 78 56 5 56 91 58 81 65 78 69 98 0 0 0 0 2 1 0 0 ...

output:

419776306
426615520
92897294
463637804
907545294
841323078
28577770
585889686
334615428
472270904
231199510
859722480
778571730
90878538
189726586
732532244
178960988
79814240
603787316
102672330
570403876
189565946
187914950
284379060
748945964
587505906
135662958
768247192
334844250
948910268
7539...

result:

ok 100002 lines

Subtask #8:

score: 11
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #83:

score: 11
Accepted
time: 2ms
memory: 3136kb

input:

3 4
-1 0 1 2 1 1 0
1 0 1 0
3 4
4 5
3 6
-1 -1
-2 -2

output:

2
0
6

result:

ok 5 lines

Test #84:

score: 0
Accepted
time: 139ms
memory: 15292kb

input:

92979 82393
-1 0 0 0 2 0 5 3 5 6 5 8 0 7 13 3 7 5 13 0 2 13 21 8 3 13 23 0 23 27 13 27 24 20 31 31 31 27 32 27 17 11 7 21 32 5 21 8 31 0 13 31 10 3 33 39 53 0 0 44 16 5 18 55 5 63 18 27 10 27 19 27 63 29 13 66 64 71 55 71 48 31 32 48 60 58 85 9 67 31 69 13 91 63 27 7 3 92 25 74 57 40 90 58 89 102 10...

output:

215458654
776193562
543132206
217200330
9477350
930296440
4042314
592699500
955953892
808064320
819529924
144069506
81919812
136879716
314849922
878880752
362049208
424497500
632208792
26886424
767520170
521945270
232350558
525084126
722174166
941725426
971890034
857198570
240218452
678411954
837091...

result:

ok 57205 lines

Test #85:

score: 0
Accepted
time: 192ms
memory: 11912kb

input:

78828 48944
-1 0 0 2 3 2 3 5 1 4 4 10 10 7 9 6 13 8 14 5 1 20 15 14 17 6 18 12 18 15 13 23 22 27 29 23 9 20 32 35 30 33 34 11 38 21 17 7 16 31 41 44 47 35 52 34 32 37 8 21 11 29 54 31 43 57 60 63 26 46 27 22 59 41 19 30 47 65 58 59 70 50 37 38 80 73 33 61 69 61 71 55 60 49 92 53 19 84 66 69 91 90 77...

output:

172996060
275074908
424992630
331469814
597607276
257144816
167302276
909427384
707849492
148535520
311392458
608864682
111373912
732542144
132575820
535002018
35135218
855866058
977284394
234948518
588603746
774040742
760503486
290960986
761549276
235083768
631958472
489455768
886292126
937529630
1...

result:

ok 100002 lines

Test #86:

score: 0
Accepted
time: 149ms
memory: 11656kb

input:

67981 56846
-1 0 0 1 1 3 2 2 6 3 4 4 10 10 11 0 13 6 16 5 8 5 17 7 18 23 21 10 9 17 2 25 29 18 27 27 29 14 34 37 11 8 13 25 13 12 40 45 31 7 29 27 16 37 40 28 44 15 26 8 56 35 16 22 59 61 9 63 43 56 45 66 70 47 12 67 54 34 35 17 78 52 56 20 74 60 19 35 38 41 47 23 89 58 39 49 42 33 12 90 41 26 64 21...

output:

210963098
588311966
956448426
592550032
798911598
246825848
753644972
519436028
355517966
28167496
995680420
679649324
246213554
21724866
317456218
167383046
473769070
479257468
212045412
814050842
371003570
282076662
455413348
511415158
803208550
885088998
963126914
289425774
635521114
548405038
77...

result:

ok 100002 lines

Test #87:

score: 0
Accepted
time: 159ms
memory: 17328kb

input:

100000 100000
-1 0 1 1 2 0 1 1 5 5 0 5 10 12 12 10 0 15 15 0 19 19 7 20 11 3 19 1 27 6 5 21 19 31 27 28 28 0 37 30 34 27 26 38 9 19 27 42 35 21 33 34 22 34 27 19 34 55 33 34 59 51 33 59 27 62 19 15 19 37 65 57 38 33 51 53 21 21 74 21 21 57 51 31 37 64 34 82 53 78 66 19 68 74 59 53 38 65 96 36 94 28 ...

output:

159909060
72596568
497733512
79295044
983123540
939068774
750571124
121102102
685516612
132405652
757245744
958388700
230378576
418175906
772843662
38342226
70162922
619695190
139476484
913831828
672482034
965913030
563218976
619006352
365455024
84467284
48895528
749831616
95267074
867912846
1146121...

result:

ok 100002 lines

Test #88:

score: 0
Accepted
time: 213ms
memory: 17204kb

input:

100000 100000
-1 0 0 2 0 1 1 4 7 0 5 0 6 12 0 7 3 0 0 14 17 11 14 22 22 23 2 22 23 5 26 14 14 22 3 19 18 27 26 14 38 22 32 35 8 10 3 33 39 31 48 3 27 11 24 0 36 51 46 47 39 11 0 14 14 57 15 18 63 17 39 14 64 52 51 39 24 28 71 22 60 52 75 14 51 0 11 39 74 10 87 80 56 26 63 14 61 18 75 48 0 74 93 22 9...

output:

414849994
960355308
924523924
977135918
888061882
916154540
804354134
131220344
758372246
331143960
758536548
697054002
538631072
64766790
117757608
150646848
471900316
654280180
244593700
954675472
948405752
731146264
116285906
831420226
927529068
504281364
115350180
774203576
76582182
171821524
36...

result:

ok 100002 lines

Test #89:

score: 0
Accepted
time: 200ms
memory: 17312kb

input:

100000 100000
-1 0 0 0 0 0 4 4 4 5 2 4 5 10 4 0 0 4 2 5 4 15 16 6 4 15 22 25 0 9 24 21 30 11 5 22 21 23 4 38 3 8 35 38 16 4 12 8 36 35 26 45 25 12 38 4 54 12 32 45 30 26 38 28 20 64 18 65 11 65 0 53 54 65 70 0 34 5 66 75 20 17 7 55 22 56 64 72 15 13 67 50 33 75 12 51 0 94 75 30 5 24 65 87 79 35 27 9...

output:

541518750
365362396
154783914
307840290
39383574
501031870
286660700
140057558
749377076
10543076
543160566
28061416
313878286
936028202
911839678
183335848
956334926
734464266
331636750
444954410
687362266
722941138
224775572
701770866
497593166
494837422
296551084
372509338
349178054
533118776
237...

result:

ok 100002 lines

Test #90:

score: 0
Accepted
time: 227ms
memory: 17292kb

input:

100000 100000
-1 0 1 2 0 0 4 0 1 5 4 2 1 9 9 0 0 1 15 3 0 0 12 5 4 6 10 17 15 15 23 17 2 13 20 32 20 21 0 20 11 12 28 18 16 39 34 12 4 36 20 6 39 41 39 38 36 3 45 34 44 54 36 19 55 20 3 51 63 21 54 58 54 50 62 49 28 46 4 50 6 67 46 11 49 36 80 82 40 80 50 54 59 82 20 59 85 94 54 98 26 98 91 26 62 37...

output:

430437630
714887064
316012250
781751966
579948846
411036840
743439084
262892248
234927450
829462740
284910798
752825688
187045540
499117772
761290980
502178996
548433148
295528616
29293000
463287500
976082966
746706810
69576950
337951230
606242974
546629940
21754364
511513670
769126870
246579782
989...

result:

ok 100002 lines

Test #91:

score: 0
Accepted
time: 226ms
memory: 17332kb

input:

100000 100000
-1 0 0 1 3 0 2 1 1 7 0 6 8 0 10 10 10 7 5 9 0 0 21 21 11 10 1 13 20 15 12 16 30 4 7 17 28 31 27 38 19 25 13 26 15 21 31 42 13 15 45 49 20 32 38 54 52 20 28 21 16 27 7 45 14 13 22 26 26 50 54 42 28 57 60 22 50 61 52 64 51 47 39 77 65 71 13 10 38 27 52 14 44 28 10 52 86 32 88 92 54 92 31...

output:

895628592
761575506
908749972
860278716
121626544
732232676
244523396
953801286
183360334
875219398
335858104
55080818
178412994
857313912
945810570
82432072
859258852
270795226
187282152
577475118
3605960
232034248
119339426
259412658
897054928
11497626
773002732
325050848
671923862
474478044
47869...

result:

ok 100002 lines

Test #92:

score: 0
Accepted
time: 141ms
memory: 10872kb

input:

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

output:

50202
49799
50200
49800
50200
49803
50198
49803
50201
49800
50195
49804
50199
49804
50201
49802
50203
49800
50204
49805
50201
49803
50200
49802
50200
49804
50197
49804
50197
49801
50196
49800
50197
49804
50200
49801
50197
49801
50197
49800
50195
49804
50197
49806
50194
49801
50199
49801
50202
49802
...

result:

ok 100002 lines

Test #93:

score: 0
Accepted
time: 170ms
memory: 10976kb

input:

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

output:

49900
49993
49972
50076
49719
49723
50047
49790
49861
49818
49969
49856
50000
49649
50206
49922
50082
50076
50018
49997
49832
49756
49771
49930
50130
49826
49805
49930
49846
50117
50123
50108
50129
49827
50197
49912
50002
50113
50186
50233
50181
49954
50008
50057
50064
49875
50012
50026
49883
50019
...

result:

ok 100002 lines

Test #94:

score: 0
Accepted
time: 102ms
memory: 34420kb

input:

100000 1
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok 100002 lines

Test #95:

score: 0
Accepted
time: 179ms
memory: 17296kb

input:

99999 100000
-1 0 1 2 3 4 5 1 6 6 9 7 7 8 12 14 11 5 15 4 13 18 14 22 23 17 24 25 11 10 23 3 0 28 31 21 16 2 24 19 32 9 27 35 21 41 39 33 20 17 44 47 34 36 26 52 15 46 29 40 16 58 53 49 54 31 65 57 61 44 55 58 45 59 65 66 73 13 57 70 60 32 41 36 74 19 73 76 38 68 35 51 91 40 79 70 48 92 25 59 52 84 ...

output:

749587248
841279802
900268384
913013174
356663616
48858138
190726520
286963142
571286802
780779824
378113030
313149082
291508006
770170704
942583352
351307216
871150438
980248552
235734206
484689994
282252614
293801558
258637724
571872048
643548590
502259314
522247998
345662424
613383358
593503174
7...

result:

ok 100002 lines

Test #96:

score: 0
Accepted
time: 174ms
memory: 13896kb

input:

49999 99999
-1 0 0 2 0 3 1 2 3 8 7 4 4 11 5 7 11 16 4 13 8 16 17 14 5 13 25 21 25 23 16 2 1 30 23 17 21 19 7 26 34 36 1 6 32 19 11 3 37 15 48 15 18 46 53 10 41 51 25 44 55 46 20 47 23 61 50 60 45 68 54 36 58 58 61 37 67 46 59 10 52 60 15 43 79 50 6 75 18 13 58 32 30 77 52 88 22 77 14 34 90 44 71 19 ...

output:

242041920
543364174
186570101
519979774
370324206
749200926
486618090
980606096
39161018
75173304
242581377
364392498
995215554
889006243
227247344
976471954
503386966
43440136
652668123
661978651
699241194
330414839
926103914
103397691
888663104
531324466
522670878
639059712
56315933
431919345
5320...

result:

ok 100002 lines

Test #97:

score: 0
Accepted
time: 208ms
memory: 12844kb

input:

24999 99997
-1 0 0 2 2 3 4 4 3 1 6 3 7 12 4 14 14 15 6 14 19 15 15 17 16 3 14 0 16 8 1 27 2 31 8 32 25 7 18 31 3 20 37 32 16 35 39 17 30 7 0 28 30 12 34 2 40 26 35 50 43 50 11 29 53 10 40 30 28 16 19 60 61 46 45 48 1 68 20 58 52 59 57 57 29 59 61 56 64 60 83 55 20 22 44 85 34 67 76 39 23 23 22 99 78...

output:

854770917
17069412
169430518
683418315
702752869
191656067
930323755
482124017
75263009
181585650
33355255
229416275
415445497
338326215
496361257
503935383
431517812
84603482
982024046
438877084
152528438
925626146
947821478
35978073
593881068
373914345
688881283
313718447
948967376
565003815
93777...

result:

ok 100002 lines

Test #98:

score: 0
Accepted
time: 157ms
memory: 10948kb

input:

450 99901
-1 0 1 1 0 2 1 0 0 1 4 0 8 6 10 8 5 8 4 2 8 9 15 1 11 15 16 4 2 8 3 18 24 10 23 24 31 31 19 31 18 36 4 36 0 23 40 17 27 19 0 45 34 11 47 34 10 56 56 15 42 48 27 18 20 0 65 45 34 65 9 1 66 70 70 48 65 8 61 72 19 66 72 76 45 48 65 70 72 34 50 49 20 81 10 74 19 65 63 49 69 52 70 56 99 88 42 3...

output:

657012858
499195535
5400837
56512214
128180623
285259147
881124067
903999853
121295498
589120954
341577574
497235142
645654130
789983521
428549581
872944204
516631459
625571196
474777035
87703893
352224040
598310115
171930993
28395036
9898078
295208069
11589756
438848613
773500922
241162458
98651743...

result:

ok 100002 lines

Test #99:

score: 0
Accepted
time: 209ms
memory: 39208kb

input:

100000 100000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97...

output:

824617168
902986724
633182732
213483020
405375522
174232952
43965128
606375108
800587074
784884610
758632960
337452034
114910884
923436416
282570214
792375154
235039644
783881306
395023888
507805732
677698328
884504116
784814044
751020370
149383888
249265038
190690706
369210026
52161688
109921470
39...

result:

ok 100002 lines

Test #100:

score: 0
Accepted
time: 237ms
memory: 40320kb

input:

100000 100000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97...

output:

49988
49929
50002
50032
50235
50300
49920
49602
50198
49920
49697
50270
49877
49963
49962
50008
49920
50317
49972
50037
49990
50074
50065
50035
50167
49997
50097
50010
49941
49999
50037
50089
50114
49950
49942
49981
49914
49903
49765
49969
50023
49785
49977
49914
49905
49966
50090
50019
49826
49844
...

result:

ok 100002 lines

Test #101:

score: 0
Accepted
time: 164ms
memory: 40316kb

input:

100000 100000
-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97...

output:

49986
50017
49986
50014
49983
50013
49981
50014
49981
50014
49982
50015
49985
50016
49984
50015
49986
50016
49986
50016
49986
50016
49983
50017
49986
50015
49982
50014
49982
50016
49982
50018
49983
50018
49986
50015
49988
50018
49981
50013
49982
50015
49982
50015
49983
50015
49987
50013
49986
50014
...

result:

ok 100002 lines

Test #102:

score: 0
Accepted
time: 141ms
memory: 15236kb

input:

77476 41463
-1 0 1 1 1 4 2 4 5 4 7 9 11 12 13 13 15 15 8 16 3 10 5 22 23 20 25 26 27 28 28 27 30 32 28 33 33 28 31 36 34 39 33 42 42 41 42 46 46 41 47 46 51 50 44 48 53 56 55 57 56 59 61 62 61 63 64 65 67 68 49 69 71 72 73 74 70 76 76 78 77 79 75 82 73 80 80 85 85 87 80 84 84 81 93 94 95 96 93 97 99...

output:

591150364
713930752
522385898
996417932
827406200
194065866
992185864
870407358
759175234
325782704
633009246
747933338
136574236
984379466
694742332
732235382
363060336
277219444
969284918
925837366
5068382
314372098
497416458
754890636
617911992
169188180
714468734
810583382
519287974
358969594
62...

result:

ok 100002 lines

Test #103:

score: 0
Accepted
time: 170ms
memory: 10544kb

input:

41015 66344
-1 0 0 0 3 3 1 0 7 7 2 9 0 11 6 13 2 7 0 12 2 2 15 19 7 17 8 14 16 14 18 26 28 20 17 33 0 1 7 7 36 39 22 31 12 19 4 33 18 48 48 36 23 38 50 32 37 16 27 34 12 59 19 26 51 51 9 29 67 44 57 19 44 49 44 33 62 62 12 24 36 18 17 19 34 24 77 58 53 62 62 38 91 18 74 19 66 86 36 45 88 53 91 85 36...

output:

152229964
832132796
746217774
513716388
630192114
263754280
664991130
672270076
587965980
744289452
606837962
129397758
177224200
730467384
208605914
948594858
583295450
456823134
403938194
46094402
25703586
609216820
794012158
525633012
508987752
579512994
480228808
9956740
121707970
11203000
25442...

result:

ok 100002 lines

Test #104:

score: 0
Accepted
time: 176ms
memory: 10972kb

input:

31857 76998
-1 0 1 1 0 0 0 4 6 6 1 6 1 10 12 6 10 9 5 10 8 9 6 4 5 12 17 25 19 10 23 23 4 7 21 26 24 13 36 37 22 19 22 19 16 5 42 25 24 36 30 31 44 30 38 15 1 46 6 42 23 33 36 14 46 35 42 54 55 54 30 70 15 50 71 40 65 40 47 7 51 41 36 73 48 45 41 46 61 10 6 33 19 39 81 44 9 66 47 18 44 7 43 93 89 53...

output:

527696478
834369280
664624124
254330594
578560888
175253932
577411444
859551966
327313406
819801164
885954546
870438564
157127692
734461216
102143006
493603350
271571058
562911436
488975650
919946496
364779960
50690894
75571678
823533018
920795740
76560376
284319092
205636652
108353486
87976294
6471...

result:

ok 100002 lines

Test #105:

score: 0
Accepted
time: 164ms
memory: 11244kb

input:

446 99683
-1 0 0 0 0 4 4 4 0 8 8 5 0 8 6 10 11 4 2 10 11 12 13 20 7 20 21 8 25 0 16 30 31 7 33 30 33 6 20 25 20 25 28 36 13 19 20 29 22 46 36 40 2 38 7 13 20 21 49 25 40 38 25 55 0 13 49 36 59 29 44 59 4 33 71 29 72 8 25 7 0 62 56 72 72 19 64 29 71 29 20 75 0 25 89 55 73 15 42 91 4 20 75 72 62 62 36...

output:

597941740
198871260
617435632
616318672
572203692
474355648
373908866
453244352
763745092
728749080
854141088
134016118
47843784
782873866
165026208
989587066
126953262
648339014
469947550
562427610
369309102
395733606
459794474
357844672
915873016
291729912
439496008
916243414
971623234
741586640
9...

result:

ok 100002 lines