Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03309 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
s=[0 for x in range(n)]
 
for i in range(n):
  a[i] -= i+1
 
a.sort()
 
s = 0
for j in range(n):
  s += abs(a[j]-a[n//2])
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
s=[0 for x in range(n)]
 
for i in range(n):
  a[i] -= i+1
 
a.sort()
 
if n%2:
　s=0
  for i in range(n):
    s += abs(a[i]-a[n//2])
  print(s)
else:
  m=10**14
  for i in range(a[n//2-1],a[n//2]+1):
    s = 0
    for j in range(n):
      s += abs(a[j]-i)
    m = min(m,s)
  print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
s=[0 for x in range(n)]
 
for i in range(n):
  a[i] -= i+1
 
a.sort()
 
s=0
if s%2:
  for i in range(n):
    s += abs(a[i]-a[n//2])
  print(s)
else:
  m=10**14
  v=(a[n//2-1]+a[n//2])//2
  for i in range(v,v+2):
    s = 0
    for j in range(n):
      s += abs(a[j]-i)
    m = min(m,s)
  print(s)
n=int(input())
a=[int(x) for x in input().split()]
s=[0 for x in range(n)]

for i in range(n):
  a[i] -= i+1

a.sort()

if n%2:
  s=0
  for i in range(n):
    s += abs(a[i]-a[n//2])
  print(s)
else:
  m=10**14
  v=(a[n//2-1]+a[n//2])//2
  for i in range(a[n//2-1],a[n//2]+1):
    s = 0
    for j in range(n):
      s += abs(a[j]-i)
    m = min(m,s)
  print(s)
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print('Yes' if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
e=[int(x)-1 for x in input().split()]
p=[i for i in range(N)]
r=[0]*N

def find(x):
	if p[x]!=x:
		p[x]=find(p[x])
	return p[x]

def unite(x,y):
	x=find(x)
	y=find(y)
	if x==y:
		return

	if r[x]<r[y]:
		p[x]=y
	else:
		p[y]=x
		if r[x]==r[y]:
			r[x]+=1

def same(x,y):
	return find(x)==find(y)

for i in range(M):
	x,y=map(int,input().split())
	unite(x-1,y-1)

c=0
for i in range(N):
	if same(i,e[i]):
		c+=1

print(c)
Problem p03035 (python)

Fixed submission:
a, b = map(int, input().split())
if a >= 13 :
  print(b)
elif a >= 6 :
  print(b//2)
else :
  print(0)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a >= 13 :
  print(b)
elif a >= 6 :
  print(b//2)
else :
  print(0)
Problem p03729 (python)

Fixed submission:
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else :
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c = map(string,input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else :
  print('NO')
Problem p02910 (python)

Fixed submission:
S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
#print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No"
Problem p02665 (python)

Fixed submission:


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

if a == 0 and A[0] == 1:
    print(1)
    exit()
ch = [1]

cH = [1]
if A[0]>0:
    print(-1)
    exit()
for e,i in enumerate(A[1:]):
    cH.append(cH[-1]*2-i)
    # ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)

# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)
if 0 in cH:
    print(-1)
    exit()
A = A[::-1]

ans = 0
n = 0
for e,i in enumerate(A[:]):
    # print(n,ch[e],-1)
    if n//2+(n%2!=0)>cH[e]:
        print(-1)
        exit()
    if n  <= cH[e]:
        # print('ans:',ans,'n:',n)
        ans += n+i
        n+=i
    else:
        # print('ans:',ans,'ch:',cH[e],'i:',i)
        ans +=cH[e]+i
        n = cH[e]+i

    # print('ans:',ans,'n:',n)
print(ans)

Buggy submission (verdict: Runtime Error):

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

ch = [1]
t = 0
for e,i in enumerate(A):
    t+=i
    if t>=2**i:
        print(-1)
        exit()

cH = [1]
if A[0]>0:
    print(-1)
    exit()
for e,i in enumerate(A[1:]):
    cH.append(cH[-1]*2-i)
    # ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)

# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)

if cH[0] 

if 0 in cH:
    print(-1)
    exit()
A = A[::-1]

ans = 0
n = 0
for e,i in enumerate(A[:]):
    # print(n,ch[e],-1)
    if n//2+(n%2!=0)>cH[e]:
        print(-1)
        exit()
    if n  <= cH[e]:
        # print('ans:',ans,'n:',n)
        ans += n+i
        n+=i
    else:
        # print('ans:',ans,'ch:',cH[e],'i:',i)
        ans +=cH[e]+i
        n = cH[e]+i

    # print('ans:',ans,'n:',n)
print(ans)

Buggy submission (verdict: Runtime Error):

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

ch = [1]
t = 0
for e,i in enumerate(A):
    t+=i
    if t>2**i:
        print(-1)
        exit()

cH = [1]
if A[0]>0:
    print(-1)
    exit()
for e,i in enumerate(A[1:]):
    cH.append(cH[-1]*2-i)
    # ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)

# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)

if cH[0] 

if 0 in cH:
    print(-1)
    exit()
A = A[::-1]

ans = 0
n = 0
for e,i in enumerate(A[:]):
    # print(n,ch[e],-1)
    if n//2+(n%2!=0)>cH[e]:
        print(-1)
        exit()
    if n  <= cH[e]:
        # print('ans:',ans,'n:',n)
        ans += n+i
        n+=i
    else:
        # print('ans:',ans,'ch:',cH[e],'i:',i)
        ans +=cH[e]+i
        n = cH[e]+i

    # print('ans:',ans,'n:',n)
print(ans)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
A = list(map(int,input().split()))
dp = [-1] * (n+1)
B = []
f = 1
c = 0
ans = n
bal = 0
while dp[f-1] == -1:
    dp[f-1] =c
    B.append(f)
    f = A[f-1]
    c +=1
t = B.index(f)
if k>t:
    k -= t
    B = B[B.index(f):]
    k%=len(B)
    print(B[k])
else:
    print(B[k])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input().split()))
dp = [0] * (n+1)
B = []
f = 1
c = 0
for e,i in enumerate(A,1):
    if dp[f-1] or i == 1:
        ans = e-dp[f-1]
        bal = dp[f-1]
        break
    else:
        dp[f-1]+=c
        B.append(A[f-1])
        f = A[f-1]
        c+=1
k-= bal
# print(bal,ans)
B = B[bal:ans+1]
# print(dp)
k = (k%ans+1)%ans
print(B[k])
Problem p02761 (python)

Fixed submission:

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

l = []

for i in range(m):
    ta,tb = map(int,input().split())
    l.append((ta-1,tb))
ans = [0]*n
l.sort()
if m ==0 and n==1:
    print(0)
    exit()
elif m ==0:
    print('1'+'0'*(n-1))
    exit()
elif n == 1:
    if len(set(l)) ==1:
        print(l[0][1])
    else:
        print(-1)
    exit()
elif l[0][1] == 0 and l[0][0]==0:
    print(-1)
    exit()
else:
    l = set(l)
    for i,j in l:
        if ans[i] ==0:
            ans[i] = j
        else:
            # print(i,j)
            print(-1)
            exit()
a = ''
for i in ans:
    a+=str(i)
if a[0]=='0':
    a='1'+a[1:]
print(a)

Buggy submission (verdict: Runtime Error):
,m = map(int,input().split())

l = []

for i in range(m):
    ta,tb = map(int,input().split())
    l.append((ta-1,tb))
ans = [0]*n
l.sort()
if m ==0 and n==1:
    print(0)
    exit()
elif m ==0:
    print('1'+'0'*(n-1))
    exit()
elif n == 1:
    if len(set(l)) ==1:
        print(l[0][1])
    else:
        print(-1)
    exit()
elif l[0][1] == 0 and l[0][0]==0:
    print(-1)
    exit()
else:
    l = set(l)
    for i,j in l:
        if ans[i] ==0:
            ans[i] = j
        else:
            # print(i,j)
            print(-1)
            exit()
a = ''
for i in ans:
    a+=str(i)
if a[0]=='0':
    a='1'+a[1:]
print(a)

Buggy submission (verdict: Runtime Error):
dp = [[0]*3 for i in range(3)]
L = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
L = [a,b,c]
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

flag = 0 

for i in range(3):
    for j in range(3):
        if L[i][j] in l:
            dp[i][j] = 1
# dp = [[1,1,0],[0,1,0],[1,0,1]]
for i in range(3):
    if sum(dp[i]) ==3:
        flag = 1

for j in range(3):
    s = 0
    for i in range(3):
        s+= dp[i][j]
    if s == 3:
        flag = 1
s = 0
t = 0
for i in range(3):
    s+=  dp[i][i]
    t+= dp[i][2-i]
if s==3 or t == 3:
    flag = 1
    
if flag:
    print('Yes')
else:
    print('No')
# print(dp)

Buggy submission (verdict: Runtime Error):

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

l = []

for i in range(m):
    ta,tb = map(int,input().split())
    l.append((ta-1,tb))
ans = [0]*n
l.sort()
if l[0][1] == 0:
    print(-1)
    exit()
else:
    for i,j in l:
        if ans[i] ==0 or ans[i] ==j:
            ans[i] = j
        else:
            # print(i,j)
            print(-1)
            exit()
a = ''
for i in ans:
    a+=str(i)
print(a)
Problem p02787 (python)

Fixed submission:
H,N =map(int, input().split())
a = [] 
M = 0 
for i in range(N):
	t = list(map(int, input().split()))
	a.append(t)
	M = max(M,t[0])
dp = [100000000]*(H+1+M)
dp[0] = 0
for i in range(H):
	for j,k in a:
		dp[i+j] = min(dp[i+j],dp[i]+k)

print(min(dp[H:]))

Buggy submission (verdict: Runtime Error):
H,N =map(int, input().split())
a = [] 
M = 0 
for i in range(N):
	t = list(map(int, input().split()))
	a.append(t)
	M = max(M,t[0])
dp = [10000]*(H+1)
dp[0] = 0
for i in range(1,H+M):
	for j,k in a:
		dp[i+j] = min(dp[i+j],dp[i]+k)

print(min(dp[H:]))
Problem p02802 (python)

Fixed submission:

a,b = map(int,input().split())
dp = [0]*(100010)
qp = [0]*(100010)
for i in range(b):
    ta,tb = map(str,input().split())
    ta = int(ta)
    if qp[ta] == 0 :
        if tb == 'WA':
            dp[ta]+=1
        else :
            qp[ta]=1
ANS = 0
for i, j in zip(dp,qp):
    ANS += i*j
print(sum(qp),ANS)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
dp = [0]*(100010)
qp = [0]*(100010)
for i in range(b):
    ta,tb = map(str,input().split())
    ta = int(ta)
    if qp[ta] == 0 :
        if tb == 'WA':dp[ta]+=1
        else qp[ta]=1
print(sum(qp),sum(dp))
Problem p02803 (python)

Fixed submission:
from collections import deque
 
INF = float('inf')
MOD = 10 ** 9 + 7
dy = (0, -1, 0, 1)
dx = (1, 0, -1, 0)


H,W=map(int,input().split())
M = []
Max_list = []
for i  in range(H):
    t = input()
    M.append(t)
dx = [0,0,-1,1]
dy = [1,-1,0,0]
dist = [[-1]*W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        dist = [[-1]*W for _ in range(H)]
        if M[i][j] == '.':
            Ma = 0
            q.append((i, j))
            dist[i][j] = 0
            while q:
                cx,cy = q.popleft()
                for nx,ny in zip(dx,dy):
                    x ,y= cx+nx,cy+ny
                    if x<0 or y<0 or x>=H or y>=W or dist[x][y]>0:
                        continue
                    if M[x][y] == "." and dist[x][y] == -1:
                        dist[x][y]=dist[cx][cy]+1
                        Ma = max(Ma,dist[x][y])
                        q.append((x,y))
            # print(Ma)
            Max_list.append(Ma)
# print(Max_list)

print(max(Max_list))

Buggy submission (verdict: Runtime Error):
from collections import deque

d=[(1,0),(0,1),(-1,0),(0,-1)]
H,W=map(int,input().split())
M = []
Max_list = []
for i  in range(H):
    t = input()
    M.append(t)
dist = [[-1]*W for _ in range(H)]
def BFS(i,j):
    q = deque()
    dist = [[-1]*W for _ in range(H)]
    if M[i][j] == '.':

        #前処理
        Ma = 0
        q.append((i, j))#スタート地点挿入
        dist[i][j] = 0
        while q:
            cx,cy = q.popleft()
            for nx,ny in d:
                x ,y= cx+nx,cy+ny
                if 0<= x < H and 0<= y < W and M[x][y] == "." and dist[x][y]==-1:
                    dist[x][y]=dist[cx][cy]+1
                    Ma = max(Ma,dist[x][y])
                    q.append((x,y))
        return Ma
for i in range(H):#全部の地点でBFSをためす
    for j in range(W):
        Max_list.append(BFS(i,j))

print(max(Max_list))

Buggy submission (verdict: Runtime Error):
from collections import deque

d=[(1,0),(0,1),(-1,0),(0,-1)]
H,W=map(int,input().split())
M = []
Max_list = []
for i  in range(H):
    t = input()
    M.append(t)
dist = [[-1]*W for _ in range(H)]
def BFS(i,j):
    q = deque()
    dist = [[-1]*W for _ in range(H)]
    if M[i][j] == '.':

        #前処理
        Ma = 0
        q.append((i, j))#スタート地点挿入
        dist[i][j] = 0
        while q:
            cx,cy = q.popleft()
            for nx,ny in d:
                x ,y= cx+nx,cy+ny
                if 0<= x < H and 0<= y < W and M[x][y] == "." and dist[x][y]==-1:
                    dist[x][y]=dist[cx][cy]+1
                    Ma = max(Ma,dist[x][y])
                    q.append((x,y))
        return Ma
for i in range(H):#全部の地点でBFSをためす
    for j in range(W):
        Max_list.append(BFS)

print(max(Max_list))
Problem p02817 (python)

Fixed submission:
a,b = map(str,input().split())
print(b+a)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())

if c<a:
    print(a-c,b)
else:
    print(0,b+a-c)
Problem p02823 (python)

Fixed submission:
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2) 
else:
    m = min(b-1,n-a)
    M = min(a-1,n-b)+(b-a-1)//2+1
    print(min(m,M))

Buggy submission (verdict: Runtime Error):
if (b-a)%2==0:
    print((b-a)//2) 
else:
    m = min(b-1,n-a)
    M = min(a-1,n-b)+(b-a-1)//2
    print(min(m,M))
Problem p02844 (python)

Fixed submission:
a = int(input())
b = input()
ans = 0
for i in range(1000):
	T = '0'*(3-len(str(i)))
	t = T+ str(i)
	I = 0
	while I < 3:
		for j in b:
			#if t == '022':print(I,t[I],j)
			if I == 3:
				break
			if t[I] == j:I+=1
			#if t == '022':print(I,j)
		
		if I == 3: 
			#print(t)
			ans +=1
		break
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
l = input()
dp = [0]*1110
qp = [0]*1110
ans = 0
#print('###############')
def bfs(i,x,y):
	#print(i,x)
	if y == 3:
		ans +=1
		return 0
	else:
		for j in range(i,a):
			if int(x+str(l[j])) != 1:bfs(j+1,x+str(l[j]),y+1)
			dp[int(x+str(l[j]))] = 1
bfs(0,'',0)
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
l = input()
dp = [0]*1110
qp = [0]*1110
ans = 0
#print('###############')
def bfs(i,x,y):
	#print(i,x)
	if y == 3:
		ans +=1
		return 0
	else:
		for j in range(i,a):
			if int(x+str(l[j])) != 1:bfs(j+1,x+str(l[j]),y+1)
			dp[int(x+str(l[j]))] = 1
bfs(0,'',0)
print(sum(qp))

Buggy submission (verdict: Runtime Error):
a = int(input())
l = input()
dp = [0]*1110
qp = [0]*1110
ans = 0
#print('###############')
def bfs(i,x,y):
	#print(i,x)
	if y == 3:
		ans +=1
		return 0
	else:
		for j in range(i,a):
			if int(x+str(l[j])) != 1:bfs(j+1,x+str(l[j]),y+1)
			dp[int(x+str(l[j]))] = 1
bfs(0,'',0)
print(sum(qp))
Problem p02882 (python)

Fixed submission:
import math
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)
# if l:
#     print(0)
#     exit()
if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
elif L == c:
    print(0)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)
# if l:
#     print(0)
#     exit()
if L  == c:
    print(0)
    exit()
if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)

Buggy submission (verdict: Runtime Error):
import math
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)

if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)
Problem p02923 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans =[]
t = 0
for i , j in zip(l,l[1:]):
    if i < j:
        ans.append(t)
        t = 0
    else:
        t+=1
ans.append(t)
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans =[]
t = 0
for i , j in zip(l,l[1:]):
    if i < j:
        ans.append(t)
        t = 0
    else:
        t+=1
ans.append(t)
print(max(t))
Problem p02952 (python)

Fixed submission:
a = int(input())
s = str(a)
c = 0
for i in range(len(s)-1):
    # print(c)
    if i%2 == 0:
        c += 10**(i+1) - 10**i 

if len(s) %2 == 1 and len(s)> 1:
    c += int(s[1:])+1 + (int(s[0])-1)*(10**(len(s)-1))
elif len(s)==1:
    c +=a

print(c)

Buggy submission (verdict: Runtime Error):
a = int(input())
s = str(a)
c = 0
for i in range(len(s)-1):
    # print(c)
    if i%2 == 0:
        c += 10**(i+1) - 10**i 

if len(s) %2 == 1:
    c += int(s[1:])+1

print(c)

Buggy submission (verdict: Runtime Error):
a = int(input())
s = str(a)
c = 0
for i in range(len(s)-1):
    # print(c)
    if i%2 == 0:
        c += 10**(i+1) - 10**i 

if len(s) %2 == 1:
    c += int(s[1:])+1

print(c)
Problem p02973 (python)

Fixed submission:
#6484898
from bisect import bisect
N= int(input())
A = []
for i in range(N):
    t = int(input())
    A.append(t)

D = [1]*(N+1)
D[0] = -10**10
for a in A:
    idx = bisect(D, -a)
    D[idx] = min(D[idx], -a)
print(bisect(D, 0)-1)

Buggy submission (verdict: Runtime Error):

a = int(input())
l = []
for i in range(a):
	t = int(input())
	l.append(t)
d=[False]*a

#a = 5
#l = [2,1,4,5,3]
used=[False]*(a+10)
res =0
for i in range(a):
	if not used[i] and i+1<a:
		f = l[i]
		#print(1,f)
		L = []
		L.append(f)
		res +=1
		used[l[i]] = True
		for j in range(i+1,a):
			if f < l[j] and not used[l[j]]:
				f = l[j]
				#print(f)
				L.append(f)
				used[l[j]] = True
		#print(L)
print(res)
Problem p02975 (python)

Fixed submission:
a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
x.sort()
ax = list(set(x))
def ch(l):
    # print(l,l[1:] + [l[0]], l[2:] + [l[0]] +[l [1]])
    for i, j ,k in zip(l,l[1:] + [l[0]], l[2:] + [l[0]] +[l [1]]):
        if j != i ^ k: break
    else:
        return(1)
    return(0)
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
if len(ax) < 3:
    if (sum(x) == 0) :
        print("Yes")
        exit()
    if (len(ax)) <2:
        print("No")
        exit()
    if x.count(0)*2 == x.count(ax[1]) and len(x) == x.count(0) + x.count(ax[1]):
        print("Yes")
        exit()
        
    print("No")
    exit()
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2]))*ch(ax)

y(1,t)

Buggy submission (verdict: Runtime Error):

a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
x.sort()
ax = list(set(x))
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
if len(ax) < 3:
    if (sum(x) == 0) :
        print("Yes")
        exit()
    if x.count(0)*2 == x.count(ax[1]) and len(x) == x.count(0) + x.count(ax[1]):
        print("Yes")
        exit()
        
    print("No")
    exit()
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2]))

y(1,t)

Buggy submission (verdict: Runtime Error):
a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2])) + (sum(x) == 0)

y(1,t)
Problem p02995 (python)

Fixed submission:
def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)

Buggy submission (verdict: Runtime Error):
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)

Buggy submission (verdict: Runtime Error):
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)
Problem p02997 (python)

Fixed submission:
a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):
        print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):
        print(1,1+i)
    c = 0
    for i in range(2,a):
        for I in range(i+1,a):
            print(i,I)
            if c == s-a:break
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S)
Problem p03026 (python)

Fixed submission:
#実験用の写経
N = int(input())
g = {i: [] for i in range(N)}
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
c = list(map(int, input().split()))
c.sort()
print(sum(c[:-1]))
nums = [0] * N
stack = [0]
while stack:
    d = stack.pop()
    nums[d] = c.pop()
    for node in g[d]:
        if nums[node] == 0:
            stack.append(node)
print(' '.join(map(str, nums)))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
from heapq import heappush, heappop
from collections import deque
from collections import defaultdict
N = int(input())
l = []
p = [0]*N
lp = [0]*(N-1)
d =defaultdict(list)
for i in range(N-1):
    ta ,tb = map(int,input().split())
    l.append([ta-1,tb-1])    
li = list(map(int,input().split()))



for i,j in l:
    d[i].append([j,li[j]])
    d[j].append([i,li[i]])
q = deque()
q.append(0)
p[0] = 1
c = li[0]
ll = []
while q:
    t = q.pop()
    c = li[t]
    p[t] = 1
    for i ,j in d[t]:
        if p[i] == 0:
            ll.append(min(c,j))
            lp[t] = c
            q.appendleft(i)
print(sum(ll))
print(*li)
Problem p03030 (python)

Fixed submission:

a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)

Buggy submission (verdict: Runtime Error):

a = int(input())
l = []
for i in range(a):
    ta,tb = map(int,input().split())
    l.append([ta,tb,i+1])
l.sort()
for i, j , k in l:
    print(k)