QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293607#6336. CouncilMax_s_xaM100 ✓219ms32788kbC++145.0kb2023-12-29 14:18:592023-12-29 14:18:59

Judging History

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

  • [2023-12-29 14:18:59]
  • 评测
  • 测评结果:100
  • 用时:219ms
  • 内存:32788kb
  • [2023-12-29 14:18:59]
  • 提交

answer

#include <iostream>

typedef long long ll;
typedef double lf;

// #define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = 3e5 + 10, MAXM = (1 << 20) + 5;

int n, m, ans, res[MAXN], cnt[22];
bool a[MAXN][22], tp[22];
int id[22], tot, sta[MAXN], qry[MAXN];

bool f[MAXM];
int mx1[MAXM], h1[MAXM], mx2[MAXM], h2[MAXM];

int main()
{
    // freopen("B.in", "r", stdin);
    // freopen("B.out", "w", stdout);
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif
    Read(n), Read(m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) Read(a[i][j]), cnt[j] += a[i][j];
    int lmt = n / 2;
    for (int j = 1; j <= m; j++)
        if (cnt[j] - 2 >= lmt) ans++;
        else if (cnt[j] >= lmt) ans++, id[++tot] = j, tp[tot] = (cnt[j] == lmt);
    // for (int i = 1; i <= tot; i++) cout << tp[i] << " "; cout << "\n";
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= tot; j++)
        {
            sta[i] |= (1 << j - 1) * a[i][id[j]];
            if (tp[j]) qry[i] |= (1 << j - 1) * (1 - a[i][id[j]]), res[i]++;
            else qry[i] |= (1 << j - 1) * a[i][id[j]], res[i] += a[i][id[j]];
        }
        // cout << sta[i] << " " << qry[i] << " " << res[i] << "\n";
        int tt = (1 << tot) - 1 - sta[i];
        // cout << tt << "\n";
        f[tt] = 1;
        if (!h1[tt]) h1[tt] = i;
        else if (!h2[tt]) h2[tt] = i;
    }
    // for (int s = 0; s < (1 << tot); s++) cout << g[s] << " "; cout << "\n";
    for (int s = (1 << tot) - 1; s >= 0; s--)
        for (int i = 1; i <= tot; i++)
            if (!(s & (1 << i - 1)))
            {
                f[s] |= f[s ^ (1 << i - 1)];
                if (!h1[s ^ (1 << i - 1)] || h2[s]) continue;
                if (!h1[s]) h1[s] = h1[s ^ (1 << i - 1)], h2[s] = h2[s ^ (1 << i - 1)];
                else if (h1[s] != h1[s ^ (1 << i - 1)]) h2[s] = h1[s ^ (1 << i - 1)];
                else if (h1[s] != h2[s ^ (1 << i - 1)]) h2[s] = h2[s ^ (1 << i - 1)];
            }
    // for (int s = 1; s < (1 << tot); s++) cout << f[s] << "\n";
    for (int s = 0; s < (1 << tot); s++)
        if (f[s]) mx1[s] = __builtin_popcount(s), mx2[s] = (h2[s] ? mx1[s] : 0);
    // for (int s = 1; s < (1 << tot); s++) cout << mx1[s] << " " << mx2[s] << "\n";
    for (int s = 0; s < (1 << tot); s++)
        for (int i = 1; i <= tot; i++)
            if (s & (1 << i - 1))
            {
                if (mx1[s] < mx1[s ^ (1 << i - 1)])
                {
                    if (h1[s] != h1[s ^ (1 << i - 1)]) mx2[s] = mx1[s], h2[s] = h1[s];
                    mx1[s] = mx1[s ^ (1 << i - 1)], h1[s] = h1[s ^ (1 << i - 1)];
                }
                else if (mx2[s] < mx1[s ^ (1 << i - 1)] && h1[s] != h1[s ^ (1 << i - 1)]) mx2[s] = mx1[s ^ (1 << i - 1)], h2[s] = h1[s ^ (1 << i - 1)];
                if (mx2[s] < mx2[s ^ (1 << i - 1)] && h1[s] != h2[s ^ (1 << i - 1)]) mx2[s] = mx2[s ^ (1 << i - 1)], h2[s] = h2[s ^ (1 << i - 1)];
            }
    // for (int s = 1; s < (1 << tot); s++)
    //     cout << mx1[s] << " " << h1[s] << " " << mx2[s] << " " << h2[s] << "\n"; cout << "\n";
    // cout << qry[3] << "\n";
    for (int i = 1; i <= n; i++) cout << ans - res[i] + (h1[qry[i]] == i ? mx2[qry[i]] : mx1[qry[i]]) << "\n";
    return 0;
}

详细

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 143ms
memory: 27080kb

input:

38 20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 ...

output:

18
18
1
1
18
18
18
1
1
18
18
18
18
18
18
18
1
18
18
1
18
1
1
18
1
1
18
18
1
1
1
18
1
1
1
18
1
1

result:

ok 38 numbers

Test #2:

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

input:

300 20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 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:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
...

result:

ok 300 numbers

Test #3:

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

input:

5 20
0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0
1 0 1 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1
0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1
0 1 0 0 1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1

output:

7
9
9
8
9

result:

ok 5 number(s): "7 9 9 8 9"

Test #4:

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

input:

20 20
1 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 0 1
1 0 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0
1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1
0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0
0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 1
1 0 0 0 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1
0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 1 0 1 0
0 0 0 1 0 0 0 ...

output:

12
13
12
13
12
13
12
13
11
13
12
12
11
11
12
13
12
13
13
11

result:

ok 20 numbers

Test #5:

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

input:

300 20
1 1 0 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 0
0 0 1 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 0 1
0 1 1 0 0 0 0 0 0 1 1 1 1 0 0 1 0 1 1 1
1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 0 0 1
0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1
0 1 1 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0
0 0 0 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 0 1
1 1 0 0 1 0 1...

output:

10
11
11
10
11
11
11
10
11
11
11
10
10
10
10
10
11
11
11
11
10
10
10
10
10
11
11
11
10
11
10
10
10
10
10
10
11
11
10
11
10
11
11
10
10
11
11
11
11
10
10
11
10
11
11
10
10
11
11
10
10
10
10
11
10
10
10
11
11
10
11
10
11
11
11
10
10
11
11
10
10
10
10
10
11
11
10
11
10
11
10
10
11
10
10
11
10
10
11
10
...

result:

ok 300 numbers

Test #6:

score: 0
Accepted
time: 143ms
memory: 20892kb

input:

5 20
1 1 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0 1 1 0
1 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 1 1
0 1 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 0 0
0 0 0 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0
0 0 0 0 0 1 1 0 0 1 0 1 1 0 0 0 1 1 1 1

output:

10
9
11
11
11

result:

ok 5 number(s): "10 9 11 11 11"

Test #7:

score: 0
Accepted
time: 151ms
memory: 21184kb

input:

20 20
0 0 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1
0 0 0 1 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0
1 1 1 1 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 1
1 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 0 1 1 1
1 0 1 0 0 0 1 0 1 0 0 1 1 1 1 1 0 1 1 1
0 0 0 1 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 1
0 0 1 1 1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 0
1 1 0 0 1 1 1 ...

output:

11
11
11
11
10
12
12
11
12
9
11
12
11
13
10
10
13
12
11
11

result:

ok 20 numbers

Test #8:

score: 0
Accepted
time: 144ms
memory: 20972kb

input:

300 20
1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 1 0 0 1 0
0 0 1 0 1 1 1 0 1 0 1 1 1 0 1 1 1 1 0 0
0 0 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 1 0 0
0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 1
0 0 1 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 1 1
0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0
0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 1 1 1 0 0
0 0 0 0 1 0 1...

output:

15
14
15
15
16
16
16
17
15
14
15
17
16
15
14
16
13
16
16
14
16
14
16
15
16
15
15
13
17
14
15
15
14
18
14
17
14
16
16
16
13
17
18
16
16
16
16
13
16
15
18
15
17
17
15
14
15
14
17
13
15
16
14
17
16
14
16
15
12
16
17
16
16
14
15
13
15
14
17
12
15
13
15
12
12
17
14
19
16
17
13
16
12
16
13
16
17
14
15
18
...

result:

ok 300 numbers

Test #9:

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

input:

3 1
0
1
0

output:

1
0
1

result:

ok 3 number(s): "1 0 1"

Test #10:

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

input:

26 1
1
0
1
1
0
1
0
0
0
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 26 numbers

Test #11:

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

input:

4 2
1 1
1 1
0 1
0 1

output:

1
1
2
2

result:

ok 4 number(s): "1 1 2 2"

Test #12:

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

input:

5 2
0 1
1 1
0 0
0 0
0 0

output:

0
0
1
1
1

result:

ok 5 number(s): "0 0 1 1 1"

Test #13:

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

input:

300 2
1 0
0 1
0 1
0 0
0 0
0 1
1 0
1 1
1 1
1 1
0 0
0 0
1 1
1 0
0 1
1 1
0 1
0 0
0 1
0 1
1 0
0 0
0 0
0 0
0 0
0 1
0 0
0 1
1 1
0 0
0 1
0 0
1 1
1 1
0 1
0 0
1 1
0 1
0 1
1 0
1 0
1 0
1 1
0 1
1 0
1 1
0 0
1 1
0 1
0 0
0 0
0 1
1 0
1 1
1 0
1 0
1 0
1 1
1 0
0 0
0 0
1 1
1 0
0 0
0 0
0 0
1 1
1 0
0 0
0 0
0 1
1 0
0 0
1 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300 numbers

Test #14:

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

input:

26 1
0
1
0
1
0
0
0
0
1
1
1
1
0
1
1
0
0
1
0
0
0
1
1
1
0
1

output:

1
0
1
0
1
1
1
1
0
0
0
0
1
0
0
1
1
0
1
1
1
0
0
0
1
0

result:

ok 26 numbers

Test #15:

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

input:

4 2
0 1
1 0
1 1
1 1

output:

2
2
1
1

result:

ok 4 number(s): "2 2 1 1"

Test #16:

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

input:

5 2
0 0
1 0
1 1
0 1
1 1

output:

2
2
2
2
2

result:

ok 5 number(s): "2 2 2 2 2"

Test #17:

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

input:

300 2
0 1
1 0
0 1
0 0
1 0
1 1
0 0
1 0
1 1
0 1
0 0
0 1
0 1
0 0
1 1
0 0
0 1
0 1
1 1
1 0
1 1
0 1
0 0
0 1
0 1
0 1
1 0
1 0
0 0
1 0
1 0
0 0
1 1
1 1
1 0
0 1
0 1
1 1
1 1
1 0
0 1
0 0
1 0
1 0
1 1
1 0
1 0
1 1
0 1
1 1
1 1
1 1
0 1
0 1
1 1
0 0
0 1
1 1
0 0
1 0
1 1
1 1
0 1
1 1
0 0
1 0
1 1
0 1
1 0
1 0
0 0
1 1
0 0
0 ...

output:

1
1
1
2
1
0
2
1
0
1
2
1
1
2
0
2
1
1
0
1
0
1
2
1
1
1
1
1
2
1
1
2
0
0
1
1
1
0
0
1
1
2
1
1
0
1
1
0
1
0
0
0
1
1
0
2
1
0
2
1
0
0
1
0
2
1
0
1
1
1
2
0
2
2
1
1
1
1
1
0
1
1
2
0
2
1
2
1
1
0
0
0
0
1
2
1
0
1
2
1
1
1
1
1
0
1
2
1
2
1
1
2
1
2
2
1
1
1
0
2
1
1
2
1
1
2
0
1
2
0
0
0
2
1
2
1
2
0
0
1
1
1
1
0
1
0
2
1
0
1
...

result:

ok 300 numbers

Test #18:

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

input:

18 10
0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 0 1
0 1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 0
0 0 1 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0
0 0 0 1 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 ...

output:

8
8
8
8
1
8
1
1
8
1
1
8
1
1
1
8
8
8

result:

ok 18 numbers

Test #19:

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

input:

5 3
1 0 0
1 0 1
0 1 1
1 1 0
0 1 0

output:

3
2
2
2
3

result:

ok 5 number(s): "3 2 2 2 3"

Test #20:

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

input:

31 4
1 1 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 1 0 0
0 1 1 1
1 1 0 0
1 0 1 0
0 1 0 0
1 1 0 0
1 0 0 0
1 1 1 1
1 1 0 0
0 0 0 1
1 1 1 0
0 0 1 0
1 0 1 0
1 1 1 0
0 0 1 0
1 1 1 0
0 0 0 1
0 1 0 1
1 1 0 1
0 1 0 1
0 1 0 0
1 1 1 0
0 0 1 1
1 0 0 0
1 0 1 1
0 0 1 0
0 0 1 0

output:

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

result:

ok 188 numbers

Test #23:

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

input:

21 7
0 0 0 1 1 0 1
1 1 0 0 0 0 0
1 0 1 0 1 1 0
1 0 0 1 0 0 0
1 1 1 1 0 1 1
0 0 1 1 0 1 1
0 1 0 0 0 0 0
1 0 0 1 0 1 1
1 0 0 1 0 0 1
0 1 0 1 0 1 0
1 0 1 0 1 0 1
1 1 0 0 1 0 1
0 1 1 0 0 1 1
0 1 0 1 0 1 0
0 1 1 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 1 0 0
0 0 1 1 0 0 1
1 0 1 0 0 1 0
0 0 1 0 1 1 0
0 1 1 1 1 1 0

output:

2
3
2
2
1
1
3
1
2
1
3
3
2
1
3
3
3
2
2
2
1

result:

ok 21 numbers

Test #24:

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

input:

53 8
1 0 0 1 1 0 1 0
0 1 0 1 1 1 1 0
0 1 1 1 1 0 1 0
0 1 1 1 1 0 0 1
1 0 0 1 1 0 0 0
0 0 0 0 1 0 1 1
1 0 0 1 0 0 1 1
0 0 1 0 1 1 1 0
0 1 0 1 0 0 0 0
1 0 1 1 0 1 0 0
0 0 1 1 1 0 1 1
1 0 1 1 1 0 0 0
1 0 1 0 0 1 1 1
1 1 0 1 0 0 1 0
0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0
0 1 0 1 1 0 1 0
0 0 1 1 1 1 0 1
0 0 0 1...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

result:

ok 53 numbers

Test #25:

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

input:

12 9
1 1 0 0 0 1 0 0 0
1 1 0 1 0 1 1 1 0
1 0 0 0 0 1 1 0 0
0 0 1 1 0 1 0 0 0
1 1 1 0 1 0 1 1 1
0 0 0 1 1 1 0 1 1
0 1 0 1 1 0 1 0 1
0 1 0 0 1 0 0 0 0
1 0 0 1 0 0 0 0 0
1 1 1 0 0 1 1 1 0
1 1 0 0 1 1 0 0 0
0 0 0 1 0 0 0 1 1

output:

3
3
4
3
3
3
3
4
3
3
3
3

result:

ok 12 numbers

Test #26:

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

input:

37 10
0 0 1 0 1 1 1 0 0 0
1 0 0 1 0 0 1 0 0 0
0 1 1 1 0 1 0 0 1 1
1 0 1 1 0 0 0 1 0 1
0 1 0 1 0 0 0 1 0 0
0 0 0 1 1 1 0 1 0 0
0 1 0 1 0 0 1 0 1 1
1 1 1 0 0 1 0 1 0 0
0 0 1 1 0 0 1 1 0 0
1 0 0 1 0 0 1 0 1 1
1 1 0 0 1 1 1 0 0 1
0 1 1 1 1 1 0 1 1 0
1 0 1 1 0 1 1 0 0 0
1 1 0 1 0 1 1 0 0 0
1 0 0 1 0 0 1 ...

output:

3
2
3
2
3
3
3
2
3
2
2
3
2
2
2
2
3
2
3
2
3
3
3
2
3
2
3
2
2
3
2
2
3
3
3
2
3

result:

ok 37 numbers

Test #27:

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

input:

300 10
0 1 1 1 0 0 1 0 1 1
0 0 0 1 1 1 1 0 1 1
0 1 0 0 1 1 1 1 1 0
0 0 0 1 0 0 1 0 0 0
0 1 0 1 1 1 0 1 1 0
1 0 0 1 1 1 1 0 1 1
1 0 1 1 1 0 1 0 0 1
1 1 1 0 1 0 1 0 1 0
1 1 1 1 0 1 0 0 0 0
0 0 1 0 1 1 1 0 1 0
1 0 0 0 1 1 0 0 1 0
1 1 1 0 1 1 1 0 1 1
1 0 1 1 0 1 0 0 1 0
1 0 0 1 0 0 1 0 1 1
1 1 0 0 1 0 0...

output:

4
4
5
5
5
4
4
5
5
5
5
4
5
4
4
5
5
4
5
4
5
4
5
4
4
5
5
5
4
5
4
4
5
4
4
5
5
4
5
5
5
4
4
5
4
4
5
5
5
4
5
5
4
5
4
5
5
5
4
5
4
5
4
4
4
4
5
5
5
5
5
4
5
5
5
4
5
5
5
5
4
4
5
4
4
4
4
4
5
4
5
5
5
4
5
5
5
5
5
4
5
4
5
4
5
4
4
4
5
4
5
5
5
4
4
5
4
5
4
5
4
4
5
4
4
5
4
4
4
5
5
4
5
5
5
5
4
4
4
4
5
5
5
4
4
4
4
5
4
4
...

result:

ok 300 numbers

Test #28:

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

input:

5 3
1 1 1
1 0 1
0 1 1
1 1 0
0 0 0

output:

3
3
3
3
3

result:

ok 5 number(s): "3 3 3 3 3"

Test #29:

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

input:

31 4
0 1 1 1
1 1 0 1
1 0 1 1
1 1 1 0
0 1 1 0
0 0 0 1
0 0 0 0
0 0 1 0
0 0 0 1
1 1 1 0
1 0 0 1
0 1 1 1
0 0 0 1
0 0 0 1
1 0 1 0
1 1 1 1
0 1 0 1
1 0 1 1
0 1 0 0
1 1 0 0
1 1 1 0
1 0 1 1
1 1 1 0
1 0 0 1
0 0 0 0
0 1 1 0
0 1 1 0
0 0 0 0
1 1 1 0
1 0 0 1
1 0 0 0

output:

2
2
3
3
3
3
4
4
3
3
3
2
3
3
4
2
2
3
3
3
3
3
3
3
4
3
3
4
3
3
4

result:

ok 31 numbers

Test #30:

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

input:

30 5
0 1 1 0 1
1 0 0 1 1
0 0 1 1 0
0 1 0 0 1
0 1 0 1 1
1 0 1 0 1
1 0 0 0 1
1 1 1 1 1
1 0 0 1 1
1 0 1 0 0
0 1 1 1 0
0 1 0 1 1
1 1 0 1 0
1 0 1 1 1
1 0 0 1 0
0 1 0 1 0
0 1 1 0 0
1 1 0 1 0
0 1 1 0 1
1 1 0 1 1
0 0 1 0 1
0 1 1 0 1
1 0 1 1 0
0 1 1 1 0
1 0 1 1 1
0 0 0 0 1
1 0 1 0 0
0 1 0 0 0
0 1 0 0 0
1 0 0...

output:

4
4
4
4
4
3
4
3
4
3
4
4
4
3
4
5
4
4
4
4
4
4
3
4
3
5
3
5
5
4

result:

ok 30 numbers

Test #31:

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

input:

188 6
1 1 1 0 1 0
1 0 1 0 0 0
1 0 1 1 1 0
0 0 1 1 0 1
0 1 1 1 1 1
1 0 1 1 0 1
1 0 1 1 1 1
1 1 1 0 0 0
1 0 1 1 1 1
0 0 0 1 0 1
1 1 1 0 1 0
0 1 0 0 1 0
0 0 0 0 0 0
1 1 1 1 0 1
0 0 0 0 0 0
0 0 0 1 1 1
1 0 1 0 0 0
1 0 1 0 0 1
0 1 1 0 1 0
0 1 1 0 0 1
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 1 1 0
0 1 1 0 1 0
0 0 1 ...

output:

3
5
4
5
3
5
4
4
4
6
3
4
6
4
6
5
5
5
3
4
5
5
4
3
5
5
5
3
5
4
4
5
6
4
4
4
4
5
3
5
4
5
6
4
5
5
6
6
3
4
5
5
4
5
4
3
6
5
6
4
4
4
5
5
4
4
6
4
4
4
4
6
5
4
4
4
5
5
5
3
4
4
4
5
6
5
4
4
4
3
4
4
5
5
5
3
5
4
4
6
4
5
4
4
6
6
4
5
5
4
5
4
6
4
5
6
3
3
4
4
3
4
6
5
4
4
4
4
4
6
3
4
5
3
6
5
3
4
4
6
4
6
5
3
4
4
4
5
4
6
...

result:

ok 188 numbers

Test #32:

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

input:

21 7
0 0 0 1 0 0 1
1 1 0 1 1 1 1
0 0 0 1 0 1 0
0 0 0 1 1 1 1
1 0 0 0 1 0 0
1 1 0 0 0 0 0
0 1 1 1 1 0 0
1 1 0 0 0 1 0
1 0 0 1 1 1 1
0 1 1 0 1 1 1
1 1 0 1 0 1 1
0 1 1 0 0 0 0
0 1 1 1 1 0 1
1 1 1 0 1 1 1
0 1 1 0 0 0 0
1 0 1 0 0 0 1
0 0 1 0 1 0 1
1 0 1 1 1 1 0
0 0 0 0 0 0 0
1 0 1 0 0 1 1
0 0 1 1 1 0 0

output:

6
3
5
5
6
5
5
4
4
5
3
6
5
4
6
6
7
4
7
5
6

result:

ok 21 numbers

Test #33:

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

input:

53 8
1 0 1 1 1 1 0 0
0 1 1 0 0 1 1 0
0 0 1 0 0 1 0 0
0 1 0 0 1 1 0 0
1 0 0 1 1 0 1 0
1 0 1 1 0 1 1 1
1 1 0 1 1 1 1 1
1 0 0 0 1 0 0 0
0 1 0 1 0 0 1 1
1 1 0 1 1 1 0 1
0 0 1 0 0 1 0 0
1 0 0 0 0 1 1 0
1 1 0 0 0 0 0 1
1 0 1 1 1 0 1 1
1 0 1 0 1 1 1 1
0 1 1 0 1 0 0 0
1 1 0 1 0 0 1 0
0 1 1 1 0 1 1 1
0 0 0 1...

output:

6
7
7
6
7
5
5
7
6
5
7
7
7
6
5
7
7
6
7
8
7
5
7
5
5
5
7
6
7
7
8
7
7
5
6
5
6
7
6
7
7
6
7
7
7
6
7
6
7
6
7
6
6

result:

ok 53 numbers

Test #34:

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

input:

12 9
0 1 1 1 1 1 0 0 0
0 1 1 0 1 0 0 0 0
0 1 0 1 0 0 0 0 0
1 1 0 0 0 1 1 1 1
1 0 0 1 0 0 1 1 0
0 0 0 0 0 0 1 1 1
1 0 1 1 1 1 0 1 1
1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 0 1
1 0 1 1 0 0 0 0 1
0 1 0 0 1 0 1 0 0
1 0 0 0 1 1 1 1 1

output:

5
6
7
5
6
6
4
4
5
6
7
5

result:

ok 12 numbers

Test #35:

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

input:

37 10
0 1 0 0 1 0 1 1 1 0
0 1 0 1 1 0 1 0 0 1
0 1 0 0 1 0 1 1 1 0
1 0 1 0 1 0 1 0 0 0
1 1 1 0 0 0 1 1 1 1
1 0 1 0 1 1 0 1 1 0
1 1 1 0 1 1 1 0 0 0
1 1 0 1 0 0 1 1 1 1
0 1 1 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 0
0 1 1 0 0 0 1 0 1 1
0 0 0 0 1 1 0 0 1 1
0 0 1 1 1 0 1 1 0 1
1 0 0 1 1 1 0 0 0 1
0 0 1 1 0 0 1 ...

output:

6
7
6
7
5
5
6
5
6
4
6
7
7
7
7
7
6
7
7
7
6
7
7
7
5
6
6
7
6
7
7
6
7
6
7
7
7

result:

ok 37 numbers

Test #36:

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

input:

300 10
1 0 1 1 0 1 1 1 0 0
1 1 1 0 1 0 0 1 0 1
0 0 0 1 1 1 1 1 0 1
0 1 1 0 1 0 1 0 0 0
0 1 1 0 1 0 0 1 1 0
0 1 0 1 0 0 0 1 0 0
0 0 0 0 1 1 0 0 1 0
0 1 1 0 1 0 1 0 1 1
1 0 1 1 1 1 0 0 1 1
1 1 1 0 1 0 1 0 1 1
0 0 1 1 0 1 1 0 0 0
0 1 0 0 1 0 0 1 1 0
0 0 1 0 0 1 0 1 0 0
1 0 1 0 1 0 1 1 1 1
1 0 0 1 1 0 1...

output:

8
8
8
8
8
10
8
7
7
6
9
8
10
6
6
7
8
7
8
8
6
10
9
8
10
9
7
8
9
6
8
7
9
8
7
7
7
8
9
7
8
8
7
7
8
8
8
8
8
7
9
9
6
8
8
8
8
7
10
8
8
9
9
7
7
8
9
8
9
8
9
9
9
6
7
8
8
9
9
8
7
10
9
9
8
8
8
8
8
6
9
8
9
8
8
9
7
9
8
8
8
7
8
7
8
9
8
8
8
7
9
9
7
8
7
8
8
6
8
6
7
7
8
8
6
7
9
9
9
8
8
7
7
7
9
9
7
7
7
8
7
9
9
8
8
7
8
...

result:

ok 300 numbers

Test #37:

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

input:

26 14
0 0 0 0 0 0 0 1 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 1 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 1 0 0 0 ...

output:

12
1
12
12
1
12
1
12
12
1
12
1
12
12
12
1
12
1
1
12
12
1
1
1
1
12

result:

ok 26 numbers

Test #38:

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

input:

5 14
0 1 1 0 1 1 0 0 1 1 0 0 1 0
0 1 1 0 1 1 0 0 1 1 0 1 1 0
1 0 1 0 0 1 1 0 1 1 1 1 0 0
1 0 1 0 1 1 1 0 0 0 0 1 1 0
0 0 1 1 0 1 0 1 1 1 1 1 0 1

output:

9
9
8
8
9

result:

ok 5 number(s): "9 9 8 8 9"

Test #39:

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

input:

20 14
0 0 0 1 1 0 1 0 1 0 1 1 1 1
1 0 1 0 1 0 0 0 1 1 0 1 1 0
0 1 1 1 0 0 0 1 0 1 1 0 1 1
1 0 0 1 1 1 1 1 1 1 0 1 1 0
0 0 1 1 1 1 0 0 1 1 1 0 0 0
1 0 0 1 0 1 0 1 0 0 1 1 0 0
0 0 0 1 0 0 1 1 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0 0 0 0 0
1 1 0 1 1 0 0 1 1 1 1 0 1 0
0 1 1 0 1 1 1 0 0 0 0 1 1 1
1 0 0 1 0 0 0 ...

output:

7
6
7
5
6
5
7
5
6
6
6
5
6
7
6
6
5
7
6
6

result:

ok 20 numbers

Test #40:

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

input:

5 14
0 0 0 1 0 1 0 0 0 1 1 1 0 1
0 0 0 1 0 1 1 1 1 0 0 1 0 0
1 0 1 0 0 0 1 0 0 1 0 0 1 1
1 1 0 1 1 0 1 1 1 1 1 0 0 1
0 1 1 0 1 0 0 0 0 0 0 0 1 0

output:

8
8
9
6
9

result:

ok 5 number(s): "8 8 9 6 9"

Test #41:

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

input:

20 14
1 0 1 0 1 0 0 1 1 0 1 0 1 1
0 0 0 1 0 1 0 1 1 0 1 0 1 0
0 1 1 0 0 1 0 0 1 1 1 1 1 1
1 0 1 0 1 1 0 1 0 1 1 1 1 0
1 1 1 0 1 0 1 1 0 1 0 1 0 1
1 1 1 0 0 0 1 1 0 1 0 1 1 0
0 1 1 1 1 0 0 0 1 0 1 1 1 0
0 0 0 1 0 1 1 0 1 0 0 1 0 0
1 1 0 0 1 1 1 1 1 0 0 1 1 0
0 0 1 1 0 0 1 1 1 0 0 0 0 1
0 1 1 0 0 0 1 ...

output:

11
11
11
9
10
10
12
11
10
11
13
9
9
11
13
11
10
11
9
11

result:

ok 20 numbers

Test #42:

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

input:

32 17
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1 0 0 0 ...

output:

15
15
15
15
15
15
15
15
15
15
1
15
1
1
15
1
1
15
15
1
15
1
1
1
1
1
1
1
15
15
1
1

result:

ok 32 numbers

Test #43:

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

input:

5 17
0 0 1 1 1 1 0 1 0 0 1 0 0 1 1 0 0
0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 1 0
0 0 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0
0 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1
0 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0

output:

10
12
11
9
12

result:

ok 5 number(s): "10 12 11 9 12"

Test #44:

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

input:

20 17
1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0
0 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 0
0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0
0 1 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1
1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0
0 1 1 1 0 1 1 0 1 0 0 0 0 0 1 0 0
1 0 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0
1 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 0
1 1 1 1 0 1 0 1 1 1 1 ...

output:

14
14
14
12
13
14
12
12
13
13
13
12
12
13
13
13
13
13
14
13

result:

ok 20 numbers

Test #45:

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

input:

5 17
0 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 0
1 1 1 1 0 0 0 1 1 0 1 1 0 1 0 1 0
0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1
0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1
1 0 0 0 1 0 1 1 1 0 0 0 1 0 0 1 1

output:

11
11
10
11
10

result:

ok 5 number(s): "11 11 10 11 10"

Test #46:

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

input:

20 17
1 1 1 1 1 0 1 0 0 0 0 0 1 1 1 0 0
0 1 0 1 1 1 1 1 1 0 1 1 1 0 0 1 0
1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1
1 0 0 0 1 0 1 1 1 0 0 0 1 1 0 1 0
1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1
0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1
1 1 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 1
1 1 0 1 1 0 0 1 0 0 1 ...

output:

12
9
12
12
12
10
12
9
10
11
11
14
12
11
13
11
14
9
9
12

result:

ok 20 numbers

Subtask #2:

score: 8
Accepted

Dependency #1:

100%
Accepted

Test #47:

score: 8
Accepted
time: 1ms
memory: 4020kb

input:

3000 20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 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:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
...

result:

ok 3000 numbers

Test #48:

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

input:

3000 20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 3000 numbers

Test #49:

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

input:

3000 20
1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 0 1 1
0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 1
0 0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 1 0 1 1
0 0 0 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0
0 1 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 1 0
0 1 0 1 0 1 1 1 0 0 0 1 1 1 0 0 1 1 0 0
0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0
0 0 1 0 0 0 ...

output:

13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
...

result:

ok 3000 numbers

Test #50:

score: 0
Accepted
time: 144ms
memory: 21172kb

input:

3000 20
1 0 1 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1
0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1
1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1
0 1 1 1 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 1
1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0
1 1 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1
1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 0 0 0
0 0 1 1 0 0 ...

output:

17
15
14
14
15
17
15
16
13
17
13
16
15
13
13
15
15
17
13
14
15
13
16
18
15
15
14
17
15
15
13
16
15
15
15
13
15
14
17
13
13
15
14
14
15
14
15
15
16
13
13
17
15
18
13
12
18
16
15
16
17
15
14
16
14
15
14
17
12
15
14
15
13
17
12
15
12
16
18
16
14
15
15
14
16
16
14
11
13
13
15
13
15
16
15
14
12
14
15
17
...

result:

ok 3000 numbers

Test #51:

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

input:

3000 2
1 0
1 0
0 0
1 1
0 0
1 1
0 0
0 0
1 0
1 1
1 0
0 0
0 0
1 0
0 1
1 0
1 1
0 0
0 0
1 0
0 0
0 0
0 1
1 1
1 0
0 0
0 0
0 1
0 1
0 0
1 1
1 1
0 1
0 1
0 1
0 0
0 1
0 1
0 1
0 0
0 1
0 0
1 1
0 1
1 1
1 1
1 0
0 0
1 0
1 0
1 1
1 0
0 0
0 0
1 0
1 1
1 0
0 0
1 1
0 0
0 1
1 0
0 1
0 0
1 0
0 0
0 0
0 0
0 1
1 1
0 0
1 1
1 0
1...

output:

1
1
2
1
2
1
2
2
1
1
1
2
2
1
2
1
1
2
2
1
2
2
2
1
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
2
1
2
2
1
2
2
1
2
2
2
2
1
2
1
1
1
1
1
1
1
2
2
2
2
1
1
2
1
2
2
2
1
1
1
1
1
2
1
1
2
2
1
2
2
2
2
2
1
1
2
1
2
2
2
1
1
2
1
1
2
2
1
2
1
1
1
1
1
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
1
2
2
2
1
1
2
1
2
...

result:

ok 3000 numbers

Test #52:

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

input:

3000 17
1 1 1 1 0 0 1 0 1 0 0 1 1 1 0 0 1
1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0
1 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0 1
1 1 1 1 0 0 0 1 0 0 1 1 0 0 1 0 0
1 0 0 1 0 0 1 1 1 0 0 0 0 0 1 0 0
1 1 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0
0 1 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1
1 0 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1
1 0 0 0 0 0 0 1 1 1 ...

output:

13
14
12
13
14
11
13
14
13
12
15
14
15
13
12
16
13
13
14
13
14
14
12
13
13
13
14
13
13
13
16
13
14
12
12
14
14
13
14
12
12
13
13
13
12
15
11
13
14
14
14
14
11
12
15
13
14
13
14
13
11
11
15
13
13
15
12
12
12
14
16
14
15
14
14
14
13
14
14
12
15
12
12
12
16
14
14
14
16
14
13
13
13
15
12
14
14
13
14
12
...

result:

ok 3000 numbers

Subtask #3:

score: 6
Accepted

Test #53:

score: 6
Accepted
time: 18ms
memory: 11012kb

input:

300000 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
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:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 300000 numbers

Test #54:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #55:

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

input:

300000 1
0
1
0
1
0
1
0
1
1
0
0
1
1
1
0
1
0
1
1
0
1
1
1
0
1
1
1
0
1
0
0
1
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #57:

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

input:

300000 1
1
0
1
1
1
0
1
1
1
1
0
0
1
0
1
0
0
0
1
1
1
1
0
0
0
1
1
0
0
0
0
0
1
1
0
1
0
1
1
1
0
0
1
0
1
0
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
1
0
0
1
1
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
1
1
1
1
1
1
0
1
0
0
1
1
1
0
0
1
1
0
0
1
1
0
1
0
0
0
1
1
1
0
1
0
1
1
1
1
1
1
0
1
0
1
1
1
1
1
0
1...

output:

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

result:

ok 300000 numbers

Test #58:

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

input:

300000 2
0 0
0 0
1 0
0 1
0 0
1 1
1 0
0 1
1 0
1 0
0 1
1 1
0 0
0 1
0 0
1 1
1 1
0 0
0 1
1 1
0 1
0 0
0 0
1 1
1 0
1 0
1 0
0 0
1 1
0 0
0 0
1 1
1 0
1 1
0 0
0 1
0 1
1 1
1 1
0 1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5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 299999 numbers

Test #60:

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

input:

299997 9
0 1 0 1 1 1 0 0 1
1 1 0 1 0 0 0 1 0
0 0 1 0 1 1 0 1 0
1 0 1 0 1 0 1 0 1
0 0 1 1 0 1 0 1 1
0 1 1 0 1 1 0 0 1
0 0 0 1 1 1 0 1 0
0 0 0 1 1 1 1 0 1
1 0 0 1 1 0 1 0 0
0 1 1 1 0 0 0 1 1
1 0 1 1 0 0 0 1 1
0 1 1 0 1 0 0 1 1
0 1 0 1 0 0 1 1 1
0 1 1 1 0 1 0 0 1
1 0 1 1 0 0 0 1 0
1 1 0 0 1 0 1 0 1
0 1...

output:

4
5
5
4
4
4
5
4
5
4
4
4
4
4
5
4
4
5
5
5
5
5
5
4
5
4
4
5
4
4
5
4
5
5
5
5
5
4
4
4
5
5
5
4
5
4
5
4
5
4
5
4
4
5
4
4
4
5
4
5
5
5
5
5
5
4
5
5
5
5
5
5
4
5
5
4
5
4
4
5
4
4
5
5
4
4
5
5
5
5
4
4
4
5
5
4
5
5
5
5
4
4
4
5
5
4
5
5
5
5
4
5
5
4
4
4
5
5
5
5
5
5
4
5
4
5
4
4
4
4
4
4
5
4
5
5
5
5
5
5
5
4
5
4
5
4
5
4
4
4
...

result:

ok 299997 numbers

Test #61:

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

input:

299997 9
1 1 0 1 0 1 0 0 1
0 0 1 1 0 1 0 1 1
0 0 1 0 1 1 1 0 0
0 1 1 0 0 0 1 1 0
0 1 1 1 1 0 0 0 0
0 1 0 1 1 0 1 0 0
0 0 1 0 1 0 1 1 0
1 0 1 0 0 1 0 1 0
0 0 1 1 1 0 1 0 0
1 1 0 0 1 0 0 1 0
1 0 1 0 0 1 1 0 0
0 1 1 0 0 1 1 0 0
1 0 0 1 1 0 1 0 0
1 0 0 1 0 0 1 1 0
0 1 1 1 1 0 0 0 0
1 0 0 1 1 0 0 1 1
0 0...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 299997 numbers

Test #62:

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

input:

300000 10
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 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:

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

result:

ok 300000 numbers

Test #63:

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

input:

300000 10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 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
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 300000 numbers

Test #65:

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

input:

300000 10
1 1 1 0 0 0 0 0 1 0
1 0 0 0 0 1 0 1 0 0
1 0 1 1 1 1 0 1 1 1
0 1 0 0 1 1 1 0 1 0
1 0 1 0 1 1 1 1 0 1
0 0 1 0 1 1 1 0 0 1
1 0 1 0 1 1 1 1 1 1
0 0 1 0 0 0 1 0 0 1
1 0 0 1 1 1 1 0 1 1
0 0 0 1 0 0 0 0 0 1
1 0 1 1 0 0 1 1 1 1
1 0 1 1 1 0 0 1 0 1
1 1 0 0 1 1 1 0 1 1
0 0 0 1 0 0 1 0 0 1
0 0 1 0 1 ...

output:

8
9
6
6
7
7
6
9
6
9
8
8
5
9
9
9
8
8
7
7
8
7
7
8
8
7
7
7
7
6
8
9
7
7
7
6
9
9
7
8
7
6
8
9
7
6
6
6
7
9
9
8
8
9
8
6
8
7
7
5
7
6
7
7
6
7
6
8
6
8
7
7
8
7
7
9
8
8
8
8
8
7
6
6
8
9
7
7
8
7
8
9
8
7
8
8
7
6
8
9
10
7
8
8
8
9
8
8
8
8
8
7
7
8
7
6
10
8
7
7
8
10
7
7
8
6
6
5
8
7
5
8
6
10
7
9
8
8
8
8
7
8
10
7
8
7
7
8...

result:

ok 300000 numbers

Subtask #5:

score: 15
Accepted

Dependency #4:

100%
Accepted

Test #66:

score: 15
Accepted
time: 32ms
memory: 15028kb

input:

299999 14
0 0 0 1 1 0 1 0 0 0 1 1 1 1
0 0 1 0 1 0 1 1 1 1 0 1 0 0
0 0 1 1 0 0 0 0 1 1 1 1 1 0
1 0 0 0 1 1 0 0 0 1 1 1 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
6
6
6
7
6
7
7
7
6
6
7
6
6
7
7
6
6
6
6
7
6
7
7
6
7
7
6
7
7
6
6
7
6
6
6
7
7
6
7
6
6
6
7
6
7
6
6
6
6
7
7
7
7
7
6
6
7
...

result:

ok 299997 numbers

Test #68:

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

input:

299997 13
0 1 0 0 1 0 0 0 1 1 1 1 0
1 1 0 1 0 0 1 0 0 1 1 0 0
0 1 1 0 0 1 0 0 1 1 0 1 0
0 0 0 1 1 0 0 1 1 1 0 1 1
1 1 0 0 1 0 0 0 1 0 1 1 0
0 1 1 1 0 1 0 0 1 0 0 1 0
1 0 0 1 1 1 0 0 1 0 0 1 0
1 0 1 1 0 0 0 1 1 0 0 1 0
0 0 1 1 0 0 1 1 1 1 0 0 1
1 0 1 0 1 1 0 0 0 1 1 0 1
0 1 0 0 1 1 0 1 0 0 1 1 0
1 1 ...

output:

7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
...

result:

ok 299997 numbers

Test #69:

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

input:

300000 14
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 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:

14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 300000 numbers

Test #70:

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

input:

300000 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #71:

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

input:

300000 14
1 1 1 1 0 0 1 1 1 0 1 1 1 0
1 0 0 1 1 0 0 1 0 0 0 1 0 1
1 0 1 1 1 1 0 1 1 1 0 1 1 1
1 0 0 1 0 1 1 0 1 0 0 0 1 0
1 0 0 1 0 0 1 1 1 0 0 1 1 1
1 1 0 1 0 0 1 1 1 1 1 0 0 1
1 0 1 1 1 1 1 0 1 1 0 0 0 0
0 1 0 1 0 0 1 1 0 1 0 1 1 0
0 1 0 1 1 1 1 1 1 0 1 0 1 1
1 1 1 0 1 0 0 0 1 1 0 1 0 1
1 0 1 1 1 ...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 300000 numbers

Test #72:

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

input:

300000 14
1 1 1 1 0 0 1 0 0 1 0 0 0 1
0 1 1 1 0 1 0 1 0 1 1 0 0 1
1 0 0 1 1 0 0 1 1 0 1 0 1 0
1 1 0 0 1 0 1 0 0 1 1 0 0 1
1 1 0 1 1 0 0 1 1 0 0 0 1 0
1 1 1 1 0 1 0 0 1 1 1 1 1 1
1 0 1 1 0 1 0 1 0 1 1 0 1 0
1 1 1 0 1 0 1 0 0 0 0 1 1 0
1 1 1 0 0 1 0 0 0 1 0 0 0 1
0 1 1 1 1 1 1 1 0 0 0 1 1 1
1 0 0 0 0 ...

output:

12
10
10
14
10
9
9
12
12
9
12
12
11
10
10
12
11
11
12
11
12
12
13
9
12
11
13
11
11
8
12
14
12
10
9
13
11
12
12
11
11
12
10
11
12
10
12
10
10
11
11
10
12
10
11
12
9
10
12
10
11
11
10
10
10
10
9
11
12
11
11
13
11
13
10
11
9
10
11
9
11
12
11
11
11
10
12
9
12
10
11
11
11
11
13
9
13
11
11
12
12
11
11
11
...

result:

ok 300000 numbers

Subtask #6:

score: 22
Accepted

Dependency #5:

100%
Accepted

Test #73:

score: 22
Accepted
time: 18ms
memory: 11064kb

input:

300000 16
0 1 0 1 0 1 1 1 1 1 1 0 0 0 1 0
1 1 1 1 0 0 1 1 1 0 0 0 0 1 1 1
1 1 1 0 1 1 0 1 1 0 1 0 0 0 0 1
0 1 0 0 1 0 1 0 0 1 1 1 1 0 1 0
1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 1
1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 1
0 0 1 0 1 0 0 1 1 0 1 1 1 0 0 1
0 0 1 1 0 1 0 0 1 1 1 1 1 0 1 1
1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1
0 ...

output:

16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
...

result:

ok 300000 numbers

Test #74:

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

input:

114692 17
0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 0 0
1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 0
1 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0 0
1 1 1 1 1 1 0 1 1 0 1 1 0 1 0 0 0
0 0 0 0 0 0 1 1 1 0 0 1 0 1 1 0 0
1 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1
1 1 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0
0 0 0 1 0 0 0 0 1 0 1 1 1 1 0 1 0
1 1 1 0 1 0 0 1 1 ...

output:

17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
...

result:

ok 114692 numbers

Test #75:

score: 0
Accepted
time: 30ms
memory: 10852kb

input:

122884 17
1 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 0
0 1 1 1 1 0 0 1 0 0 0 0 0 1 1 1 0
1 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1
1 0 1 1 0 1 0 1 0 1 1 1 1 1 0 1 0
0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0
0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0
1 0 1 1 0 1 0 0 1 1 1 1 1 0 0 1 0
0 1 0 0 0 1 0 1 0 0 1 1 1 0 1 0 1
1 0 0 1 1 0 0 1 0 ...

output:

17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
...

result:

ok 122884 numbers

Test #76:

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

input:

126980 17
1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 1 0
0 1 0 1 0 1 1 0 1 0 0 1 1 1 0 0 1
0 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 0
0 0 1 0 1 1 1 1 0 1 0 0 0 1 0 0 0
0 0 0 1 0 1 1 0 1 1 1 1 1 0 0 0 0
0 0 1 1 1 0 1 0 1 1 0 0 0 1 1 0 0
0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0
0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 1 1
0 0 0 0 0 1 1 1 0 ...

output:

17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
...

result:

ok 126980 numbers

Test #77:

score: 0
Accepted
time: 30ms
memory: 15628kb

input:

299999 16
0 1 0 1 0 0 0 0 0 1 1 1 1 0 1 1
0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1
0 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0
1 1 0 0 0 1 1 1 0 1 1 1 0 0 0 0
0 0 1 1 1 0 0 0 0 1 1 1 1 1 0 0
1 0 0 1 0 0 1 0 0 1 1 1 0 1 0 1
1 0 0 1 1 1 0 1 0 0 0 1 1 1 0 0
1 0 1 1 1 0 0 1 1 1 0 0 1 0 0 0
0 0 0 0 1 0 1 1 1 0 1 1 1 0 1 0
0 ...

output:

8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
...

result:

ok 299999 numbers

Test #78:

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

input:

299997 17
1 1 0 0 1 0 0 0 1 0 0 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
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
...

result:

ok 299997 numbers

Test #80:

score: 0
Accepted
time: 26ms
memory: 11084kb

input:

300000 17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 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:

17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
...

result:

ok 300000 numbers

Test #81:

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

input:

300000 17
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0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8
8
8
...

result:

ok 300000 numbers

Test #83:

score: 0
Accepted
time: 50ms
memory: 16760kb

input:

300000 17
1 1 1 1 1 0 0 0 1 1 1 0 0 1 1 0 1
1 1 0 1 0 0 1 1 0 1 1 0 1 0 1 1 1
0 1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1
0 1 1 1 0 0 1 0 1 0 1 0 0 0 0 0 1
0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 1 1
1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 0 1
1 0 0 1 1 0 0 0 1 0 1 1 0 1 1 1 0
1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 1 1
0 0 0 0 1 0 0 1 0 ...

output:

12
12
15
14
13
14
14
12
15
14
14
13
14
11
12
13
15
13
15
15
14
14
15
14
13
12
13
14
14
12
12
14
14
15
13
13
14
13
15
13
15
15
15
14
14
13
13
14
14
13
13
16
14
14
14
15
15
16
15
13
15
12
14
14
14
15
15
13
16
14
13
13
15
14
15
14
13
15
13
16
14
13
15
14
14
12
14
15
12
13
14
15
13
13
15
17
12
13
15
12
...

result:

ok 300000 numbers

Subtask #7:

score: 22
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

Test #84:

score: 22
Accepted
time: 191ms
memory: 32204kb

input:

299999 20
1 1 1 1 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 0
0 1 1 0 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0
0 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1
0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 0 1
1 1 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1
0 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0
0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 0
1 1 1 1 1 ...

output:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
...

result:

ok 299999 numbers

Test #85:

score: 0
Accepted
time: 191ms
memory: 31940kb

input:

300000 20
0 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1 0 1 0 0 0 1 1 0 1 1
0 1 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 0
1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1
1 1 1 1 1 ...

output:

7
0
6
14
0
7
13
7
7
13
6
6
6
20
13
7
7
7
13
20
0
13
7
7
0
13
7
7
0
14
7
20
7
7
0
7
14
20
6
13
7
13
0
20
20
7
7
13
0
14
13
13
0
14
6
6
14
14
14
13
7
7
14
13
0
7
6
13
7
6
7
14
13
14
13
14
14
7
7
7
14
0
13
7
0
14
7
20
13
7
7
0
6
7
13
13
7
7
14
13
6
14
7
14
14
13
13
7
6
20
13
0
20
13
6
7
20
6
13
13
6
7
...

result:

ok 300000 numbers

Test #86:

score: 0
Accepted
time: 196ms
memory: 32788kb

input:

299999 20
0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0
1 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1
0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 1
1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 0 1 1
1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0
1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
1 1 1 0 0 ...

output:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
...

result:

ok 299999 numbers

Test #87:

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

input:

300000 20
1 0 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 1 0 0
1 1 0 0 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0
1 1 0 0 1 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0
1 1 0 1 0 1 0 0 1 1 0 1 0 0 1 0 0 0 1 1
1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 1
0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 0 0 0 1 1
1 0 1 1 1 0 1 1 1 0 1 1 0 0 0 0 1 0 0 0
0 1 0 1 1 ...

output:

10
9
10
9
10
10
9
10
10
10
10
10
10
9
10
10
10
10
9
10
10
10
10
10
9
9
10
10
9
10
9
10
9
9
10
9
10
10
10
10
10
10
10
10
10
9
9
9
9
10
10
10
10
10
10
10
9
9
10
10
10
10
9
9
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
9
10
10
10
9
9
10
10
10
10
9
10
10
10
10
10
10
10
10
9
10
10
9
10
10
10
10
10
10
10
...

result:

ok 300000 numbers

Test #88:

score: 0
Accepted
time: 207ms
memory: 32092kb

input:

299999 20
1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 1
1 1 0 1 0 1 0 1 1 0 0 0 0 1 0 0 1 1 1 0
0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0
0 1 0 1 1 1 0 1 0 0 0 0 0 0 1 1 1 1 0 1
1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 0 1 1 0 0
1 1 1 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0
1 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 1 1 0
1 0 0 1 1 ...

output:

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

result:

ok 299999 numbers

Test #89:

score: 0
Accepted
time: 121ms
memory: 23452kb

input:

299997 19
1 0 0 1 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1
0 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1
1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 0
0 1 1 0 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0
1 1 1 0 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0
0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1
1 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0 1 0
1 0 0 1 1 1 1 1 1 0 1 1 ...

output:

9
9
10
10
10
9
10
10
9
10
10
10
10
9
10
9
10
10
9
10
10
10
9
10
10
10
9
9
10
10
9
9
10
9
9
10
10
9
10
10
9
9
10
10
9
9
10
10
9
10
10
9
9
10
10
9
10
9
10
10
9
10
10
9
9
9
10
10
9
10
9
9
10
10
9
9
9
9
10
10
10
10
10
9
10
9
10
10
10
9
10
10
9
9
10
9
10
10
9
9
9
9
9
9
10
9
10
9
10
9
9
10
9
10
10
9
10
9
...

result:

ok 299997 numbers

Test #90:

score: 0
Accepted
time: 118ms
memory: 23204kb

input:

299997 19
0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0
1 0 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1
1 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 0 0 0
0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0
0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1
0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 0 1
1 1 0 0 0 0 1 1 1 1 0 1 0 0 0 1 0 1 0
0 1 0 0 1 1 1 1 0 0 1 1 ...

output:

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

result:

ok 299997 numbers

Test #91:

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

input:

300000 20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 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:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
...

result:

ok 300000 numbers

Test #92:

score: 0
Accepted
time: 33ms
memory: 11304kb

input:

300000 20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #93:

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

input:

300000 20
1 1 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 0 1 0
1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0
0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0
0 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0
1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0
1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0
0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 0 0 1 0
0 1 0 1 1 ...

output:

8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
...

result:

ok 300000 numbers

Test #94:

score: 0
Accepted
time: 219ms
memory: 32004kb

input:

300000 20
1 1 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0
1 1 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 1 1
0 1 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0
1 1 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 0 1
0 1 0 0 0 1 0 1 1 1 1 0 1 0 0 1 0 1 1 0
1 0 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1
0 1 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1
1 1 0 1 0 ...

output:

15
16
12
16
15
12
14
17
16
17
10
11
12
14
16
13
11
15
14
14
12
10
12
14
13
13
11
11
12
14
13
12
13
13
13
14
9
16
13
14
12
16
12
12
13
13
13
11
14
17
14
15
13
12
18
14
12
17
15
15
14
11
12
16
13
15
14
13
16
13
15
12
15
13
15
13
12
15
15
12
14
11
12
14
16
16
14
15
13
16
12
16
12
17
17
13
14
13
13
11
1...

result:

ok 300000 numbers

Extra Test:

score: 0
Extra Test Passed