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

Fixed submission:
a = int(input())
if a == 1:
    print('Hello World')
else:
    b = int(input())
    c = int(input())
    print(b + c)

Buggy submission (verdict: Runtime Error):
x = input().split()
N,T = int(x[0]),int(x[1])
a,b,c,d = [],[],[],[]
for i in range(N):
    v = input().split()
    v = [int(s) for s in v]
    a.append(v)
for i in range(N):
    b.append(a[i][0])
for i in range(N):
    c.append(a[i][1])
for i in range(N):
    if b[i] < T:
        d.append(a[b.index(b[i])][0])
if len([i for i, x in enumerate(d) if x == min(d)]) == 1 and [i for i, x in enumerate(d) if x == min(d)] != [0]:
    print(min(d))
else:
    print('TLE')

Buggy submission (verdict: Runtime Error):
x = input().split()
N,T = int(x[0]),int(x[1])
a = []
b = []
c = []
d = []
for i in range(N):
    v = input().split()
    v = [int(s) for s in v]
    a.append(v)
for i in range(N):
    b.append(a[i][0])
for i in range(N):
    c.append(a[i][1])
for i in range(N):
    if b[i] < T:
        d.append(a[b.index(b[i])][0])
if len([i for i, x in enumerate(d) if x == min(d)]) == 1 and [i for i, x in enumerate(d) if x == min(d)] != [0]:
    print(min(d))
else:
    print('TLE')
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

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

root = [-1]*n

def r(x):
    if root[x] < 0 :
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return - root[x]

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

max_size = max(map(size,range(n)))

print(max_size)

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

root = [-1]*n

def r(x):
    if root[x] < 0 :
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return - root[x]

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

max_size = max(map(size,range(n)))

print(max_size)
Problem p02612 (python)

Fixed submission:
# coding: utf-8
# Your code here!

n = int(input())
mai = n//1000
mai += 1
if mai*1000-n == 1000:
    print((mai-1)*1000-n)
else:
    print(mai*1000-n)

Buggy submission (verdict: Runtime Error):
mai = n//1000
mai += 1
if mai*1000-n == 1000:
    print((mai-1)*1000-n)
else:
    print(mai*1000-n)
Problem p02641 (python)

Fixed submission:
X, N = map(int,input().split())


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    i = 0
    while(True):
        # print(X-i)
        if X-i not in P:
            print(X-i)
            break
        elif X+i not in P:
            print(X+i)
            break
        if i > 120:
            break
        i +=1

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


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    min_abs = 99999
    min_abs_list = []
    search_list = [i for i in range(1,101) if i not in P]
    
    
    
    for p in search_list:
        diff = abs(X-p)
        if diff < min_abs:
            min_abs = diff
            min_abs_list=[]
            min_abs_list.append(p)
        if diff == min_abs:
            min_abs_list.append(p)
        
    print(min(min_abs_list))
Problem p02684 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)

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

pos = 0
visited = [0]*N
move = []
loop = []

while visited[pos]!=2:
  if visited[pos] ==0:
    move.append(pos)
  else:
    loop.append(pos)
  visited[pos] += 1
  pos = A[pos]-1

if len(move)>k:
  print(move[k]+1)
else:
  print(roop[(K-(len(move)-len(loop)))%len(loop)]+1)
Problem p03456 (python)

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

flg = False
for i in range(1,1000):
  if i*i == A:
    flg = True
    break

if flg:
  print("Yes")
else:
  print("No")

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

flg = False
for i in range(1,101):
  if i*i = A:
    flg = True
    break

if flg:
  print("Yes")
else:
  print("No")
Problem p02756 (python)

Fixed submission:
from collections import deque

S=deque(str((input())))
Q=int(input())
t=0
for _ in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        t+=1
    else:
        if (T[1]=="1" and t%2 == 0) or (T[1]=="2" and t%2 != 0):
            S.appendleft(T[2])
        else:
            S.append(T[2])


if t%2 != 0:
    S.reverse()

print("".join(S))

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

S=deque(str((input())))
Q=int(input())
t=0
for _ in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        t+=1
    else:
        if (T[1]=="1" and t%2 == 0) or (T[1]=="2" and t%2 != 0):
            S.insert(0,T[2])
        else:
            S.append(T[2])


if t%2 != 0:
    S.reverse()

print("".join(S))

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

S=deque(str((input())))
Q=int(input())
t=0
for _ in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        t+=1
    else:
        if (T[1]=="1" and t%2 == 0) or (T[1]=="2" and t%2 != 0):
            S.insert(0,T[2])
        else:
            S.append(T[2])


if t%2 != 0:
    S.reverse()

print("".join(S))
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1

#もしリストにまだ数字が入っていなかったらCを代入
    if X[s-1] < 0:
        X[s-1] = c
    
#もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for i in range(M):
    s, c = map(str, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1
    if X[s-1] < 0:#もしリストにまだ数字が入っていなかったらCを代入
        X[s-1] = c
    
    #もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する
Problem p02780 (python)

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


l=sum(P[0:K])
k=l
for i in range(N-K):
  l = l-P[i]+P[i+K]
  if l>k:
    k=l

print((k+K)/2)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
def E(n):
  e=0
  for i in range(1,n+1):
    e+=i
  e = e/n
  return e

l=sum(P[0:K])
k=0
for i in range(1,N-K+1):
  l = l-P[i-1]+P[i-1+K]
  if l>k:
    k=l
    L=P[i:i+K]

A=0
for i in range(K):
  A+=E(L[i])
print(A)
Problem p02796 (python)

Fixed submission:
N=int(input())
xl=[]
for i in range(N):
  x,l=map(int,input().split())
  xl.append([x-l,x+l])

XL=sorted(xl,key=lambda x:x[1])

w=1
robot=XL[0]
for i in XL:
  if robot[1] <= i[0]:
    w+=1
    robot=i
print(w)

Buggy submission (verdict: Runtime Error):
import itertools
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=[]
for i in a:
	ma=i[0] + i[1]
	mi=i[0] - i[1]
	c=[mi,ma]
	b.append(c)


while True:
	count=[]
	for i in range(n):
		count.append(0)
	p=0
	d=list(itertools.combinations(range(n), 2))
	for i in d:
		p+=1
		if b[i[0]][0]<b[i[1]][0]<b[i[0]][1] or b[i[0]][0]<b[i[1]][1]<b[i[0]][1]:
			count[i[0]]+=1
			count[i[1]]+=1
	del b[count.index(max(count))]
	del b[count.index(max(count))]
	print(count)
	n-=1
	if sum(count)==0:
		break
print(len(count))
Problem p02830 (python)

Fixed submission:
N = input()
S,T=map(str,input().split())

A=0
P=""
while A < int(N):
  P+=S[A]+T[A]
  A=A+1

print(P)

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

A=0
P=""
while A < int(N):
  P+=S[A]+T[A]
  A=A+1

print(P)
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
L=b*a**2
if L==x:
  alfa=0
elif x >= L/2:
  h=x/(a**2)
  beta=math.atan((a/2)/(b-h))
  alfa=(math.pi)/2 - beta
else:
  alfa=math.atan(b/(2*x/(a*b)))
print(math.degrees(alfa))

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
h=x/(a**2)
if x >= (b*a**2)/2:
  beta=math.atan((a/2)/(b-h))
  alfa=(math.pi)/2 - beta
else:
  alfa=math.atan(b/(2*x/(a*b)))
print(math.degrees(alfa))
Problem p02924 (python)

Fixed submission:
N=int(input())-1
print(N*(N+1)//2)

Buggy submission (verdict: Runtime Error):
N=int(input())
dp=[0]*(N)
for i in range(1,N):
  dp[i] += dp[i-1]+i
print(dp[-1])
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
d=0
i=0
for i in range(N):
  d+=L[i]
  if d<=X:
    i+=1
  else:break
print(i+1)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
d=0
i=0
while d<=X:
  d+=L[i]
  i+=1
print(i)
Problem p03125 (python)

Fixed submission:
A,B=map(int,input().split())
if B%A==0:
  print(A+B)
else:
  print(B-A)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
if B%A==0:
  print(A+B)
else:
  print(A-B
Problem p03262 (python)

Fixed submission:
import fractions
N,X=map(int,input().split())
x=list(map(lambda x: abs(int(x)-X), input().split()))
x_min=min(x)
g_min=x_min
for i in x:
  g=fractions.gcd(g_min,i)
  if g < g_min:
    g_min = g
print(g_min)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,X=map(int,input().split())
x=list(map(lambda x: abs(int(x)-X), input().split()))

x_min=min(x)
a=[x_min]*N
g=np.gcd(a,x)
print(min(g))
Problem p03359 (python)

Fixed submission:
a,b=map(int,input().split())
if b>=a:
  print(a)
else:
  print(a-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int(input().split()))
if b>=a:
  print(a)
else:
  print(a-1)
Problem p03379 (python)

Fixed submission:
import copy
N=int(input())
X=list(map(int,input().split()))

Y=copy.copy(X)
Y.sort()
center = N//2
right = Y[center]
left = Y[center-1]
center_line = (right+left)/2

for i in range(N):
  if X[i] > center_line:
    print(left)
  else:
    print(right)

Buggy submission (verdict: Runtime Error):
import copy
N=int(input())
X=list(map(int,input().split()))
d=[0]*(max(X))

for i in range(N):
  if d[X[i]-1]>0:
    print(d[X[i]-1])
  else:
    Y=copy.copy(X)
    Y.pop(i)
    Y.sort()
    ans = Y[(N-2)//2]
    print(ans)
    d[X[i]-1] = ans
Problem p03470 (python)

Fixed submission:
N=int(input())
d=[int(input()) for i in range(N)]
d=set(d)
print(len(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
d=set[int(input()) for i in range(N)]
print(len(d))
Problem p03501 (python)

Fixed submission:
N,A,B=map(int,input().split())
print(min(N*A,B))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input(),split())
print(min(N*A,B))
Problem p03573 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b:
  print(c)
elif b==c:
  print(a)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b:
  print(c)
elif b==c:
  print(a):
else:
  print(b)
Problem p02554 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
if N == 1:
  answer = 0
else:
  answer = (10 ** N) - (9 ** N) - (9 ** N) + (8 ** N)
print(answer % rest)

Buggy submission (verdict: Runtime Error):
import math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
  
if N == 1:
  answer = 0
else:
  answer = cmb(N, 2) * 2 * (10 ** (N - 2))
print(answer % rest)

a = cmb(N, 2)
print(a)
Problem p02621 (python)

Fixed submission:
a = int(input())

print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
n, m ,k = map(int,input().split())
a_list = [int(a) for a in input().split()]
b_list = [int(b) for b in input().split()]
time = 0
a_num = 0
b_num = 0
count = 0

# 次回が小さい方を選択する
while True:
    
    if (len(a_list) < a_num + 1) and (len(b_list) < b_num + 1): 
        break

    elif  (len(a_list) < a_num + 1) and(len(b_list) >= b_num + 1):
        time += b_list[b_num]      
        b_num += 1
     
    elif (len(a_list) >= a_num + 1) and (len(b_list) < b_num + 1):
        time += a_list[a_num]      
        a_num += 1
        
    else:
        if sum(a_list[a_num:]) < sum(b_list[b_num:]):
            time += a_list[a_num]
            a_num += 1
        else:
            time += b_list[b_num]      
            b_num += 1
    
    if time <= k:
        count += 1
    else:
        break

print(count)
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())
 
if (1 <= X <= 100) and (1 <= Y <= 100):
  kame = ( Y - (2 * X)) / 2
  turu = (Y - (4 * X)) / -2
  
  if kame.is_integer() and turu.is_integer() and kame >= 0 and turu >= 0:
  	print("Yes")
  else:
    print("No")

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

if (1 <= X <= 100) and (1 <= Y <= 100):
  if isinstance(( Y - X ) / 2, int) and isinstance((Y - X) / -2, int)
  	print("Yes")
  else:
    print("No")
Problem p02945 (python)

Fixed submission:
inputs = input().split()
a      = int(inputs[0])
b      = int(inputs[1])
if -100 <= a and b <= 100:
	print(max([a+b, a-b, a*b]))
else:
	raise ValueError

Buggy submission (verdict: Runtime Error):
inputs = input().split()
 
if -100 <= inputs[0] and inputs[1] <= 100:
	print(max([inputs[0]+inputs[1], inputs[0]-inputs[1], inputs[0]*inputs[1]]))
else:
	raise ValueError

Buggy submission (verdict: Runtime Error):
inputs = input().split()

if -100 <= input[0] and input[1] <= 100:
	print(max([input[0]+input[1], input[0]-input[1], input[0]*input[1]]))
else:
	raise ValueError
Problem p03085 (python)

Fixed submission:
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
elif b == 'G':
  print('C')

Buggy submission (verdict: Runtime Error):
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
elif b == 'G':
  print('C'):
Problem p03086 (python)

Fixed submission:
S = input()
ACGT = [ 'A', 'C', 'G', 'T' ]
listResult = []
sum = 0

for i in S:
    if i in ACGT:
        sum += 1
    else:
        listResult.append(sum)
        sum = 0
else:
    listResult.append(sum)
    
print(max(listResult))

Buggy submission (verdict: Runtime Error):
S = input()
ACGT = [ 'A', 'C', 'G', 'T' ]
listResult = []
sum = 0
for i in S:
    if i in ACGT:
        sum += 1
    else:
        listResult.append(sum)
        sum = 0
print(max(listResult))
Problem p02536 (python)

Fixed submission:
N,M = map(int,input().split( ))
loads = []
teams = [[i] for i in range(N)]
syozoku = {i:i for i in range(N)}
for _ in range(M):
    A,B = map(int,input().split( ))
    if syozoku[A-1] != syozoku[B-1]:
        hairu,nukeru = min(syozoku[A-1],syozoku[B-1]),max(syozoku[A-1],syozoku[B-1])
        team = teams[nukeru]
        teams[nukeru] = []
        teams[hairu] += team
        for i in team:
            syozoku[i] = hairu

ans = -1
for team in teams:
    if len(team) != 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split( ))
loads = []
teams = [[i] for i in range(N)]
syozoku = {i:i for i in range(N)}
for _ in range(M):
    A,B = map(int,input().split( ))
    if syozoku[A-1] != syozoku[B-1]:
        hairu,nukeru = min(syozoku[A-1],syozoku[B-1]),max(syozoku[A-1],syozoku[B-1])
        team = teams.pop(nukeru)
        teams[hairu] += team
        for i in team:
            syozoku[i] = hairu
ans = len(teams) - 1
print(ans)
Problem p02657 (python)

Fixed submission:
A,B = map(int,input().split( ))
print(A*B)

Buggy submission (verdict: Runtime Error):
import itertools
N,S = map(int,input().split( ))
A = list(map(int,input().split( )))
a = [i for i in range(N)]
C = []
for i in range(1,N+1):
    C += list(itertools.combinations(a,i))
ans = 0
for c in C:
    wa = 0
    for i in c:
        wa += A[i]
    if wa == S:
        for cc in C:
            if set(c) <= set(cc):
                ans += 1
print(ans)
Problem p02664 (python)

Fixed submission:
T = str(input())
ans = ''
for t in T:
    if t != '?':
        ans += t
    else:
        ans += 'D'
print(ans)

Buggy submission (verdict: Runtime Error):
T = str(input())
ans = ''
for i,t in eumerate(T):
    if t != '?':
        ans += t
    else:
        ans += 'D'
print(ans)
Problem p02555 (python)

Fixed submission:
s=int(input())
import math
ketamax=int(math.floor(s/3))

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=cmb(nokori+i-1,i-1)%waru
  ans=(ans+kazu)%waru


answer=int(ans%waru)
print(answer)

Buggy submission (verdict: Runtime Error):
s=int(input())
import math
from scipy.special import comb
ketamax=int(math.floor(s/3))


waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=comb(nokori+i-1,i-1)%waru
  ans=(ans+kazu)%waru


answer=int(ans%waru)
print(answer)

Buggy submission (verdict: Runtime Error):
s=int(input())
import math
ketamax=int(math.floor(s/3))

def kaijo(a,b):
    x=a
    for i in range(a+1,b+1):
        x=x*i
    return x

def comb(n, r):
    if r==0:
        return 1
    else:
        a=kaijo(n-r+1,n)/kaijo(1,r)
    return a


waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=comb(nokori+i-1,i-1)%waru
  ans=(ans+kazu)%waru


answer=int(ans%waru)
print(answer)

Buggy submission (verdict: Runtime Error):
s=int(input())
import math
ketamax=math.floor(s/3)

def kaijo(a,b):
    x=a
    for i in range(a+1,b+1):
        x=x*i
    return x

def comb(n, r):
    if r==0:
        return 1
    elif r==1:
        return n
    else:
        a=kaijo(n-r+1,n)/kaijo(1,r)
    return a

ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=comb(nokori+i-1,i-1)
  ans+=kazu

waru=pow(10,9)+7
answer=int(ans%waru)
print(answer)
Problem p02573 (python)

Fixed submission:
import sys

#UnionFindTreeクラスの定義
class UnionFind():
    #クラスコンストラクタ
    #selfはインスタンス自身
    def __init__(self, n):
        #親ノードを-1に初期化する
        self.parents = [-1] * n

    #根を探す（再帰関数）
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    #xとyの木を併合する
    def union(self, x, y):
        #x,yの根をX,Yとする
        X = self.find(x)
        Y = self.find(y)

        #根が同じなら結合済み
        if X == Y:
            return

        #ノード数が多い方をXとする
        if self.parents[X] > self.parents[Y]:
            X, Y = Y, X

        #XにYのノード数を足す
        self.parents[X] += self.parents[Y]
        #Yの根をXとする
        self.parents[Y] = X


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]

#UnionFindインスタンスの生成
uf = UnionFind(N)
for a, b in info:
    #インデックスを調整し、a,bの木を結合
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)

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

ab = [map(int, input().split()) for _ in range(m)]
a,b = [list(i) for i in zip(*ab)]

indexlist=[-1]*n

def findroot(x):
    while 1:
        if indexlist[x-1] < 0:
            return x
        else:
            x=indexlist[x-1]
            
def merge(a,b):
    art=findroot(a)
    brt=findroot(b)
    if not art == brt:
        indexlist[art-1]+=indexlist[brt-1]
        indexlist[brt-1]=a
        return
    else:
        return     

for j in range(m):
    a1=a[j]
    b1=b[j]
    merge(a1,b1)

ans=min(indexlist)*(-1)
print(ans)

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

ab = [map(int, input().split()) for _ in range(m)]
a,b = [list(i) for i in zip(*ab)]

indexlist=[-1]*n

def findroot(x):
    while 1:
        if indexlist[x-1] < 0:
            return x
        else:
            x=indexlist[x-1]
            


def merge(a,b):
    art=findroot(a)
    brt=findroot(b)
    if not art == brt:
        indexlist[art-1]+=indexlist[brt-1]
        indexlist[brt-1]=a
        return
    else:
        return
        

for j in range(m):
    a1=a[j]
    b1=b[j]
    merge(a1,b1)

ans=min(indexlist)*(-1)
print(ans)

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

ab = [map(int, input().split()) for _ in range(m)]
a,b = [list(i) for i in zip(*ab)]

indexlist=[-1]*n

def findroot(x):
    while 1:
        if indexlist[x-1] < 0:
            return x
        else:
            x=indexlist[x-1]
            


def merge(a,b):
    art=findroot(a)
    brt=findroot(b)
    art_ix=indexlist[art-1]
    brt_ix=indexlist[brt-1]
    if not art_ix<0 == brt_ix<0:
        indexlist[art-1]+=brt_ix
        indexlist[brt-1]=a
        return
    else:
        return
        

for j in range(m):
    a1=a[j]
    b1=b[j]
    merge(a1,b1)

ans=min(indexlist)*(-1)
print(ans)
Problem p02615 (python)

Fixed submission:
n=int(input())
a=a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
if n%2==0:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans+=a[0]
else:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans +=a[n//2]
  ans+=a[0]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
if n%2==0:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans+=ans[0]
else:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans +=a[n//2]
  ans+=a[0]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
if n%2==0:
  for i in range(1:n//2):
    ans +=2*a[i]
  ans+=ans[0]
else:
  for i in range(1:n//2):
    ans +=2*a[i]
  ans +=a[n//2]
  ans+=a[0]
print(ans)
Problem p02630 (python)

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
q=int(input())
bc = [list(map(int, input().split())) for l in range(q)]
cnt=[0]*100001
Sum=0
for i in range(n):
  cnt[a[i]]+=1
  Sum+=a[i]
for i in range(q):
  Sum+=(bc[i][1]-bc[i][0])*cnt[bc[i][0]]                           
  cnt[bc[i][1]]+=cnt[bc[i][0]]
  cnt[bc[i][0]]=0
  print(Sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
q=int(input())
bc = [list(map(int, input().split())) for l in range(q)]
cnt=[0]*100000
Sum=0
for i in range(n):
  cnt[a[i]]+=1
  Sum+=a[i]
for i in range(q):
  Sum+=(bc[i][1]-bc[i][0])*cnt[bc[i][0]]                           
  cnt[bc[i][1]]+=cnt[bc[i][0]]
  cnt[bc[i][0]]=0
  print(Sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
q=int(input())
bc = [list(map(int, input().split())) for l in range(q)]
cnt=[0]*(n+1)
Sum=0
for i in range(n):
  cnt[a[i]]+=1
  Sum+=a[i]
for i in range(q):
  Sum+=(bc[i][1]-bc[i][0])*cnt[bc[i][1]]                           
  cnt[bc[i][1]]+=cnt[bc[i][0]]
  cnt[bc[i][0]]=0
  print(Sum)
Problem p02640 (python)

Fixed submission:
X,Y=map(int,input().split())

if Y%2==0 and Y-2*X>=0 and 4*X-Y>=0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X=int(input())
Y=int(input())

if Y%2==0 and Y-2*X>=0 and 4*X-Y>=0:
  print("Yes")
else:
  print("No")