Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
put = []

for i in reversed(range(N)):
    if A[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                A[tmp-1] ^= 1
                if tmp != n//tmp:
                    A[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = [0]*N
put = []

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
                if tmp != n//tmp:
                    B[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = [0]*N
put = []

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
                if tmp != n//tmp:
                    B[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = [0]*N
put = []

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
                if tmp != n//tmp:
                    B[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(input()) for _ in range(N)]
Q = [L[0]]

for l in L[1:]:
    r = bisect.bisect_left(Q, l)
    if r == 0:
        Q.insert(0, l)
    else:
        Q[r-1] = l
print(len(Q))


Fixed submission:
from collections import deque
import bisect

N = int(input())
L = [int(input()) for _ in range(N)]
Q = deque()
Q.append(L[0])

for l in L[1:]:
    r = bisect.bisect_left(Q, l)
    if r == 0:
        Q.appendleft(l)
    else:
        Q[r-1] = l
print(len(Q))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(input()) for _ in range(N)]
Q = [L[0]]

for l in L[1:]:
    #print("Q=>", Q)
    Q = sorted(Q)
    r = bisect.bisect_left(Q, l)
    if r == 0:
        Q.append(l)
        Q = sorted(Q)
    else:
        Q[r-1] = l
print(len(Q))


Fixed submission:
from collections import deque
import bisect

N = int(input())
L = [int(input()) for _ in range(N)]
Q = deque()
Q.append(L[0])

for l in L[1:]:
    r = bisect.bisect_left(Q, l)
    if r == 0:
        Q.appendleft(l)
    else:
        Q[r-1] = l
print(len(Q))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
colored = [0]*N
for i in range(N):
    if colored[i] != 0:
        continue
    else:
        ans += 1
        tmp = A[i]
        colored[i] = ans
    for j in range(i+1, N):
        if A[j] > tmp and colored[j] == 0:
            colored[j] = ans
            tmp = A[j]
print(ans)


Fixed submission:
from collections import deque
import bisect

N = int(input())
L = [int(input()) for _ in range(N)]
Q = deque()
Q.append(L[0])

for l in L[1:]:
    r = bisect.bisect_left(Q, l)
    if r == 0:
        Q.appendleft(l)
    else:
        Q[r-1] = l
print(len(Q))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))


low=0
high=10**10

#binary search the value of rain onto Mountain1
while low<=high:
    mid=(low+high)//2

    cur=mid
    for i,a in enumerate(A):
        cur=a-cur
        if cur<0:#途中で足りなくなったら、midが大きすぎ
            break
       #break
    if cur>=mid:
        low=mid+1
    else:
        if i%2==0:
            low=mid+1
        else:
          	high=mid-1
            low=mid+1


ans=[]
cur=high
for a in A:
    ans.append(cur*2)
    cur=a-cur
print(" ".join(map(str,ans)))



Fixed submission:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans[:-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))


low=0
high=10**9*2

#binary search the value of rain onto Mountain1
while low<=high:
    mid=(low+high)//2

    cur=mid
    for a in A:
        cur=a-cur
        if cur<0:#途中で足りなくなったら、midが大きすぎ
            break
       #break
    if cur>=mid:
        low=mid+1
    else:
        high=mid-1


ans=[]
cur=high
for a in A:
    ans.append(cur*2)
    cur=a-cur
assert cur==high
print(" ".join(map(str,ans)))






    



Fixed submission:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans[:-1])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
from collections import Counter
input = sys.stdin.readline

S=input[:-1]
C=Counter(S)
if all([v==2 for key,v in C.items()]):
    print("Yes")
else:
    print("No")

    


Fixed submission:
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
C = Counter(S)
if all([v == 2 for key, v in C.items()]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

N3=N*3
grid=[[-1]*(N3) for _ in range(N3)]

for a,b in edges:
    for i in range(3):
        start = a+N*i
        dst = b+N*(i+1)
        grid[start%N3][dst%N3]=1


Q=[S]
visited={S}
dist=[-1]*N3
dist[S]=0

while Q:
    tmp=[]
    for q in Q:
        for i in range(N3):
            nex = grid[q][i]
            if nex==-1:
                continue
            elif i in visited:
                continue
            else:
                dist[i]=dist[q]+1
                visited.add(i)
                tmp.append(i)
    Q = tmp
print(dist[T] if dist[T]==-1 else dist[T]//3)



Fixed submission:
N,M = map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

N3=N*3
adj=[set() for _ in range(N3)]

for a,b in edges:
    for i in range(3):
        start = a+N*i
        dst = b+N*(i+1)
        adj[start%N3].add(dst%N3)


Q=[S]
visited={S}
dist=[-1]*N3
dist[S]=0

while Q:
    tmp=[]
    for q in Q:
        for i in adj[q]:
            if i in visited:
                continue
            else:
                dist[i]=dist[q]+1
                visited.add(i)
                tmp.append(i)
    Q = tmp
print(dist[T] if dist[T]==-1 else dist[T]//3)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

N3=N*3
grid=[[-1]*(N3) for _ in range(N3)]

for a,b in edges:
    for i in range(3):
        start = a+N*i
        dst = b+N*(i+1)
        grid[start%N3][dst%N3]=1


Q=[S]
visited={S}
dist=[-1]*N3
dist[S]=0

while Q:
    tmp=[]
    for q in Q:
        for i in range(N3):
            nex = grid[q][i]
            if nex==-1:
                continue
            elif i in visited:
                continue
            else:
                dist[i]=dist[q]+1
                visited.add(i)
                tmp.append(i)
    Q = tmp
print(dist[T] if dist[T]==-1 else dist[T]//3)



Fixed submission:
N,M = map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

N3=N*3
adj=[set() for _ in range(N3)]

for a,b in edges:
    for i in range(3):
        start = a+N*i
        dst = b+N*(i+1)
        adj[start%N3].add(dst%N3)


Q=[S]
visited={S}
dist=[-1]*N3
dist[S]=0

while Q:
    tmp=[]
    for q in Q:
        for i in adj[q]:
            if i in visited:
                continue
            else:
                dist[i]=dist[q]+1
                visited.add(i)
                tmp.append(i)
    Q = tmp
print(dist[T] if dist[T]==-1 else dist[T]//3)
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, K = map(int, input().split())

    if K > (N-1)*(N-2)//2:
        print(-1)
    else:
        edges = []
        m = N-1+(N-1)*(N-2)//2-K
        for i in range(1, N+1):
            edges.append("{} {}".format(1, i))

        add_edge = (N-1)*(N-2)//K

        fr = 2
        to = 3
        while add_edge:
            edges.append("{} {}".format(fr, to))
            to += 1
            if to >= N:
                fr += 1
                to = fr+1
            add_edge -= 1
        print(m)
        print("\n".join(edges))


solve()


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, K = map(int, input().split())

    if K > (N-1)*(N-2)//2:
        print(-1)
    else:
        edges = []
        m = N-1+(N-1)*(N-2)//2-K
        for i in range(2, N+1):
            edges.append("{} {}".format(1, i))

        add_edge = (N-1)*(N-2)//2-K

        fr = 2
        to = 3
        while add_edge:
            edges.append("{} {}".format(fr, to))
            to += 1
            if to > N:
                fr += 1
                to = fr+1
            add_edge -= 1
        print(m)
        print("\n".join(edges))


solve()
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
import bisect
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))

A_acc = [0]+list(accumulate(A))
ans = 0
# スタート位置を固定して、にぶたん
for l in range(N):
    tmp_acc = [v-A_acc[l] for v in A_acc]
    right = bisect.bisect_left(tmp_acc, K)
    ans += max(N-right+1, 0)

print(ans)


Fixed submission:
X,A=map(int,input().split())
print("1"*(X>=A)+"0")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
P = set(tuple(map(int, input().split())) for _ in range(N))

p_q_cand = []
for p in P:
    for q in P:
        if p == q:
            continue
        diff_p = p[0]-q[0]
        diff_q = p[1]-q[1]
        p_q_cand.append((abs(diff_p), abs(diff_q)))

C = Counter(p_q_cand)
p, q = C.most_common()[0][0]
ans = 0
used = set()
for a, b in sorted(P):
    if (a-p, b-q) not in used:
        ans += 1
    used.add((a, b))
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))
P = sorted(P)

p_q_cand = []
for i in range(N):
    for j in range(i+1, N):
        diff_p = P[j][0]-P[i][0]
        diff_q = P[j][1]-P[i][1]
        p_q_cand.append((diff_p, diff_q))

if N == 1:
    print(1)
else:
    C = Counter(p_q_cand)
    ans = float('inf')
    for v, c in C.items():
        p = v[0]
        q = v[1]
        tmp = 0
        used = set()
        for a, b in sorted(list(P), key=lambda x: (x[0], x[1])):
            if (a-p, b-q) not in used:
                tmp += 1
            used.add((a, b))
        ans = min(ans, tmp)
    print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
P = set(tuple(map(int, input().split())) for _ in range(N))

p_q_cand = []
for p in P:
    for q in P:
        if p == q:
            continue
        diff_p = p[0]-q[0]
        diff_q = p[1]-q[1]
        p_q_cand.append((abs(diff_p), abs(diff_q)))

C = Counter(p_q_cand)
p, q = C.most_common()[0][0]
ans = 0
used = set()
for a, b in sorted(P):
    if (a-p, b-q) not in used:
        ans += 1
    used.add((a, b))
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))
P = sorted(P)

p_q_cand = []
for i in range(N):
    for j in range(i+1, N):
        diff_p = P[j][0]-P[i][0]
        diff_q = P[j][1]-P[i][1]
        p_q_cand.append((diff_p, diff_q))

if N == 1:
    print(1)
else:
    C = Counter(p_q_cand)
    ans = float('inf')
    for v, c in C.items():
        p = v[0]
        q = v[1]
        tmp = 0
        used = set()
        for a, b in sorted(list(P), key=lambda x: (x[0], x[1])):
            if (a-p, b-q) not in used:
                tmp += 1
            used.add((a, b))
        ans = min(ans, tmp)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
sum_L = sum(L)
N_neg = bisect.bisect_left(L, 0)
process = []
if N_neg == 0:  # minのみ-にする
    ans = sum_L-min(L)*2
    l = min(L)
    for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
elif N_neg == N:  # maxのみを+にする
    ans = -sum_L(L)+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r
else:  # negのやつを-にする
    ans = sum([abs(v) for v in L])
    l = L[0]
    for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
    l = L[-1]-l
    for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r
print(ans)
print("\n".join(process))


Fixed submission:
import bisect
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
sum_L = sum(L)
N_neg = bisect.bisect_left(L, 0)
process = []
if N_neg == 0:  # minのみ-にする
    ans = sum_L-min(L)*2
    l = min(L)
    for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
elif N_neg == N:  # maxのみを+にする
    ans = -sum_L+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r
else:  # negのやつを-にする
    ans = sum([abs(v) for v in L])
    l = L[0]
    for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
    l = L[-1]-l
    for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r
print(ans)
print("\n".join(process))
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L[B-2:min(C, D)]):
        print("Yes")
	e;se:
      print("No")

Fixed submission:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L[B-2:min(C, D)+1]):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def brute_force():
    N, M = map(int, input().split())
    lamps = [list(map(lambda x:int(x)-1, input().split()))[1:]
             for _ in range(M)]
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for r in range(M):
            on_sum = 0
            for j in range(M):
                if i >> j & 1 and lamps[r][0]<=j<=lamps[r][1]:
                    on_sum += 1
            if on_sum % 2 == p[r]:
                continue
            else:
                break
        else:
            ans += 1
    print(ans)


brute_force()


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def brute_force():
    N, M = map(int, input().split())
    lamps = [list(map(lambda x:int(x)-1, input().split()))[1:]
             for _ in range(M)]
    p = list(map(int, input().split()))
    ans = 0

    for i in range(1 << N):
        for r in range(M):
            on_sum = 0
            for j in range(N):
                if i >> j & 1 and j in lamps[r]:
                    on_sum += 1
            if on_sum % 2 != p[r]:
                break
        else:
            ans += 1
    print(ans)


brute_force()
Buggy python submission (verdict: Runtime Error):
from itertools import accumurate
N,M=map(int,input().split())
L = [0]*(N+1)
for _ in range(M):
  l,r = map(lambda x:int(x)-1,input().split())
  L[l]+=1
  L[r+1]+=1

L = list(accumurate(L))
print(L.count(M)) 

Fixed submission:
from itertools import accumulate
N,M=map(int,input().split())
L = [0]*(N+1)
for _ in range(M):
  l,r = map(lambda x:int(x)-1,input().split())
  L[l]+=1
  L[r+1]-=1

L = list(accumulate(L))
print(L.count(M))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
L = list(map(int, input().split()))
OP = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(L)
OP = sorted(OP, key=lambda x: x[1], reverse=True)
ans = 0

for m, n in OP:
    for _ in range(m):
        head = heapq.heappop(L)
        if head < n:
            ans += n
        else:
            print(ans+sum(L)+head)
            exit()
print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
L = list(map(int, input().split()))
OP = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(L)
OP = sorted(OP, key=lambda x: x[1], reverse=True)
ans = 0

for m, n in OP:
    for _ in range(m):
        if L:
            head = heapq.heappop(L)
            if head < n:
                ans += n
            else:
                print(ans+sum(L)+head)
                exit()
        else:
            print(ans)
            exit()
print(ans+sum(L))
Buggy python submission (verdict: Runtime Error):
from math import ceil
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=5 else 4 +ceil(N/min(L))


Fixed submission:
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=N else 4 -((-N)//min(L)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=5 else 4 -((-N)//min(L))


Fixed submission:
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=N else 4 -((-N)//min(L)))
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def f(a):
    """
    xor [0,a]
    """
    ans = 0
    l = []
    d = 2
    while (a+1)//d > 0:
        t = (a+1)//d*(d//2)+max((a+1) % d-d//2, 0)
        ans += (t % 2)*(d//2)
        l.append(t % 2)
        d *= 2
    ans += (((a+1)-d) % 2)*(d//2)
    l.append(((a+1)-d) % 2)
    return l


def solve2(a, b):
    rb = f(b)
    ra = f(a-1)
    for i in range(len(ra)):
        rb[i] ^= ra[i]
    ans = "".join(map(str, reversed(rb)))
    print(int(ans, 2))


A, B = map(int, input().split())
if A == 0 and B == 0:
    print(0)
else:
    solve2(A, B)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M, C = map(int, input().split())
B = list(map(int, input().split()))

cnt = 0
for _ in range(N):
    A = list(map(int, input().split()))
    s = sum([a*b for a, b in zip(A, B)])
    if s+C > 0:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
from functools import reduce
from math import log2
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def floor(x, y):
    return int((-x)//y*(-1))


def floorlog(x):
    if x > 0:
        return floor(log2(x), 1)
    else:
        return 0


def XXor(X, A):
    #    print("x,a->", X, A)
    return X ^ A


N, K = map(int, input().split())
A = list(map(int, input().split()))


def xorSum(X):
    ret = 0
    for a in A:
        ret += XXor(X, a)
    return ret


def solve():

    ans = 0
    ans_x = 0
    for x in range(K+1):
        tmp = xorSum(x)
        if tmp > ans:
            ans = tmp
            ans_x = x
    # print("ans_x->", ans_x)

    return ans


def solve2():
    a = sorted(A, reverse=True)
    ans = reduce(XXor, a)
    k_log = floorlog(K)
    a_log = floorlog(a[0])
    if k_log == a_log:
        ans = ans
    else:
        a.ppend(K)
        ans = reduce(XXor, a)

    return xorSum(ans)


# print("1---->", solve())
# print("2----->", solve2())
print(solve2())


Fixed submission:
# python template for atcoder1
from functools import reduce
from math import log2
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def floor(x, y):
    return int((-x)//y*(-1))


def floorlog(x):
    if x > 0:
        return floor(log2(x), 1)
    else:
        return 0


def XXor(X, A):
    #    print("x,a->", X, A)
    return X ^ A


N, K = map(int, input().split())
A = list(map(int, input().split()))


def xorSum(X):
    ret = 0
    for a in A:
        ret += XXor(X, a)
    return ret


def solve():

    ans = 0
    ans_x = 0
    for x in range(K+1):
        tmp = xorSum(x)
        if tmp > ans:
            ans = tmp
            ans_x = x
    # print("ans_x->", ans_x)

    return ans


def solve2():
    ans = 0
    for i in reversed(range(0, 40)):
        b = sum([(a >> i) % 2 for a in A])*2 < N
        if b and ans+(1 << i) <= K:
            ans += (1 << i)
        else:
            continue
    return xorSum(ans)


print(solve2())