Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
fin = open('in_4.txt', 'r')
sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    # †私は証明のない決め打ちを提出しました†
    if N == 1:
        print(abs(a[-1]-W))
    elif abs(a[-1] - W) > abs(a[-1] - a[-2]):
        print(abs(a[-1] - W))
    else:
        print(abs(a[-1] - a[-2]))

Fixed submission:
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_4.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    # †私は証明のない決め打ちを提出しました†
    if N == 1:
        print(abs(a[-1]-W))
    elif abs(a[-1] - W) > abs(a[-1] - a[-2]):
        print(abs(a[-1] - W))
    else:
        print(abs(a[-1] - a[-2]))
Buggy python submission (verdict: Runtime Error):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return print(-1)
    return print(score)

check(a1 , b2)

Fixed submission:
list = input().split(" ")

a = int(list[0])
b = int(list[1])

print(a * b)

Buggy python submission (verdict: Runtime Error):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  now = 10 ** 18
  if '0' in b:
    return print(0)
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return print(-1)
    
    return print(score)

check(a1 , b2)

Fixed submission:
list = input().split(" ")

a = int(list[0])
b = int(list[1])

print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  now = 10 ** 18
  if '0' in b:
    return print(0)
  else:
    for i in range(a):
      score *= int(b[i])
    if score > 10 ** 18:
      return print(-1)
    else:
      return print(score)

check(a1 , b2)

Fixed submission:
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())

b = input().split(" ")
score = 1

for i in range(a):
  t = int(b[i])
  score *= t
  
if score > 10 ** 18:
  print(-1)
else:
  print(score)

Fixed submission:
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))

Buggy python submission (verdict: Runtime Error):
a = int(input())

score = 1
for i in range(a):
  b = int(input())
  score *= b
 
if score > 10 ** 18:
  print(-1)
else:
  print(score)

Fixed submission:
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))
Buggy python submission (verdict: Runtime Error):
H, N = map(int,input().split())
A = list(map(int, input().split()))

sum = 0

for i in range(A.length()):
    sum += A[i]

if(sum >= H):
    print("Yes")
else:
    print("No")

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

sum = 0

for i in range(len(A)):
    sum += A[i]

if(sum >= H):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import deque
q =deque(input())

ans = 0
while q:
    while q[0] == 'R':
        q.popleft()
    while q[-1] == 'W':
        q.pop()
    ans += 1
    q.popleft()
    q.pop()
print(ans)

Fixed submission:
n=int(input())
from collections import deque
q =deque(input())

ans = 0
while q:
    while q and q[0] == 'R' and q:
        q.popleft()
    while q and q[-1] == 'W' and q:
        q.pop()
    if not q:break
    ans += 1
    q.popleft()
    q.pop()
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n//=26
print(ans[::-1])n=int(input())

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n//=26
print(ans[::-1])

Fixed submission:
n=int(input())

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n-=1
    n//=26
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
amax = a[-1]
isok = [True]*(amax+1)
ans = 0

for i in range(n):
    x = a[i]
    if isok[x]:
        if i == 0 and a[i] != a[i+1]:
            ans += 1
        elif i == n-1 and a[i] != a[i-1]:
            ans += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            ans += 1
        orix = x
        while x<=amax:
            isok[x]=False
            x+=orix
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
amax = a[-1]
isok = [True]*(amax+1)
ans = 0
if n == 1:
    print(1)
    exit()
for i in range(n):
    x = a[i]
    if isok[x]:
        if i == 0 and a[i] != a[i+1]:
            ans += 1
        elif i == n-1 and a[i] != a[i-1]:
            ans += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            ans += 1
        orix = x
        while x<=amax:
            isok[x]=False
            x+=orix
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

ans =0
for i in range(2,int(n**0.5)+5):
    cnt = 0
    while n%i==0:
        n//=i
        cnt += 1
        s=0
    while cnt:
        s +=1
        cnt -= s
        ans += 1
if n!=1:ans+=1
print(ans)

Fixed submission:
n=int(input())

ans =0
for i in range(2,int(n**0.5)+5):
    cnt = 0
    while n%i==0:
        n//=i
        cnt += 1
    s=1
    while cnt-s>=0:
        cnt -= s
        s +=1
        ans += 1
if n!=1:ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
inf = float('inf')

def solve(s):
    if len(s) == n:
        res = 0
        li = [0]*n
        for i in range(n):
            if s[i] == '1':
                res += ca[i][0]
                for j in range(m):
                    li[j] += ca[i][j+1]

        if all(a >= x for a in li):
            return res
        else:
            return inf
    
    else:
        return min(solve(s+'1'), solve(s+'0'))

print(solve(""))

Fixed submission:
n,m,x=map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

ans = 1234567890123

for bit in range(1<<n):
    syu = [0]*m
    cost = 0
    for i in range(n):
        if (bit>>i)&1:
            cost += ca[i][0]
            for j in range(1,m+1):
                syu[j-1] += ca[i][j]
    ok = True
    for i in range(m):
        if syu[i] < x:
            ok = False

    if ok:
        ans = min(ans,cost)
print(ans if ans != 1234567890123 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = map(int,input().split())
x,y=x-1,y-1

dist = [0]*5000

for i in range(n):
    for j in range(i+1,n):
        tmp = j - i
        tmp = min(tmp,abs(i-x) + abs(y-j)+1)
        tmp = min(tmp,abs(i-y) + abs(x-j)+1)
        dist[tmp] +=1

for i in range(1,n):
    print(dist[i])

Fixed submission:
n,x,y = map(int,input().split())
x,y=x-1,y-1

dist = [0]*5000

for i in range(n):
    for j in range(i+1,n):
        tmp = j - i
        tmp = min(tmp,abs(i-x) + abs(y-j)+1)
        tmp = min(tmp,abs(i-y) + abs(x-j)+1)
        dist[tmp] +=1

for i in range(1,n):
    print(dist[i])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

if rev == 1:
    ans = fr[::-1]+s+rr
else:
    ans = rr[::-1]+s[::-1]+fr
print(ans)

Fixed submission:
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

if rev == 1:
    ans = fr[::-1]+s+rr
else:
    ans = rr[::-1]+s[::-1]+fr
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

ans = fr[::-1]+s+rr
if rev == -1:
    ans = ans[::-1]
print(ans)

Fixed submission:
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

if rev == 1:
    ans = fr[::-1]+s+rr
else:
    ans = rr[::-1]+s[::-1]+fr
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans =[-1] * (n+1)
for _ in range(m):
    s,c = map(int,input().split())
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()

for i in range(1,n+1):
    if ans[i] == -1:
        ans[i] = 0
if ans[1] == 0:
    print(-1)
else:
    print(ans[1]*100 + ans[2]*10+ans[3])

Fixed submission:
n,m=map(int,input().split())
ans = [-1] * 4

for _ in range(m):
    s,c=map(int,input().split())
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()
    
if n == 1:
    print(ans[1] if ans[1]!=-1 else 0)
else:
    if ans[1] == 0:
        print(-1)
        exit()
    if ans[1] == -1:
        ans[1] = 1
    for i in range(2,n+1):
        if ans[i] == -1:
            ans[i] = 0
    res = 0
    for i in range(1,n+1):
        res*=10
        res += ans[i]
    print(res)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
    for i in range(nu):
        res/=i+1
    res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)

Fixed submission:
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
        res %= mod
        res *= pow(i+1,mod-2,mod)
        res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(n)]

dp = [123456789012] * (10**8 + 10)

dp[0] = 0
for i in range(h+1):
    if dp[i] == 123456789012:
        continue
    for j in range(n):
        dp[i+ab[j][0]] = min(dp[i+ab[j][0]],dp[i] + ab[j][1])
ans = 123456789012
for i in range(h,h+10000+2):
    ans = min(ans,dp[i])
print(ans)

Fixed submission:
h,n=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(n)]

dp = [123456789012] * (10**8 + 10)

dp[0] = 0
for i in range(h+1):
    if dp[i] == 123456789012:
        continue
    for j in range(n):
        dp[i+ab[j][0]] = min(dp[i+ab[j][0]],dp[i] + ab[j][1])
ans = 123456789012
for i in range(h,h+10000+2):
    ans = min(ans,dp[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def powmod(a,b,m):
	ans=1
	while(b):
		if b%2:
			ans*=a
			ans%=m
			b//=2
		a*=a
		a%=m
	return ans

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
mod=10**9+7
fact = [1]*100005
inv = [0]*100005
for i in range(2,100003):
	fact[i] = (fact[i-1]*i)%mod
for i in range(1,100003):
	inv[i] = powmod(fact[i],mod-2,mod)

#n!//k!(n-k)!
def nCk(n,k):
	return fact[n]*inv[k]%mod*inv[n-k]%mod

ans = 0

for i in range(n-3):
	ans += (a[i]-a[n-1-i])*nCk(n-1-i,k-1)
	ans%=mod
print(ans)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
mod=10**9+7
fact = [1]*100005
inv = [1]*100005
for i in range(2,100003):
	fact[i] = (fact[i-1]*i)%mod
for i in range(1,100003):
	inv[i] = pow(fact[i],mod-2,mod)

#n!//k!(n-k)!
def nCk(n,k):
	return fact[n]*inv[k]%mod*inv[n-k]%mod

ans = 0

for i in range(n-k+1):
	ans += (a[i]-a[n-1-i])*nCk(n-1-i,k-1)
	ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
	[]	cnt+=1
print(cnt)


Fixed submission:
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
		cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min( a + (b-a-1)//2, n - b + 1 + (b-a-1)//2) )
    

Fixed submission:
x,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min( a + (b-a-1)//2, x - b + 1 + (b-a-1)//2) )
Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
for i in range(len(s)//2)-1:
	if s[i]!=s[len(s)-1-i]:
		ans+=1
print(ans)

Fixed submission:
s=input()
ans=0
for i in range(len(s)//2):
	if s[i]!=s[len(s)-1-i]:
		ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,l=map(int,input().split())
abcs=[list(map(int,input().split())) for _ in range(m)]
for i in range(m):
	abcs[i][0]-=1
	abcs[i][1]-=1
inf =1234567890123456
dist = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	dist[i][i] = 0

for i in range(m):
	a=abcs[i][0]
	b=abcs[i][1]
	c=abcs[i][2]
	dist[a][b] = dist[b][a] = c

for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

ans = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	ans[i][i]=0
for i in range(n):
	for j in range(i+1,n):
		if dist[i][j]<=l:
			ans[i][j]=ans[j][i]=1
for k in range(n):
	for i in range(n):
		for j in range(n):
			ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j])


for _ in range(int(input())):
	f,t=map(int,input().split())
	f-=1
	t-=1
	print(ans[f][t]-1 if ans[f][t]!=inf else -1)

Fixed submission:
n,m,l=map(int,input().split())
abcs=[list(map(int,input().split())) for _ in range(m)]
for i in range(m):
	abcs[i][0]-=1
	abcs[i][1]-=1
inf =1234567890123456
dist = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	dist[i][i] = 0

for i in range(m):
	a=abcs[i][0]
	b=abcs[i][1]
	c=abcs[i][2]
	dist[a][b] = dist[b][a] = c

for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

ans = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
	ans[i][i]=0
for i in range(n):
	for j in range(i+1,n):
		if dist[i][j]<=l:
			ans[i][j]=ans[j][i]=1
for k in range(n):
	for i in range(n):
		for j in range(n):
			ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j])


for _ in range(int(input())):
	f,t=map(int,input().split())
	f-=1
	t-=1
	print(ans[f][t]-1 if ans[f][t]!=inf else -1)
Buggy python submission (verdict: Runtime Error):
s,t=map(int,input().split())
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
s,t=map(int,input().split())
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(nas)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]

maxa = max(a[0],a[1])
mina = min(a[0],a[1])

for i in range(2,n):
    if a[i] >= maxa:
        mina = maxa
        maxa = a[i]
    elif a[i] >mina:
        mina = a[i]

for i in range(n):
    if a[i] == maxa:
        print(mina)
    else:
        print(maxa)
å


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

maxa = max(a[0],a[1])
mina = min(a[0],a[1])

for i in range(2,n):
    if a[i] >= maxa:
        mina = maxa
        maxa = a[i]
    elif a[i] >mina:
        mina = a[i]

for i in range(n):
    if a[i] == maxa:
        print(mina)
    else:
        print(maxa)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[]
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if x[0] == x[1] == x[2] == n//3 or (a[0] == 0 and x[0]==n//3 and x[1]==x[2]==2*n//3):
    print('Yes')
else:
    print('No')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[0]*3
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if a[0]^a[n//2] == a[-1] and x[0] == x[1] == x[2] == n//3:
    print('Yes')
elif a[0] == 0 and x[0] == n//3 and x[1] == x[2] == n*2//3:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
n = len(s)
same = True
for i in range(1,len(s)):
    if s[i]!=s[i-1]:
        same = False
if same:
    print(len(s)*k//2)
    exit()

for i in range(1,len(s)):
    if s[i] != s[i-1]:
        before = i-1
        break
for i in range(len(s)-1,-1,-1):
    if s[i] != s[i-1]:
        after = i
        break

ans = (before+1)//2 
ans += (len(s)-after)//2
if s[0] == s[-1]:
    ans += (before + 1 + len(s) - after)//2 * (k-1)
else:
    ans += ((before+1)//2  + (len(s)-after)//2)*(k-1)
cnt = 1
for i in range(before+2, after):
    if s[i] != s[i-1]:
        ans += cnt //2 *k
        cnt = 1
    else:
        cnt +=1
ans += cnt //2 * k
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[0]*3
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if a[0]^a[n//2] == a[-1] and x[0] == x[1] == x[2] == n//3:
    print('Yes')
elif a[0] == 0 and x[0] == n//3 and x[1] == x[2] == n*2//3:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
li=list(map(int,input().split()))
li.sort()
print(li[n/2]-li[n/2-1])

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
li.sort()
print(li[n//2]-li[n//2-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
red = n-k
mod=10**9+7

for i in range(1,200320032003):
  a=4
nCk =[[0]*2005 for _ in range(2005)]
for i in range(2003):
    nCk[i][0] = 1

for i in range(1,2003):
    for j in range(1,i+1):
        nCk[i][j] = nCk[i-1][j]+nCk[i-1][j-1]

for i in range(1,k+1):
    print(nCk[k-1][i-1]*nCk[red+1][i]%mod)


Fixed submission:
n,k=map(int,input().split())
red = n-k
mod=10**9+7

nCk =[[0]*2005 for _ in range(2005)]
for i in range(2003):
    nCk[i][0] = 1

for i in range(1,2003):
    for j in range(1,i+1):
        nCk[i][j] = nCk[i-1][j]+nCk[i-1][j-1]

for i in range(1,k+1):
    print(nCk[k-1][i-1]*nCk[red+1][i]%mod)
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
ans=0
while(d<=x):
    ans+=1
    d=d+l[ans-1]
print(ans)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
ans=0
while(d<=x):
    ans+=1
    if ans == n+1:
        break
    d=d+l[ans-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
xys=[list(map(int,input().split())) for _ in range(n)]
vec = []

for i in range(n):
    for j in range(i+1,n):
        diffx = xys[i][0] - xys[j][0]
        diffy = xys[i][1] - xys[j][1]
        if diffx == 0:
            vec.append([12345678901234,i,j])
        else:
            vec.append([diffy/diffx,i,j])
vec.sort()
cnt =1
cntMax = 0
val=-1
for i in range(1,len(vec)):
    if vec[i][0] != vec[i-1][0]:
        if cnt > cntMax:
            val = vec[i-1][0]
            cntMax = cnt
        cnt = 1
    else:
        cnt += 1
if cnt > cntMax:
    val = vec[-1][0]
    cntMax = max(cntMax,cnt)

check = [1]*(n+1)
check[0]=0

for i in range(len(vec)):
    if vec[i][0] == val:
        check[vec[i][2]] = 0
print(sum(check))

Fixed submission:
n=int(input())
xys=[list(map(int,input().split())) for _ in range(n)]
vec = []
pqs = []
for i in range(n):
    for j in range(i+1,n):
        pqs.append([(xys[i][0]-xys[j][0]),(xys[i][1]-xys[j][1])])
        pqs.append([-(xys[i][0]-xys[j][0]),-(xys[i][1]-xys[j][1])])
pqs.sort()
import collections

cnt = 1
cntMax = 0
for i in range(1,len(pqs)+1):
    if i == len(pqs):
        cntMax = max(cntMax,cnt)
    elif pqs[i] == pqs[i-1]:
        cnt += 1
    else:
        cntMax = max(cntMax,cnt)
        cnt = 1
print(n-cntMax)
Buggy python submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
su =sum(w)

ans = 1234567890
cnt =0
for i in range(n):
    cnt += w[i]
    ans = min(ans,abs(su-cnt)
print(ans)

Fixed submission:
n=int(input())
w=list(map(int,input().split()))
wa=[0]*(n+1)
for i in range(n):
	wa[i+1] = wa[i]+w[i]

ans = 1234567890
for i in range(1,n+1):
	ans = min(ans,abs(wa[n]-2*wa[i]))
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
wa=[0]*(n+1)
for i in range(n):
	wa[i+1] = wa[i]+w[i]

ans = 1234567890
for i in range(1,n+1):
	ans = min(ans,abs(wa[n+1]-wa[i]))
print(ans)

Fixed submission:
n=int(input())
w=list(map(int,input().split()))
wa=[0]*(n+1)
for i in range(n):
	wa[i+1] = wa[i]+w[i]

ans = 1234567890
for i in range(1,n+1):
	ans = min(ans,abs(wa[n]-2*wa[i]))
print(ans)