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

Fixed submission:
_=input()
s=input()
mod=7+10**9
ans=1
for i in range(26):
    ans*=1+s.count(chr(ord('a') + i))
    ans%=mod
print(ans-1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100005)
_=int(input())
s=input()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    if t[0] in l:
        return dp(t[1:],l)%mod
    else:
        g=l+[t[0]]
        ans=dp(t[1:],g)+dp(t[1:],l)
        ans%=mod
        return ans

print(dp(s,[])-1)

Buggy submission (verdict: Runtime Error):
_=input()
s=input().rstrip()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    elif t[0] in l:
        return dp(t[1:],l)%mod
    else:
        g=l+[t[0]]
        ans=dp(t[1:],g)+dp(t[1:],l)
        ans%=mod
        return ans
print(dp(s,[])-1)

Buggy submission (verdict: Runtime Error):
_=int(input())
s=input()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    elif t[0] in l:
        return dp(t[1:],l)%mod
    else:
        g=l+[t[0]]
        ans=dp(t[1:],g)+dp(t[1:],l)
        ans%=mod
        return ans
print(dp(s,[])-1)

Buggy submission (verdict: Runtime Error):
_=int(input())
s=input()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    if t[0] in l:
        return dp(t[1:],l)%mod
    else:
        ans=dp(t[1:],l+[t[0]])+dp(t[1:],l)
        ans%=mod
        return ans
print(dp(s,[])-1)

Buggy submission (verdict: Runtime Error):
_=int(input())
s=input()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    if t[0] in l:
        return dp(t[1:],l)
    else:
        return (dp(t[1:],l+[t[0]])+dp(t[1:],l))%mod
print(dp(s,[])-1)
Problem p03096 (python)

Fixed submission:
mod=7+10**9
n=int(input())
c=['$']+[int(input()) for _ in [0]*n]
data=[1]+[0]*n
s={}

for i in range(1,n+1):
  if c[i] in s.keys():
    if c[i]!=c[i-1]:
      s[c[i]]+=data[i-1]
      s[c[i]]%=mod
  else:
    s[c[i]]=data[i-1]
  data[i]=s[c[i]]%mod
        
print(data[n])

Buggy submission (verdict: Runtime Error):
mod=7+10**9
n=int(input())
c=[int(input()) for _ in [0]*n]
data=[0]*n+[1]
def dp(k,l):
    if data[k]>0:
        return data[k]
    if k>=n-1:
        return 1
    ans=0
    i=0
    while i<len(l):
        if l[i]==l[0]:
            j=i
            while j<len(l) and l[j]==l[0]:
                j+=1
            ans+=dp(j,l[j:])
            ans%=mod
            i=j
        i+=1
    data[k]=ans%mod
    return data[k]
print(dp(c))

Buggy submission (verdict: Runtime Error):
mod=7+10**9
n=int(input())
c=[int(input()) for _ in [0]*n]
data=[0]*n
def dp(k,l):
    if data[k]>0:
        return data[k]
    if len(l)<=1:
        return 1
    ans=0
    i=0
    while i<len(l):
        if l[i]==l[0]:
            j=i
            while j<len(l) and l[j]==l[0]:
                j+=1
            ans+=dp(j,l[j:])
            ans%=mod
            i=j
        i+=1
    data[k]=ans%mod
    return data[k]
print(dp(c))
Problem p03109 (python)

Fixed submission:
a = input().rstrip().split('/')
a = list(map(int, a))
if a[0] < 2019:
  print('Heisei')
elif a[1] < 5:
  print('Heisei')
else:
  print('TBD')

Buggy submission (verdict: Runtime Error):
a = input().split('/')
a = list(map(int, a))
if a[0] < 2019:
  print('Heisei')
elif a[1] < 5:
  print('Heisei')
else:
  print('TBD')
a = input().split('/')
if a[0] < 2019:
  print('Heisei')
elif a[1] < 5:
  print('Heisei')
else:
  print('TBD')

Buggy submission (verdict: Runtime Error):
a = input().split('/')
if a[0] < 2019:
  print('Heisei')
elif a[1] < 5:
  print('Heisei')
else:
  print('TBD')
Problem p03110 (python)

Fixed submission:
n = int(input().rstrip())
m = 0
for i in range(n):
  a, b = input().rstrip().split(' ')
  a = float(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input().rstrip())
m = 0
for i in range(n):
  a, b = input().rstrip().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = 0
for i in range(n):
  a, b = input().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000*a
    m = m + a
  else:
    m = m + a
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = 0
for i in range(n):
  a, b = input().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000.0*a
  m += a
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = 0
for i in range(n):
  a, b = input().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)
Problem p03136 (python)

Fixed submission:
n = int(input())
l = map(int, input().split())
s = 0
t = 0
for x in l:
  s += x
  t = max(x, t)
if s>2*t:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
l = map(int, input().split())
s = 0
t = 0
for x in l:
  s += x
  t = max(x, t)
if s>t:
  print(Yes)
else:
  print(No)
Problem p03138 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
_sum = [0]*41
ans = 0
f = 0
 
for x in a:
  for i in range(41):
    _sum[i] += (x >> i) & 1
for i in range(41):
  if _sum[i] <= n//2:
    _sum[i] = 1
  else:
    _sum[i] = 0
for i in range(40, -1, -1):
  s = _sum[i] << i
  ans += s
  if ans > k:
    ans -= s
for x in a:
  f += x ^ ans
print(f)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
_sum = list(map(int, input().split()))
m, f = 0, 0
for i in range(40, -1, -1):
  _sum = sum(map(lambda x: (x >> i) & 1, _sum))
  _min = min(_sum, n-_sum) << i
  _max = max(_sum, n-_sum) << i
  s = 0 if _sum > n//2 else 1 << i
  if s > max(k - m, 0):
    f += _min
  elif s > 0:
    m += s
    f += _max
  else:
    f += _max
print(f)
Problem p03471 (python)

Fixed submission:
N, Y=map(int,input().split())
flag=False

for i in range(0,N+1):
    for j in range(0, N+1):
        if Y==10000*(N-i-j)+5000*i+1000*j and i+j<=N:
            flag=True
            print(N-i-j, i, j)
            break
    if flag:
        break
else:
    print('-1 -1 -1')

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

for i in range(0,N+1):
    for j in range(0, N+1):
        if Y==10000*(N-i-j)+5000*i+1000*j and i+j=<N:
            flag=True
            print(N-i-j, i, j)
            break
    if flag:
        break
else:
    print('-1 -1 -1')
Problem p03495 (python)

Fixed submission:
from collections import Counter


N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
S=set(A)
c=Counter(A)
L=c.most_common(len(S))

x=len(S)-1
for _ in range(len(S)-K):
    count=count+int(L[x][1])
    x=x-1

print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from pandas import Series, DataFrame
 
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
S=set(A)
c=Counter(A)
L=c.most_common(len(S))
 
x=len(S)-1
for _ in range(len(S)-K):
    count=count+int(L[x][1])
    x=x-1
 
print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from pandas import Series
 
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
S=set(A)
c=Counter(A)
L=c.most_common(len(S))
 
x=len(S)-1
for _ in range(len(S)-K):
    count=count+int(L[x][1])
    x=x-1
 
print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from pandas import Series

N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
S=set(A)
c=Counter(A)
L=c.most_common(len(S))

x=len(S)-1
for _ in range(len(S)-K):
    count=count+int(L[x][1])
    x=x-1

print(count)
Problem p03503 (python)

Fixed submission:
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
#print(table)

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)
#print(F)
for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)
#print(P)

maxx=-1000000000001

for i in range(1,1024):
    total=0
    for j in range(N):
        n=0
        for k in range(10):
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Buggy submission (verdict: Runtime Error):
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
#print(table)

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)
#print(F)
for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)
#print(P)

max=-1000000000001

for i in range(1,1024):
    total=0
    for j in range(N):
        n=0
        for k in range(10):
            n +=(1 if i&table[k] !=0 else 0)*F[j][t]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)
Problem p03545 (python)

Fixed submission:
# coding: utf-8
# 整数の入力
a, b, c, d = [int(i) for i in input()]
# 計算
if a+b+c+d == 7:
    s = "{}+{}+{}+{}=7"
elif a+b+c-d == 7:
    s = "{}+{}+{}-{}=7"
elif a+b-c+d == 7:
    s = "{}+{}-{}+{}=7"
elif a+b-c-d == 7:
    s = "{}+{}-{}-{}=7"
elif a-b+c+d == 7:
    s = "{}-{}+{}+{}=7"
elif a-b+c-d == 7:
    s = "{}-{}+{}-{}=7"
elif a-b-c+d == 7:
    s = "{}-{}-{}+{}=7"
elif a-b-c-d == 7:
    s = "{}-{}-{}-{}=7"
# 出力
print(s.format(a, b, c, d))

Buggy submission (verdict: Runtime Error):
H, W=map(int,input().split(' '))
c=[list(map(int,input().split(' '))) for i in range(10)]
a=[list(map(int,input().split(' '))) for i in range(H)]
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

for i in range(H):
    for j in range(W):
        if a[i][j]>=0:
            ans += c[a[i][j]][1]

print(ans)
Problem p03611 (python)

Fixed submission:
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
 
C = Counter(A)
 
ans = 0
for i in range(max(A)+1):
    ans = max(C[i] + C[i-1] + C[i+1], ans)
 
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
 
C = Counter(A)
 
ans = 0
for i in range(max(A)+1):
    ans = max(C[i] + C[i-1] + C[i+1], ans)
 
print(ans)
from collections import Counter

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

C = Counter(A)

ans = 0
for i in range(max(A)+1):
    ans = max(C[i] + C[i-1] + C[i+1], ans)

print(ans)
Problem p03681 (python)

Fixed submission:
import math
N, M =map(int,input().split())
ans=0

if abs(N-M)==0:
    ans=math.factorial(N)*math.factorial(M)*2
elif abs(N-M)==1:
    ans=math.factorial(N)*math.factorial(M)
else:
    ans=0

ans=ans%(10**9+7)

print(ans)

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

def fact(n):
    if n==0:
        return 1
    return n*fact(n-1)

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==0:
    ans=fact(N)*4
elif abs(N-M)==1:
    ans=fact(N)*fact(M)
else:
    print(0)

ans=ans%(10**9+7)

print(ans)

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

def fact(n):
    if n==0:
        return1:
    return n*fact(n-1)

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==0:
    ans=fact(N)*4
elif abs(N-M)==1:
    ans=fact(N)*fact(M)
else:
    print(0)

ans=ans%(10**9+7)

print(ans)
Problem p03761 (python)

Fixed submission:
from collections import Counter

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    ans=ans+c*counter[c]
print(ans)

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

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]
    ans=ans+c*counter[c]
print(ans)
Problem p03231 (python)

Fixed submission:
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

n, m = map(int, input().split())
s = list(str(input()))
t = list(str(input()))
s_out = []
t_out = []
for i in range(int(gcm(n, m))) :
  s_out.append(s[i*int(n/gcm(n, m))])
for i in range(int(gcm(n, m))) :
  t_out.append(t[i*int(m/gcm(n, m))])
  
if(s_out == t_out) : print(lcm(n, m))
else : print(-1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
for i in range(n) :
  x -= a[i]
  if(x == 0) : 
    print(i+1)
    exit()
  elif(a[i] > x) : print(i)
Problem p03294 (python)

Fixed submission:
n = input()
print(sum(list(map(lambda x: int(x)-1, input().split()))))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

b = a[0]
for i in range(n-1) :
  b = lcm(b, a[i+1])
  
print(sum([(b-1)%a[i] for i in range(n)]))
Problem p03607 (python)

Fixed submission:
n = int(input())
a = sorted([int(input()) for _ in range(n)])
tmp = a[0]
cnt = [0]*n
ptr = 0
for i in range(n) :
  if(a[i-1] != a[i]) :
    ptr += 1
  cnt[ptr] += 1
print(sum([cnt[i]%2 for i in range(len(cnt))]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = [0]*int(1e5+10)
for i in range(n) :
  cnt[a[i]] += 1
print(sum([cnt[i]%2 for i in range(len(cnt))]))
Problem p03323 (python)

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

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')
Problem p03337 (python)

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

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)
Problem p03239 (python)

Fixed submission:
def input_N_T():
    N_T=input().split()
    int_N_T=list(map(int,N_T))
    N=int_N_T[0]
    T=int_N_T[1]
    return [N,T]

N,T=input_N_T()

min_c,min_t=1001,1001

for i in range(N):
    c,t=input_N_T()
    if(t<=T and min(min_c,c)==c):
        min_c=c

if(min_c==1001):
    print("TLE")
    
else:
    print(min_c)

Buggy submission (verdict: Runtime Error):
def input_N_T():
    N_T=input().split()
    int_N_T=list(map(int,N_T))
    N=int_N_T[0]
    T=int_N_T[1]
    return [N,T]

N,T=input_N_T()

min_c,min_t=1001,1001

for i in range(N):
    c,t=input_N_T()
    if(t<=T and min(min_c,c)==c):
        min_c,min_t=c,t

if(N==1001 and T==1001):
    print("TLE")
    
else:
print(c)
Problem p03243 (python)

Fixed submission:
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>=L[i] and N<=L[i+1]):
        print(L[i+1])
    else:
        continue
Problem p03353 (python)

Fixed submission:
s=input()
K=int(input())

sub_list=[]
i,j=0,1
while True:
    if(i+j>=len(s) and i==len(s)):
        break
    else:
        sub_list.append(s[i:i+j])
        if(j<=K):
            j+=1
        else:
            i+=1
            j=1
set_list=set(sub_list)

dict_list=list(set_list)
dict_list.sort(key=str)

print(dict_list[K-1])

Buggy submission (verdict: Runtime Error):
s=input()
K=int(input())

sub_list=[]

for i in range(len(s)):
    for j in range(1,K+1):
        if(i+j<len(s)):
            sub_list.append(s[i:i+j])

sub_set=set(sub_list)
sub_dict=sorted(sub_set,key=str)

print(sub_dict[K-1])

Buggy submission (verdict: Runtime Error):
s=input()
K=int(input())

sub_list=[]
i,j=0,1
while True:
    if(i+j>=len(s) and i==len(s)-1):
        break
    else:
        sub_list.append(s[i:i+j])
        if(j<=K):
            j+=1
        else:
            i+=1
            j=1
set_list=set(sub_list)

dict_list=list(set_list)
dict_list.sort(key=str)

print(dict_list[K-1])
Problem p03469 (python)

Fixed submission:
S = str(input())
S = S.replace("2017", "2018", 1)
print(S)

Buggy submission (verdict: Runtime Error):
S = str(input())
S = S.replace(2017, 2018, 1)
print(S)
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = input()
t = [0]*(N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=="AC" else 0)

for i in range(Q):
    r,l = map(int,input().split())
    print(t[l-1]-t[r-1])

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


def fnc(l,r):
    cnt = 0
    for i in range(l-1,r):
        if S[i] == "A" and S[i+1] == "C" and i != r-1:
            cnt += 1
    print(cnt)
    
for i in range(Q):
    L,R = map(int,input().split())
    fnc(L,R)
Problem p03698 (python)

Fixed submission:
from collections import Counter

print('yes' if all([True if x <= 1 else False for x in list(Counter(input()).values())]) else 'no')

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter

print('yes' if all([True if x <= 1 else False for x in list(Counter(sys.argv[1]).values())]) else 'no')
Problem p03289 (python)

Fixed submission:
def count_apper(str) :
    n = 0
    for c in str :
        if c.isupper() :
            n = n+1
    return n

str = input()
if (str[0] == "A") and (str.count("C") == 1) and (1 < str.find("C") < len(str)-1) and (count_apper(str) == 2) :
                print("AC")
                exit()
print("WA")

Buggy submission (verdict: Runtime Error):
def count_apper(str) :
    n = 0
    for c in str :
        if c.isuppper() :
            n = n+1
    return n

str = input()
if (str[0] == "A") && (str.count("C") == 1) && (2 < str.find("C") < len(str)-1) && (count_apper(str) == 2) :
                print("AC")
                exit()
print("WA")
Problem p03129 (python)

Fixed submission:
input_string = input().split()
N = int(input_string[0])
K = int(input_string[1])

r = int(N / 2 + 0.5)

if (r >= K):
    print("YES")
else:
    print("NO")

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

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

if (A > B):
    print(K+1)
    
# y = -Ax + B(K-x)
# y = -Ax + BK - Bx
# y = -(A + B)x + BK

y = -(A + B)*0 + B*K + 1

print(y)
Problem p03109 (python)

Fixed submission:

def main():
    year, month, day = map(int, input().strip().split('/'))

    if year < 2019:
        print('Heisei')
        return
    
    if year == 2019:
        if month < 4:
            print('Heisei')
            return
        elif month == 4 and day <= 30:
            print('Heisei')
            return

    print('TBD')
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    year, month, day = int(input().strip().split('/'))

    if year < 2019:
        print('Heisei')
        return
    
    if year == 2019:
        if month < 4:
            print('Heisei')
            return
        elif month == 4 and day <= 30:
            print('Heisei')
            return

    print('TBD')
    return

if __name__ == '__main__':
    main()
Problem p03103 (python)

Fixed submission:
from sys import stdin
import heapq
hq = []  

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

hq = []
AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])
  heapq.heappush(hq, (int(temp[0]), int(temp[1])))

cost = 0
amount = 0
for i in range(N):
  temp = heapq.heappop(hq)
  if amount + temp[1] < M:
    amount += temp[1]
    cost += temp[0]*temp[1]
  else:
    temp1 = M - amount
    cost += temp[0]*temp1
    break
    
print(cost)

Buggy submission (verdict: Runtime Error):
from sys import stdin

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] < M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)

Buggy submission (verdict: Runtime Error):
from sys import stdin

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] <= M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)

Buggy submission (verdict: Runtime Error):
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] <= M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    print(amount)
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)
Problem p03136 (python)

Fixed submission:
n = input()
 
l = list(map(int, input().split()))
 
l.sort(reverse=True)
 
total = sum(l)
 
if (total - 2 * l[0] > 0 ) :
  print("Yes")
else:
  print("No")

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

l = list(map(int, input().split()))

l.sort(reverse=True)

total = l.sum()

if (total - 2 * l[0] > 0 ) :
  print("yes")
else:
  print("no")
Problem p03106 (python)

Fixed submission:
A,B,K =[int(_) for _ in input().split()]

iC = 0
for i in range(100,0,-1):
    if A % i == 0 and B % i ==0:
        iC += 1
        if K == iC:
            print(i)
            exit()

Buggy submission (verdict: Runtime Error):
A,B,K =[int(_) for _ in input().split()]

def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

igcd = fgcd(A,B)
if igcd == 1:
    print(1)
else:
    aP = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97)
    aD =[igcd,1]
    for eP in aP:
        if igcd < eP:
            break
        if igcd % eP == 0:
            i = 1
            while igcd % (eP**i) == 0 :
                aD.append(eP**i)
                aD.append(igcd // (eP ** i))
                i += 1
    aD = sorted(list(set(aD)),reverse=True)
    print(aD[K-1])

Buggy submission (verdict: Runtime Error):
A,B,K =[int(_) for _ in input().split()]

def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

igcd = fgcd(A,B)
if igcd == 1:
    print(1)
else:
    aP = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97)
    aD =[igcd,1]
    for eP in aP:
        if igcd % eP == 0:
            aD.append(eP)
            i = 1
            while igcd % (eP**i) == 0 :
                aD.append(igcd // (eP ** i))
                i += 1
    aD = sorted(list(set(aD)),reverse=True)
    print(aD[K-1])