Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n =input()
fn = 0
for i in range(len(n)):
  fn += n[i]
if int(n) % fn == 0:
  print('Yes')
else:
  print('No')


Fixed submission:
n =input()
fn = 0
for i in range(len(n)):
  fn += int(n[i])
if int(n) % fn == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n =input()
fn = 0
for i in range(len(n)):
  fn += n[i]
if n // fn == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
n =input()
fn = 0
for i in range(len(n)):
  fn += int(n[i])
if int(n) % fn == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(4)]
print(min(a[0],a[1])+min(a[2]+a[3]))

Fixed submission:
a = [int(input()) for i in range(4)]
print(min(a[0],a[1])+min(a[2],a[3]))
Buggy python submission (verdict: Runtime Error):
c=[input() for i in range(3)]
for j in range(3):
  print(c[i],end='')

Fixed submission:
c=[input() for i in range(3)]
for i in range(3):
  print(c[i][i],end='')
Buggy python submission (verdict: Runtime Error):
n=input()
a = []
for i in range(len(n)):
  a.append(int(n[i]))
if n % sum(a)== 0:
  print('Yes')
else:print('No')


Fixed submission:
n=input()
a = []
for i in range(len(n)):
  a.append(int(n[i]))
if int(n) % sum(a) == 0:
  print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(2):
  count=0
  for j = in range(i+1,4):
    if s[i] == s[j]:
      count+=1
    else:count=0
    if count >= 3:
      print('Yes')
      exit()
print('No')

Fixed submission:
s=input()
for i in range(2):
  count=1
  for j in range(i+1,4):
    if s[i] == s[j]:
      count+=1
    else:count=0
    if count >= 3:
      print('Yes')
      exit()
print('No')

Buggy python submission (verdict: Runtime Error):
a=sorted(input())
for i in range(4)
	if a.count(a[0]) <= 3:
    print('Yes')
    break
print('No')

Fixed submission:
s=input()
for i in range(2):
  count=1
  for j in range(i+1,4):
    if s[i] == s[j]:
      count+=1
    else:count=0
    if count >= 3:
      print('Yes')
      exit()
print('No')
Buggy python submission (verdict: Runtime Error):
a,b=input.split()
if ord(a) > ord(b):print('>')
elif a == b:print('=')
else:print('<')

Fixed submission:
a,b=input().split()
if ord(a) > ord(b):print('>')
elif a == b:print('=')
else:print('<')
Buggy python submission (verdict: Runtime Error):
a=input().list()
a=sorted(a)
print(a[2])

Fixed submission:
a=input().split()
a=sorted(a)
if a.count(a[0]) == 1:print(a[0])
else:print(a[2])
Buggy python submission (verdict: Runtime Error):
a=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:prnit('No')

Fixed submission:
a=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:print('No')

Buggy python submission (verdict: Runtime Error):
n=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:prnit('No')

Fixed submission:
a=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print('Possible')
else:print('Impossible')

Fixed submission:
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print('Possible')
else:print('Impossible')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
l = [list(map(int,input().split())) for i in range(a)]
l=sorted(l)
l=l[::-1]
sum = 0
for i in range(b-1):
  sum += l[i]
print(sum)
  

Fixed submission:
a,b=map(int,input().split())
l = list(map(int,input().split()))
l=sorted(l)
l=l[::-1]
sum = 0
for i in range(b):
  sum += l[i]
print(sum)
Buggy python submission (verdict: Runtime Error):
a=sorted(list(map(int,input().split()))
print(a[0]+a[1])

Fixed submission:
a=sorted(list(map(int,input().split())))
print(a[0]+a[1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

Fixed submission:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==1:
    b.reverse()

print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

Fixed submission:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==1:
    b.reverse()

print(*b)
Buggy python submission (verdict: Runtime Error):
x,a,c=map(int,input().split())
if -1*a+b <= 0:
  print('delicious')
elif -1*a+b <= x:
  print('safe')
else:print('dangerous')

Fixed submission:
x,a,b=map(int,input().split())
if -1*a+b <= 0:
  print('delicious')
elif -1*a+b <= x:
  print('safe')
else:print('dangerous')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

record = []
index = 0
count = 0
tf = True
while True:
    index=a[index]-1
    record.append(index)
    if record.count(index) == 2:
        print(-1)
        tf = False
        break
    else:
        count += 1
        if index == 1:
            break
if tf:
    print(count)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

index = 0
count = 1
tf = False

while True:
  if a[index]==2:
    tf = True
    break
  else:
    index=a[index]-1
    if count == n:
      break
    else:
      count += 1
if tf:
    print(count)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

record = []
index = 0
count = 0
tf = True
while True:
    index=a[index]-1
    record.append(index)
    if record.count(index) == 2:
        print(-1)
        tf = False
        break
    else:
        count += 1
        if index == 1:
            break
if tf:
    print(count)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

index = 0
count = 1
tf = False

while True:
  if a[index]==2:
    tf = True
    break
  else:
    index=a[index]-1
    if count == n:
      break
    else:
      count += 1
if tf:
    print(count)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
a,b=input.split()
if a == 'H':print(b)
elif a == 'D' and b == 'H':print('D')
else:print('H')

Fixed submission:
a,b=input().split()
if a == 'H':print(b)
elif a == 'D' and b == 'H':print('D')
else:print('H')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans = 1
for i in range(2,n+1):
  ans *= i
print(ans%(10**9+7))

Fixed submission:
n=int(input())
ans = 1
for i in range(2,n+1):
  ans = ans*i%(10**9+7)
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans = 1
for i in range(2,n+1):
  ans *= i
print(ans%(10**9+7))

Fixed submission:
n=int(input())
ans = 1
for i in range(2,n+1):
  ans = ans*i%(10**9+7)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a,op,b=input().split()
if op == "+":print(a+b)
else:print(a-b)

Fixed submission:
a,op,b=input().split()
if op == "+":print(int(a)+int(b))
else:print(int(a)-int(b))
Buggy python submission (verdict: Runtime Error):
a=set(list(map,input().split()))
print(len(a))

Fixed submission:
a=set(map(int,input().split()))
print(len(a))

Buggy python submission (verdict: Runtime Error):
a=set(map,input().split())
print(len(a))

Fixed submission:
a=set(map(int,input().split()))
print(len(a))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum = 0
mod = 10 ** 9 + 7
for i in range(N):
    for j in range(N - i - 1):
        sum += A[i] * A[N -1 - j]

print(sum % mod)

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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum = 0

for i in range(N):
    for j in range(N - i - 1):
        sum += A[i] * A[N -1 - j]

print(sum % (1000000007))


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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum = 0

for i in range(N):
    for j in range(N - i - 1):
        sum += A[i] * A[N -1 - j]

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


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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int, input())
print("Yes" if C//B <= A//D else "No")

Fixed submission:
A,B,C,D = map(int, input().split())
print("Yes" if (C-1)//B <= (A-1)//D else "No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(chr,input().split())
print(len(set(A)))

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

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(input().split())
print(len(set(A)))

Fixed submission:
N=int(input())
A=set(input() for i in range(N))
print(len(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(1,N):
  l[A[i-1]-1] += 1
for i in range(N):
  print(l[i])
  

Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(1,N):
  l[A[i-1]-1] += 1
for i in range(N):
  print(l[i])

Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
r = (int input())
print(6.3*r)

Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
r = (int input())
print(r*6.3)


Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
r = int input()
print(r*6.3)

Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
print((int input())*6.3)


Fixed submission:
r = int(input())
print(6.3*r)

Buggy python submission (verdict: Runtime Error):
print(int input()*6.3)

Fixed submission:
r = int(input())
print(6.3*r)
Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
l = [0]*int(input())
for i in A:
  l[i-1] += 1
print(*l)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(N-1):
  l[A[i]-1] += 1
for i in range(N):
  print(l[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(N+1):
  l[A[i]-1] += 1
for i in range(N):
  print(l[i])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(N-1):
  l[A[i]-1] += 1
for i in range(N):
  print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
array = list(map(int, input().strip().split()))
ans = 1
for i in array:
  ans *= i
if ans > 1e18:
  print(-1)
else :
  print(ans)

Fixed submission:
import sys
N = int(input().strip())
array = list(map(int, input().strip().split()))
ans = 1
for i in array:
  if i == 0:
    print(0)
    sys.exit()
for i in array:
  ans *= i
  if ans > 1e18:
    print(-1)
    sys.exit()
if ans > 1e18:
  print(-1)
else :
  print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,D = map(int, input().split())
#複数行
xy = [list(map(int, input().split())) for i in range(N)]
sum=0
for x,y in zip(xy):
    if np.sqrt(x*x+y*y)<=D:
        sum+=1
print(sum)

Fixed submission:
#------------------------------------------------------
import numpy as np
N,D = map(int, input().split())
#複数行
xy_list = [list(map(int, input().split())) for i in range(N)]
sum=0
for xy in xy_list:
    if np.sqrt(xy[0]*xy[0]+xy[1]*xy[1])<=D:
        sum+=1
print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N%1000=0:
    print(0)
else:
    print(1000-(N%1000))

Fixed submission:
N = int(input())

if N%1000==0:
    print(0)
else:
    print(1000-(N%1000))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [str(input()) for i in range(N)]

ac = 0
wa = 0
tle = 0
re = 0
for i in S:
    if i=='AC':
        ac+=1
    elif i=='WA':
        wa+=1
    elif i='TLE':
        tle+=1
    else:
        re+=1
print('AC x　'+str(ac))
print('WA x　'+str(wa))
print('TLE x　'+str(tle))
print('RE x　'+str(re))


Fixed submission:
N = int(input())
S = [str(input()) for i in range(N)]

ac = 0
wa = 0
tle = 0
re = 0
for i in S:
    if i=='AC':
        ac+=1
    elif i=='WA':
        wa+=1
    elif i=='TLE':
        tle+=1
    else:
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [str(input()) for _ in range(N)]

list = []
cnt = 0
for item in S:
	if item not in list:
		cnt += 1
		list.append(item)
print(cnt)


Fixed submission:
N = int(input())
S = [str(input()) for _ in range(N)]

set_S = set(S)
print(len(set_S))
Buggy python submission (verdict: Runtime Error):
import sys

def ispalindrome(str):return 1 if str == str[::-1] else 0

S=str(input())
len_s = len(S)
len_h = int((len_s-1)/2)


if ispalindrome(S)==0:
	print('No')
	sys.exit(1)
else:
	if ispalindrome(S[:len_h])==0:
		print('No')
		sys.exit(1)
	elif ispalindrome(S[-1:len_h])==0:
		print('No')
		sys.exit(1)
print('Yes')

Fixed submission:
import sys

def ispalindrome(str):return 1 if str == str[::-1] else 0

S=str(input())
len_s = len(S)
len_h = int((len_s-1)/2)


if ispalindrome(S)==0:
	print('No')
	sys.exit()
else:
	if ispalindrome(S[:len_h])==0:
		print('No')
		sys.exit()
	elif ispalindrome(S[-1:len_h])==0:
		print('No')
		sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial
from scipy.special import comb
# a = comb(n, r)
a = comb(n, r, exact=True)

def comb(n,r):
	#_a = factorial(n) / factorial(r) / factorial(n - r)
	a = comb(n, r, exact=True)
	return int(_a)


N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
#
for a in A:
	c[a]-=1
	#print(c)
	sum=0
	for b in set(c):
		if c[b]>=2:
			sum+=comb(c[b],2)
	c[a]+=1
	print(sum)


Fixed submission:
L=int(input())

print(pow(L/3,3.0))
Buggy python submission (verdict: Runtime Error):
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = [int(input()) for _ in range(N)]

cnt11=0
cnt12=0
cnt13=0
cnt21=0
cnt22=0
cnt23=0
cnt31=0
cnt32=0
cnt33=0

for i in range(N):
    if b[i]==A11:
        cnt11+=1
    elif b[i]==A12:
        cnt12+=1
    elif b[i]==A13:
        cnt13+=1
    elif b[i]==A21:
        cnt21+=1
    elif b[i]==A22:
        cnt22+=1
    elif b[i]==A23:
        cnt23+=1
    elif b[i]==A31:
        cnt31+=1
    elif b[i]==A32:
        cnt32+=1
    elif b[i]==A33:
        cnt33+=1
    else:
        pass

bingo=0
if cnt11>0:
    if((cnt12>0 and cnt13>0)or(cnt22>0 and cnt33>0)or(cnt21>0 and cnt31>0)):
        bingo+=1
    else:
        pass
elif cnt12>0:
    if (cnt22>0 and cnt32>0):
        bingo+=1
    else:
        pass
elif cnt13>0:
    if((cnt22>0 and cnt31>0)or(cnt23>0 and cnt33>0)):
        bingo+=1
    else:
        pass
elif cnt21>0:
    if(cnt22>0 and cnt23>0):
        bingo+=1
    else:
        pass
elif cnt31>0:
    if(cnt32>0 and cnt33>0):
        bingo+=1
    else:
        pass
else:
    pass
if bingo>0:
    print('Yes')
else:
    print('No')

Fixed submission:
N=int(input())

if N%2==1:
	print(int(N/2)+1)
else:
	print(int(N/2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

list=[]
cnt=0
for a in A:
    if a in list:
        print('NO')
        break
    else:
        list.append(a)
        cnt+=1
if cnt==N:
    print('YES')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
cnt=0
for i in range(N-1):
    if A[i]==A[i+1]:
        print('NO')
        break
    else:
        cnt+=1
if cnt==N-1:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
p = list(map(int, input().split()))

max=0
for i in range(0,N-(K-1)):
    tmp=0
    for j in range(K):
        tmp+=p[i+j]
    if tmp>max:
        max=tmp
print((max+K)*0.5)

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

max=0
tmp=0
for x in range(0,K):
    max+=p[x]
    tmp+=p[x]
for i in range(K,N):
    tmp=tmp+p[i]-p[i-K]
    if tmp>max:
        max=tmp
print((max+K)*0.5)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
A,B,K = map(int, input().split())

for i in range(K):
	if A>0:
		A-=1
	elif B>0:
		B-=1
	else:
		pass
print('{} {}'.format(A,B))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,K = map(int, input().split())

if A>K:
	print('{} {}'.format(A-K,B))
else:
	if K-A<B:
		print('{} {}'.format(0,B-(K-A)))
	else:
		print('{} {}'.format(0,0))
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int, input().split())

if abs(A-B)%2==0:
	print(int(abs(A-B)//2))
else:
	min(N-B,A-1)+1+((B=A-1)//2)

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

if abs(A-B)%2==0:
	print(int(abs(A-B)//2))
else:
	print(min(N-B,A-1)+1+((B-A-1)//2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())

cnt=0
if N%2==1:
    print('No')
else:
    for i in range(int(N/2)):
        if S[i]==S[int(N/2)+i]:
            cnt+=1
        else:
            print('No')
            break
    if cnt==int(N/2):
    print('Yes')

Fixed submission:
N = int(input())
S = str(input())

cnt=0
if N%2==1:
    print('No')
else:
    for i in range(int(N/2)):
        if S[i]==S[int(N/2)+i]:
            cnt+=1
        else:
            print('No')
            break
    if cnt==int(N/2):
        print('Yes')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sys

N = int(input())

for i in range(1,10):
  #print(N,i,N%i,len(str(int(N/i))))
  if N%i == 0 and len(str(int(N/i))) == 1:
    print('Yes')
    sys.exit()
print('No')

Fixed submission:
A,B= map(int, input().split())
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
S = int(input())
T = int(input())

cnt=0
for i in range(len(S)):
    if S[i]==T[i]:
        cnt+=1
print(cnt)

Fixed submission:
S = str(input())
T = str(input())

cnt=0
for i in range(len(S)):
    if S[i]==T[i]:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
L,R = map(int, input().split())
mod_min=2020

for i in range(L,R):
    for j in range(i+1,R+1):
        tmp = (i*j)%2019
        if tmp<mod_min:
            mod_min=tmp
print(mod_min)

Fixed submission:
# coding: utf-8
L,R = map(int, input().split())
mod_min=2020

if R-L>2018:
    mod_min=0
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp<mod_min:
                mod_min=tmp
print(mod_min)
Buggy python submission (verdict: Runtime Error):
S = str(input())
cnt1=0
cnt2=0
for i in range(len(S)):
    if i==0:
        list1=S[0]
        cnt1+=1
    elif i==1:
        if S[i]==list1:
            cnt1+=1
        else:
            list2=S[i]
            cnt2+=1
    else:
        if S[i]==list1:
            cnt1+=1
        elif S[i]==list2:
            cnt2+=1
        else:
            pass
if cnt1==2 and cnt2==2:
    print('Yes')
else:
    print('No')
#print(cnt1,cnt2)

Fixed submission:
S = str(input())
s = list(S)
s.sort()
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = str(input())
cnt1=0
cnt2=0
for i in range(len(S)):
    if i==0:
        list1=S[0]
        cnt1+=1
    elif i==1:
        if S[i]==list1:
            cnt1+=1
        else:
            list2=S[i]
            cnt2+=1
    else:
        if S[i]==list1:
            cnt1+=1
        elif S[i]==list2:
            cnt2+=1
        else:
            pass
if cnt1==2 and cnt2==2:
    print('Yes')
else:
    print('No')


Fixed submission:
S = str(input())
s = list(S)
s.sort()
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
drink_list = [list(map(int, input().split())) for _ in range(N)]

drink_list.sort(key=lambda x: x[0])
#print(drink_list)

_cnt=0
_sum=0
i=0
if N==1 or drink_list[i][1]>=M:
    _sum=drink_list[i][0]*M
else:
    while _cnt<M:
        if _cnt+drink_list[i][1]>M:
            break
        else:
            _sum+=drink_list[i][0]*drink_list[i][1]
            _cnt+=drink_list[i][1]
            i+=1
        #print(_sum,_cnt,i)
    _sum+=drink_list[i][0]*(M-_cnt)

print(_sum)

Fixed submission:
N,M = map(int, input().split())
drink_list = [list(map(int, input().split())) for _ in range(N)]

drink_list.sort(key=lambda x: x[0])
#print(drink_list)

_cnt=0
_sum=0
i=0
if N==1 or drink_list[i][1]>=M:
    _sum=drink_list[i][0]*M
else:
    while _cnt<=M:
        if _cnt+drink_list[i][1]>=M:
            break
        else:
            _sum+=drink_list[i][0]*drink_list[i][1]
            _cnt+=drink_list[i][1]
            i+=1
        #print(_sum,_cnt,i)
    _sum+=drink_list[i][0]*(M-_cnt)

print(_sum)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
drink_list = [list(map(int, input().split())) for _ in range(N)]

drink_list.sort(key=lambda x: x[0])
#print(drink_list)

_cnt=0
_sum=0
i=0
if N==1:
    _sum=drink_list[i][0]*M
else:
    while _cnt<M:
        if _cnt+drink_list[i][1]>M:
            break
        else:
            _sum+=drink_list[i][0]*drink_list[i][1]
            _cnt+=drink_list[i][1]
            i+=1
        #print(_sum,_cnt,i)
    _sum+=drink_list[i][0]*(M-_cnt)

print(_sum)

Fixed submission:
N,M = map(int, input().split())
drink_list = [list(map(int, input().split())) for _ in range(N)]

drink_list.sort(key=lambda x: x[0])
#print(drink_list)

_cnt=0
_sum=0
i=0
if N==1 or drink_list[i][1]>=M:
    _sum=drink_list[i][0]*M
else:
    while _cnt<=M:
        if _cnt+drink_list[i][1]>=M:
            break
        else:
            _sum+=drink_list[i][0]*drink_list[i][1]
            _cnt+=drink_list[i][1]
            i+=1
        #print(_sum,_cnt,i)
    _sum+=drink_list[i][0]*(M-_cnt)

print(_sum)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N,X = map(int, input().split())
x = list(map(int, input().split()))

def gcd_calc(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

x.sort()
for i,_x in enumerate(x):
  if (_x-X)>0:
    x.insert(i, X)
    break
list=[]
for i in range(len(x)-1):
  list.append(x[i+1]-x[i])

print(gcd_calc(list))
    

Fixed submission:
from fractions import gcd

N,X = map(int, input().split())
x = list(map(int, input().split()))

def gcd_calc(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

x.sort()
cnt=0
for i,_x in enumerate(x):
  if (_x-X)>0:
    x.insert(i, X)
    cnt=1
    break
if cnt!=1:
  x.append(X)
list=[]
for i in range(len(x)-1):
  list.append(x[i+1]-x[i])

print(gcd_calc(list))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

cnt=0
for i in range(N):
    if S[i]=='Y':
        print('Four')
        break
        cnt=0
    else:
        cnt+=1
if cnt==N:
    print('Three')

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

cnt=0
for i in range(N):
    if S[i]=='Y':
        print('Four')
        break
        cnt=0
    else:
        cnt+=1
if cnt==N:
    print('Three')