Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
strs = [[] for _ in range(26)]
cnts = [0]*26

for ind,i in enumerate(s):
    if(sum(cnts[:ord(i)-97])>=5):
        continue
    for j in range(1,len(s)-ind+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)
            cnts[ord(i)-97]+=1


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])


Fixed submission:
s = input()
K = int(input())
strs = [[] for _ in range(26)]
cnts = [0]*26

for ind,i in enumerate(s):
    if(sum(cnts[:ord(i)-97])>=5):
        continue
    for j in range(1,K+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)
            cnts[ord(i)-97]+=1


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
strs = [[] for _ in range(26)]

for ind,i in enumerate(s):
    for j in range(1,len(s)-ind+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])


Fixed submission:
s = input()
K = int(input())
strs = [[] for _ in range(26)]
cnts = [0]*26

for ind,i in enumerate(s):
    if(sum(cnts[:ord(i)-97])>=5):
        continue
    for j in range(1,K+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)
            cnts[ord(i)-97]+=1


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
strs = [[] for _ in range(26)]

for ind,i in enumerate(s):
    for j in range(1,len(s)-ind+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])


Fixed submission:
s = input()
K = int(input())
strs = [[] for _ in range(26)]
cnts = [0]*26

for ind,i in enumerate(s):
    if(sum(cnts[:ord(i)-97])>=5):
        continue
    for j in range(1,K+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)
            cnts[ord(i)-97]+=1


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])
Buggy python submission (verdict: Runtime Error):
H,W = [int(x) for x in input().split()]
S = [list('.'*(W+2))]+[list('.'+input()+'.') for _ in range(H)]+[list('.'*(W+2))]
lix = [-1,0,1,0]
liy = [0,-1,0,1]
flag = True
def dfs(x,y):
    cnt = 0
    if(S[x][y]=='.'):
        return 0
    else:
        cnt += 1
        S[x][y]='.'
        for i in range(4):
            if(S[x+lix[i]][y+liy[i]]!='.'):
                cnt += dfs(x+lix[i],y+liy[i])
        return cnt

for i in range(1,H+1):
    for j in range(1,W+1):
          if(dfs(i,j)==1):
              flag = False
if(flag):
    print('Yes')
else:
    print('No')


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

H,W = [int(x) for x in input().split()]
S = [list('.'*(W+2))]+[list('.'+input()+'.') for _ in range(H)]+[list('.'*(W+2))]
lix = [-1,0,1,0]
liy = [0,-1,0,1]
flag = True
def dfs(x,y):
    cnt = 0
    if(S[x][y]=='.'):
        return 0
    else:
        cnt += 1
        S[x][y]='.'
        for i in range(4):
            if(S[x+lix[i]][y+liy[i]]!='.'):
                cnt += dfs(x+lix[i],y+liy[i])
        return cnt

for i in range(1,H+1):
    for j in range(1,W+1):
          if(dfs(i,j)==1):
              flag = False
if(flag):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

N = int(input())
X = [(int(x),ind) for ind,x in enumerate(input().split())]
X.sort(key=itemgetter(0))
B = [0]*N
for i in range(N):
    B[X[i][1]] = (X[:i]+X[i+1:])[(N-2)//2]
for i in B:
    print(i[0])


Fixed submission:
N = int(input())
X = [int(x) for x in input().split()]
B = sorted(X)
for i in X:
    if(i<B[N//2]):
        print(B[N//2])
    else:
        print(B[N//2-1])
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = [int(x) for x in input().split()]
for i in range(A,B+1):
  if(i<= A+K-1 or i>= B-K+1):
    print(i)
    

Fixed submission:
A,B,K = [int(x) for x in input().split()]
if(B-A+1>2*K):
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
else:
  for i in range(A,B+1):
    if(i<= A+K-1 or i>= B-K+1):
      print(i)
Buggy python submission (verdict: Runtime Error):
A,B,C,D = [int(x) for x in input().split()]
print(min(A,B)+min(C,D))

Fixed submission:
A,B,C,D = [int(input()) for _ in range(4)]
print(min(A,B)+min(C,D))
Buggy python submission (verdict: Runtime Error):
A,B = [int(x) for x in input().split()]
K = 50
h,w = 2*K,2*K
cntA = A-1
cntB = B-1
print(h,w)
for i in range(h):
    if(i<K):
        pr = ['#'*w]
        for j in range(w):
            if(cntA>0):
                if(i%2==0 and w%2==0):
                    pr[j] = '.'
                    cntA -= 1
                elif(i%2==1 and w%2==1):
                    pr[j] = '.'
                    cntA -= 1
    else:
        pr = ['.'*w]
        for j in range(w):
            if(cntB>0):
                if(i%2==0 and w%2==0):
                    pr[j] = '#'
                    cntA -= 1
                elif(i%2==1 and w%2==1):
                    pr[j] = '#'
                    cntA -= 1
    print(str(*pr))
        

Fixed submission:
A,B = [int(x) for x in input().split()]
K = 50
h,w = 2*K,2*K
cntA = A-1
cntB = B-1
print(h,w)
for i in range(h):
    pr = ''
    if(i<K):
        for j in range(w):
            if(cntA>0):
                if((i%2==0 and j%2==0)):
                    pr += '.'
                    cntA -= 1
                else:
                    pr += '#'
            else:
                pr += '#'
    else:
        pr = ''
        for j in range(w):
            if(cntB>0 and i>K):
                if((i%2==0 and j%2==0)):
                    pr += '#'
                    cntB -= 1
                else:
                    pr += '.'
            else:
                pr += '.'
    print(pr)
Buggy python submission (verdict: Runtime Error):
a = [x for x in input().split()]
b = [x for x in input().split()]
c = [x for x in input().split()]
print(a[0]+b[1]+c[2])

Fixed submission:
a = input()
b = input()
c = input()
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Time Limit Exceeded):
def bfs(S,H,W):
    stk = [(0,0)]
    cnt = 0
    seen = set()
    while True:
        nxt = []
        while stk:
            h,w = stk.pop()
            if(not (0<=h<H and 0<=w<W) or S[h][w]=='#' or (h,w) in seen):
                continue
            elif(h==H-1 and w==W-1):
                break
            seen.add((h,w))
            li=[(1,0),(-1,0),(0,-1),(0,1)]
            for x,y in li:
                nxt.append((h+y,w+x))
        else:
            stk = nxt
            cnt += 1
            continue
        break
    return cnt

H,W = [int(x) for x in input().split()]
S = [list(input()) for _ in range(H)]
wht = 0
for s in S:
    wht += s.count('.')
print(wht-(bfs(S,H,W)+1))


Fixed submission:
def bfs(S,H,W):
    stk = [(0,0)]
    cnt = 0
    seen = set()
    while True:
        nxt = []
        while stk:
            h,w = stk.pop()
            if(not (0<=h<H and 0<=w<W) or S[h][w]=='#' or (h,w) in seen):
                continue
            elif(h==H-1 and w==W-1):
                break
            seen.add((h,w))
            li=[(1,0),(-1,0),(0,-1),(0,1)]
            for x,y in li:
                nxt.append((h+y,w+x))
        else:
            stk = nxt
            cnt += 1
            if(cnt>H*W+5):return -1
            continue
        break
    return cnt

H,W = [int(x) for x in input().split()]
S = [list(input()) for _ in range(H)]
wht = 0
for s in S:
    wht += s.count('.')
rt = bfs(S,H,W)
if(rt>=0):
    print(wht-(rt+1))
else:
    print(rt)
Buggy python submission (verdict: Runtime Error):
import math
X,Y = [int(x) for x in input().split()]
lcm = X*Y//math.gcd(X,Y)
if(lcm==X):
    print(-1)
else:
    print(X)


Fixed submission:
import fractions as math
X,Y = [int(x) for x in input().split()]
lcm = X*Y//math.gcd(X,Y)
if(lcm==X):
    print(-1)
else:
    print(X)

Buggy python submission (verdict: Runtime Error):
import math
X,Y = [int(x) for x in input().split()]
lcm = X*Y//math.gcd(X,Y)
if(lcm//X<=2):
    print(-1)
else:
    print(X*2)


Fixed submission:
import fractions as math
X,Y = [int(x) for x in input().split()]
lcm = X*Y//math.gcd(X,Y)
if(lcm==X):
    print(-1)
else:
    print(X)
Buggy python submission (verdict: Runtime Error):
S = input()
S[3] = '8'
print(S)

Fixed submission:
S = input()
s = ''
for index,i in enumerate(S):
  if(index == 3):
    s+='8'
  else:
  	s+=i
print(s)
Buggy python submission (verdict: Runtime Error):
A,B = [int(x) for x in input().split()]
S = input()
flag = True
for ind,i in enumerate(S):
  if(ind!=A):
      if(ord(i)<48 or 57<ord(i):
         flag = False
         break
  else:
      if(i!='-'):
         flag = False
         break
if(flag):
         print('Yes')
else:
         print('No')

Fixed submission:
A,B = [int(x) for x in input().split()]
S = input()
flag = True
for ind,i in enumerate(S):
  if(ind!=A):
      if(ord(i)<48 or 57<ord(i)):
         flag = False
         break
  else:
      if(i!='-'):
         flag = False
         break
if(flag):
     print('Yes')
else:
     print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
for i in T:
    if(i in D):
        D.pop(D.index(i))
    else:
        flag=False
if(flag):
    print('YES')
else:
    print('NO')


Fixed submission:
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
di = {}
for i in D:
    if(i in di):
        di[i]+=1
    else:
        di[i]=1
for i in T:
    if(i not in di):
        flag=False
        break
    elif(di[i]<=0):
        flag=False
        break
    else:
        di[i]-=1

if(flag):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
for i in T:
    if(i in D):
        D.pop(D.index(i))
    else:
        flag=False
if(flag):
    print('YES')
else:
    print('NO')


Fixed submission:
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
di = {}
for i in D:
    if(i in di):
        di[i]+=1
    else:
        di[i]=1
for i in T:
    if(i not in di):
        flag=False
        break
    elif(di[i]<=0):
        flag=False
        break
    else:
        di[i]-=1

if(flag):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = []
n = 4/N
for i in range(1,3501):
    flag = True
    for j in range(1,3501):
        if(n-1/i-1/j==0):
            continue
        k = 1/(n-1/i-1/j)
        if(int(k)==k and k>0):
            ans=[i,j,int(k)]
            flag = False
            break
    if(not flag):
        break
print(ans[0],ans[1],ans[2])

Fixed submission:
N = int(input())
ans = []
n = 4/N
for i in range(1,3501):
    flag = True
    for j in range(1,3501):
        if(4*i*j-N*j-N*i==0):
            continue
        k = N*i*j/(4*i*j-N*j-N*i)
        if(int(k)==k and k>0):
            ans=[i,j,int(k)]
            flag = False
            break
    if(not flag):
        break
print(ans[0],ans[1],ans[2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = []
n = 4/N
for i in range(3501,0,-1):
    for j in range(3501,0,-1):
        if(n-1/i-1/j==0):
            continue
        k = 1/(n-1/i-1/j)
        if(int(k)==k and k>0):
            ans=[i,j,k]
            break
print(ans[0],ans[1],int(ans[2]))

Fixed submission:
N = int(input())
ans = []
n = 4/N
for i in range(1,3501):
    flag = True
    for j in range(1,3501):
        if(4*i*j-N*j-N*i==0):
            continue
        k = N*i*j/(4*i*j-N*j-N*i)
        if(int(k)==k and k>0):
            ans=[i,j,int(k)]
            flag = False
            break
    if(not flag):
        break
print(ans[0],ans[1],ans[2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = []
n = 4/N
for i in range(N,0,-1):
    for j in range(N,0,-1):
        if(n-1/i-1/j==0):
            continue
        k = 1/(n-1/i-1/j)
        if(int(k)==k and k>0):
            ans=[i,j,k]
            break
print(ans[0],ans[1],int(ans[2]))

Fixed submission:
N = int(input())
ans = []
n = 4/N
for i in range(1,3501):
    flag = True
    for j in range(1,3501):
        if(4*i*j-N*j-N*i==0):
            continue
        k = N*i*j/(4*i*j-N*j-N*i)
        if(int(k)==k and k>0):
            ans=[i,j,int(k)]
            flag = False
            break
    if(not flag):
        break
print(ans[0],ans[1],ans[2])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    INF = float('inf')
    N = int(input())
    d = [[int(x) for x in input().split()]for _ in range(N)]
    ans = 0
    for i in d:
        ans += sum(i)
    ans //= 2
    max_d = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if(i==j or j==k or i==k or d[i][j]==INF):continue
                max_d = max(max_d,d[i][j])
                if(d[i][j]>=d[i][k] + d[k][j]):
                    ans -= d[i][j]
                    d[i][j] = INF
                    d[j][i] = INF
    print(ans if ans >= max_d else -1)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
def main():
    INF = float('inf')
    N = int(input())
    d = [[int(x) for x in input().split()]for _ in range(N)]
    ans = 0
    flag = True
    for i in d:
        ans += sum(i)
    ans //= 2
    max_d = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if(i==j or j==k or i==k or d[i][j]==INF):continue
                max_d = max(max_d,d[i][j])
                if(d[i][j]==d[i][k] + d[k][j]):
                    ans -= d[i][j]
                    d[i][j] = INF
                    d[j][i] = INF
                elif(d[i][j]>d[i][k] + d[k][j]):
                    flag = False
    print(ans if (ans >= max_d)and flag else -1)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
INF = float('inf')

def warshall_floyd(d,n):
    max_d = 0
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if(i==j or j==k or i==k):continue
                if(d[i][j]!=INF):
                    max_d = max(max_d,d[i][j])
                if(d[i][j]>=d[i][k] + d[k][j]):
                    d[i][j] = INF
                    d[j][i] = INF
    return max_d

N = int(input())
gp = [[int(x) for x in input().split()]for _ in range(N)]
max_d = warshall_floyd(gp,N)
ans = 0
for d in gp:
    ans += sum([i if i!=INF else 0 for i in d])
print(ans//2 if ans//2 >= max_d else -1)


Fixed submission:
import sys
input = sys.stdin.readline
def main():
    INF = float('inf')
    N = int(input())
    d = [[int(x) for x in input().split()]for _ in range(N)]
    ans = 0
    flag = True
    for i in d:
        ans += sum(i)
    ans //= 2
    max_d = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if(i==j or j==k or i==k or d[i][j]==INF):continue
                max_d = max(max_d,d[i][j])
                if(d[i][j]==d[i][k] + d[k][j]):
                    ans -= d[i][j]
                    d[i][j] = INF
                    d[j][i] = INF
                elif(d[i][j]>d[i][k] + d[k][j]):
                    flag = False
    print(ans if (ans >= max_d)and flag else -1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(x) for x in input().split()]
cnt = 0
flag = True
for ind,i in enumerate(p):
    if(ind+1==i and flag):
        cnt+=1
        if(p[ind+1]==ind+2):
            flag = False
    else:
        flag = True
print(cnt)

Fixed submission:
N = int(input())
p = [int(x) for x in input().split()]
cnt = 0
flag = True
for ind,i in enumerate(p):
    if(ind+1==i and flag):
        cnt+=1
        if(ind!=N-1):
            if(p[ind+1]==ind+2):
                flag = False
    else:
        flag = True
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = 1
while(N>=X):
  　X = X<<1
print(X>>1)


Fixed submission:
N = int(input())
X = 1
while(N>=X):
  X = X<<1
print(X>>1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = 1
while(N>=X):
  　X<<1
print(X>>1)


Fixed submission:
N = int(input())
X = 1
while(N>=X):
  X = X<<1
print(X>>1)
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l.sort(reversed = True)
print(sum(l[:K]))

Fixed submission:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l.sort(reverse = True)
print(sum(l[:K]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(x) for x in input().split()]
b = []
for ind,i in enumerate(a):
    if(ind%2==0):
        b.append(i)
    else:
        b.insert(0,i)
if(N%2!=0):
    b.reverse()
for i in b[:-1]:
    print(i,end=' ')
print(b[-1])

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]

if(N==1):
    print(a[0])
elif(N%2==0):
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(0,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])
else:
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(1,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(x) for x in input().split()]
b = []
for ind,i in enumerate(a):
    if(ind%2==0):
        b.append(i)
    else:
        b.insert(0,i)
if(N%2!=0):
    b.reverse()
for i in b[:-1]:
    print(i,end=' ')
print(b[-1])

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]

if(N==1):
    print(a[0])
elif(N%2==0):
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(0,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])
else:
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(1,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])
Buggy python submission (verdict: Runtime Error):
def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0
  
  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v-1: return -1
  
  return dist


N,M = [int(x) for x in input().split()]
edges = []
for _ in range(N):
    l = [int(x) for x in input().split()]
    l[2]*=-1
    edges.append(l)

route = BellmanFord(edges,N,1)
if(route == -1):
    print('inf')
else:
    print(-route[-1])


Fixed submission:
from operator import itemgetter

def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float('inf')
  dist=[inf for i in range(num_v)]
  dist[source-1]=0

  #辺の緩和
  for i in range(num_v+1):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v and edge[1]==num_v: return -1

  return dist


#%%
N,M = [int(x) for x in input().split()]
edges = []
for _ in range(M):
    l = [int(x) for x in input().split()]
    l[2]*=-1
    edges.append(l)
#%%
route = BellmanFord(edges,N,1)
if(route == -1):
    print('inf')
else:
    print(-int(route[N-1]))
Buggy python submission (verdict: Runtime Error):
a,b,c = [int(x) for x in input().split()]
if(b-a = c-b):
  print('YES')
else:
  print('NO')

Fixed submission:
a,b,c = [int(x) for x in input().split()]
if(b-a == c-b):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
li=[13,1,2,3,4,5,6,7,8,9,10,11,12]
A,B = [int(x) for x in input().split()]
if(li[A]>li[B]):
  print('Alice')
elif(li[A]==li[B]):
  print('Draw')
else:
  print('Bob')

Fixed submission:
li=[13,1,2,3,4,5,6,7,8,9,10,11,12]
A,B = [int(x)-1 for x in input().split()]
if(li[A]>li[B]):
  print('Alice')
elif(li[A]==li[B]):
  print('Draw')
else:
  print('Bob')
Buggy python submission (verdict: Runtime Error):
N,M = [int(x) for x in input().split()]
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M):
    for j in range(N-M):
        flagx = True
        for x in range(M):
            if(A[i+x][j:j+M]!=B[x]):
                flagx = False
        if(flagx): break

if(flagx):
    print('Yes')
else:
    print('No')


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N,M = [int(x) for x in input().split()]
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
#%%
flag = False
for i in range(N-M):
    for j in range(N-M):
        flagx = True
        for x in range(M):
            if(A[i+x][j:j+M]!=B[x]):
                flagx = False
        if(flagx):
            flag = flag|flagx
            break

if(flag or (N==1 and M==1)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A,op,B = [x for x in input().split()]
A = int(A)
B = int(B)
if(op = '+'):
  print(A+B)
else:
  print(A-B)

Fixed submission:
A,op,B = [x for x in input().split()]
A = int(A)
B = int(B)
if(op == '+'):
  print(A+B)
else:
  print(A-B)