Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mylist = []
x = 0
while x <= 1:
  val = input()
  x = x + 1
  if val:
    mylist.append(val)
  else:
    break
 


a = mylist[0].split( )
A = int(a[0])
B = int(a[1])
C = int(a[2])
K = int(mylist[1])
r = A
g = B 
b = C



for k in range(K):
    if r > b and r > g:
        if r > b:
            b = b * 2
        elif r > g:
            g = g * 2
        elif g > b:
            b = b * 2
    elif g > r:
        g = g * 2
    elif b == g or b == r:
        b = b * 2
    elif b > g and g == r:
        g = g * 2


if b > g and g > r:
    print("yes")
else:
    print("no")    


Fixed submission:
import sys

x = input()
y = int(x)


a = 400
b = 0
kyu = 8

while(1):
    
    if a + b <= y <= a + b + 199:
        print(str(kyu))
        break
    
    b = b + 200
    kyu = kyu - 1

Buggy python submission (verdict: Runtime Error):
mylist = []
x = 0
while x <= 1:
  val = input()
  x = x + 1
  if val:
    mylist.append(val)
  else:
    break
 


a = mylist[0].split( )
A = int(a[0])
B = int(a[1])
C = int(a[2])
K = int(mylist[1])
r = A
g = B 
b = C



for k in range(K):
    if r > b and r > g:
        if r > b:
            b = b * 2
        elif r > g:
            g = g * 2
        elif g > b:
            b = b * 2
    elif g > r:
        g = g * 2
    elif b == g or b == r:
        b = b * 2
    elif b > g and g == r
        g = g * 2


if b > g and g > r:
    print("yes")
else:
    print("no")    


Fixed submission:
import sys

x = input()
y = int(x)


a = 400
b = 0
kyu = 8

while(1):
    
    if a + b <= y <= a + b + 199:
        print(str(kyu))
        break
    
    b = b + 200
    kyu = kyu - 1

Buggy python submission (verdict: Runtime Error):
mylist = []
x = 0
while x <= 1:
  val = input()
  x = x + 1
  if val:
    mylist.append(val)
  else:
    break
 


a = mylist[0].split( )
A = int(a[0])
B = int(a[1])
C = int(a[2])
K = int(mylist[1])
r = A
g = B 
b = C



for k in range(K):
    if r > b and r > g:
        if r > b:
            b = b * 2
        elif r > g:
            g = g * 2
        elif g > b:
            b = b * 2
    elif g > r:
        g = g * 2


if b > g and g > r:
    print("yes")
else:
    print("no")    

        



Fixed submission:
import sys

x = input()
y = int(x)


a = 400
b = 0
kyu = 8

while(1):
    
    if a + b <= y <= a + b + 199:
        print(str(kyu))
        break
    
    b = b + 200
    kyu = kyu - 1

Buggy python submission (verdict: Runtime Error):
mylist = []
x = 0
while x <= 1:
  val = input()
  x = x + 1
  if val:
    mylist.append(val)
  else:
    break
 


a = mylist[0].split( )
A = int(a[0])
B = int(a[1])
C = int(a[2])
K = int(mylist[1])
r = A
g = B 
b = C



for k in range(K):
    if r > b:
        b = b * 2
    elif r > g:
        g = g * 2
    elif g > b:
        b = b * 2

if b > g and g > r:
    print("yes")
else:
    print("no")    


Fixed submission:
import sys

x = input()
y = int(x)


a = 400
b = 0
kyu = 8

while(1):
    
    if a + b <= y <= a + b + 199:
        print(str(kyu))
        break
    
    b = b + 200
    kyu = kyu - 1
Buggy python submission (verdict: Runtime Error):
a=input()
e=a[len(a)-1:len(a)-1]
if e == "s":
    print(a+"es")
else:
    print(a+"s"

Fixed submission:
a=input()
e=a[len(a)-1:len(a)]
if e == "s":
    print(a+"es")
else:
    print(a+"s")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
print(max(a)-min(a))

Fixed submission:
a=int(input())
if (a%2)==0: print(a)
else: print(a*2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
print(max(a)-min(a))

Fixed submission:
a=int(input())
if (a%2)==0: print(a)
else: print(a*2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
a.sort()
print(a[n-1]-a[0])

Fixed submission:
a=int(input())
if (a%2)==0: print(a)
else: print(a*2)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  l=list(map(int,input().split()))
  x=[i for i in range(l[0],l[1]+1)]
  y=[j for j in range(l[2],l[3]+1)]
  all_pair=[i*j for i in x for j in y]
  print(sorted(all_pair)[-1])
if __name__=='__main__':
  main()

Fixed submission:
import itertools
def main():
    l = list(map(int, input().split()))
    all_pair = []
    all_pair.append(l[0]*l[2])
    all_pair.append(l[0]*l[3])
    all_pair.append(l[1]*l[2])
    all_pair.append(l[1]*l[3])
    print(sorted(all_pair)[-1])
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    l = list(map(int, input().split()))
    x = [i for i in range(l[0],l[1])]
    y = [i for i in range(l[2],l[3])]
    all_pair = [x*y  for i in x for j in y]
    print(sorted(all_pair)[-1])
if __name__ == '__main__':
    main()

Fixed submission:
import itertools
def main():
    l = list(map(int, input().split()))
    all_pair = []
    all_pair.append(l[0]*l[2])
    all_pair.append(l[0]*l[3])
    all_pair.append(l[1]*l[2])
    all_pair.append(l[1]*l[3])
    print(sorted(all_pair)[-1])
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import itertools
def main():
    number = int(input())
    num_list = list(map(int, stdin.readline().split()))
    comb = list(itertools.combinations(num_list, 2))
    total = sum([c1*c2 for c1, c2 in comb])
    print(total % (1000000000 + 7))
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    l_input = list(map(int, input().split()))
    time = l_input[0] / l_input[2]
    if(time <= l_input[1]):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    number = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    num_list = list(range(1, number+1))
    permu = list(itertools.permutations(num_list, number))
    where_p = permu.index(p)
    where_q = permu.index(q)
    print(abs(where_p-where_q))
if __name__ == '__main__':
    main()

Fixed submission:
import itertools

def main():
    number = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    num_list = list(range(1, number+1))
    permu = list(itertools.permutations(num_list, number))
    where_p = permu.index(p)
    where_q = permu.index(q)
    print(abs(where_p-where_q))
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
x = 7%k
s = set()
i = 1
while list(s).count(x) == 0:
  if x == 0:
    print(i)
    exit()
  s.add(x)
  x = (x*10+7)%k
  i += 1
print(-1)


Fixed submission:
k = int(input())
x = 7%k
s = set()
#i = 1
#while len(s) == 0:
for i in range(1, k+1):
  if x == 0:
    print(i)
    exit()
  #s.add(x)
  x = (x*10+7)%k
  #i += 1
print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
c=0
for i in range(1,n):
  a = 0
  while a<n-i:
    a+=i
    c+=1
 
print(c)

Fixed submission:
s = input()

if s[-1] == 's':
  print(s + 'es')
else:
  print(s + 's')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c=0
for i in range(1,n):
  a = 0
  while a<n-i:
    a+=i
    c+=1
 
print(c)

Fixed submission:
n = int(input())
c=0
for i in range(1,n):
  a = 0
  while a<n-i:
    a+=i
    c+=1
 
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 

M = 1
for i in range(N):
  M = M * A[i]
  
if M >10**18:
  print(-1)
else:
  print(M)

Fixed submission:
import sys

N = int(input())
A = sorted(map(int, input().split())) 

M = 1
for i in range(N):
  M = M * A[i]
  if M >10**18:
    print(-1)
    sys.exit()
  
print(M)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
l = len(t)
ans = 0
a = 0
list1 = []
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
      list1.append(ans)
    else:
      pass
  ans = 0
m =  max(list1)
print(l-m)

Fixed submission:
s = input()
t = input()
l = len(t)
ans = 0
a = 0
list1 = [0]
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
      list1.append(ans)
    else:
      pass
  ans = 0
m =  max(list1)
print(l-m)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
l = len(t)
ans = 0
a = 0
list1 = []
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
      list1.append(ans)
    else:
        ans = 0
  ans = 0
m =  max(list1)
print(l-m)

Fixed submission:
s = input()
t = input()
l = len(t)
ans = 0
a = 0
list1 = [0]
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
      list1.append(ans)
    else:
      pass
  ans = 0
m =  max(list1)
print(l-m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list1 = list(map(int, input().split()))
s = 0
for i in range(n):
    p = list1[i] * sum(list1[i+1:n])
    s += p
print(s % (10**9 + 7))

Fixed submission:
n = int(input())
list1 = list(map(int, input().split()))
s = 0
ss = sum(list1)
for i in range(n):
  a = list1[i]
  ss = ss - a
  p = a * ss
  s += p
print(s % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list1 = list(map(int, input().split()))
s = 0
for i in range(n):
  for j in range(i+1,n):
    p = list1[i] * list1[j]
    s += p
print(s % (10**9 + 7))

Fixed submission:
n = int(input())
list1 = list(map(int, input().split()))
s = 0
ss = sum(list1)
for i in range(n):
  a = list1[i]
  ss = ss - a
  p = a * ss
  s += p
print(s % (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
x=0
c=list()
for i in range(1,n+1):
  a=i+l[i-1]
  c.append(a)
  b=i-l[i-1]
  if b in c:
    x=x+c.count(b)
print(x)



Fixed submission:
s=input()
if s== 'ABC':
  print('ARC')
if s=='ARC':
  print('ABC')

Buggy python submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
x=0
c=list()
for i in range(1,len(l)+1):
  a=i+l[i-1]
  c.append(a)
  b=i-l[i-1]
  if b in c:
    x=x+c.count(b)
print(x)



Fixed submission:
s=input()
if s== 'ABC':
  print('ARC')
if s=='ARC':
  print('ABC')
Buggy python submission (verdict: Runtime Error):
x,y,z = input()
print(z,y,x)

Fixed submission:
x,y,z = map(int,input().split())
print(z,x,y)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  print("No")

Fixed submission:
text = input()
tend = len(text)
text2 = ""
if text[len(text)-1:len(text)] == "s":
    text2 = text +'es'
else:
    text2 = text +'s'
print(text2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  print("No")

Fixed submission:
text = input()
tend = len(text)
text2 = ""
if text[len(text)-1:len(text)] == "s":
    text2 = text +'es'
else:
    text2 = text +'s'
print(text2)
Buggy python submission (verdict: Runtime Error):
R,G,B = map(int,input().split())
K = int(input())

if R < G < B:
  print("Yes")
  
for i in range(K):
  if R > G:
    G*=2
  elif G > B:
    B*=2
  elif R > B:
    B*=2
  elif R == G == B:
    B *= 2
  elif R == G:
    G *= 2
  elif G == B:
    B *= 2
  else:
    pass
if R < G < B:
  print("Yes")
else:
  print("No")

Fixed submission:
Kyu = int(input())

if 400 <= Kyu < 600:
  print("8")
elif 600 <= Kyu < 800:
  print("7")
elif 800 <= Kyu < 1000:
  print("6")
elif 1000 <= Kyu < 1200:
  print("5")
elif 1200 <= Kyu < 1400:
  print("4")
elif 1400 <= Kyu < 1600:
  print("3")
elif 1600 <= Kyu < 1800:
  print("2")
elif 1800 <= Kyu < 2000:
  print("1")
Buggy python submission (verdict: Runtime Error):
a = input()
print(a+(a*a)+(a*a*a))


Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))
Buggy python submission (verdict: Runtime Error):
n = "NO"
y = "YES"

A, V = map(int, input().split()) #Aは初期座標 Vは1秒あたりの移動距離#
B, W = map(int, input().split()) #Aは初期座標 Wは1秒あたりの移動距離#
T = int(input()) #移動許可秒数#

##################################################
# 答えはT秒後に鬼が逃げ役と同じ座標or追い越せばYES#
# 計算はTLE対策として掛け算を使用　　　　　　　　　#
#V,W * T でT秒間の移動距離を算出 　　　　　　　　　#
# ANS = A,B + V,W * T　　　　　　　　　　　　　　　#   
##################################################

X = V * T
Y = W * T

A += X
B += Y

if B > A:
  print(y)
else:
  print(n)


Fixed submission:
S = input()

print(S[0:3])

Buggy python submission (verdict: Runtime Error):
n = "NO"
y = "YES"

A, V = map(int, input().split()) #Aは初期座標 Vは1秒あたりの移動距離#
B, W = map(int, input().split()) #Aは初期座標 Wは1秒あたりの移動距離#
T = int(input()) #移動許可秒数#

##################################################
# 答えはT秒後に鬼が逃げ役と同じ座標or追い越せばYES#
# 計算はTLE対策として掛け算を使用　　　　　　　　　#
#V,W * T でT秒間の移動距離を算出 　　　　　　　　　#
# ANS = A,B + V,W * T　　　　　　　　　　　　　　　#   
##################################################

X = V * T
Y = W * T

A += X
B += Y

if B >= A:
  print(y)
else:
  print(n)


Fixed submission:
S = input()

print(S[0:3])
Buggy python submission (verdict: Runtime Error):
a, b, h, m = map(int,input().split())

hk = h * 30
mk = m * 6

kaku = mk - hk

print(((b ** 2)+(a ** 2)) - (2 * a * b * kaku))

Fixed submission:
a = int(input())
z = input()

if len(z) > a: 
  print(z[0:a] + "...")
else:
  print(z)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
if a <= 1000000:
for i in range(a):
    if i % 15 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
print(sum(b))


Fixed submission:
a = input()

if "7" in a:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
if a <= 1000000:
for i in range(a):
    if i % 15 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
else:
  pass
print(sum(b))


Fixed submission:
a = int(input())
b = []

for i in range(a+1):
    if i % 3 == 0 and i % 5 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
print(sum(b))
Buggy python submission (verdict: Runtime Error):
as. bs = map(str,input().split())
ci, di = map(int,input().split())
es = str(input())

if es == as:
  ca = ci - 1
  print(ca)
elif es == bs:
  da = di -1
  print(da)

Fixed submission:
A, B = map(str, input().split())
N, M = map(int, input().split())
S = input()

if A == S:
  print(N-1,M)
elif B == S:
  print(N,M-1)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

l = [1,2,3]

l.remove(a)
l.remove(b)

print(l)


Fixed submission:
a = int(input())
b = int(input())
l = [1,2,3]
l.remove(a)
l.remove(b)
print(''.join(map(str,l)))
Buggy python submission (verdict: Runtime Error):
A = input()

S = [SUN,MON,TUE,WED,THU,FRI,SAT]

for i in range(7):
  if A == S[i]:
    print(7-i)
    break
  i+=1


Fixed submission:
A = input()

S = ['SUN','MON','TUE','WED','THU','FRI','SAT']

for i in range(7):
  if A == S[i]:
    print(7-i)
    break
  i+=1
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
N = list(map(int,input().split()))

c=0

for i in range(A):
  if N[i] >= B:
    c+=1
  else:
    pass
  i+=1
print(c)


Fixed submission:
N = int(input())

L = [i for i in range(N+1)]

odd = []

for j in range(N+1):
  if L[j] % 2 == 0:
    pass
  else:
    odd.append(L[j])
  j+=1

print(len(odd)/(len(L)-1))

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

c=0

for i in range(A):
  if N[i] >= B:
    c+=1
  else:
    pass
  i+=1
print(c)


Fixed submission:
N = int(input())

L = [i for i in range(N+1)]

odd = []

for j in range(N+1):
  if L[j] % 2 == 0:
    pass
  else:
    odd.append(L[j])
  j+=1

print(len(odd)/(len(L)-1))
Buggy python submission (verdict: Runtime Error):
A=B=int(input())
N = list(int,input().split())

c=0

for i in range(A):
  if N[i] >= B:
    c+=1
  else:
    pass
  i+=1
print(c)

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

c=0

for i in range(A):
  if N[i] >= B:
    c+=1
  else:
    pass
  i+=1
print(c)
Buggy python submission (verdict: Runtime Error):
N = input()

W = ['Sunny','Cloudy','Rainy']

for i in range(3):
  if N == W[i]:
    print(W[i+1])
  else:
    pass
  i+=1

Fixed submission:
N = input()

W = ['Sunny','Cloudy','Rainy']

for i in range(3):
  if N == 'Rainy':
    print('Sunny')
    break
  elif N == W[i]:
    print(W[i+1])
  else:
    pass
  i+=1
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())

p = A+B
m = A-B
M = A*B

L = []

L.append(p)
L.append(m)
L.append(M)

print(max(M))

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

p = A+B
m = A-B
M = A*B

L = []

L.append(p)
L.append(m)
L.append(M)

print(max(L))
Buggy python submission (verdict: Runtime Error):
r = input();
print(3 * r * r);


Fixed submission:
r = int(input())
print(3 * r * r)
Buggy python submission (verdict: Runtime Error):
n = int(input())  
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))

ans = []
for i in range(n):
  a = num_list[i]
  a1= a[0]
  a2 = a[1]
  if a1 == a2:
    ans.append(1)
    if i > 1 and ans[i-2] == 1 and ans[i-1] == 1 and ans[i] == 1:
      print('Yes')
      break
  else:
    ans.append(0)
if len(ans) == n:
  print('No')


Fixed submission:
n = input()
if n[-1] == 's':
  print(n+'es')
else:
  print(n+'s')
Buggy python submission (verdict: Runtime Error):
D,T,S = map(float,raw_input().split())
def intime(D,T,S):
  if D<=T*S:
    print('Yes')
  else:
    print('No')

Fixed submission:
A, B, C = map(int, input().split())
if A <= B*C:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
s = list(map(int,input().split()))
g = list(map(int,input().split()))
s[0] -= 1
s[1] -= 1
g[0] -= 1
g[1] -= 1
raw = []
seen = []
for _ in range(h):
  tmp = input()
  raw.append(tmp)
  t = []
  for j in range(w):
    if tmp[j] == '.':
      t.append(0)
    else:
      t.append(1)
  seen.append(t)

now = [s]
ans = 0

def check(ii,jj):
  if 0 <= ii < h and 0 <= jj < w:
    if seen[ii][jj] == 0:
      seen[ii][jj] = 1
      now.append([ii,jj])

while now:
  for x in now:
    a,b = x
    check(a-1,b)
    check(a+1,b)
    check(a,b-1)
    check(a,b+1)
  if seen[g[0]][g[1]] == 1:
    print(ans)
    break
  ans += 1
  last = now
  now = []
  for x in last:
    a,b = x
    for di in range(-2,3):
      for dj in range(-2,3):
        check(a+di,b+dj)
else:
  print(-1)

Fixed submission:
h,w = map(int,input().split())
s = list(map(int,input().split()))
g = list(map(int,input().split()))
s[0] -= 1
s[1] -= 1
g[0] -= 1
g[1] -= 1
raw = []
seen = []
for _ in range(h):
  tmp = input()
  raw.append(tmp)
  t = []
  for j in range(w):
    if tmp[j] == '.':
      t.append(0)
    else:
      t.append(1)
  seen.append(t)

now = [s]
ans = 0

def check(ii,jj):
  if 0 <= ii < h and 0 <= jj < w:
    if seen[ii][jj] == 0:
      seen[ii][jj] = 1
      now.append([ii,jj])

while now:
  for x in now:
    a,b = x
    check(a-1,b)
    check(a+1,b)
    check(a,b-1)
    check(a,b+1)
  if seen[g[0]][g[1]] == 1:
    print(ans)
    break
  ans += 1
  last = now
  now = []
  for x in last:
    a,b = x
    for di in range(-2,3):
      for dj in range(-2,3):
        check(a+di,b+dj)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        continue
    par[x] = y
    size[y] += size[x]
    size[x] = 0

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

Ans =0
for j in size[1:]:
    if j != 0:
        Ans +=1
print(Ans)


Fixed submission:
N, M = map(int,input().split())
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0
    
for i in range(M):
    x, y,  z= map(int,input().split())
    unite(x,y)
    
Ans =0
for j in size[1:]:
    if j != 0:
        Ans +=1
print(Ans)

Buggy python submission (verdict: Runtime Error):
import collections

N, M = map(int, input().split())
par = [i for i in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y

for i in range(M):
    X, Y, Z = map(int, input().split())
    unite(X, Y)
    print(par)

res = par[1:]
c = collections.Counter(res)
print(len(c))

Fixed submission:
N, M = map(int,input().split())
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0
    
for i in range(M):
    x, y,  z= map(int,input().split())
    unite(x,y)
    
Ans =0
for j in size[1:]:
    if j != 0:
        Ans +=1
print(Ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

dp = [0, abs(h[1]-[0])]

for i in range(2,n):
    dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i] + abs(h[i]-h[i+2])))
    
print(dp[-1])

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]

for i in range(2, n):
    dp.append(min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] + abs(h[i-2]-h[i])))

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = 'E' + input() + 'W'
res, point= N, 0

for i in range(1, N+1):
    point = (S[:i]).count('W') + (S[i+1:]).count('E')
    res = min(res, point)
print(res)

Fixed submission:
N=int(input())
S=list(input())
e,w=[0]*(N+1),[0]*(N+1)
for i in range(1,N+1):
    w[i] += w[i-1] + (1 if S[i-1]=='W' else 0)
    e[i] += e[i-1] + (1 if S[i-1]=='E' else 0)
ans=N
for i in range(N):
    ans=min(ans,w[i]+e[-1]-e[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = ["."*(W+2)] + ["." + input() + "." for _ in range(H)] + ["."*(W+2)]
for y in range(1, H+1):
    for x in range(1, W+1):
        if S[y][x] = '#' and (S[y-1][x] + S[y+1][x] + S[y][x-1] + S[y][x+1]).count('#') == 0:
            print("No")
            exit()
print("Yes")

Fixed submission:
H, W = map(int, input().split())
S = ["."*(W+2)] + ["." + input() + "." for _ in range(H)] + ["."*(W+2)] #塗りたし

for y in range(1, H+1):
    for x in range(1, W+1):
        if S[y][x] == '#' and (S[y-1][x] + S[y+1][x] + S[y][x-1] + S[y][x+1]).count('#') == 0:
            print("No")
            exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
for a500 in range(A + 1):
    for b100 in range(B + 1):
        for c50 in range(C + 1):
            if a500 * 500 + b100 * 100 + c50 * 50 = X:
                res += 1
print(res)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
for a500 in range(A + 1):
    for b100 in range(B + 1):
        for c50 in range(C + 1):
            if a500 * 500 + b100 * 100 + c50 * 50 == X:
                res += 1
print(res)