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

Fixed submission:
import fractions
a,b,k=map(int,input().split())
n=fractions.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[-k])

Buggy submission (verdict: Runtime Error):
from math import factorial
a,b,k=map(int,input().split())
n=math.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[k-1])
Problem p03129 (python)

Fixed submission:
print("YNEOS"[eval(input().replace(" ","<-1+2*"))::2])

Buggy submission (verdict: Runtime Error):
print("YNEOS"[::2])print("YNEOS"[eval(input().replace(" ","<")+"*2-1")::2])
Problem p03219 (python)

Fixed submission:
n,m=map(int,input().split())
print(n+m//2)

Buggy submission (verdict: Runtime Error):
print(int(input())+int(input())//2)
Problem p03240 (python)

Fixed submission:
l=[list(map(int,input().split())) for i in range(int(input()))]
l.sort(key=lambda x:x[2])
for i in range(0,101):
    for j in range(0,101):
        h=l[-1][2]+abs(i-l[-1][0])+abs(j-l[-1][1])
        for a,b,c in l[:-1]:
            if c!=max(0,h-abs(i-a)-abs(j-b)):break
        else:
            print(i,j,h)
            exit()

Buggy submission (verdict: Runtime Error):
def search():
    for i in range(0,101):
        for j in range(0,101):
            h=l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
            for a,b,c in l[1:]:
                hi=c+abs(i-a)+abs(j-b)
                if h!=hi:break
            else:
                return [i,j,hi]

l=[list(map(int,input().split())) for i in range(int(input()))]
a,b,c=search()
print(a,b,c)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
if len(set(v))==1:print(n//2)
else:
    v.extend([0,0])
    voc=Counter(v[::2]).most_common(2)
    vec=Counter(v[1::2]).most_common(2)
    if len(voc)==len(vec)==1:print(0)
    elif voc[0][0]==vec[0][0]:print(n-max(voc[0][1]+vec[1][1],voc[1][1]+vec[0][1]))
    else:print(n-voc[0][1]-vec[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
if len(set(v))==1:print(n//2)
else:
    voc=Counter(v[::2]).most_common(2)
    vec=Counter(v[1::2]).most_common(2)
    if len(voc)==len(vec)==1:print(0)
    elif voc[0][0]==vec[1][0]:
        if len(voc)==len(vec)==2:print(n-max(voc[0][1]+vec[1][1],voc[1][1]+vec[0][1]))
        elif len(voc)==1:print(n-voc[0][1]-vec[1][1])
        else:print(n-voc[1][1]-vec[0][1])
    else:
        print(n-voc[0][1]-vec[0][1])
Problem p03262 (python)

Fixed submission:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:b.append(abs(x-i))
while len(b)>1:b.append(fractions.gcd(b.pop(-1),b.pop(-1)))
print(b[0])

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:b.append(abs(x-i))
while len(b)>1:b.append(fractions.gcd(b.pop(-1),b.pop(-1)))
print(b[0])
Problem p03263 (python)

Fixed submission:
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
a=[]
for i in range(h):
    if i%2==0:
        for j in range(w-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j+2])
                l[i][j+1]+=1
        j=w-1
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,j+1,i+2,j+1])
            l[i+1][j]+=1
    else:
        for j in range(w-1,0,-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j])
                l[i][j-1]+=1
        j=0
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,1,i+2,1])
            l[i+1][j]+=1

print(len(a))
for i in a:print(' '.join(map(str,i)))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
a=[]
for i in range(h):
    if i%2==0:
        for j in range(w-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j+2])
                l[i][j+1]+=1
        j=w-1
        if l[i][j]%2==1:
            a.append([i+1,j+1,i+2,j+1])
            l[i+1][j]+=1
    else:
        for j in range(w-1,0,-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j])
                l[i][j-1]+=1
        j=0
        if l[i][j]%2==1:
            a.append([i+1,1,i+2,1])
            l[i+1][j]+=1
print(len(a))
for i in a:print(' '.join(map(str,i)))
Problem p03633 (python)

Fixed submission:
import fractions
n=int(input())
a=[]
for i in range(n):a.append(int(input()))
while len(a)>1:
    j=a.pop()
    k=a.pop()
    a.append(j*k//fractions.gcd(j,k))
print(a[0])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=[]
for i in range(n):a.append(int(input()))
while len(a)>1:
    j=a.pop()
    k=a.pop()
    a.append(j*k//math.gcd(j,k))
print(a[0])
Problem p03695 (python)

Fixed submission:
n=input()
l=list(map(int,input().split()))
c=[0]*8
ma=0
for i in l:
    if i<3200:c[i//400]=1
    else:ma+=1
mi=sum(c)
print(max(mi,1),mi+ma)

Buggy submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
c=[0]*9
for i in l:c[i//400]+=1
mi=0
for i in range(8):
    if c[i]>0:mi+=1
print(max(mi,1),mi+c[8])
Problem p03777 (python)

Fixed submission:
a,b=map(str,input().split())
if a==b:print("H")
else:print("D")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b:print("H")
else:print("D")
Problem p03853 (python)

Fixed submission:
h,w=map(int,input().split())
for i in range(h):
    s=input()
    print(s)
    print(s)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
for i in range(n):
    s=input()
    print(s)
    print(s)
Problem p03994 (python)

Fixed submission:
s=input()
l=[]
for i in s:l.append((123-ord(i))%26)
k=int(input())
for i,j in enumerate(l):
    if j<=k:l[i],k=26,k-j
l[-1]=(l[-1]-k%26)+[0,26][l[-1]-k%26<1]
for i,j in enumerate(l):l[i]=chr(123-j)
print(''.join(map(str,l)))

Buggy submission (verdict: Runtime Error):
s=input()
l=[]
for i in s:l.append((123-ord(i))%26)
k=int(input())
for i,j in enumerate(l):
    if j<=k:l[i],k=26,k-j
l[-1]=(l[-1]-k)+[0,26][l[-1]-k<1]
for i,j in enumerate(l):l[i]=chr(123-j)
print(''.join(map(str,l)))
Problem p03998 (python)

Fixed submission:
a=list(input().replace("a",""))
b=list(input().replace("b",""))
c=list(input().replace("c",""))
t=0
while 1:
    if t==0:
        if len(a)==0:
            print("A")
            break
        else:
            t=ord(a.pop(0))-97
    elif t==1:
        if len(b)==0:
            print("B")
            break
        else:
            t=ord(b.pop(0))-97
    elif t==2:
        if len(c)==0:
            print("C")
            break
        else:
            t=ord(c.pop(0))-97

Buggy submission (verdict: Runtime Error):
sa=input()
sb=input()
sc=input()
i=sa[0]
sa=sa[1:]
while 1:
    if i=="a":i,sa=sa[0],sa[1:]
    elif i=="b":i,sb=sb[0],sb[1:]
    elif i=="c":i,sc=sc[0],sc[1:]
    if i=="a" and sa=="":
        print("A")
        break
    elif i=="b" and sb=="":
        print("B")
        break
    elif i=="c" and sc=="":
        print("C")
        break
Problem p02981 (python)

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

print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n,a,b = input(),input(),input()
    print (max(n*a,b))
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())
if a*n < b:
    print(a*n)
else:
    print(b)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input.split())
if a*n < b:
    print(a*n)
else:
    print(b)
Problem p03206 (python)

Fixed submission:
print('Christmas'+' Eve'*(25-int(input())))

Buggy submission (verdict: Runtime Error):
n,*p=map(int,open(0).read().split())
print(int(sum(p)-max(p)/2))
Problem p02981 (python)

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

print(min(a*b, c))

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(input().split()))
print(min(a*b, c))
Problem p03623 (python)

Fixed submission:
# Meal Delivery
x,a,b, = list(map(int, input().split()))

if ( abs(a-x) < abs(b-x) ):
    print("A")
else:
    print("B")

Buggy submission (verdict: Runtime Error):
#Make a Rectangle
N = int(input())
A = list(map(int, input().split()))
 
a = sorted(list(set(A)), reverse=True)
b = []
for ai in a:
    c = A.count(ai)
    for i in range(c//2):
        b.append(ai)
    if (len(b)>=4):
        break
 
if (len(b)<2):
    print(0)
else:
    print(b[0]*b[1])
Problem p03625 (python)

Fixed submission:
#Make a Rectangle
N = int(input())
A = list(map(int, input().split()))

a = sorted(A, reverse=True)
b = []

i = 0
while i<N-1:
    if ( a[i]==a[i+1] ):
        b+=[a[i]]
        i+=2
    else:
        i+=1
    if (len(b)>1):
        break

if (len(b)<2):
    print(0)
else:
    print(b[0]*b[1])

Buggy submission (verdict: Runtime Error):
#Make a Rectangle
N = int(input())
A = list(map(int, input().split())

a = sorted(A, reverse=True)
b = []

i = 0
while i<N-2:
    if ( a[i]==a[i+1] ):
        b+=[a[i]]
        i+=2
    else:
        i+=1
    if (len(b)>=2):
        break

if (len(b)<2):
    print(0)
else:
    print(b[0]*b[1])
Problem p03665 (python)

Fixed submission:
#Biscuits

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

#奇数の数
k = 0
for a in A:
    k += a%2
if ( k ==0 ):
    ans = (3-P)%2 * 2**N
else:
    ans = 2**(N-1)
print(ans)

Buggy submission (verdict: Runtime Error):
#Biscuits

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

#奇数の数
k = 0
for a in A:
    if a%2 ==1:
        k+=1

if ( k ==0 ):
    ans = int(p==0)
else:
    ans = 2**(N-1)
print(ans)

Buggy submission (verdict: Runtime Error):
#Biscuits

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

#奇数の数
k = sum([A[i]%2 for i in range(N)])

if ( k ==0 ):
    ans = int(p==0)
else:
    ans = 2**(N-1)
print(ans)
Problem p03674 (python)

Fixed submission:

MOD = 10**9+7
n = int(input())
la = list(map(int,input().split()))
L = [-1]*(n+1)
l = 0
for i in range(n+1):
  a = la[i]
  if L[a] == -1:
    L[a] = i
  else:
    l = i - L[a] - 1
    break
 
MAX = n
factorial = [1, 1]
inverse = [0, 1]
inverse_factorial = [1, 1]
for i in range(2,MAX+1):
  factorial.append( (factorial[-1]*i)%MOD )
  inverse.append( (-inverse[MOD%i]*(MOD//i))%MOD )
  inverse_factorial.append( (inverse_factorial[-1]*inverse[-1])%MOD )
 
def C_MOD(n, k):
  if k < 0 or k > n:
    return 0
  k = min(k,n-k)
  return factorial[n] * inverse_factorial[k] * inverse_factorial[n-k] % MOD
 
print(n)
#print((2*C_MOD(n-1,1)-C_MOD(n-1-l,1)+C_MOD(n-1,2)+1)%MOD)
for i in range(2,n+1):
  if n > l+1:
    print((2*C_MOD(n-1,i-1)-C_MOD(n-1-l,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
  else:
    print((2*C_MOD(n-1,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
print(1)

Buggy submission (verdict: Runtime Error):
#11
n = int(input())
a = list(map(int, input().split()))

import math

flag = [a.count(a[i])-1 for i in range(n+1) ]

cc = [ math.factorial(n+1)/math.factorial(i+1)/math.factorial(n-i) for i in range( n//2 )]
cc = cc + list(reversed(cc)) +[1]

for i in range(n+1):
    p = flag.index(1) + list(reversed(flag)).index(1)
    
    if ( p>=i ):
        c = cc[i] - math.factorial(p)/math.factorial(i)/math.factorial(p-i)
    else:
        c = cc[i]
    print( int(c)%(10**9+7) )

Buggy submission (verdict: Runtime Error):
#11
n = int(input())
a = list(map(int, input().split()))

import math

flag = [a.count(a[i])-1 for i in range(n+1) ]

cc = [ math.factorial(n+1)/math.factorial(i+1)/math.factorial(n-i) for i in range( n//2 )]
cc + list(reversed(cc)) +[1]

for i in range(n+1):
    p = flag.index(1) + list(reversed(flag)).index(1)
    
    if ( p>=i ):
        c = cc[i] - math.factorial(p)/math.factorial(i)/math.factorial(p-i)
    else:
        c = cc[i]
    print( int(c)%(10**9+7) )
Problem p03693 (python)

Fixed submission:
#RGB card
import numpy as np
r,g,b = list(map(int, input().split()))
if((100*r+10*g+b)%4==0):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#Colorful Leaderboard
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
b = sorted (a//400)
cnt = 0
for i in range(len(b)):s
    if b[i]  < 8:
        None
    else:
        b[i]+=i
        cnt+=1
c = len(list(set(b)))

print(str(c-cnt) + " " + str(c))

Buggy submission (verdict: Runtime Error):
#Traveling AtCoDeer Problem
import numpy as np
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))
Problem p03695 (python)

Fixed submission:
#Colorful Leaderboard
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
b = sorted (a//400)
cnt = 0
for i in range(len(b)):
    if b[i]  < 8:
        None
    else:
        b[i]+=i
        cnt+=1
c = len(list(set(b)))

print(str(max([1,c-cnt])) + " " + str(c))

Buggy submission (verdict: Runtime Error):
#Colorful Leaderboard
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
b = sorted (a//400)
cnt = 0
for i in range(len(b)):s
    if b[i]  < 8:
        None
    else:
        b[i]+=i
        cnt+=1
c = len(list(set(b)))

print(str(c-cnt) + " " + str(c))

Buggy submission (verdict: Runtime Error):
#Colorful Leaderboard
import numpy as np
import math as m
n = int(input())
a = np.array(list(map(int, input().split())))
b = sorted (a//400)
cnt = 0
for i in range(len(b)):s
    if b[i]  < 8:
        None
    else:
        b[i]+=i
        cnt+=1
c = len(list(set(b)))

print(str(c-cnt) + " " + str(c))
Problem p03697 (python)

Fixed submission:
#Restricted

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

if ( a+b >9 ):
    print("error")
else:
    print(a+b)

Buggy submission (verdict: Runtime Error):
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))

import math

sup = sum([hh // a + 1 for hh in h])
inf = 1
 
while sup - inf > 1:
    x = (sup + inf) // 2
    c = sum([math.ceil((hh - x * b)/(a-b)) for hh in h if hh > x * b])
    if c <= x:
        sup = x
    else:
        inf = x
 
print(sup)
Problem p03700 (python)

Fixed submission:
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))

import math

sup = sum([hh // a + 1 for hh in h])
inf = 1
 
while sup - inf > 1:
    x = (sup + inf) // 2
    c = sum([math.ceil((hh - x * b)/(a-b)) for hh in h if hh > x * b])
    if c <= x:
        sup = x
    else:
        inf = x
 
print(sup)

Buggy submission (verdict: Runtime Error):
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))
    
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

Buggy submission (verdict: Runtime Error):
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))


# やり直し
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

Buggy submission (verdict: Runtime Error):
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))

# やり直し
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)
Problem p03729 (python)

Fixed submission:
#Shiritori
a,b,c = input().split()

if ( a[-1]==b[0] and b[-1]==c[0] ):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#Shiritori

a,b,c = input().split()

if ( a[-1]==b[0] and b[-1]==c[0] ):
    print("YES")
else:
    prtin("NO")
Problem p03761 (python)

Fixed submission:
# 怪文書 / Dubious Document
n = int(input())
s=[]
for i in range(n):
    s.append(input())
ls = sorted(list(set(s[0])))
ans = ""
for l in ls:
    cnt = min ([s[i].count(l) for i in range(n)] )
    ans += l*cnt
print(ans)

Buggy submission (verdict: Runtime Error):
# 怪文書 / Dubious Document
n = int(input())
s=[]
for i in range(n):
    s.append(input())
ans = ""
ls = sorted(s[0])
for l in ls:
    if ( sum([l in s[i+1] for i in range(n-1)])//(n-1) ) :
        ans += l
        ls = ls[1:]
print(ans)

Buggy submission (verdict: Runtime Error):
# 怪文書 / Dubious Document
n = int(input())
s=[]
for i in range(n):
    s.append(input())
ans = ""
ls = sorted(s[0])
for l in ls:
    if ( sum([l in s[i+1] for i in range(n-1)])//(n-1) ) :
        print(l)
        ans += l
        ls = ls[1:]
print(ans)
Problem p02999 (python)

Fixed submission:
x,a=list(map(int,input().split()))
if x<a:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
d=0
for i in range(n):
  d+=l[i]
  if d>x:
    print(i+1)
    break
else:
  print(n+1)
Problem p03001 (python)

Fixed submission:
W,H,x,y=list(map(float,input().split()))
if x==W/2 and y==H/2:
  print("{:.6f} 1".format(W*H/2))
else:
  print("{:.6f} 0".format(W*H/2))

Buggy submission (verdict: Runtime Error):
W,H,x,y=list(map(int,input().split()))
print(W,H,x,y)
if x==W/2 and y=H/2:
  print("{:.6f} 1".format(W*H/2))
else:
  print("{:.6f} 0".format(W*H/2))
Problem p03238 (python)

Fixed submission:
N=int(input().strip())
if N==1:
    print('Hello World')
elif N==2:
    A=int(input().strip())
    B=int(input().strip())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
ct=[]
for i in range(N):
    ct.append(list(map(int, input().strip().split(' '))))
    
tle=True
c=10000

for i in range(N):
    if ct[i][1]<=T:
        tle=False
        c=min(c,ct[i][0])
        
if tle:
    print('TLE')
else:
    print(c)
Problem p03239 (python)

Fixed submission:
N, T=map(int,input().strip().split(' '))

ct=[]
for i in range(N):
    ct.append(list(map(int, input().strip().split(' '))))
    
tle=True
c=100000000

for i in range(N):
    if ct[i][1]<=T:
        tle=False
        c=min(c,ct[i][0])
        
if tle:
    print('TLE')
else:
    print(c)

Buggy submission (verdict: Runtime Error):
ct=[]
for i in range(N):
    ct.append(list(map(int, input().strip().split(' '))))
    
tle=True
c=10000

for i in range(N):
    if ct[i][1]<=T:
        tle=False
        c=min(c,ct[i][0])
        
if tle:
    print('TLE')
else:
    print(c)

Buggy submission (verdict: Runtime Error):
ct=[]
for i in range(N):
    ct.append(list(map(int, input().strip().split(' '))))
    
tle=True
c=100000000

for i in range(N):
    if ct[i][1]<=T:
        tle=False
        c=min(c,ct[i][0])
        
if tle:
    print('TLE')
else:
    print(c)
Problem p03546 (python)

Fixed submission:
H, W=map(int,input().strip().split(' '))

cost=[]
for i in range(10):
    cost.append(list(map(int,input().strip().split(' '))))

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in a:
        if j!=-1:
            ans+=cost[j][1]
print(ans)

Buggy submission (verdict: Runtime Error):
H, W=map(int,input().strip().split(' '))

def w_f():
    cost=[]
    for i in range(10):
        cost.append(list(map(int,input().strip().split(' '))))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
    rerurn cost
    
d=w_f()
ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in a:
        if j!=-1:
            ans+=cost[j][1]
print(ans)

Buggy submission (verdict: Runtime Error):
H, W=map(int,input().strip().split(' '))

V=10
E=45
inf=10**9

def w_f():
    cost=[]
    for i in range(10):
        cost.append(list(map(int,input().strip().split(' '))))

    for i in range(V):
        for j in range(V):
            for k in range(V):
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
    return cost


d=w_f()

ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in a:
        if j!==-1:
            ans+=d[j][1]

print(ans)

Buggy submission (verdict: Runtime Error):
H, W=map(int,input().strip().split(' '))

V=10
E=45
inf=10**9

def w_f():
    for i in range(10):
        c=list(map(int,input().strip().split(' ')))
        for j in range(10):
            cost[i][j]=c[j]

    for i in range(V):
        for j in range(V):
            for k in range(V):
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
    return cost


d=w_f()

ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in range(W):
        if a[j]!=-1:
            ans+=d[a[j]][1]

print(ans)
Problem p03565 (python)

Fixed submission:
sd = input()
T = input()

if len(sd)<len(T):
    fl=False
else:
    for i in range(len(sd)-len(T),-1,-1):
    #    print(i)
        st=sd[i:len(T)+i]
    #    print(sd[i:len(T)+i])
        fl=True
        for j in range(len(T)):
            if st[j]!='?':
                if st[j]!=T[j]:
                    fl=False
        if fl:
            s=sd[:i]+T+sd[len(T)+i:]
            for k in range(len(s)):
                if s[k]=='?':
                    s=s[:k]+'a'+s[k+1:]
            break
if fl:
    print(s)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
sd = input()
T = input()

for i in range(len(sd)-len(T),-1,-1):
#    print(i)
    st=sd[i:len(T)+i]
#    print(sd[i:len(T)+i])
    fl=True
    for j in range(len(T)):
        if st[j]!='?':
            if st[j]!=T[j]:
                fl=False
    if fl:
        s=sd[:i]+T+sd[len(T)+i:]
        for k in range(len(s)):
            if s[k]=='?':
                s=s[:k]+'a'+s[k+1:]
        break
if fl:
    print(s)
else:
    print('UNRESTORABLE')