Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
Sr = []

al = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
  m = al.index(S[i])
  n = (1 + n + N) % 26 - 1
  Sr.append(al[n])
  
print(''.join(Sr))

Fixed submission:
N = int(input())
S = input()
Sr = []

al = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
  n = al.index(S[i])
  Sr.append(al[(1 + n + N) % 26 - 1])
  
print(''.join(Sr))
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-2*x/a**2)
d = (2*x)/(a*b**2)
if x/a >= a*b/2:
  result = math.atan(c)
else:result = math.degrees(math.atan(d))
print(result)

Fixed submission:
A,B = map(int,input().split())
if 1<=A<=9 and 1<=B<=9:
  print(A*B)
else:print(-1)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-(2*x)/(a*a))
d = (2*x)/(a*b*b)
if x/a >= a*b/2:
  result = math.atan(c)
else:
  result = math.degrees(math.atan(d))
print(result)
  

Fixed submission:
A,B = map(int,input().split())
if 1<=A<=9 and 1<=B<=9:
  print(A*B)
else:print(-1)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
L = []

for i in range(1,1000000000001):
  for j in range(1,1000000000001):
    if i * j == N: 
      L.append(i + j - 2)
print(min(L))


Fixed submission:
import math
N = int(input())
L = []

def f(x):
  n = int(math.sqrt(x))
  for i in range(n,0,-1):
    if x % i == 0:
       return i
result = f(N) + N // f(N) - 2
print(result)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-(2*x)/(a*a))
d = (2*x)/(a*b*b)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)

Fixed submission:
import math
a,b,x = map(float,input().split())

c = (2*b-(2*x)/(a*a))/a
d = (a*b*b)/(2*x)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-2*x/a**2)
d = (2*x)/(a*b**2)
if x/a >= a*b/2:
  result = math.atan(c)
else:result = math.degrees(math.atan(d))
print(result)

Fixed submission:
import math
a,b,x = map(float,input().split())

c = (2*b-(2*x)/(a*a))/a
d = (a*b*b)/(2*x)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-2*x/a**2)
d = (2*x)/(a*b**2)
if x/a >= a*b/2:
  result = math.atan(c)
else:
  result = math.degrees(math.atan(d))
print(result)

Fixed submission:
import math
a,b,x = map(float,input().split())

c = (2*b-(2*x)/(a*a))/a
d = (a*b*b)/(2*x)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(float,input().split())

c = a/(2*b-2*x/a**2)
d = (2*x)/(a*b**2)
if x/a >= a*b/2:
  result = math.atan(c)
else:
  result = math.degrees(math.atan(d))
print(result)
  

Fixed submission:
import math
a,b,x = map(float,input().split())

c = (2*b-(2*x)/(a*a))/a
d = (a*b*b)/(2*x)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)
Buggy python submission (verdict: Runtime Error):
C = [input().split() for i in range(2)]
if C[0][0] == C[1][2] and C[0][1] == C[1][1] and C[0][2] == C[1][0]:
  print('YES')
else:print('NO')

Fixed submission:
import sys
C = [[str(c) for c in l.strip()] for l in sys.stdin]
if (C[0][0] == C[1][2]) and (C[0][1] == C[1][1]) and (C[0][2] == C[1][0]):
  print('YES')
else:print('NO')

Buggy python submission (verdict: Runtime Error):
C = [input().split() for i in range(2)]
if (C[0][0] == C[1][2]) and (C[0][1] == C[1][1]) and (C[0][2] == C[1][0]):
  print('YES')
else:print('NO')

Fixed submission:
import sys
C = [[str(c) for c in l.strip()] for l in sys.stdin]
if (C[0][0] == C[1][2]) and (C[0][1] == C[1][1]) and (C[0][2] == C[1][0]):
  print('YES')
else:print('NO')

Buggy python submission (verdict: Runtime Error):
C = [input().split() for i in range(2)]
if (C[0][0] == C[1][2]) and (C[0][1] == C[1][1]) and (C[0][2] == C[1][0]):
  print('YES')
else:print('NO')

Fixed submission:
import sys
C = [[str(c) for c in l.strip()] for l in sys.stdin]
if (C[0][0] == C[1][2]) and (C[0][1] == C[1][1]) and (C[0][2] == C[1][0]):
  print('YES')
else:print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

count = 0
for X in range(K + 1):
  for Y in range(K + 1):
    for Z in range(K + 1):
      if X + Y + Z == S:
        count += 1

print(count)

Fixed submission:
K,S = map(int,input().split())

result = 0
for X in range(K + 1):
  YZ = S - X
  if 0 <= YZ <= K:
    result += YZ + 1
  elif K < YZ <= 2 * K:
    result += 2 * K + 1 - YZ
  
print(result)
Buggy python submission (verdict: Runtime Error):
s = input()
L = []

for i in range(len(s)):
  if s[i] == '0':
    L.append('0')
  elif s[i] == '1':
    L.append('1')
  elif s[i] == 'B':
    del L[-1]

print(''.join(L))

Fixed submission:
s = input()
L = []

for i in range(len(s)):
  if s[i] == '0':
    L.append('0')
  elif s[i] == '1':
    L.append('1')
  elif s[i] == 'B' and len(L) > 0:
    del L[-1]

print(''.join(L))
Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
A=[1]*A
B=[0]*B
C=[-1]*C
D=A+B+C
print(sum(D[:K]))


Fixed submission:
A,B,C,K=map(int,input().split())

if A>=K:print(K)
elif A+B>=K:print(A)
else: print(A-(K-(B+A)))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K=map(int,input().split())

A=[1 for x in range(A)]
B=[0 for x in range(B)]
C=[-1 for x in range(C)]
D=A+B+C

print(sum(D[:K]))


Fixed submission:
A,B,C,K=map(int,input().split())

if A>=K:print(K)
elif A+B>=K:print(A)
else: print(A-(K-(B+A)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
member=[0]+list(map(int,input().split()))
max=max(member)
member=list(map(str,member))
answer=""
for i in range(max+1):
    answer=answer+str(member.count(str(i+1)))+"\n"
answer=answer+"0\n"*(N-max-1)
print(answer[:-1])


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

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
member=["0"]+input().split()
answer=""
for i,x in enumerate(member):
    answer=answer+str(member.count(str(i+1)))+"\n"
print(answer[:-1])


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

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
member=["0"]+input().split()
for i,x in enumerate(member):
    print(member.count(str(i+1)))


Fixed submission:
a=[0]*int(input())
for i in input().split():a[int(i)-1]+=1
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
num_list=[x for x in range(N+1)]
answer=0
count=N-K+2
for y in range(K,N+2):
    min=sum(num_list[:y])
    max=sum(num_list[-y:])
    answer+=max-min+1

print(answer%(10**9+7))


Fixed submission:
N,K=map(int,input().split())
answer=0
count=N-K+2
for y in range(K,N+2):
    min=int(y*(0+y-1)/2)
    max=int(y*(N-y+1+N)/2)
    answer+=(max+1-min)
print(answer%(10**9+7))
Buggy python submission (verdict: Runtime Error):
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
    exit()
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)),2)
    tile2=int("10"*int(math.ceil(len(str(tile))/2)),2)
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))


Fixed submission:
a,b=map(int,input().split())
answer=0
for x in range(2):
    if a>=b:
        answer+=a
        a-=1
    else:
        answer+=b
        b-=1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
b,c= map(int, input().split())
a=0
for x in range(b,c+1):
    a=a^x
print(a)


Fixed submission:
def xor(a,b):
    c=a-b+1
    flg1= a%2!=0
    flg2= b%2!=0
    flg3= int((c/2))%2!=0
    if a==b:
        return 1

    if not flg1 and flg2:
        if not flg3:
            return 0
        else:
            return 1
    elif not flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b
    elif flg1 and flg2:
        if not flg3:
            return a
        else:
            return a^1

    elif flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b




a,b = map(int, input().split())
print(xor(0,a-1)^xor(0,b))

Buggy python submission (verdict: Time Limit Exceeded):
b, c = map(int, input().split())
a=0
for x in range(b,c+1):
    a=x^a
print(a)

Fixed submission:
def xor(a,b):
    c=a-b+1
    flg1= a%2!=0
    flg2= b%2!=0
    flg3= int((c/2))%2!=0
    if a==b:
        return 1

    if not flg1 and flg2:
        if not flg3:
            return 0
        else:
            return 1
    elif not flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b
    elif flg1 and flg2:
        if not flg3:
            return a
        else:
            return a^1

    elif flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b




a,b = map(int, input().split())
print(xor(0,a-1)^xor(0,b))
Buggy python submission (verdict: Time Limit Exceeded):
a=str(input())
count=0
while 1:
    before=a
    if "01" in a:
        a=a.replace("01","",1)
        count+=2
    if "10" in a:
        a=a.replace("10","",1)
        count+=2
    after=a
    if before==after:
        break
print(count)


Fixed submission:
a=list(input())
min_count=2*min(a.count("0"),a.count("1"))
print(min_count)
Buggy python submission (verdict: Runtime Error):
def Sol(n,a,b):
    
    if n == 1:
        print("OK")
        return
    if n == 0:
    	print("NG")
        return
    m = a%n
    if b-m >= a:
        print("OK")
    else:
        print("NG")
    
    return

    
n = int(input())

#for t in range(int(input())):
a,b = map(int,input().split())
#    arr = []
#    for i in range(c):
#        arr.append(list(map(int,input().split())))
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n,a,b)


Fixed submission:
def Sol(n,a,b):
    
    m = b%n
    if b-m >= a:
        print("OK")
    else:
        print("NG")
    
    return

    
n = int(input())

#for t in range(int(input())):
a,b = map(int,input().split())
#    arr = []
#    for i in range(c):
#        arr.append(list(map(int,input().split())))
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n,a,b)
Buggy python submission (verdict: Time Limit Exceeded):
def RevFlag(flag):
    if flag:
        return False
    else:
        return True

def main():
    S = input()
    N = int(input())
    rev = False
    for i in range(N):
        Q = [i for i in input().split()]
        if len(Q) == 1:
            rev = RevFlag(rev)
        else:
            F = int(Q[1])
            C = Q[2]
            if F == 1:
                if rev:
                    S = '{}{}'.format(S, C)  # 末尾
                else:
                    S = '{}{}'.format(C, S)  # 先頭
            else:
                if rev:
                    S = '{}{}'.format(C, S)  # 先頭
                else:
                    S = '{}{}'.format(S, C)  # 末尾
    if rev:
        S = ''.join(list(reversed(S)))
    print(S)


if __name__ == '__main__':
    main()

Fixed submission:
def RevFlag(flag):
    if flag:
        return False
    else:
        return True

def main():
    from collections import deque
    S = input()
    d = deque()
    for s in S:
        d.append(s)
    N = int(input())
    rev = False

    for i in range(N):
        Q = [i for i in input().split()]
        if len(Q) == 1:
            rev = RevFlag(rev)
        else:
            F = int(Q[1])
            C = Q[2]
            if F == 1:
                if rev:
                    d.append(C)  # 末尾
                else:
                    d.appendleft(C)  # 先頭
            else:
                if rev:
                    d.appendleft(C)  # 先頭
                else:
                    d.append(C)  # 末尾
    if rev:
        d = ''.join(list(reversed(d)))
    else:
        d = ''.join(list(d))
    print(d)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    N = int(input())
    for i in range(N):
        Q = [i for i in input().split()]
        if len(Q) == 1:
            S = ''.join(list(reversed(S)))
        else:
            F = int(Q[1])
            C = Q[2]
            if F == 1:
                S = '{}{}'.format(C, S)
            else:
                S = '{}{}'.format(S, C)
    print(S)


if __name__ == '__main__':
    main()

Fixed submission:
def RevFlag(flag):
    if flag:
        return False
    else:
        return True

def main():
    from collections import deque
    S = input()
    d = deque()
    for s in S:
        d.append(s)
    N = int(input())
    rev = False

    for i in range(N):
        Q = [i for i in input().split()]
        if len(Q) == 1:
            rev = RevFlag(rev)
        else:
            F = int(Q[1])
            C = Q[2]
            if F == 1:
                if rev:
                    d.append(C)  # 末尾
                else:
                    d.appendleft(C)  # 先頭
            else:
                if rev:
                    d.appendleft(C)  # 先頭
                else:
                    d.append(C)  # 末尾
    if rev:
        d = ''.join(list(reversed(d)))
    else:
        d = ''.join(list(d))
    print(d)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for n in range(N):
    S.append(input())


def main():
    while True:
        unique = list(set(S))
        #print(unique)

        if len(unique) == len(S):
            return S

        for u in unique:
            S.remove(u)

        #print(S)


out = main()
out = sorted(out)
for o in out:
    print(o)


Fixed submission:
import collections

N = int(input())
S = []
for n in range(N):
    S.append(input())

c = collections.Counter(S)
most_common = c.most_common()
#print(most_common)

max_count = most_common[0][1]

# for t in most_common:
#     print(t[1])
c_list = [t[0] for t in most_common if t[1] == max_count]
# print(sorted(c_list))

out = sorted(c_list)
for o in out:
    print(o)
Buggy python submission (verdict: Time Limit Exceeded):
def q4():
    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    # pが大きいほど、期待値も大きくなる
    max_sum = 0
    max_pos = 0
    for i in range(0, N-K+1):
        s = sum(P[i:(i+K)])
        if max_sum < s:
            max_sum = s
            max_pos = i

    ans = 0
    for p in P[max_pos:(max_pos + K)]:
        s = p * (p+1) / (2 * p)
        ans += s
    print('{0:.7f}'.format(ans))

if __name__ == '__main__':
    q4()

Fixed submission:
def q4():
    from itertools import accumulate

    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]

    P_kitai = [0]
    # 整数1からNまでの合計は、sum = N(N+1)/2
    # 期待値は sum / N より、(N+1)/2 で表される。
    for p in P:
        P_kitai.append((p+1)/2)
    accu = list(accumulate(P_kitai))
    #print(accu)
    max_sum = 0
    for i in range(0, N-K+2):
        max_sum = max(max_sum, accu[i+K-1] - accu[i-1])
    print(max_sum)

if __name__ == '__main__':
    q4()

Buggy python submission (verdict: Time Limit Exceeded):
def q4():
    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    # pが大きいほど、期待値も大きくなる
    max_sum = 0
    max_pos = 0
    for i in range(0, N-K+1):
        s = sum(P[i:(i+K)])
        if max_sum < s:
            max_sum = s
            max_pos = i

    ans = 0
    for p in P[max_pos:(max_pos + K)]:
        s = sum([i for i in range(1,p+1)]) / p
        ans += s
    print('{0:.7f}'.format(ans))

if __name__ == '__main__':
    q4()

Fixed submission:
def q4():
    from itertools import accumulate

    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]

    P_kitai = [0]
    # 整数1からNまでの合計は、sum = N(N+1)/2
    # 期待値は sum / N より、(N+1)/2 で表される。
    for p in P:
        P_kitai.append((p+1)/2)
    accu = list(accumulate(P_kitai))
    #print(accu)
    max_sum = 0
    for i in range(0, N-K+2):
        max_sum = max(max_sum, accu[i+K-1] - accu[i-1])
    print(max_sum)

if __name__ == '__main__':
    q4()
Buggy python submission (verdict: Time Limit Exceeded):
def q3():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        m = min(P[:i+1])
        if P[i] == m:
            ans += 1
    print(ans)

    
if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    min_p = P[0]
    for i in range(N):
        if P[i] <= min_p:
            min_p = P[i]
            ans += 1
    print(ans)


if __name__ == '__main__':
    q3()

Buggy python submission (verdict: Time Limit Exceeded):
def q3():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        m = min(P[:i+1])
        if P[i] == m:
            ans += 1
    print(ans)


if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    min_p = P[0]
    for i in range(N):
        if P[i] <= min_p:
            min_p = P[i]
            ans += 1
    print(ans)


if __name__ == '__main__':
    q3()
Buggy python submission (verdict: Runtime Error):
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        import math
        return (x * y) // math.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        # import math
        import fractions
        return (x * y) // fractions.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()
Buggy python submission (verdict: Time Limit Exceeded):
def q3():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(''.join(sorted(list(input()))))

    def combinations_count(n, r):
        """ 組み合わせ総数を計算 """
        import math
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    ans = 0
    unique_list = set(S)
    for u in unique_list:
        cnt = S.count(u)
        if cnt >= 2:
            ans += combinations_count(cnt, 2)

    print(ans)

    
if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    N = int(input())
    from collections import deque
    S = deque()
    for _ in range(N):
        S.append(''.join(sorted(list(input()))))

    ans = 0
    d = {}  # key:文字列 value:出現回数
    for s in S:
        if s in d:
            ans += d[s]
            d[s] += 1
        else:
            d[s] = 1

    print(ans)


if __name__ == '__main__':
    q3()
Buggy python submission (verdict: Time Limit Exceeded):
def q3():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    for n in range(N):
        tmp = A.copy()
        tmp.pop(n)
        print(max(tmp))

        
if __name__ == '__main__':
    q3()

Fixed submission:
def q3():
    """ C - Exception Handling """
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    max_A = max(A)
    second_A = sorted(A, reverse=True)[1]
    for n in range(N):
        if A[n] == max_A:
            print(second_A)
        else:
            print(max_A)

            
if __name__ == '__main__':
    q3()

Buggy python submission (verdict: Runtime Error):
def q3():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    for n in range(N):
        tmp = A.copy()
        tmp.pop(n)
        print(max(tmp))


if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    """ C - Exception Handling """
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    max_A = max(A)
    second_A = sorted(A, reverse=True)[1]
    for n in range(N):
        if A[n] == max_A:
            print(second_A)
        else:
            print(max_A)

            
if __name__ == '__main__':
    q3()
Buggy python submission (verdict: Time Limit Exceeded):
def q2():
    N, K = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]

    # dp配列の初期化 (最小化問題なので初期値をINFとする)
    dp = [float('inf')]*N
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])

    for i in range(1, N):
        max_K = i if K > i else K
        for k in range(0, max_K + 1):
            step = dp[i-k] + abs(H[i] - H[i-k])
            dp[i] = min(dp[i], step)

    print(dp[N-1])


if __name__ == '__main__':
    q2()

Fixed submission:
def q2():
    N, K = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]

    # dp配列の初期化 (最小化問題なので初期値をINFとする)
    dp = [float('inf')]*N
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])

    for i in range(1, N):
        max_K = i if K > i else K
        for k in range(0, max_K + 1):
            step = dp[i-k] + abs(H[i] - H[i-k])
            dp[i] = min(dp[i], step)

    print(dp[N-1])


if __name__ == '__main__':
    q2()
Buggy python submission (verdict: Runtime Error):
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        # import math
        import fractions
        return (x * y) // fractions.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()


Fixed submission:
def q3():
    """C - Vacation"""
    N = int(input())

    dp = [[0]*N for i in range(3)]
    dp[0][0], dp[1][0], dp[2][0] = (int(i) for i in input().split())

    if N == 1:
        print(max([dp[0][0], dp[1][0], dp[2][0]]))
        return

    a, b, c = (int(i) for i in input().split())
    dp[0][1] = max(dp[1][0], dp[2][0]) + a
    dp[1][1] = max(dp[0][0], dp[2][0]) + b
    dp[2][1] = max(dp[1][0], dp[0][0]) + c

    if N == 2:
        print(max([dp[0][1], dp[1][1], dp[2][1]]))
        return

    for i in range(1, N-1):
        a, b, c = (int(i) for i in input().split())
        dp[0][i+1] = max(dp[1][i], dp[2][i]) + a
        dp[1][i+1] = max(dp[0][i], dp[2][i]) + b
        dp[2][i+1] = max(dp[1][i], dp[0][i]) + c
    print(max([dp[0][-1], dp[1][-1], dp[2][-1]]))


if __name__ == '__main__':
    q3()
Buggy python submission (verdict: Runtime Error):
n = input()
dic = {}
for i in map(int, raw_input().split()):
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
if len(dic) > 3:
	print "No"
elif len(dic) == 3:
	vals = []
	for i in dic:
		vals.append(i)
	if vals[0]^vals[2] != vals[1] or vals[1]^vals[0] != vals[2] or vals[0] != vals[1]^vals[2]:
		print "No"
	elif max(dic.values()) - min(dic.values()) > 1:
		print "No"
	else:
		print "Yes"
elif len(dic) == 2:
	assert(1 > 2)
	if 0 in dic and n%2 and dic[0] == n/2:
		print "Yes"
	else:
		print "No"
else:
	if 0 in dic.keys():
		print "Yes"
	else:
		print "No"

Fixed submission:
n = input()
dic = {}
for i in map(int, raw_input().split()):
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
if len(dic) > 3:
	print "No"
elif len(dic) == 3:
	vals = []
	for i in dic:
		vals.append(i)
	if vals[0]^vals[2] != vals[1] or vals[1]^vals[0] != vals[2] or vals[0] != vals[1]^vals[2]:
		print "No"
	elif max(dic.values()) - min(dic.values()) > 1:
		print "No"
	else:
		print "Yes"
elif len(dic) == 2:
	if 0 in dic and dic[0] == n/3 and n%3 == 0:
		print "Yes"
	else:
		print "No"
else:
	if 0 in dic.keys():
		print "Yes"
	else:
		print "No"