Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import math

line = input()
N = line.split(' ')[0]
D = line.split(' ')[1]

count = 0

for i in range(1,int(D)):
  inputs = input()
  X = int(inputs.split(' ')[0])
  Y = int(inputs.split(' ')[1])
  if(math.sqrt(pow(X,2) + pow(Y,2)) <= int(D) ):
    count = count + 1

print(count)

Fixed submission:
import sys
import math

line = input()
N = line.split(' ')[0]
D = line.split(' ')[1]

count = 0

for i in range(int(N)):
  inputs = input()
  X = int(inputs.split(' ')[0])
  Y = int(inputs.split(' ')[1])
  if(math.sqrt(pow(X,2) + pow(Y,2)) <= int(D) ):
    count = count + 1

print(count)
Buggy python submission (verdict: Runtime Error):
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(mt.gcd,H))

Fixed submission:
# Hariom_Pandey
# 11.11.2019
from functools import reduce
from fractions import gcd
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(gcd,H))

Buggy python submission (verdict: Runtime Error):
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split())) 
print(reduce(mt.gcd,H))


Fixed submission:
# Hariom_Pandey
# 11.11.2019
from functools import reduce
from fractions import gcd
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(gcd,H))
Buggy python submission (verdict: Time Limit Exceeded):
N = input()

cnt = 0
for s in N:
    cnt += int(N)

if cnt % 9 == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()

cnt = 0
for s in N:
    cnt += int(s)

if cnt % 9 == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S,T=map(string,input().split())
ans=T+S
print(ans\n)

Fixed submission:
S,T=input().split()
print(T+S)

Buggy python submission (verdict: Runtime Error):
S,T=map(string, input().split())
print(S+T)

Fixed submission:
S,T=input().split()
print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        sol = 0
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)
Buggy python submission (verdict: Runtime Error):
n=int(inpt())
c=n**3
print(c)

Fixed submission:
n=int(input())
c=n**3
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
c=0
for i in range(n):
  c+=1//a[i]
print(1//c)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
c=0
for i in range(n):
  c+=a[i]**(-1)
print(c**(-1))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
c=0
for i in range(n):
  c+=1//i
print(1//c)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
c=0
for i in range(n):
  c+=a[i]**(-1)
print(c**(-1))
Buggy python submission (verdict: Runtime Error):
n=int(input(())
v=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
s=0
for i in range(n):
  if v[i]>c[i]:
    s+=v[i]-c[i]
print(s)

Fixed submission:
n=int(input())
v=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
s=0
for i in range(n):
  d=v[i]-c[i]
  if d>0:
    s+=d
print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=(int(x) for x in input().split())
a.sort(reverse=True)
alice=0
bob=0
for i in range(0,n,2):
  alice+=a[i]
for i in range(1,n,2):
  bob+=a[i]
print(alice-bob)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
a.sort(reverse=True)
alice=0
bob=0
for i in range(0,n,2):
  alice+=a[i]
for i in range(1,n,2):
  bob+=a[i]
print(alice-bob)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a1=[int(x) for x in input(.split())]
a2=[int(x) for x in input(.split())]
max=0
for i in range(1,n+1):
  count=sum(a1[:i])+sum(a2[i-1:])
  max=count if max < count
print(max)

Fixed submission:
n=int(input())
a1=[int(x) for x in input().split()]
a2=[int(x) for x in input().split()]
max=0
for i in range(1,n+1):
  count=sum(a1[:i])+sum(a2[i-1:])
  if max<count:
    max=count
print(max)
Buggy python submission (verdict: Runtime Error):
n,a,b=(int(input().split()))
c=0
for i in range(n+1):
  d=0
  for j in str(i):
    d+=int(j)
  if a<=d<=b:
    c+=1
print(c)

Fixed submission:
n,a,b=(int(x) for x in input().split())
c=0
for i in range(n+1):
  d=0
  for j in str(i):
    d+=int(j)
  if a<=d<=b:
    c+=i
print(c)

Buggy python submission (verdict: Runtime Error):
n,a,b=int(input().split())
c=0
for i in range(n+1):
  d=0
  for j in str(i):
    d+=int(j)
  if a<=d<=b:
    c+=1
print(c)

Fixed submission:
n,a,b=(int(x) for x in input().split())
c=0
for i in range(n+1):
  d=0
  for j in str(i):
    d+=int(j)
  if a<=d<=b:
    c+=i
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())

a = []
for _ in range(n):
    aa = input().split('.')
    aaa = int(aa[0])*10**9
    if len(aa) == 2:
        aaa += int(aa[1])*10**(9-len(aa[1]))
    a2, a5 = 0, 0
    while aaa % 2 == 0:
        a2 += 1
        aaa = aaa // 2
    while aaa % 5 == 0:
        a5 += 1
        aaa = aaa // 5
    a.append([a2, a5])

na = np.array(a)

ans = 0
for i, aa in enumerate(a):
    ans += np.count_nonzero((na[i+1:, 0] >= 18-aa[0]) & (na[i+1:, 1] >= 18-aa[1]))

print(ans)


Fixed submission:
import numpy as np

n = int(input())

ans = 0
ma = np.zeros((19, 19), dtype=np.int)
for _ in range(n):
    aa = input().split('.')
    a2, a5 = 0, 0
    if len(aa) == 1:
        aaa = int(aa[0])
        a2, a5 = 9, 9
    else:
        aaa = int(aa[0]) * 10 ** 9
        aaa += int(aa[1])*10**(9-len(aa[1]))

    while aaa % 2 == 0:
        a2 += 1
        aaa = aaa // 2
    while aaa % 5 == 0:
        a5 += 1
        aaa = aaa // 5

    a2, a5 = min(a2, 18), min(a5, 18)

    oa2, oa5 = 18-a2, 18-a5
    ans += ma[oa2, oa5]

    ma[:a2+1, :a5+1] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = input()

c = x.count('1')
cp = c+1
cn = c-1

rp = [0] * n
if cp > 1:
    rp[0] = 1
rn = [0] * n
if cn > 1:
    rn[0] = 1
for i in range(1, n):
    rp[i] = (rp[i-1] * 2) % cp
    rn[i] = (rn[i-1] * 2) % cn

xp = 0
xn = 0
for i in range(n):
    xx = x[i]
    if xx == '1':
        xp = (xp + rp[n-i-1]) % cp
        xn = (xn + rn[n-i-1]) % cn

for i in range(n):
    o = 1
    if x[i] == '1':
        xx = (xn-rn[n-i-1]) % cn
    else:
        xx = (xp+rp[n-i-1]) % cp
    while xx > 0:
        cc = bin(xx)[2:].count('1')
        xx = xx % cc
        o += 1
    print(o)


Fixed submission:
n = int(input())
x = input()

c = x.count('1')
cp = c+1
cn = c-1

rp = [0] * n
if cp > 1:
    rp[0] = 1
rn = [0] * n
if cn > 1:
    rn[0] = 1
for i in range(1, n):
    rp[i] = (rp[i-1] * 2) % cp
    if cn > 0:
        rn[i] = (rn[i-1] * 2) % cn

xp = 0
xn = 0
for i in range(n):
    xx = x[i]
    if xx == '1':
        xp = (xp + rp[n-i-1]) % cp
        if cn > 0:
            xn = (xn + rn[n-i-1]) % cn

for i in range(n):
    o = 1
    if x[i] == '1':
        if cn == 0:
            print(0)
            continue
        xx = (xn-rn[n-i-1]) % cn
    else:
        xx = (xp+rp[n-i-1]) % cp
    while xx > 0:
        cc = bin(xx)[2:].count('1')
        xx = xx % cc
        o += 1
    print(o)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = map(int, input().split())
d = Counter(a)

s = sum([k*v for k, v in d.items()])

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b not in d.keys():
        print(s)
        continue
    cc = 0
    if c in d.keys():
        cc = d[c]
    d[c] = cc + d[b]
    del d[b]
    s = sum([k * v for k, v in d.items()])
    print(s)


Fixed submission:
from collections import Counter

n = int(input())
a = map(int, input().split())
d = Counter(a)

s = sum([k*v for k, v in d.items()])

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b not in d.keys():
        print(s)
        continue
    cc = 0
    s = s + (c-b) * d[b]
    print(s)
    if c in d.keys():
        cc = d[c]
    d[c] = cc + d[b]
    del d[b]
Buggy python submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1

m = [[-1] * w for _ in range(h)]
for hh in range(h):
    c = input()
    for ww, cc in enumerate(c):
        if cc == '.':
            m[hh][ww] = h*w

from collections import deque
q = deque()

q.append((0, x1, y1))
while q:
    s, x, y = q.popleft()

    for i in range(1, k+1):
        xx, yy = x + i, y
        if xx >= h or m[xx][yy] == -1:
            break
        if m[xx][yy] <= s+1:
            continue
        if xx == x2 and yy == y2:
            print(s+1)
            exit(0)
        m[xx][yy] = s+1
        q.append((s+1, xx, yy))

    for i in range(1, k+1):
        xx, yy = x - i, y
        if xx < 0 or m[xx][yy] == -1:
            break
        if m[xx][yy] <= s+1:
            continue
        if xx == x2 and yy == y2:
            print(s+1)
            exit(0)
        m[xx][yy] = s+1
        q.append((s+1, xx, yy))

    for i in range(1, k+1):
        xx, yy = x, y + i
        if yy >= w or m[xx][yy] == -1:
            break
        if m[xx][yy] <= s+1:
            continue
        if xx == x2 and yy == y2:
            print(s+1)
            exit(0)
        m[xx][yy] = s+1
        q.append((s+1, xx, yy))

    for i in range(1, k+1):
        xx, yy = x, y - i
        if yy < 0 or m[xx][yy] == -1:
            break
        if m[xx][yy] <= s+1:
            continue
        if xx == x2 and yy == y2:
            print(s+1)
            exit(0)
        m[xx][yy] = s+1
        q.append((s+1, xx, yy))

print(-1)


Fixed submission:
x = input().split()

print(x.index('0')+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
nu = {k for k, v in c.items() if v > 1}

s = set()
for aa in a:
    m = 2
    while aa*m <= 10**6:
        s.add(aa*m)
        m += 1

o = 0
for aa in a:
    if aa in s or aa in nu:
        continue
    o += 1

print(o)


Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
mx = max(a)

c = Counter(a)
nu = {k for k, v in c.items() if v > 1}

s = set()
u = set()
for aa in a:
    m = 2
    if aa in s or aa in u:
        continue
    u.add(aa)
    while aa*m <= mx:
        s.add(aa*m)
        m += 1

o = 0
for aa in a:
    if aa in s or aa in nu:
        continue
    o += 1

print(o)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, s = map(int, input().split())

edges = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    edges[u].append((v, a, b))
    edges[v].append((u, a, b))

banks = tuple(tuple(map(int, input().split())) for _ in range(n))

max_s = 50 * (n-1)

s = min(s, max_s)

import heapq

h = []
dp = [[float('inf')] * (max_s+1) for _ in range(n)]
ans = [float('inf')] * n

heapq.heappush(h, (0, 0, s))
while h:
    time, node, coin = heapq.heappop(h)
    if time < dp[node][coin]:
        dp[node][coin] = time
    if time < ans[node]:
        ans[node] = time

    c, d = banks[node]
    if coin < max_s:
        heapq.heappush(h, (time+d, node, min(coin + c, max_s)))

    for n, a, b in edges[node]:
        new_time = time + b
        new_coin = coin - a
        if new_coin < 0 or new_time >= dp[n][new_coin]:
            continue
        heapq.heappush(h, (new_time, n, new_coin))

for a in ans[1:]:
    print(a)


Fixed submission:
n, m, s = map(int, input().split())

edges = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    edges[u].append((v, a, b))
    edges[v].append((u, a, b))

banks = tuple(tuple(map(int, input().split())) for _ in range(n))

max_s = 50 * (n-1)

s = min(s, max_s)

import heapq

h = []
dp = [[float('inf')] * (max_s+1) for _ in range(n)]
ans = [float('inf')] * n

heapq.heappush(h, (0, 0, s))
while h:
    time, node, coin = heapq.heappop(h)
    if time >= dp[node][coin]:
        continue
    dp[node][coin] = time
    if time < ans[node]:
        ans[node] = time

    c, d = banks[node]
    if coin < max_s:
        heapq.heappush(h, (time+d, node, min(coin + c, max_s)))

    for n, a, b in edges[node]:
        new_time = time + b
        new_coin = coin - a
        if new_coin < 0 or new_time >= dp[n][new_coin]:
            continue
        heapq.heappush(h, (new_time, n, new_coin))

for a in ans[1:]:
    print(a)
Buggy python submission (verdict: Runtime Error):
from sympy import divisors

n = int(input())

a = len(divisors(n-1)[1:])

d = divisors(n)
for dd in d[1:]:
    nn = n
    while nn % dd == 0:
        nn = nn // dd
    if nn % dd == 1:
        a += 1

print(a)


Fixed submission:
from math import sqrt, ceil


def divisors(n):
    out = []
    nn = ceil(sqrt(n))
    for i in range(1, nn):
        if n % i == 0:
            out.append(i)
            out.append(n//i)

    if nn ** 2 == n:
        out.append(nn)

    out.sort()
    return out


n = int(input())
a = len(divisors(n-1)[1:])

d = divisors(n)
for dd in d[1:]:
    nn = n
    while nn % dd == 0:
        nn = nn // dd
    if nn % dd == 1:
        a += 1

print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

s = [float('inf')] * n
s[0] = 0
for i in range(n):
    for j in range(i+1, min(i+k+1, n)):
        s[j] = min(s[j], s[i] + abs(h[i]-h[j]))

print(s[n-1])

Fixed submission:
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

s = [float('inf')] * n
s[0] = 0
for i in range(n):
    for j in range(i+1, min(i+k+1, n)):
        s[j] = min(s[j], s[i] + abs(h[i]-h[j]))

print(s[n-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, w = [int(i) for i in input().split()]
a = np.array([[int(n) for n in input().split()] for i in range(n)])
a = a[np.argsort(a[:, 1] / a[:, 0])][::-1]

sv = {}
for ww, vv in a:
    added = {}
    for k, v in sv.items():
        added[ww+k] = vv+v
    for k, v in added.items():
        if (k <= w) and (k not in sv or v > sv[k]):
            sv[k] = v

    if (ww <= w) and (ww not in sv or vv > sv[ww]):
        sv[ww] = vv

print(max(sv.values()))

Fixed submission:
n, w = [int(i) for i in input().split()]
a = [[int(n) for n in input().split()] for i in range(n)]

sv = {}
for ww, vv in a:
    added = {}
    for k, v in sv.items():
        added[ww+k] = vv+v
    for k, v in added.items():
        if (k <= w) and (k not in sv or v > sv[k]):
            sv[k] = v

    if (ww <= w) and (ww not in sv or vv > sv[ww]):
        sv[ww] = vv

print(max(sv.values()))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, ww = map(int, input().split())

s = np.zeros(ww+1, dtype=np.int64)
for i in range(n):
    w, v = map(int, input().split())
    s[w:] = np.maximum(s[w:], s[:-w] + v)

print(s[ww])

Fixed submission:
import numpy as np

n, ww = map(int, input().split())

s = np.full(1000*100+1, 10**11, dtype=np.int64)
s[0] = 0
for i in range(n):
    w, v = map(int, input().split())
    s[v:] = np.minimum(s[v:], s[:-v] + w)

print(np.max(np.where(s<=ww)))

Buggy python submission (verdict: Time Limit Exceeded):
n, w = [int(i) for i in input().split()]
a = [[int(n) for n in input().split()] for i in range(n)]

sv = {}
for ww, vv in a:
    added = {}
    for k, v in sv.items():
        added[ww+k] = vv+v
    for k, v in added.items():
        if (k <= w) and (k not in sv or v > sv[k]):
            sv[k] = v

    if (ww <= w) and (ww not in sv or vv > sv[ww]):
        sv[ww] = vv

print(max(sv.values()))

Fixed submission:
import numpy as np

n, ww = map(int, input().split())

s = np.full(1000*100+1, 10**11, dtype=np.int64)
s[0] = 0
for i in range(n):
    w, v = map(int, input().split())
    s[v:] = np.minimum(s[v:], s[:-v] + w)

print(np.max(np.where(s<=ww)))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
bs = 0
for ai in range(n):
    bs = bs + bisect.bisect_right(b[bs:], a[ai])
    cs = 0
    for bi in range(bs, n):
        cs = cs + bisect.bisect_right(c[cs:], b[bi])
        ans = ans + (n-cs)

print(ans)

Fixed submission:
import bisect

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
for bb in b:
    ai = bisect.bisect_left(a, bb)
    ci = bisect.bisect_right(c, bb)
    ans = ans + (ai * (n-ci))

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
S = []
tmp = int(input())
s = tmp + 1
for _ in range(m-1):
  a = int(input())
  S.append(a-tmp)
  tmp = a
g = n-tmp+1

fib = [1 for _ in range(n+1)]
for i in range(2, n-1):
  fib[i+2] = fib[i] + fib[i+1]
total = fib[s]*fib[g]

fib[1] = 0

for x in S:
  total *= fib[x]
  
print(s, S, g)
print(total%1000000007)

Fixed submission:
n, m = map(int, input().split())
S = []
tmp = -1
for _ in range(m):
  a = int(input())
  S.append(a-tmp-2)
  tmp = a
S.append(n-tmp-1)

fib = [1 for _ in range(n+1)]
for i in range(n-1):
  fib[i+2] = fib[i] + fib[i+1]

total = 1
for x in S:
  if x == -1:
    print(0)
    exit()
  total *= fib[x]

#print(S)
print(total%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = map(int, input().split())
ls = list(int(input()) for i in range(A))
lt = list(int(input()) for i in range(B))
lx = list(int(input()) for i in range(Q))

def go(x, list, N):
  clist = []
  for i in range(N):
    clist.append(abs(list[i] - x))
  return min(clist)

for x in lx:
  l = []
  for i in range(A):
    if x - ls[i] < 0:
      break
  if i:
    l.append(abs(ls[i-1]-x) + go(ls[i-1], lt, B))
  if i < A:
    l.append(abs(ls[i]-x) + go(ls[i], lt, B))
  for i in range(B):
    if x - lt[i] < 0:
      break
  if i:
    l.append(abs(x-lt[i-1]) + go(lt[i-1], ls, A))
  if i < B:
    l.append(abs(lt[i]-x) + go(lt[i], ls, A))
  print(min(l))

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b-1], s[b]]:
    for T in [t[d-1], t[d]]:
      d1, d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)
      res = min(res, d1, d2)
  print(res)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = map(int, input().split())
ls = list(int(input()) for i in range(A))
lt = list(int(input()) for i in range(B))
lx = list(int(input()) for i in range(Q))

def go(x, list, N):
  clist = list.copy()
  for i in range(N):
    clist[i] = abs(clist[i] - x)
  return min(clist)

for x in lx:
  l = []
  for i in range(A):
    if x - ls[i] < 0:
      break
  if i:
    l.append(abs(ls[i-1]-x) + go(ls[i-1], lt, B))
  if i < A:
    l.append(abs(ls[i]-x) + go(ls[i], lt, B))
  for i in range(B):
    if x - lt[i] < 0:
      break
  if i:
    l.append(abs(x-lt[i-1]) + go(lt[i-1], ls, A))
  if i < B:
    l.append(abs(lt[i]-x) + go(lt[i], ls, A))
  print(min(l))

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b-1], s[b]]:
    for T in [t[d-1], t[d]]:
      d1, d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)
      res = min(res, d1, d2)
  print(res)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

zero = [0] * 50
one = [0] * 50

for a in A:
  for d in range(40):
    r = a % 2
    if r:
      one[d] += 1
    else:
      zero[d] += 1
    a = int(a / 2)

k = [0] * 40
d = 0
while K:
  r = K % 2
  if r:
    k[d] = 1
  K = int(K / 2)
  d += 1

d_tmp = d - 1
d = 49
flag = 0
max = 0
while d >= 0:
  if flag == 0 and k[d] == 0:
    max += one[d] * pow(2, d)
  else:
    if zero[d] >= one[d]:
      max += zero[d] * pow(2, d)
      if k[d]:
        flag = 1
    else:
      max += one[d] * pow(2, d)
  d -= 1

print(max)

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

zero = [0] * 50
one = [0] * 50

for a in A:
  for d in range(40):
    r = a % 2
    if r:
      one[d] += 1
    else:
      zero[d] += 1
    a = int(a / 2)

k = [0] * 50
d = 0
while K:
  r = K % 2
  if r:
    k[d] = 1
  K = int(K / 2)
  d += 1

d = 49
flag = 0
max = 0
while d >= 0:
  if flag == 0:
    if k[d] == 0:
      max += one[d] * pow(2, d)
    else:
      if zero[d] >= one[d]:
        max += zero[d] * pow(2, d)
      else:
        max += one[d] * pow(2, d)
        flag = 1
  else:
    if zero[d] >= one[d]:
      max += zero[d] * pow(2, d)
    else:
      max += one[d] * pow(2, d)
  d -= 1

print(max)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
 
if K % 2:
  print(pow(int(N / K), 3)
else:
  even = int(N / K)
  odd = int(N / int(K / 2)) - even
  print(even, odd)
  print(pow(even, 3) + pow(odd, 3))

Fixed submission:
N, K = map(int, input().split())
 
if K % 2 == 1:
  print(pow(int(N / K), 3))
else:
  even = int(N / K)
  odd = int(N / int(K / 2)) - even
  print(pow(even, 3) + pow(odd, 3))

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

if N % 2:
  print(int(N / K))
else:
  even = int(N / K)
  odd = int(N / int(K / 2)) - even
  print(pow(even, 2) + pow(odd, 2))

Fixed submission:
N, K = map(int, input().split())
 
if K % 2 == 1:
  print(pow(int(N / K), 3))
else:
  even = int(N / K)
  odd = int(N / int(K / 2)) - even
  print(pow(even, 3) + pow(odd, 3))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
cnt = 0

for i in range(N):
  a = i+1
  for j in range(N):
    b = j+1
    if (a+b) % K == 0:
      for k in range(N):
        c = k+1
        if (b+c)%K==0 and (c+a)%K==0:
          cnt += 1

print(cnt)

Fixed submission:
N, K = map(int, input().split())
 
if K % 2 == 1:
  print(pow(int(N / K), 3))
else:
  even = int(N / K)
  odd = int(N / int(K / 2)) - even
  print(pow(even, 3) + pow(odd, 3))
Buggy python submission (verdict: Runtime Error):
s=list(input())
for i in range(100):
    if s[i] == '1':
        continue
    else :
        print(s[i])
        break

Fixed submission:
s=list(input())
k=int(input())
#print(s)
#print(len(s))
#print(k)
for i in range(len(s)):
    if s[i] != '1' or i == len(s)-1:
        if k <= i:
            print(s[k-1])
        else :
            print(s[i])
        break
Buggy python submission (verdict: Runtime Error):
l = input()
if l<1200:
    print("ABC")
elif l<2800
    print("ARC")
else :
    print("AGC")

Fixed submission:
l = int(input())
if l<1200:
    print("ABC")
elif l<2800:
    print("ARC")
else :
    print("AGC")