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

Fixed submission:
def gcd(a, b) :
    if a < b :
        a,b = b,a
    if b == 0 :
        return a
    else :
        return gcd(b, a%b)


n,k = map(int, input().split())
a = list(map(int, input().split()))

g = a[0]
for i in range(n-1) :
    g = gcd(g,a[i+1])

if (k < max(a) and k%g == 0) or (k in a) :
    print('POSSIBLE')
else :
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import sys

n,k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a) :
    print('IMPOSSIBLE')
    sys.exit()
elif k in a or 1 in a:
    print('POSSIBLE')
    sys.exit()

a.sort()
l = []
for i in range(n-1,-1,-1) :
    if a[i] < k :
        break
    else :
        l.append(a[i]-k)
else :
    l = list(set(l))

diff = [0]*(n-1)
for i in range(n-1) :
    diff[i] = a[i+1] - a[i]
else :
    diff = list(set(diff))
    diff.sort()

for d in diff :
    for ll in l :
        if ll%d == 0 or ll%d in diff :
            print('POSSIBLE')
            sys.exit()
else :
    print('IMPOSSIBLE')
Problem p03687 (python)

Fixed submission:
S = input()
chars = set(S)
ans = len(S)

for c in chars :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
chars = set(S)
ans = len(S)

for c in chas :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)

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

for c in string.lowercase :
    if c not in S :
        continue

    X = S.split(c)
    ans = 0
    for str in X :
        ans = max(ans, len(str))

print(ans)
Problem p03700 (python)

Fixed submission:
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

for i in range(N) :
    h[i] = int(input())

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while mx != mn :
    if (mx-mn) == 1 :
        tmp_mx = h-B*mx
        tmp_mn = h-B*mn
        T_mx = sum(np.ceil(tmp_mx[tmp_mx>0]/(A-B)))
        T_mn = sum(np.ceil(tmp_mn[tmp_mn>0]/(A-B)))

        if T_mn == mn :
            ans = mn
        else :
            ans = mx

        break

    tmp = h-B*now
    T = sum(np.ceil(tmp[tmp>0]/(A-B)))
    if now >= T :
        ans = now
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

for i in range(N) :
    h[i] = int(input())

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) > 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

for i in range(N) :
    h[i] = int(input())

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) <= 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))
Problem p03779 (python)

Fixed submission:
X = int(input())
     
L = 0
for i in range(1, X+1) :
  L += i
  if L >= X :
    print(i)
    break

Buggy submission (verdict: Runtime Error):
    X = int(input())
     
    L = 0
    for t in range(1, X) :
        L += t
        if L >= X :
            print(t)
            break

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

L = 0
for i in range(1, X) :
    L += i
    if L >= X :
Problem p03155 (python)

Fixed submission:
n = int(input())
h = int(input())
w = int(input())
print((n - h + 1) * (n - w + 1))

Buggy submission (verdict: Runtime Error):
n, h, w = map(int, input().split())
print((n - h + 1) * (n - w + 1))
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
_list = [input() for i in range(n)]
costs, times = [], []
for elem in _list:
    # print(elem)  # debug
    cost, time = map(int, elem.split())
    costs.append(cost)
    times.append(time)

min_cost = 1001  # 最小コストを入れる変数。初期値は制約上のMAX + 1 にしておく
for cost, time in zip(costs, times):
    if time <= t and cost < min_cost:
        min_cost = cost  # 時間内 and costがこれまでの最小コストより小さければ更新

if min_cost <= 1000:
    print(min_cost)
else:
    print('TLE')

Buggy submission (verdict: Runtime Error):
n, t = map(int, input().split())
costs, times = [map(int, input().split()) for i in range(n)]

min_cost = 1001  # 最小コストを入れる変数。初期値は制約上のMAX + 1 にしておく
for cost, time in zip(costs, times):
    if time <= t and cost < min_cost:
        min_cost = cost

if min_cost < 1000:
    print(min_cost)
else:
    print('TLE')
Problem p03240 (python)

Fixed submission:
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]
xyh=sorted(xyh, key= lambda x : x[2], reverse=True)
#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

#ans=[]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = -1
        c=1
        for plc in xyh:
            #if not plc[2]:
            #    continue
            h = hgh([x,y],plc)
            #print(x,y,h)
            if th<0:
                th = h
                continue
            if h==th:
                continue
            if  h >= th:
                if not plc[2]:
                    continue
            c=0
            break
        if c:
            ef=1
            ans=[str(s) for s in [x,y,th]]
            break

print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]

#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

#ans=[]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = 0
        for plc in xyh:
            c=1
            if not th:
                if not plc[2]:
                    continue
            h = hgh([x,y],plc)
            if not th:
                th = h
                continue
            if h!=th:
                c=0
                break
        if c:
            ef=1
            ans=[str(s) for s in [x,y,th]]
            break

print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]

#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

#ans=[]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = 0
        for plc in xyh:
            c=1
            if not th and not plc[2]:
                continue
            h = hgh([x,y],plc)
            if not th:
                th = h
                continue
            if h!=th:
                c=0
                break
        if c:
            ef=1
            ans=[str(s) for s in [x,y,th]]
            break

print(" ".join(ans))
Problem p03290 (python)

Fixed submission:
import math

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
# 各配点について全問解いた時のポイント
fsp = [p[i]*100*(i+1)+c[i] for i in range(D)]

# print(fsp)

min_pro = 100000000

def dfs(solve):
    global min_pro
    max_rest = -1
    if len(solve) == D:
        sum_point = 0
        sum_pro = 0
        for i in range(D):
            if solve[i] == "1":
                sum_point += fsp[i]
                sum_pro += p[i]
            else:
                max_rest = i
        #print(solve, sum_point, max_rest,math.ceil((G - sum_point) / ((max_rest+1)*100)))
        if sum_point < G:
            if math.ceil((G - sum_point) / ((max_rest+1)*100)) < p[max_rest]:
                sum_pro += math.ceil((G - sum_point) / ((max_rest+1)*100))
            else:
                sum_pro += 100000
        if min_pro > sum_pro:
            min_pro = sum_pro


        #pps[counter] = [sum_point, sum_pro, solve]
        #counter += 1
        return 0

    dfs(solve+"0")
    dfs(solve+"1")
    return 0

dfs("0")
dfs("1")

print(min_pro)
print("\n")

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
# 各配点について全問解いた時のポイント
fsp = [p[i]*100*(i+1)+c[i] for i in range(D)]

# print(fsp)

min_pro = 100000000

def dfs(solve):
    global min_pro
    max_rest = -1
    if len(solve) == D:
        sum_point = 0
        sum_pro = 0
        for i in range(D):
            if solve[i] == "1":
                sum_point += fsp[i]
                sum_pro += p[i]
            else:
                max_rest = i
        #print(solve, sum_point, max_rest,math.ceil((G - sum_point) / ((max_rest+1)*100)))
        if sum_point < G:
            if math.ceil((G - sum_point) / ((max_rest+1)*100)) < p[max_rest]:
                sum_pro += math.ceil((G - sum_point) / ((max_rest+1)*100))
            else:
                sum_pro += 100000
        if min_pro > sum_pro:
            min_pro = sum_pro


        #pps[counter] = [sum_point, sum_pro, solve]
        #counter += 1
        return 0

    dfs(solve+"0")
    dfs(solve+"1")
    return 0

dfs("0")
dfs("1")

print(min_pro)
print("\n")
Problem p03448 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())

 
counter = 0
 
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
 
an=X//A
bn=X//B
cn=X//C
 
counter = 0
 
for i in range(an):
  for j in range(bn):
    for k in range(cn):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

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

an=X/A
bn=X/B
cn=X/C

counter = 0

for i in range(an):
  for j in range(bn):
    for k in range(cn):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)
Problem p03493 (python)

Fixed submission:
li = list(input())
count = 0
for i in range(3):
  if li[i] == '1':
    count += 1
print(count)

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

counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    else:
      A[i] = A[i] / 2    
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

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

counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] / 2    
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] % 2    
      
  counter += 1
  if end_judge == 1:
    break
Problem p03494 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
 
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    A[i] = A[i] / 2    
      
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
  	if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] % 2    
  counter += 1
  if end_judge == 1:
    break

print(counter)
Problem p03324 (python)

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

start = pow(n, d)

if n == 100:
    print(pow(100, d) * (n + 1))
else:
    print(pow(100, d) * n)

Buggy submission (verdict: Runtime Error):
d, n = map(int, input().split())

start = pow(n, d)

elif n == 100:
    print(pow(100, d) * (n + 1))
else:
    print(pow(100, d) * n)
Problem p03308 (python)

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = for list(map(int,input().split()))
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)

Buggy submission (verdict: Runtime Error):
a = int(input)
b = map(int,input().split())
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)
Problem p03381 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-1]
r = y[n//2]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)
Problem p03382 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))

y = max(x)
sub = y
res = 0
for i in range(n):
    if abs(float(y/2-x[i])) < sub and x[i] != y:
        sub = abs(float(y/2-x[i]))
        res = x[i]

print(y,res)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
mid = bisect.bisect_left(y,y[-1]/2)
if y[-1]/2-x[mid]>=x[mid+1]-y[-1]/2:print(y[-1],x[mid+1])
else:print(y[-1],x[mid])
Problem p03383 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for i in range(H)]
 
def check(l):
    u = [0]*W
    mid = W % 2
    for i in range(W):
        if u[i]:
            continue
        for j in range(i+1, W):
            for p, q in l:
                sp = S[p]; sq = S[q]
                if sp[i] != sq[j] or sp[j] != sq[i]:
                    break
            else:
                u[j] = 1
                break
        else:
            if mid:
                for p, q in l:
                    sp = S[p]; sq = S[q]
                    if sp[i] != sq[i]:
                        break
                else:
                    mid = 0
                    continue
            break
    else:
        return 1
    return 0
 
def make(c, l, u, p):
    while c in u:
        c += 1
    if c == H:
        if check(l):
            print("YES")
            exit(0)
        return
    if p:
        l.append((c, c))
        make(c+1, l, u, 0)
        l.pop()
    for i in range(c+1, H):
        if i in u:
            continue
        u.add(i)
        l.append((c, i))
        make(c+1, l, u, p)
        l.pop()
        u.remove(i)
 
make(0, [], set(), H%2)
print("NO")

Buggy submission (verdict: Runtime Error):
h,w = list(map(int,input().split()))
s = []
for i in range(h):
    s.append(input())

con = []

for i in range(h):
    for j in range(i+1,h):
        ij = []
        ji = []
        for k in range(w):
            ij.append(s[i][k]+s[j][k])
            ji.append(s[j][k]+s[i][k])
        if sorted(ij) == sorted(ji):
            con.append([i,j])

rest = set()
for i in range(h):
    rest.add(i)
for x in con:
    if x[0] in rest and x[1] in rest:
        rest -= {x[0],x[1]}

if len(rest) == 0:print('YES')
elif len(rest) == 1 and [rest[0],rest[0]] in con:print('YES')
else:print('NO')
Problem p03389 (python)

Fixed submission:
x = list(map(int,input().split()))
x.sort()
a = x[2]-x[0]
b = x[2]-x[1]

if a%2 == 0 and b%2 == 0:print(a//2+b//2)
if a%2 == 0 and b%2 == 1:print(a//2+(b+1)//2+1)
if a%2 == 1 and b%2 == 0:print((a+1)//2+b//2+1)
if a%2 == 1 and b%2 == 1:print((a-1)//2+(b-1)//2+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
c = -1
s = 0
for i in range(N):
    ai,bi = map(int,input().split())
    s += ai
    if ai > bi:
        if c == -1:
            c = bi
        if bi < c:
            c = bi
if c == -1:
    print(0)
else:
    print(s-c)
Problem p03471 (python)

Fixed submission:
N, Y = [int(i) for i in input().split()]

ans = None

for i in range(N+1):
    for j in range(i+1):
        y = (N-i)*10000 + (i-j)*5000 + j*1000
        if y == Y:
            ans=(i, j)
            break
    if y == Y:
        break
        
if ans:
    answer = ' '.join(
        [str(N-ans[0]), str(ans[0]-ans[1]), 
         str(ans[1])])
else:
    answer = '-1 -1 -1'
    
print(answer)

Buggy submission (verdict: Runtime Error):
N, Y = [int(i) for input().split()]

ans = None

for i in range(N+1):
    for j in range(i+1):
        y = (N-i)*10000 + (i-j)*5000 + j*1000
        if y == Y:
            ans=(i, j)
            break
    if y == Y:
        break
        
if ans:
    answer = ' '.join(
        [str(N-ans[0]), str(ans[0]-ans[1]), 
         str(ans[1])])
else:
    answer = '-1 -1 -1'
    
print(answer)
Problem p03836 (python)

Fixed submission:
sx, sy, tx, ty = [
  int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

p1 = dy * 'U' + dx * 'R'
p2 = dy * 'D' + dx * 'L'
p3 = 'D' + (dx + 1) * 'R' + \
	(dy + 1) * 'U' + 'L'
p4 = 'U' + (dx + 1) * 'L' + \
	(dy + 1) * 'D' + 'R'
  
print(p1 + p2 + p3 + p4)

Buggy submission (verdict: Runtime Error):
sx = int(input())
sy = int(input())
tx = int(input())
ty = int(input())

dx = tx - sx
dy = ty - sy

p1 = dy * 'U' + dx * 'R'
p2 = dy * 'D' + dx * 'L'
p3 = 'D' + (dx + 1) * 'R' + \
	(dy + 1) * 'U' + 'L'
p4 = 'U' + (dx + 1) * 'L' + \
	(dy + 1) * 'D' + 'R'
  
print(p1 + p2 + p3 + p4)
Problem p03160 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    c = [0] * n
    c[1] = abs(h[1] - h[0])

    for i in range(2, n):
        c[i] = min(c[i-1] + abs(h[i] - h[i-1]), c[i-2] + abs(h[i] - h[i-2]))

    print(c.pop())

Buggy submission (verdict: Runtime Error):

def dp(i, h, c):
    if i == len(h)-1:
        return c
    elif i == len(h)-2:
        return dp(i+1, h, c + abs(h[i] - h[i+1]))
    return min(dp(i+1, h, c + abs(h[i] - h[i+1])), dp(i+2, h, c + abs(h[i] - h[i+2])))

if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    c = 0

    print(dp(0, h, c))
Problem p03308 (python)

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

    print(max(A) - min(A))

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

    print(max(A) - min(B))
Problem p03086 (python)

Fixed submission:
import re
s=input()
r=[0]
for i in re.finditer("[ACGT]+", s):
    r.append(len(i.group()))
print(max(r))

Buggy submission (verdict: Runtime Error):
import re
s=input()
r=[0]
for i in re.finditer("[ACGT]+", s):
    r.append(len(i[0]))
print(max(r))
Problem p03161 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.array([0] * N)
#candi = np.array([0] * N)

for i in range(1, N):
	j = max(0, i-K)
	#print()
	#candi[j:i] = dp[j:i] + np.abs(h[i] - h[j:i])
	dp[i] = (dp[j:i] + np.abs(h[i] - h[j:i])).min()
	#print('j,i=',j,i)
	#print('dp[j:i]=',dp[j:i])
	#print('np.abs(h[i] - h[j:i]) = ', np.abs(h[i] - h[j:i]) )		
	#print('candi[j:i]=',candi[j:i])
	#dp[i] = candi[j:i].min()
	#print('dp=',dp)
				
print(dp[-1])

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

dp = [0] + [1000000000] * (N-1)

for i in range(N-1):
	for j in range(1, min(K+1, N-i)):
      if dp[i] + abs(h[i+j] - h[i]) < dp[i+j]:
		dp[i+j] = dp[i] + abs(h[i+j] - h[i])			

print(dp[-1])
Problem p03165 (python)

Fixed submission:
s = input()
t = input()

len_s = len(s)
len_t = len(t)

dp = [ [0 for _ in range(len_t+1)] for _ in range(len_s+1) ]

for i in range(len_s):
        for j in range(len_t):
                if s[i] == t[j]:
                    dp[i+1][j+1] = max( dp[i+1][j+1], dp[i][j]+1 )
                dp[i+1][j+1] = max( dp[i+1][j+1], dp[i+1][j] )
                dp[i+1][j+1] = max( dp[i+1][j+1], dp[i][j+1] )

i = len_s
j = len_t
str = ''

while i > 0 and j > 0:
        if dp[i-1][j] == dp[i][j]:
            i -= 1
        elif dp[i][j-1] == dp[i][j]:
            j -= 1
        else:
            str += s[i-1]
            i -= 1
            j -= 1
            
print(str[::-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

s = input()
t = input()

len_s = len(s)
len_t = len(t)

dp = np.zeros((len_s+1, len_t+1), dtype = int)

for i in range(len_s):
    for j in range(len_t):
        if s[i] == t[j]:
            dp[i+1, j+1] = np.maximum( dp[i+1, j+1], dp[i, j] + 1)
        dp[i+1, j+1] = np.maximum(dp[i+1,j+1], dp[i+1,j])
        dp[i+1, j+1] = np.maximum(dp[i+1,j+1], dp[i,j+1])
#        print(dp)

i = len_s
j = len_t
str = ''

while i > 0 and j > 0:
    if dp[i-1, j] == dp[i, j]:
        i -= 1
    elif dp[i, j-1] == dp[i, j]:
        j -= 1
    else:
        str += s[i-1]
        i -= 1
        j -= 1
           
print(str[::-1])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = cnt(i)

print(max(length))

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

print(max([ cnt(i) for i in range(N) ]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
 
graph = [ [] for _ in range(N) ]
 
for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)
 
dp = [-1] * N
length = [0] * N
 
def count(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(count(k)+1, dp[j])
        return dp[j]
 
for i in range(N):
    length[i] = count(i)
 
print(max(length))

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def count(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(count(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = count(i)

print(max(length))
Problem p03062 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N-1]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B)-2*m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B))