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

Fixed submission:
h=int(input())

w=int(input())

n=int(input())

i=0
j=0

if(h>=w):
  s=h
else:
  s=w

while j<n:
  i+=1
  j=j+s

print(i)

Buggy submission (verdict: Runtime Error):
print("please input W")
w=int(input())

print("please input N")
n=int(input())

i=0
j=0

if(h>=w):
  s=h
else:
  s=w

while j<n:
  i+=1
  j=j+s

print(i)
Problem p02732 (python)

Fixed submission:
def cmb(n, r):
    if r > n: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

c = collections.Counter(A)
keys = c.keys()
ans_dict = {}
ans_dict2 = {}
for key in keys:
    ans_dict[key] = cmb(c[key]-1,2)
    ans_dict2[key] = cmb(c[key],2)

SUM  = sum(ans_dict2.values())

# print(ans_dict)
# print(ans_dict2)

for key in A:
    print(SUM-ans_dict2[key]+ans_dict[key])

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

c = collections.Counter(A)
keys = c.keys()
ans_dict = {}
ans_dict2 = {}
for key in keys:
    ans_dict[key] = cmb(c[key]-1,2)
    ans_dict2[key] = cmb(c[key],2)

SUM  = sum(ans_dict2.values())

# print(ans_dict)
# print(ans_dict2)

for key in A:
    print(SUM-ans_dict2[key]+ans_dict[key])
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
Switch = False
Query = []

import collections
dq = collections.deque(S)

for i in range(Q):
    s = input()
    if s[0] == '1':
        if Switch:
            Switch = False
        else:
            Switch = True
    if s[0] == '2':
        if s[2] == '1' and Switch==False:
            dq.appendleft(s[4])
#             S = s[4]+S
        elif s[2]=='1' and Switch==True:
            dq.append(s[4])
#             S = S+s[4]
        elif s[2] == '2' and Switch==False:
            dq.append(s[4])
#             S = S+s[4]
        else:
#             S = s[4]+S
            dq.appendleft(s[4])

if Switch == False:
    print(''.join(dq))
else:
    print(''.join(dq)[::-1])

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
Switch = False
Query = []

import collections
dq = collections.deque(S)

for i in range(Q):
    s = input()
    if s[0] == '1':
        if Switch:
            Switch = False
        else:
            Switch = True
    if s[0] == '2':
        if s[2] == '1' and Switch==False:
            dq.appendleft(s[4])
#             S = s[4]+S
        elif s[2]=='1' and Switch==True:
            dq.append(s[4])
#             S = S+s[4]
        elif s[2] == '2' and Switch==False:
            dq.append(s[4])
#             S = S+s[4]
        else:
#             S = s[4]+S
            dq.appendleft(s[4])

if Switch == False:
    print('',join(dq))
else:
    print(''.join(dq)[::-1])
Problem p02787 (python)

Fixed submission:
import numpy as np
 
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = np.array(ab)
 
a = ab[:, 0]
b = ab[:, 1]
 
dp = np.zeros(100001, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()

print(dp[h])

Buggy submission (verdict: Runtime Error):
import numpy as np
H,N = map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    
dp = [np.inf for i in range(10**7+1)]
dp[0] = 0
for i in range(H+1):
    for j in range(N):
        dp[i+A[j]] = min(dp[i+A[j]],dp[i]+B[j])
        
print(min(dp[H:]))

Buggy submission (verdict: Runtime Error):
import numpy as np
H,N = map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    
dp = [10**8+1 for i in range(H*N+1)]
dp[0] = 0
for i in range(H+1):
    for j in range(N):
        dp[i+A[j]] = min(dp[i+A[j]],dp[i]+B[j])
        
print(min(dp[H:]))

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
sys.setrecursionlimit(2000)
H,N = map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

memo = [10**4+1 for i in range(H+1)]

def memorize(H,memo,A,B,N):
    if H<= 0:
        return 0
    else:
        if memo[H]!=10**4+1:
            return memo[H]
        cost_min = 10**4+1
        for i in range(N):
            cost = B[i] + memorize(H-A[i],memo,A,B,N)
            cost_min = min(cost_min,cost)
        memo[H] = cost_min
        return cost_min
        
print(memorize(H,memo,A,B,N))

Buggy submission (verdict: Runtime Error):
import numpy as np
sys.setrecursionlimit(10**4+1)
H,N = map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

memo = [10**4+1 for i in range(H+1)]

def memorize(H,memo,A,B,N):
    if H<= 0:
        return 0
    else:
        if memo[H]!=10**4+1:
            return memo[H]
        cost_min = 10**4+1
        for i in range(N):
            cost = B[i] + memorize(H-A[i],memo,A,B,N)
            cost_min = min(cost_min,cost)
        memo[H] = cost_min
        return cost_min
        
print(memorize(H,memo,A,B,N))
Problem p02861 (python)

Fixed submission:
import math
# import numpy as np
import itertools
N = int(input())
x = []
y = []
for i in range(N):
    s1,s2 = map(int,input().split())
    x.append(s1)
    y.append(s2)
    
def length(i,j):
    return math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)

LI = [i for i in range(N)]
A = list(itertools.permutations(LI))
ans = 0
for item in A:
#     print(item)
    count = 0
    for i in range(len(item)):
        if i == len(item)-1:
            break
#         print(length(item[count],item[count+1]))
        ans = ans+length(item[count],item[count+1])
        count +=1
print(ans/math.factorial(N))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
import itertools
N = int(input())
x = []
y = []
for i in range(N):
    s1,s2 = map(int,input().split())
    x.append(s1)
    y.append(s2)
    
def length(i,j):
    return np.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)

LI = [i for i in range(N)]
A = list(itertools.permutations(LI))
ans = 0
for item in A:
#     print(item)
    count = 0
    for i in range(len(item)):
        if i == len(item)-1:
            break
#         print(length(item[count],item[count+1]))
        ans = ans+length(item[count],item[count+1])
        count +=1
print(ans/math.factorial(N))
Problem p02866 (python)

Fixed submission:
BIGMOD = 998244353
 
def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD
 
def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact
 
def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact
 
def modPlus(a,b):
    return (a + b) % BIGMOD
 
def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD
 
# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD
 
def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD
 
def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans
 
import collections
 
N = int(input())
D = list(map(int,input().split()))
 
S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.Counter(D)
if c[0] > 1:
  ans=0
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
BIGMOD = 998244353

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD

def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans

import collections

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

S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.ounter(D)
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
if x/(a*a) <= (b/2):
    ans = 2*x/(a*b*b)
    print(90-math.degrees(math.atan(ans)))
else:
    ans = (2*a*a*b-2*x)/(a*a*a)
    print(math.degrees(math.atan(ans)))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import numpy as np
if x<=(a*a*b)/2:
    A = 2*x/(a*b*b)
    Z = A
    print(A)
    print(np.arctan(Z)*180/(np.pi))
else:
    A = a*a*b-x
    B = (a*a)/A
    Z = B
    print(np.arctan(Z)*180/np.pi)
Problem p02888 (python)

Fixed submission:
import bisect
 
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        tmp=a[i]+a[j]
        index=bisect.bisect_left(a,tmp)
        ans+=index-j-1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
L = list(map(int,input().split()))
cnt = 0
L.sort()
L = L[::-1]

def nibutan(L,i,j,N):
    lower = N-1
    upper = j+1
    middle = int(np.round(upper+lower)/2)
    if upper> lower:
        return 0

    for cnt in range(16):
        if L[i] < L[j] + L[middle]:
            upper = middle
            middle = int(np.round((upper+lower)/2))
        else:
            lower = middle
            middle = int(np.round((upper+lower)/2))-1
#         print(middle)
    return max([middle - j,0])

# print('L',L)
for i in range(N):
    for j in range(i+1,N):
#         print('test',L[i],L[j])
        cnt += nibutan(L,i,j,N)
print(cnt)
Problem p02909 (python)

Fixed submission:
S = input()
if S == 'Sunny':
    print('Cloudy')
elif S =='Cloudy':
    print('Rainy')
else:
    print('Sunny')

Buggy submission (verdict: Runtime Error):
S = input()
if S == 'Sunny':
  print('Cloudy')
elif S =='Cloudy':
  print('Rainy')
else S=='Rainy':
  print('Sunny')
Problem p02983 (python)

Fixed submission:
s = input().split()
L = int(s[0])
R = int(s[1])

MIN = 2020
flag = 0

for i in range(L,R+1):
    for j in range(i+1,R+1):
        mod = i*j % 2019
        MIN = min(MIN,mod%2019)
        if MIN == 0:
            flag = 1
            break
    if flag == 1:
        break

if R == 0 or L == 0:
    print(0)
elif R - L == 1:
     print((R*L)%2019)
else:
    print(MIN)

Buggy submission (verdict: Runtime Error):
s = input().split()
L = int(s[0])
R = int(s[1])
 
L = L%2019
R = R%2019
MIN = 2020
if R - L >= 2019:
    flag = True

for i in range(min(L,R),max(L,R)+1):
    for j in range(i,max(L,R)+1):
        if i != j:
            mod = i*j
            MIN = min(MIN,mod%2019)
if R == 0 or L == 0 or flag:
    print(0)
elif abs(R - L) == 1:
    print((R*L)%2019)
elif R == L:
    print((R*L)%2019)
else:
    print(MIN)
Problem p03000 (python)

Fixed submission:
s = input().split()
N = int(s[0])
X = int(s[1])
ss = input().split()
L = [0]*(N+1)
for i in range(N):
    L[i] = int(ss[i])
    
D = 0
count =0
for i in range(N+1):
    D = D+L[i]
    count = count+1
   # print(D)
    if D > X:
        break
        
print(count)

Buggy submission (verdict: Runtime Error):
s = input().split()
N = int(s[0])
X = int(s[1])
ss = input().split()
L = []
for i in range(N):
    L.append(int(ss[i]))
    
D = 0
count =0
for i in range(N+1):
    D = D+L[i]
    count = count+1
    if D > X:
        break
        
print(count)
Problem p03060 (python)

Fixed submission:
N = 0
V = []
C = []
 
i = 0
ans = 0

str = input()
N = int(str)
 
str = input().split()
while i < N:
  V.append(int(str[i]))
  i = i+1
  
i=0
str = 0
str = input().split()
while i < N:
  C.append(int(str[i]))
  i = i+1

i=0
while i<N:
  if V[i] > C[i]:
    ans = ans + V[i] - C[i]
  i = i+1
    
    
print(ans)

Buggy submission (verdict: Runtime Error):
V = []
C = []
N = 0
 
i = 0
ans = 0

str = input()
N = int(str)
 
str = input().split()
while i < N:
  V[i] = int(str[i])
  i = i+1
  
i=0
str = 0
str = input().split()
while i < N:
  C[i] = int(str[i])
 
while i<N:
  if V[i] > C[i]:
    ans = ans + V[i] - C[i]
    
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
N = (int)N
i=0
V = []
C = []
num = 0
while i<N:
  num = input()
  num = (int)num
  V.append(num)
 
num = 0
i=0
while i<N:
  num = input()
  num = (int)num
  C.append(num)
max = 0
while i<N:
  max = max + V[i] - C[i]
  
print(max)

Buggy submission (verdict: Runtime Error):
N = input()
N = (int)N
i=0
V = []
C = []
num = 0
while i<N:
  num = input()
  V.append((int)num)
 
num = 0
i=0
while i<N:
  num = input()
  C.append((int)num)
max = 0
while i<N:
  max += V[i] - C[i]
  
print(max)

Buggy submission (verdict: Runtime Error):
N = input()
N = (int)N
i=0
V = []
C = []
num = 0
while i<N:
  num = input()
  V.append((int)num)

num = 0
i=0
while i<N:
  num = input()
  C.append((int)num)
max = 0
while i<N:
  max += v[i] - C[i]
  
print(max)

Buggy submission (verdict: Runtime Error):
N = input();
i=0
V = []
C = []
var = 0
while i<(int)N:
  var = (int)input()
  if var <=50 and var >= 0:
    V.append(var)
i = 0

while i<(int)N:
  var = (int)input()
  if var <= 50 and var >= 0:
    C.append(var)

i = 0
max = 0
while i < N:
  if V[i] - C[i] > 0:
    max = max + V[i] - C[i]

print(max)
Problem p03071 (python)

Fixed submission:
str = input().split()
A = int(str[0])
B = int(str[1])
ans = 0
 
if A> B:
  ans = ans + A
  A = A-1
else :
  ans = ans + B
  B = B-1
if A> B:
  ans = ans + A
else :
  ans = ans + B
  
print(ans)

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

if A> B:
  ans = ans + A
else :
  ans = ans + B
  
if A> B:
  ans = ans + A
else :
  ans = ans + B
  
print(ans)
Problem p03076 (python)

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

min = 9
num = 0
for i in range(len(A)):
    if min > A[i]%10 and A[i] % 10 != 0:
      min = A[i]%10
      num = i
      
ans = 0
for i in range(5):
  if i != num:
    ans = ans + int((A[i]+9)/10) * 10
ans = ans + A[num]

print(ans)

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

min = 9
num = 0
 for i in range(len(A)):
    if min > A[i]%10 and A[i] % 10 != 0:
      min = A[i]%10
      num = i
      
ans = 0
for i in range(5):
  ans = ans + int(A[i]/10)
ans = ans + A[num] % 10

print(ans)
Problem p03086 (python)

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

ans = 0
num = 0

for i in range(len(S)):
  if S[i] == "A" or S[i] == "G" or S[i] == "T" or S[i] == "C":
    num = 1
    for j in range(i+1,len(S)):
      if S[j] == "A" or S[j] == "G" or S[j] == "T" or S[j] == "C":
        num = num + 1
      else :
        break
  if ans < num :
    ans = num
  num = 0
  
print(ans)

Buggy submission (verdict: Runtime Error):
str = input()
S = list(str)

ans = 0
num = 0

for i in range(len(str)):
  if list[i] == "A" or list[i] == "G" or list[i] == "T" or list[i] == "C":
    num = 1
    for j in range(len(str)):
      if list[j] == "A" or list[j] == "G" or list[j] == "T" or list[i] == "C":
        num = num + 1
      else :
        break
  if ans < num :
    ans = num
  num = 0
  
print(ans)

Buggy submission (verdict: Runtime Error):
str = input()
S = list(str)

ans = 0
num = 0

for i in range(len(str)):
  if list[i] == "A" or list[i] == "G" or list[i] == "T" or list[i] == "C":
    num = 1
    for j in range(len(str)):
      list[j] == "A" or list[j] == "G" or list[j] == "T" or list[i] == "j":
        num = num + 1
      else :
        break
  if ans < num :
    ans = num
  num = 0
  
print(ans)
Problem p03160 (python)

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

if N ==2:
    print(abs(h[1] - h[0]))
else:
    dp = [10**4+1]*N
    dp[0] = 0
    dp[1] = abs(h[0]-h[1])
    for i in range(2,N):
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i-2] + abs(h[i-2]-h[i-1]) + abs(h[i-1] - h[i]), dp[i-1]+abs(h[i-1]-h[i]))
        
    print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def frog(h,h2,h1):
    if h1 <= 0:
        return abs(h[h2] - h[0])
    else:
        return min(frog(h,h1,h1-1) + abs(h[h2] -  h[h1]),frog(h,h1,h1-2) + abs(h[h2]-h[h1]) ) 

N = int(input())
s = input().split()
h = []
for i in range(N):
    h.append(int(s[i]))

print(min(frog(h,N-1,N-2),frog(h,N-1,N-3)))

Buggy submission (verdict: Runtime Error):
def frog(h,h2,h1):
    if h1 <= 0:
        return abs(h[h2] - h[0])
    else:
        return min(frog(h,h1,h1-1) + abs(h[h2] -  h[h1]),frog(h,h1,h1-2) + abs(h[h2]-h[h1]) ) 

N = int(input())
s = input().split()
h = []
for i in range(N):
    h.append(int(s[i]))

print(min(frog(h,N-1,N-2),frog(h,N-1,N-3)))
Problem p03161 (python)

Fixed submission:
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**15+1 for i in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
        
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input.split()))
dp = [1000000000]＊n
Problem p03165 (python)

Fixed submission:
s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while True:
    if len(ans)==dp[-1][-1]:
        break
    if dp[x-1][y] ==dp[x][y]:
        x = x-1
    elif dp[x][y] == dp[x][y-1]:
        y = y-1
    elif dp[x-1][y-1]+1== dp[x][y]:
        ans =s[x-1] + ans
        x = x-1
        y = y-1
        continue
#     elif dp[x-1][y] == dp[x][y-1]:
#         x = x-1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while x>0 and y>0:
    if dp[y][x] == dp[y-1][x]:
        y = y-1
    elif dp[y][x] == dp[y][x-1]:
        x = x-1
    else:
        ans = s[x-1] + ans       

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while True:
    if dp[y][x] == dp[y-1][x]:
        y = y-1
    elif dp[y][x] == dp[y][x-1]:
        x = x-1
    else:
        ans = s[x-1] + ans       

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while True:
    if len(ans)==dp[-1][-1]:
        break
    if dp[x-1][y] == dp[x][y-1]:
        if dp[x-1][y-1] < dp[x][y]:
            ans.append(s[x-1])
            x = x-1
            y = y-1
            continue
        else:
            x = x-1
            continue
    elif dp[x-1][y] < dp[x][y-1]:
        y = y-1
    elif dp[x-1][y] < dp[x][y-1]:
        x = x-1

print(ans[::-1])
Problem p03633 (python)

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

def lcm(a,b):
    return a*b//fractions.gcd(a,b)
ans = 1
for i in range(N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import fraction

N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
lcd = 1

for i in range(N):
    lcd = int(lcd*T[i] / fraction.gcd(lcd,T[i]))
    
print(lcd)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
lcd = 1

for i in range(N):
    lcd = int(lcd*T[i] / math.gcd(lcd,T[i]))
    
print(lcd)