Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())))
cnt = M*V
B = [[A[i],i] for i in range(N)]
for i in range(N):
    if cnt>=M:
        B[i][0] += M
        cnt -= M
    else:break
B = sorted(B,key=lambda x:x[1],reverse=True)
B = sorted(B,key=lambda x:x[0],reverse=True)
ind = B[P-1][1]
cur = P-1
while True:
    if B[cur+1][0]==B[cur][0]:
        ind = B[cur+1][1]
        cur += 1
    else:break
low = -1
high = ind
while high-low>1:
    mid = (high+low)//2
    cnt = M*V
    B = A[:]
    for i in range(mid+1):
        B[i] += M
        cnt -= M
    b = B[mid]
    for i in range(mid+1,N):
        if B[i]<b and cnt>=b-B[i]:
            B[i] += b-B[i]
            cnt -= b-B[i]
        else:break
    for i in range(N-1,-1,-1):
        if cnt>=M:
            B[i] += M
            cnt -= M
        elif 0<cnt<M:
            B[i] += cnt
            break
    ind = bisect_right(B,b)
    if N-ind<P:
        high = mid
    else:
        low = mid
print(N-high)

Fixed submission:
from bisect import bisect_left,bisect_right
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())))
low = -1
high = A[-1]+M
while high-low>1:
    mid = (low+high)//2
    indL = bisect_left(A,mid-M)
    indR = bisect_right(A,mid)
    if indL>N-P:
        high = mid
        continue
    if indR<N-P+1:
        low = mid
        continue
    tot = M*V
    i = indL
    while i<N-P+1:
        if tot-(mid-A[i])<0:break
        tot -= mid-A[i]
        i += 1
    if i<N-P+1 or 0<=tot<=M*(P-1+indL):
        high = mid
    else:
        low = mid
ind = bisect_left(A,high-M)
print(N-ind)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = {i:0 for i in range(20)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(20):
    if C[i]>0:
        cnt += C[i]*(N-C[i])*2**i
print(cnt)

Fixed submission:
p = 10**9+7
N = int(input())
C = {i:0 for i in range(60)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(60):
    if C[i]>0:
        cnt = (cnt+C[i]*(N-C[i])*2**i)%p
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input().strip()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if int(S[n])==cur[ind]:
                    ind += 1
                    if ind==3:
                      cnt += 1
                      break
print(cnt)


Fixed submission:
N = int(input())
S = list(map(int,list(input().strip())))
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if S[n]==cur[ind]:
                    ind += 1
                    if ind==3:
                        cnt += 1
                        break
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input().strip()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if int(S[n])==cur[ind]:
                    ind += 1
                    if ind==3:break
            if ind==3:
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = list(map(int,list(input().strip())))
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if S[n]==cur[ind]:
                    ind += 1
                    if ind==3:
                        cnt += 1
                        break
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input().strip()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if int(S[n])==cur[ind]:
                    ind += 1
                    if ind==3:break
            if ind==3:
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = list(map(int,list(input().strip())))
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cur = [i,j,k]
            ind = 0
            for n in range(N):
                if S[n]==cur[ind]:
                    ind += 1
                    if ind==3:
                        cnt += 1
                        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())
dif = T1*A1+T2*A2-T1*B1-T2*B2
if dif==0:
    print("infinity")
elif dif>0:
    if B1>A1:
        k = int(((B1-A1)*T1)/dif)
        if abs(((B1-A1)*T1)/dif-round(((B1-A1)*T1)/dif))<1e-20:
            print(2*round(((B1-A1)*T1)/dif))
        else:
            print(2*k+1)
    else:
        print(0)
else:
    if A1>B1:
        k = int(((A1-B1)*T1)/abs(dif))
        if abs((A1-B1)*T1/abs(dif)-round(((A1-B1)*T1)/abs(dif))<1e-20:
            print(2*round(((A1-B1)*T1)/abs(dif)))
        else:
            print(2*k+1)
    else:
        print(0)

Fixed submission:
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())
dif = T1*A1+T2*A2-T1*B1-T2*B2
if dif==0:
    print("infinity")
elif dif>0:
    if B1>A1:
        k = int(((B1-A1)*T1)/dif)
        if abs(((B1-A1)*T1)/dif-round(((B1-A1)*T1)/dif))<1e-20:
            print(2*round(((B1-A1)*T1)/dif))
        else:
            print(2*k+1)
    else:
        print(0)
else:
    if A1>B1:
        k = int(((A1-B1)*T1)/abs(dif))
        if abs((A1-B1)*T1/abs(dif)-round(((A1-B1)*T1)/abs(dif)))<1e-20:
            print(2*round(((A1-B1)*T1)/abs(dif)))
        else:
            print(2*k+1)
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
G = {i:[] for i in range(1,N+1)}
E = {}
A = []
for _ in range(N-1):
    a,b = map(int,input().split())
    A.append((a,b))
    G[a].append(b)
    G[b].append(a)
    E[(a,b)] = 0
hist = [0 for _ in range(N+1)]
heap = deque([1])
c = 1
for y in G[1]:
    E[(1,y)]=c
    c += 1
K = c-1
hist[1]=1
while heap:
    x = heap.popleft()
    for y in G[x]:
        if hist[y]==0:
            K = max(K,len(G[y]))
            col = [0 for _ in range(K+1)]
            for z in G[y]:
                if y<z:
                    col[E[(y,z)]]=1
                else:
                    col[E[(z,y)]]=1
            cur = 1
            for z in G[y]:
                if y<z and E[(y,z)]==0:
                    for i in range(cur,K+1):
                        if col[i]==0:
                            E[(y,z)]=i
                            col[i]=1
                            cur = i+1
                            break
                elif z<y and E[(z,y)]==0:
                    for i in range(cur,K+1):
                        if col[i]==0:
                            E[(z,y)]=i
                            col[i]=1
                            cur = i+1
                            break
            heap.append(y)
            hist[y]=1
print(K)
for e in A:
    print(E[e])

Fixed submission:
from collections import deque         
N = int(input())
G = {}
E = {}
E1 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(a)
    E[(a,b)] = 0
    E[(b,a)] = 0
    E1.append((a,b))
col = 0
for x in G:
    col = max(col,len(G[x]))
hist = [0 for _ in range(N+1)]
heap = deque([(1,0)])
while heap:
    x = heap.popleft()
    hist[x[0]] = 1
    if x[1]!=0:
        c = E[(x[0],x[1])]
    else:
        c = 0
    for y in G[x[0]]:
        if hist[y]==0:
            c = c%col+1
            E[(x[0],y)] = c
            E[(y,x[0])] = c
            heap.append((y,x[0]))
print(col)
for i in range(N-1):
    print(E[E1[i]])
Buggy python submission (verdict: Runtime Error):
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
G = []
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            G.append((i,j))
G = sorted(G,key=lambda x:x[0])
G = sorted(G,key=lambda x:x[1])
k = len(G)
cnt = 1
u = 0
l = 0
for i in range(k):
    if G[i][1]<W-1 and G[i][1]<G[i+1][1]:
        for i1 in range(u,H):
            for j1 in range(l,G[i+1][1]):
                A[i1][j1] = cnt
        u = 0
        l = G[i+1][1]
        cnt += 1
    elif G[i][1]<W-1 and G[i][1]==G[i+1][1]:
        j = i+2
        flag = 0
        while j<k:
            if G[i][1]<G[j][1]:
                flag = 1
                break
            j += 1
        if flag==1:
            for i1 in range(u,G[i+1][0]):
                for j1 in range(l,G[j][1]):
                    A[i1][j1] = cnt
            u = G[i+1][0]
            cnt += 1
        else:
            for i1 in range(u,G[i+1][0]):
                for j1 in range(l,W):
                    A[i1][j1] = cnt
            u = G[i+1][0]
            l = 0
            cnt += 1
    else:
        if i<k-1:
            for i1 in range(u,G[i+1][0]):
                A[i1][W-1] = cnt
            u = G[i+1][0]
            cnt += 1
        else:
            for i1 in range(u,H):
                A[i1][W-1] = cnt
for i in range(H):
    print(*A[i])

Fixed submission:
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
row = 0
cnt = 1
for i in range(H):
    B = []
    for j in range(W):
        if S[i][j]=="#":
            B.append(j)
    if len(B)==0:
        continue
    elif len(B)==1:
        for k in range(row,i+1):
            for j in range(W):
                A[k][j] = cnt
        cnt += 1
        row = i+1
    else:
        for l in range(len(B)):
            if l==0:
                for k in range(row,i+1):
                    for j in range(B[0]+1):
                        A[k][j] = cnt
                cnt += 1
            elif l<len(B)-1:
                for k in range(row,i+1):
                    for j in range(B[l-1]+1,B[l]+1):
                        A[k][j] = cnt
                cnt += 1
            else:
                for k in range(row,i+1):
                    for j in range(B[-2]+1,W):
                        A[k][j] = cnt
                cnt += 1
        row = i+1
if row != H:
    for i in range(row,H):
        for j in range(W):
            A[i][j] = A[i-1][j]
for i in range(H):
    print(*A[i])
Buggy python submission (verdict: Time Limit Exceeded):
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x%p
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(10**6+1)]
for i in range(1,10**6+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(10**6+1)]
for i in range(2,10**6+1):
    B[i] = pow(A[i],p-2)

X,Y = map(int,input().split())
if (X+Y)%3!=0:
    cnt = 0
else:
    k = (X+Y)//3
    if X>Y:
        X,Y = Y,X
    n = X-k
    cnt = (A[k]*B[n]*B[k-n])%p
print(cnt)

Fixed submission:
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x%p
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(10**6+1)]
for i in range(1,10**6+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(10**6+1)]
B[10**6] = pow(A[10**6],p-2)
for i in range(10**6-1,1,-1):
    B[i] = (B[i+1]*(i+1))%p

X,Y = map(int,input().split())
if (X+Y)%3!=0:
    cnt = 0
else:
    k = (X+Y)//3
    if X>Y:
        X,Y = Y,X
    n = X-k
    if X<k:
        cnt = 0
    else:
        cnt = (((A[k]*B[n])%p)*B[k-n])%p
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = input().strip()
V = []
for i in range(len(S)-1):
    if S[i]==">" and S[i+1]=="<":
        V.append(i+1)
if S[-1]==">":
    V.append(len(S))
B = [0 for _ in range(len(S)+1)]
for i in range(len(S)):
    if S[i]==">":
        B[i+1] = B[i]-1
    else:
        B[i+1] = B[i]+1
for j in V:
    if B[j]<0:
        B[j] = 0
        cur = j-1
        while S[cur]==">":
            B[cur] = max(B[cur],B[cur+1]+1)
            cur -= 1
        cur = j
        while cur<len(S) and S[cur]=="<":
            B[cur+1]=B[cur]+1
            cur += 1
    elif B[j]>0:
        B[j] = 0
        cur = j-1
        while S[cur]==">":
            if cur-1>=0 and S[cur-1]==">":
                B[cur] = B[cur+1]+1
            cur -= 1
        cur = j
        while cur<len(S) and S[cur]=="<":
            B[cur+1] = B[cur]+1
            cur += 1
print(sum(B))   

Fixed submission:
S = input().strip()
N = len(S)+1
A = [0 for _ in range(N)]
B = []
for i in range(N):
    if i==0 and S[i]=="<":
        B.append(0)
    elif i<N-2 and S[i]==">" and S[i+1]=="<":
        B.append(i+1)
    elif i==N-2 and S[i]==">":
        B.append(i+1)
for j in range(len(B)-1):
    ind0 = B[j]
    ind1 = B[j+1]
    c = ind0
    while S[c]=="<":
        A[c+1] = max(A[c+1],A[c]+1)
        c += 1
    c = ind1
    while S[c-1]==">":
        A[c-1] = max(A[c-1],A[c]+1)
        c -= 1
c = B[0]
if c>0:
    for i in range(c-1,-1,-1):
        A[i] = A[i+1]+1
c = B[-1]
if c<N-1:
    for i in range(c+1,N):
        A[i] = A[i-1]+1
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i]+L[j]
        ind = bisect.bisect_left(L[j+1:],a)
        cnt += ind
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i]+L[j]
        ind = bisect.bisect_left(L,a)
        cnt += ind-j-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
cnt = B[0]+B[N-2]
for i in range(1,N-1):
    cnt += min(B[i-1],B[i])
print(cnt)

Fixed submission:
N,K = map(int,input().split())
S = list(input())
a = S[0]
cur = 0
cnt = 0
for i in range(N):
    if S[i] != a:
        cnt += i-cur-1
        a = S[i]
        cur = i
if S[N-1]==a:
    cnt += N-cur-1
print(min(cnt+2*K,N-1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def score(x):
    cur = x
    p = 0
    while cur>0:
        p += T[cur][2]
        cur = T[cur][0]
    return p
N,Q = map(int,input().split())
G = {}
for _ in range(N-1):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(a)
T = {i:[0,[],0] for i in range(1,N+1)}
cur = 1
T[cur][1] = G[cur]
T[cur][0] = -1
hist = deque([cur])
while hist:
    cur = hist.popleft()
    for y in T[cur][1]:
        T[y][0] = cur
        G[y].remove(cur)
        T[y][1] = G[y]
        hist.append(y)
for _ in range(Q):
    p,x = map(int,input().split())
    T[p][2] += x
S = []
for i in range(1,N+1):
    S.append(score(i))
print(*S)

Fixed submission:
from collections import deque
N,Q = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
C = [0 for _ in range(N+1)]
for _ in range(Q):
    p,x = map(int,input().split())
    C[p] += x
heap = deque([1])
hist = [0 for _ in range(N+1)]
while heap:
    cur = heap.popleft()
    hist[cur] = 1
    for x in G[cur]:
        if hist[x]==0:
            C[x] += C[cur]
            heap.append(x)
C.pop(0)
print(*C)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = [0 for _ in range(M+1)]
for x in C:
    A,B = x[0],x[1]
    try:
        ind = hist[-A-1::-1].index(0)
        hist[M-A-ind]=1
        rev += B
    except:pass
print(rev)

Fixed submission:
import bisect
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = list(range(0,M+1))
for x in C:
    A,B = x[0],x[1]
    ind = bisect.bisect_right(hist,M-A)
    if ind>0:
        hist.pop(ind-1)
        rev += B
print(rev)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = [0 for _ in range(M+1)]
for x in C:
    A,B = x[0],x[1]
    if 0 in hist[-A-1::-1]:
        ind = hist[-A-1::-1].index(0)
        hist[M-A-ind]=1
        rev += B
print(rev)

Fixed submission:
import bisect
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = list(range(0,M+1))
for x in C:
    A,B = x[0],x[1]
    ind = bisect.bisect_right(hist,M-A)
    if ind>0:
        hist.pop(ind-1)
        rev += B
print(rev)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = [0 for _ in range(M+1)]
for x in C:
    A,B = x[0],x[1]
    for i in range(M-A,-1,-1):
        if hist[i]==0:
            rev += B
            hist[i]=1
            break
print(rev)

Fixed submission:
import bisect
N,M = map(int,input().split())
C = []
for _ in range(N):
    A,B = map(int,input().split())
    C.append([A,B])
C = sorted(C,key=lambda x:x[0],reverse=True)
C = sorted(C,key=lambda x:x[1],reverse=True)
rev = 0
hist = list(range(0,M+1))
for x in C:
    A,B = x[0],x[1]
    ind = bisect.bisect_right(hist,M-A)
    if ind>0:
        hist.pop(ind-1)
        rev += B
print(rev)
Buggy python submission (verdict: Time Limit Exceeded):
S = int(input())
n = int(S**0.5)
for i in range(n,0,-1):
    if S%i==0:
        L = i
        H = S//i
        break
x1 = 0
y1 = 0
x2 = L
y2 = 0
x3 = L
y3 = H
print(x1,y1,x2,y2,x3,y3)

Fixed submission:
S = int(input())
if S<=10**9:
    print(0,0,0,1,S,0)
else:
    a = S%(10**9)
    x = 10**9
    y = 1
    if a==0:
        z = 0
    else:
        z = 10**9-a
    w = (S+y*z)//(10**9)
    print(0,0,x,y,z,w)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
G = []
for i in range(N):
    a = A[i]
    gmax = -1
    for j in range(len(G)):
        if G[j][-1]<a:
            if G[j][-1]>gmax:
                gmax = G[j][-1]
                ind = j
    if gmax>=0:
        G[ind].append(a)
    else:
        G.append([a])
print(len(G))

Fixed submission:
import bisect
from collections import deque
N = int(input())
S = deque([int(input())])
for _ in range(N-1):
    a = int(input())
    ind = bisect.bisect_right(S,a)
    if S[ind-1]==a:
        ind1 = bisect.bisect_left(S,a)
        if ind1>0 and S[ind1-1]<a:
            S[ind1-1]=a
        else:
            S.appendleft(a)
    elif ind==0:
        S.appendleft(a)
    else:
        S[ind-1]=a
#     print("a,S = {}{}".format(a,S))
print(len(S))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
S = [int(input())]
for _ in range(N-1):
    a = int(input())
    ind = bisect.bisect_right(S,a)
    if S[ind-1]==a:
        ind1 = bisect.bisect_left(S,a)
        if ind1>0 and S[ind1-1]<a:
            S[ind1-1]=a
        else:
            bisect.insort_right(S,a)
    elif ind==0:
        bisect.insort_right(S,a)
    else:
        S[ind-1]=a
#     print("a,S = {}{}".format(a,S))
print(len(S))

Fixed submission:
import bisect
from collections import deque
N = int(input())
S = deque([int(input())])
for _ in range(N-1):
    a = int(input())
    ind = bisect.bisect_right(S,a)
    if S[ind-1]==a:
        ind1 = bisect.bisect_left(S,a)
        if ind1>0 and S[ind1-1]<a:
            S[ind1-1]=a
        else:
            S.appendleft(a)
    elif ind==0:
        S.appendleft(a)
    else:
        S[ind-1]=a
#     print("a,S = {}{}".format(a,S))
print(len(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = [A[0],A[1],A[0]^A[1]]
flag = 0
for i in range(2,N):
    if A[i] not in C:
        flag = 1
        break
if flag==1:
    print("No")
else:
    if N%3==0:
        if A[0]==A[1]==0:
            print("Yes")
        elif A[0]==0 or A[1]==0:
            cnt = 0
            for i in range(N):
                if A[i]==0:
                    cnt += 1
            if cnt==N//3:
                print("Yes")
            else:
                print("No")
        else:
            C = {A[0]:0,A[1]:0,A[0]^A[1]:0}
            for i in range(N):
                C[A[i]] += 1
            if C[A[0]]==C[A[1]]==C[A[0]^A[1]]:
                print("Yes")
            else:
                print("No")
    else:
        if A[0]==A[1]==0:
            print("Yes")
        else:
            print("No")
    

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
C = list(B)
k = len(C)
if N%3==0:
    if k==3 and C[0]^C[1]==C[2] and A.count(C[0])==A.count(C[1]) and A.count(C[0])==A.count(C[2]):
        print("Yes")
    elif k==2:
        C = sorted(C)
        if C[0]==0 and A.count(C[0])==N//3:
            print("Yes")
        else:
            print("No")
    elif k==1 and C[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    if k==1 and C[0] ==0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))
cnt = 0
i = 0
cnt += L[i]
while cnt<=X:
    i += 1
    cnt += L[i]
print(i+1)

Fixed submission:
import bisect
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0 for _ in range(N+1)]
for i in range(1,N+1):
    D[i] = D[i-1]+L[i-1]
ind = bisect.bisect_right(D,X)    
print(ind)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
C = {}
for z in combinations(X,2):
    x1,x2 = z
    a = x1[0]-x2[0]
    b = x1[1]-x2[1]
    if a>=0 and b>=0:
        if (a,b) not in C:
            C[(a,b)] = 0
        C[(a,b)] += 1
    elif a>=0 and b<0:
        if (a,b) not in C:
            C[(a,b)] = 0
        C[(a,b)] += 1
    elif a<0 and b>=0:
        if (-a,-b) not in C:
            C[(-a,-b)] = 0
        C[(-a,-b)] += 1
    elif a<0 and b<0:
        if (-a,-b) not in C:
            C[(-a,-b)] = 0
        C[(-a,-b)] += 1
C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
k = C[0][1]
print(N-k)

Fixed submission:
import itertools
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
if N==1:
    cmin = 1
else:
    cmin = 100
    for y in itertools.combinations(X,2):
        x1,y1 = y[0]
        x2,y2 = y[1]
        p = x2-x1
        q = y2-y1
        cnt0 = 0
        cnt1 = 0
        for i in range(N):
            x,y = X[i]
            if [x+p,y+q] in X:
                cnt0 += 1
            if [x-p,y-q] in X:
                cnt1 += 1
        cnt = max(cnt0,cnt1)
        cmin = min(cmin,N-cnt)
print(cmin)