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

Fixed submission:
N, M, L = map(int,input().split(' '))
Ms=[]
inf = 10**11
for i in range(N+1):
    #for j in range(N):
    Ms.append([inf]*(N+1) )
#print(d)
#print(d[1][1])
for i in range(M):
    a,b,c = map(int,input().split(' '))
    #print(a,b,c)
    Ms[a][b] = c
    Ms[b][a] = c
    #print(Ms)
Q = int(input())

def warshall_floyd(Ms):
    for k in range(1,len(Ms)):
        for i in range(1,len(Ms)):
            for j in range(1,len(Ms)):
                Ms[i][j]=min(Ms[i][j],Ms[i][k]+Ms[k][j])
    return Ms

Ms = warshall_floyd(Ms)
#print(Ms)
#print("Ms",Ms[3][2],Ms[2][3])
#Ls = Ms.copy()
Ls = Ms
for i in range(N+1):
    for j in range(N+1):
        if Ls[i][j] <= L:
            Ls[i][j] = 1
        else:
            Ls[i][j]=inf
#print("Ls",Ls[3][2])
Ls = warshall_floyd(Ls)
#print(Ls)
for i in range(Q):
    s,t = map(int,input().split(' '))
    if Ls[s][t] == inf:
        print(-1)
    else:
        print(Ls[s][t]-1)

Buggy submission (verdict: Runtime Error):
N, M, L = map(int,input().split(' '))
Ms=[]
inf = 10**11
for i in range(N+1):
    #for j in range(N):
    Ms.append([inf]*(N+1) )
#print(d)
#print(d[1][1])
for i in range(M):
    a,b,c = map(int,input().split(' '))
    #print(a,b,c)
    Ms[a][b] = c
    Ms[b][a] = c
    #print(Ms)
Q = int(input())

def warshall_floyd(Ms):
    for k in range(1,len(Ms)):
        for i in range(1,len(Ms)):
            for j in range(1,len(Ms)):
                Ms[i][j]=min(Ms[i][j],Ms[i][k]+Ms[k][j])
    return Ms

Ms = warshall_floyd(Ms)
#print(Ms)
#print("Ms",Ms[3][2],Ms[2][3])
Ls = Ms.copy()
for i in range(N+1):
    for j in range(N+1):
        if Ls[i][j] <= L:
            Ls[i][j] = 1
        else:
            Ls[i][j]=inf
#print("Ls",Ls[3][2])
Ls = warshall_floyd(Ls)
#print(Ls)
for i in range(Q):
    s,t = map(int,input().split(' '))
    if Ls[s][t] == inf:
        print(-1)
    else:
        print(Ls[s][t]-1)
Problem p03061 (python)

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

def myGCD(a,b):
    if a == 0:
        return b
    while b!=0:
        a,b = b,a%b
    return a

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))

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

def myGCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def list_gcd(numbers):
    tmp=numbers[0]
    for i in range(len(numbers)-1):
        tmp=min(tmp,myGCD(numbers[i],numbers[i+1]))
    return(tmp)

#print(list_gcd(A))

candidate=[0,0]
t1 = A[0]
candidate[0]=max(A[0],A[1])
candidate[1]=myGCD(A[0],A[1])
candidate[2]=myGCD(A[0],A[1])

for i in range(2,N):
    candidate[0]=myGCD(candidate[0],A[i])
    candidate[1]=candidate[1]
    candidate[2]=myGCD(candidate[2],A[i])
    candidate[0]=min(candidate[0],candidate[1])

#print(min(candidate))

print(max(candidate))

Buggy submission (verdict: Runtime Error):
import math

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

def list_gcd(numbers):
    tmp=numbers[0]
    for i in range(len(numbers)-1):
        tmp=min(tmp,math.gcd(numbers[i],numbers[i+1]))
    return(tmp)

maxgcd = 0
for i in range(N):
    Atmp=A[0:i]
    if i < N-1:
        Atmp.extend(A[i+1:N])
    #print(Atmp)
    tmpgcd=list_gcd(Atmp)
    #print(tmpgcd)
    if tmpgcd > maxgcd:
        maxgcd = tmpgcd

print(maxgcd)

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

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

def list_gcd(numbers):
    return(reduce(math.gcd,numbers))

maxgcd = 0
for i in range(N):
    Atmp=A[0:i]
    if i < N-1:
        Atmp.extend(A[i+1:N])
    #print(Atmp)
    tmpgcd=list_gcd(Atmp)
    #print(tmpgcd)
    if tmpgcd > maxgcd:
        maxgcd = tmpgcd

print(maxgcd)
Problem p03074 (python)

Fixed submission:
N, K = map(int,input().split(' '))
S = input()
S2=[]
key=S[0]
tmpcnt=1
if key=='0':
    S2.append(0)
S2.append(0)
S2.append(0)
for i in range(1,len(S)):
    if key!=S[i]:
        if key == '0':
            S2.append(-1*tmpcnt)
        else:
            S2.append(tmpcnt)
        key=S[i]
        tmpcnt=1
    else:
        tmpcnt+=1
if key == '0':
    S2.append(-1*tmpcnt)
    S2.append(0)
    S2.append(0)
else:
    S2.append(tmpcnt)
    S2.append(0)
    S2.append(0)
#print(S2)
max=0
tmp=S2[0]
maxj=len(S2)-1
for j in range(1,K*2+1):
    tmp+=abs(S2[min(0+j,maxj)])
    #print(S2[i],S2[min(i+j,maxj)])
if tmp >= max:
    max=tmp
    #print(tmp)

for i in range(2,len(S2),2):
    tmp-=abs(S2[i-1])
    tmp-=abs(S2[i-2])
    tmp+=abs(S2[min(i+j-1,maxj)])
    tmp+=abs(S2[min(i+j,maxj)])
    #print(i-1,i-2,i+j-1,i+j)
    #print(tmp)
    if tmp>= max:
        max=tmp
print(max)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split(' '))
S = input()
S2=[]
key=S[0]
tmpcnt=1
if key=='0':
    S2.append(0)
for i in range(1,len(S)):
    if key!=S[i]:
        if key == '0':
            S2.append(-1*tmpcnt)
        else:
            S2.append(tmpcnt)
        key=S[i]
        tmpcnt=1
    else:
        tmpcnt+=1
if key == '0':
    S2.append(-1*tmpcnt)
    S2.append(0)
    S2.append(0)
else:
    S2.append(tmpcnt)
    S2.append(0)
    S2.append(0)
#print(S2)
max=0
tmp=S2[i]
maxj=len(S2)-1
for j in range(1,K*2+1):
    tmp+=abs(S2[min(0+j,maxj)])
    #print(S2[i],S2[min(i+j,maxj)])
if tmp >= max:
    max=tmp
    #print(tmp)

for i in range(2,len(S2)):
    tmp-=abs(S[i-1])
    tmp-=abs(S[i-2])
    tmp+=abs(S[min(i+j,maxj)])
    tmp+=abs(S[min(i+j+1,maxj)])
    if tmp>= max:
        max=tmp
print(max)
Problem p03229 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()) )

B=sorted(A)
#print(B[N-1]-B[0] + B[N-1]-B[0])
hN=int(N/2)
cnt=0
C=[]
if N ==2:
    print(B[1]-B[0])
    exit()

if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[N-1-i])
        C.append(B[i])
    C.append(B[hN-1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[N-1-i])
        C.append(B[i])

#print(C)

for i in range(1,N):
    cnt+=abs(C[i]-C[i-1])

C=[]
cnt2=0
if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[i])
        C.append(B[N-1-i])
    C.append(B[hN-1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])

#print(C)
for i in range(1,N):
    cnt2+=abs(C[i]-C[i-1])

print(max(cnt,cnt2))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()) )

B=sorted(A)
#print(B[N-1]-B[0] + B[N-1]-B[0])
hN=int(N/2)
cnt=0
C=[]
if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[N-1-i])
        C.append(B[i])
    C.append(B[hN+1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[N-1-i])
        C.append(B[i])

#print(C)

for i in range(1,N):
    cnt+=abs(C[i]-C[i-1])

C=[]
cnt2=0
if N %2 == 0:
    C.append(B[hN-1])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])
    C.append(B[hN+1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])

#print(C)
for i in range(1,N):
    cnt2+=abs(C[i]-C[i-1])

print(max(cnt,cnt2))
Problem p03480 (python)

Fixed submission:
import math

s = input()
minpos = len(s)

for i in range(1,len(s)):
    if s[i] != s[i-1]:
        pos = max(i,len(s)-i)

        if pos < minpos:
            minpos = pos

print(minpos)

Buggy submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==1 or len(ss)==2:
    ans = maxs
elif max(ss[1:len(ss)-2]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、隣の長いほうも入る。
# 但し、とろうとしている長いのが端なら、短いほうしか入れられない。
else:
    tmpmax = 0
    print(ss)
    for i in range(1,len(ss)-1 ):
        if ss[i] == maxs:
            if i == 1:
                if ss[0] > ss[2]:
                    tmp = maxs + ss[2] 
                else:
                    tmp = maxs + ss[0]
            elif i == len(ss)-2:
                if ss[len(ss)-1] > ss[len(ss)-3]:
                    tmp = maxs + ss[len(ss)-3]
                else:
                    tmp = maxs + ss[len(ss)-1]
            else:
                tmp= maxs+max(ss[i-1],ss[i+1])

            if tmp > tmpmax:
                tmpmax = tmp
        else:
            pass

    ans = tmpmax

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==2:
    ans = maxs
elif max(ss[1:len(ss)-1]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、隣の長いほうも入る。
else:
    tmpmax = 0
    for i in range(1,len(ss)-2 ):
        if ss[i] == maxs:
           tmp= maxs+max(ss[i-1],ss[i+1])
           if tmp > tmpmax:
               tmpmax = tmp
        else:
            pass

    ans = tmpmax

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==2:
    ans = maxs
elif max(ss[1:len(s)-1]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、短いほうも入る
else:
    ans = maxs + min(ss[0],ss[len(ss)-1])

print(ans)
Problem p03485 (python)

Fixed submission:
import math

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

a = A1[0]*1.0
b = A1[1]*1.0

print(math.ceil( ( a + b ) / 2 ))

Buggy submission (verdict: Runtime Error):
import math

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in prey:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")
Problem p03488 (python)

Fixed submission:
import math

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
tmpx=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
tmpy=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in prey:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in prey:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in tmpy:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")
Problem p03651 (python)

Fixed submission:
import math

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

A.sort()
A.reverse()

t=A[0]

def myGCD(a,b):
    while b!=0:
        a,b=b,a%b 
    return(a)   

for i in range(1,N):
    t=myGCD(t,A[i])

if K > A[0]:
    print("IMPOSSIBLE")
else:
    if K%t==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import math

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

A.sort()
A.reverse()

t=A[0]
for i in range(1,N):
    t=math.gcd(t,A[i])

if K > A[0]:
    print("IMPOSSIBLE")
else:
    if K%t==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
Problem p03501 (python)

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

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
print(min(n*a, b))
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
j = 0
while j <= N:
  if S[j]<= X:
    c += 1
    j += 1
  
  else:
    j += 1

    
print(c)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
i = 0
while S[i] <= X:
  if S[i]<= X:
    c += 1
    i += 1

    
print(c)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
i = 0
while S[i] <= X:
  if S[i]<= X:
    c += 1
    i += 1
  else:
    print(c)
    
print(c)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]

i = 0
while i <= N:
  S.append(S[i-1]+L[i])
  i += 1
  
print(S)
Problem p03325 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
m = 1
ans = 0

for i in range(N):
  while a[i] % 2 == 0:
    a[i] /= 2
    ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
m = 1
ans = 0
 
for i in range(N):
  m *= a[i]
  
  
while m % 2 == 0:
  m /= 2
  ans += 1
    
print(ans)
Problem p02675 (python)

Fixed submission:
N = str(input())

if int(N[-1])==3:
  print('bon')
elif int(N[-1]) in [0, 1, 6, 8]:
  print('pon')
else:
  print('hon')

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

if N[-1]==3:
  print('bon')
elif N[-1] in [0, 1, 6, 8]:
  print('pon')
else:
  print('hon')
Problem p02741 (python)

Fixed submission:
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])

Buggy submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
root_ab = int(math.sqrt(a)) + int(math.sqrt(b))
root_c = int(math.sqrt(c))
if root_ab < root_c:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[int(input())])

Buggy submission (verdict: Runtime Error):
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[input()])
Problem p02755 (python)

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

flg = False
for price in range(1,1010):
    if int(price*0.08)==A and int(price*0.1)==B:
        flg = True
        break

if flg:
    print(price)
else:
    print(-1)

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

S = input()
Q = int(input())
head = 1
d = deque([S])

for _ in range(Q):
    q = input().split()
    if q[0]=='1':
        head = head*-1
    else:
        if q[1]=='1':
            h = head*1
        else:
            h = head*-1
        
        if h==1:
            d.appendleft(q[2])
        else:
            d.append(q[2])
if head == -1:
    d.reverse()

print("".join(list(d)))
Problem p03155 (python)

Fixed submission:
N = int(input())
W = int(input())
H = int(input())

print((N - W + 1) * (N - H + 1))

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

print((N - W + 1) * (N - H + 1))
Problem p03282 (python)

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

for i, c in enumerate(S):
    if i >= K:
        print(1)
        quit()
    elif c != '1':
        print(c)
        quit()
print(1)
quit()

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

if S[K - 1] == '1':
    print(S[K - 1])

for c in S:
    if c != '1':
        print(c)
        quit()
Problem p03373 (python)

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

ans = A * X + B * Y
if X >= 1 and Y >= 1:

    z = min(X, Y)
    ans = min(ans, A * (X - z) + B * (Y - z) + C * (z * 2))

    z = max(X, Y)
    ans = min(ans, A * max(0, (X - z)) + B * max(0, (Y - z)) + C * (z * 2))

print(ans)

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

if X >= 2 and Y >= 2:
    ans = A * X + B * Y
    if C * 2 < A + B:
        z = min(X // 2, Y // 2)
        ans = A * (X - z * 2) + B * (Y - z * 2) + C * (z * 4)

        z = max(X // 2, Y // 2)
        ans = min(ans, A * max(0, (X - z * 2)) + B * max(0, (Y - z * 2)) + C * (z * 4))

print(ans)
Problem p03380 (python)

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

n = max(a)
r = 0
M = 0
mid = n / 2
diff = 1000000000
for x in a:
    if x == n:
        continue
    if diff > abs(mid - x):
        diff = abs(mid - x)
        r = x

print(n, r)

Buggy submission (verdict: Runtime Error):
def comb(n, r):
    ans = 1
    for i in range(n - r + 1, n + 1):
        ans *= i
    for i in range(1, r + 1):
        ans /= i
    return ans

N = int(input())
a = tuple(map(int, input().split()))

n = max(a)
M = 0
for x in a:
    if x == n:
        continue
    res = comb(n, x)
    if M < res:
        M = res
        r = x

print(n, r)

Buggy submission (verdict: Runtime Error):
def comb(n, r):
    ans = 1
    for i in range(n - r + 1, n + 1):
        ans *= i
    for i in range(1, r + 1):
        ans /= i
    return ans

N = int(input())
a = tuple(map(int, input().split()))

Max = 0
for i in range(0, N):
    for j in range(i + 1, N):
        M = max(a[i], a[j])
        m = min(a[i], a[j])
        res = comb(M, m)
        if Max < res:
            Max = res;
            n = M
            r = m

print(n, r)
Problem p03388 (python)

Fixed submission:
Q = int(input())

while Q:
    Q -= 1
    A, B = map(int, input().split())
    M = max(A, B)
    m = min(A, B)
    if M == m:
        print(2 * m - 2)
        continue
    if M == m + 1:
        print(2 * m - 2)
        continue
    last = int((M * m) ** 0.5)
    if last == (M * m) ** 0.5:
        last -= 1
    if last * (last + 1) >= M * m:
        print(last * 2 - 2)
    else:
        print(last * 2 - 1)

Buggy submission (verdict: Runtime Error):
Q = int(input())

while Q:
    Q -= 1
    from math import sqrt
    A, B = map(int, input().split())
    M = max(A, B)
    for i in range(min(A, B), max(A, B)):
        if i ** 2 >= A * B:
            break
        else:
            last = i
    ans = 2 * last
    if last >= min(A, B):
        ans -= 1
    if last * (last + 1) >= A * B:
        ans -= 1
    print(ans)
Problem p03597 (python)

Fixed submission:
N = int(input())
M = int(input())
print(N * N - M)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(N * N - M)
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
print(['EQUAL', 'GREATER', 'LESS'][(a>b)-(a<b)])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(['LESS', 'GEATER', 'EQUAL'][(a>b)-(a==b)])
Problem p02683 (python)

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(100000)

def dfs(cost, i, ratio):
    if i == n:
        global ans
        if cost < ans and all([r >= x for r in ratio]):
            ans = cost
        return
    dfs(cost, i+1, ratio)
    dfs(cost+c[i], i+1, ratio+a[i])

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    c = [None]*n
    a = np.array([None]*n)
    for i in range(n):
        c[i], *a[i] = map(int, input().split())
    ans = 10**8
    dfs(0, 0, np.array([0]*m))
    if ans == 10**8:
        print(-1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
sys.setrecursionlimit(1000000)

def dfs(cost, i, A):
    if i == n-1:
        global ans
        if cost < ans and all([ai>=x for ai in A]):
            ans = cost
        return
    i += 1
    dfs(cost, i, A)
    dfs(cost+c[i], i, A+a[i])

    

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    c, a = [None]*n, np.array([None]*n)
    for i in range(n):
        c[i], *a[i] = map(int, input().split())
    ans = 10**10
    dfs(0, -1, np.array([0]*m))
    if ans == 10**10:
        print(-1)
    else:
        print(ans)
Problem p02657 (python)

Fixed submission:
a,b = (input().split())
print(int(a)*int(b))

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

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

Fixed submission:
from collections import deque
from scipy.sparse.csgraph import floyd_warshall

def solve():
  h,w = (int(i) for i in input().split())
  maze = ["#"*(w+2)]
  for i in range(h):
    maze.append("#" + input() + "#")
  maze.append("#"*(w+2))

  dist = [(1,0),(0,1),(-1,0),(0,-1)]
  d = [[0]*500 for _ in range(500)]
  for y in range(1,h+1):
    for x in range(1,w+1):
      if maze[y][x] == ".":
        for dy,dx in dist:
          if maze[y+dy][x+dx] == ".":
            oldy = x + w*y
            inty = x+dx + w*(y+dy)
            d[inty][oldy] = 1
            d[oldy][inty] = 1
  ans = 0
  d = floyd_warshall(d)
  for i in range(500):
    for j in range(500):
      if d[i][j] < 10**15:
              ans = max(d[i][j],ans)
  print(int(ans))




solve()

Buggy submission (verdict: Runtime Error):
from collections import deque
from scipy.sparse.csgraph import floyd_warshall

def solve():
  h,w = (int(i) for i in input().split())
  maze = ["#"*(w+2)]
  for i in range(h):
    maze.append("#" + input() + "#")
  maze.append("#"*(w+2))

  dist = [(1,0),(0,1),(-1,0),(0,-1)]
  d = [[0]*500 for _ in range(500)]
  for y in range(1,h+1):
    for x in range(1,w+1):
      if maze[y][x] == ".":
        for dy,dx in dist:
          if maze[y+dy][x+dx] == ".":
            oldy = x + w*y
            inty = x+dx + w*(y+dy)
            d[inty][oldy] = 1
            d[oldy][inty] = 1
  ans = 0
  d = floyd_warshall(d)
  for i in range(500):
    for j in range(500):
      if d[i][j] < 10**15:
              ans = max(d[i][j],ans)
  print(int(ans))




solve()