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

Fixed submission:
import numpy as np

L, R = map(int, input().split())
MOD = 2019

# if L == R:
#     tmp = L % MOD
#     print(tmp*tmp)
# else:
#     a = np.array(range(L, R+1)) % MOD
#     b = np.sort(a,kind='quicksort')
#     print(b[0]*b[1])

minMOD = 2019
# minMOD2 = 2019
#
# for i in range(L, R+1):
#     tmp = i % MOD
#     if tmp == 0:
#         minMOD = 0
#         break
#
#     if tmp < minMOD:
#         minMOD = tmp
#     elif tmp < minMOD2:
#         minMOD2 = tmp

#print((minMOD * minMOD2) % MOD)

for i in range(L, R+1):
    if(i % MOD) == 0:
        minMOD = 0
        break
    for j in range(i+1, R+1):
        if(j % MOD) == 0:
            minMOD = 0
            break
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)

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

L, R = map(int, input().split())
MOD = 2019

# if L == R:
#     tmp = L % MOD
#     print(tmp*tmp)
# else:
#     a = np.array(range(L, R+1)) % MOD
#     b = np.sort(a,kind='quicksort')
#     print(b[0]*b[1])

minMOD = 2019
# minMOD2 = 2019
#
# for i in range(L, R+1):
#     tmp = i % MOD
#     if tmp == 0:
#         minMOD = 0
#         break
#
#     if tmp < minMOD:
#         minMOD = tmp
#     elif tmp < minMOD2:
#         minMOD2 = tmp

#print((minMOD * minMOD2) % MOD)

for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)

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

L, R = map(int, input().split())
MOD = 2019

minMOD = 2019

for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)
Problem p02999 (python)

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

if numX < numA:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = ndp[m] + dp[m+1]
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = ndp[m] + dpleft[m]
        dp[m] = ndp[m]
    dp[M] = ndp[M]
print(dp[-1] % MOD)

Buggy submission (verdict: Runtime Error):
# 累積和

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7

for n in range(N):
    ndp = [1]
    for m in range(M):
        if S[n] == T[m]:
            ndp.append(ndp[-1] + dp[m+1])
            dpleft[m] = dp[m+1]
        else:
            ndp.append(ndp[-1] + dpleft[m])
    dp = ndp
print(dp[-1] % MOD)
Problem p02993 (python)

Fixed submission:
n = str(input())
lst = []
STATUS = "Good"
lst = list(map(int, n))
for i in range(3):
  if lst[i] == lst[i + 1]:
    STATUS = "Bad"
  else:
    pass
print(STATUS)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = []
STATUS = "Good"
while n > 0:
    lst.append(n%10)
    n //= 10 # 必須
lst.reverse()
for i in range(3):
  if lst[i] == lst[i + 1]:
    STATUS = "Bad"
  else:
    pass
print(STATUS)
Problem p02947 (python)

Fixed submission:
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
from collections import defaultdict
d = defaultdict(list)
for i in range(n):
    d[anagrams[i]].append(i)
from scipy.misc import comb
cnt=0
for k, v in d.items():
    cnt+=comb(len(v), 2, exact=True)
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
from scipy.special import comb
print(sum([comb(anagrams.count(word), 2, exact=True)\
          for word in set(anagrams)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
import pandas as pd
import math

print(sum([math.factorial(i-1) for i in pd.DataFrame(anagrams, columns=["word"]).groupby("word")["word"].count().values]))

Buggy submission (verdict: Runtime Error):
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
print(sum([math.factorial(i-1) for i in pd.DataFrame(anagrams, columns=["word"]).groupby("word")["word"].count().values]))
Problem p02953 (python)

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

result = True
for i in range(n):
    if n == 1:
        break
    
    pos = ""
    if (i == 0):
        if (h[i] > h[i+1]):
            h[i] -= 1
    elif (i == (n-1)):
        if (h[i] > h[i-1]):
            h[i] -= 1
    else:
        if (h[i] > h[i+1]) | (h[i] > h[i-1]):
            h[i] -= 1
    
    if (i != 0):
        if(h[i] < h[i-1]):
            result = False
            break

            
if result:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
result = True
for i in range(n):
    # except the last case, 前よりも自分が高ければ下がる
    if (i != (n-1)):
        if(h[i] > h[i+1]): 
            h[i] -= 1
    # except the 1st case, 後ろよりも自分が高ければ下がる
    elif (i != 0):
        if(h[i] > h[i-1]): 
            h[i] -= 1
    # 後ろよりも自分が低ければアウト
    if (i != 0):
        if(h[i] < h[i-1]):
            result = False
            break

if result:
    print("Yes")
else:
    print("No")
Problem p03061 (python)

Fixed submission:
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y, x%y)

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

left_gcd = [A[0]]
a = A[0]
for i in range(1,N-1):
  a = gcd(a, A[i])
  left_gcd.append(a)

right_gcd = [A[N-1]]
b = A[N-1]
for k in range(N-2, 0, -1):
  b = gcd(b, A[k])
  right_gcd.append(b)

ans_gcd = [right_gcd[N-2], left_gcd[N-2]]

for p in range(N-2):
  ans_gcd.append(gcd(left_gcd[p], right_gcd[N-p-3]))

print(max(ans_gcd))

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

A.sort()
cnt = [] 
bad = 0
j = True
for i in range(1, A[1]):
    for n in range(N):
        if bad==2:
            cnt.append(0)
            j = False
            break
        elif A[n]%i != 0:
            bad += 1
    if j:
        cnt.append(i)



print(max(cnt))

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

A.sort()
cnt = [] 
bad = 0
j = True
for i in range(1, A[1]):
    for n in range(N):
        if bad==2:
            cnt.append(0)
            j = False
            break
        elif A[n]%i != 0:
            bad += 1
    if j:
        cnt.append(i)



print(max(cnt))

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

A.sort()
cnt = [] 
bad = 0
j = True
for i in range(1, A[1]):
    for n in range(N):
        if bad==2:
            cnt.append(0)
            j = False
            break
        elif A[n]%i != 0:
            bad += 1
    if j:
        cnt.append(i)



print(max(cnt))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
from fractions import Fraction
import numpy as np
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))
ans=0
for i in range(N):
    a = A[0]
    del A[0]
    
    b = gcd_list(A)
    if ans < b:
        ans = b
    A.append(a)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
import numpy as np
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))
ans=0
for i in range(N):
    a = A[0]
    del A[0]
    
    b = gcd_list(A)
    if ans < b:
        ans = b
    A.append(a)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
import numpy as np
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))
ans=0
for i in range(N):
    a = A[0]
    del A[0]
    
    b = gcd_list(A)
    if ans < b:
        ans = b
    A.append(a)

print(ans)
Problem p03074 (python)

Fixed submission:
from itertools import accumulate

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

S = input()
n = list(map(int, str(S)))
count = 1
mas = []
for i in range(N-1):
    if n[i] == n[i + 1]:
        count += 1
        if i == N-2:
            mas.append(count)
    else:
        mas.append(count)
        count = 1
        if i == N-2:
            mas.append(1)
        

mas2 = []
if n[0] == 0:
    mas.insert(0, 0)
    
if n[N-1] == 0:
    mas.append(0)
    
l=len(mas)
mas2=[0] + list(accumulate(mas))
#for i in range(1, 1+len(mas)):
#    mas2.append(sum(mas[:i]))
    
if K >= (l-1)/2:
    print(N)
else:
    mas3 = []
    k = int(((l-1)/2)-K+1)
    for i in range(k):
        mas3.append(mas2[K*2 + 2*i+1]-mas2[0 + 2*i])
    print(max(mas3))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
n = list(map(int, str(S)))
count = 1
mas = []
for i in range(N-1):
    if n[i] == n[i + 1]:
        count += 1
    else:
        mas.append(count)
        count = 1
        if i == N-2:
            mas.append(1)
        
l = len(mas)
mas2 = []
for m in K:
    

    if l%2==0:
            for k in range(l//2):
                mas2.append(mas[2*k+1] + mas[2*k] + mas[2*k+2])
        else:
            for k in range(l/2-1):
                mas2.append(mas[2*k+1] + mas[2*k] + mas[2*k+2])
            mas.append(mas[l-2] + mas[l-1])
    
    else:
        else:
            mas2.append(mas[0] + mas[1])
            for k in range(1, l//2):
                mas2.append(mas[2*k-1] + mas[2*k] + mas[2*k+1])
        else:
            mas2.append(mas[0] + mas[1])
            for k in range(1, l//2-1):
                mas2.append(mas[2*k+1] + mas[2*k] + mas[2*k-1])
            mas.append(mas[l-2] + mas[l-1])

            
            
print(max(mas2))
Problem p03105 (python)

Fixed submission:
A, B, C = map(int, input().split())
if B//A>C:
    print(C)
else:
    print(B//A)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if B//A>C:
    print(C)
else:
    print(b//A)
Problem p03296 (python)

Fixed submission:
import sys  
import numpy as np

input = sys.stdin.readline
A = int(input())
a = list(map(int, input().split()))
sum1 = 0
for i in range(1,A):
    if a[i-1] == a[i]:
        sum1+=1
        a[i] = 0

print(sum1)

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

input = sys.stdin.readline
A = int(input())
a = list(map(int, input().split()))
sum1 = 0
for i in range(1,A):
    if a[i-1] == a[i]:
        sum+=1
        a[i] = 0

print(sum1)
Problem p03338 (python)

Fixed submission:
import sys  
import numpy as np

input = sys.stdin.readline
N = int(input())
S = list(input())

S = S[:-1]

temp = []
for i in range(1,N):
    a = S[:i]
    b = S[i:]
    a = list(set(a))
    b = list(set(b))

    j = list(set(a+b))
    
    temp.append(len(a) + len(b) - len(j))
    

print(max(temp))

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

input = sys.stdin.readline
N = int(input())
S = list(input())

S = S[:-1]

temp = []
for i in range(1,N-1):
    a = S[:i]
    b = S[i:]
    a = list(set(a))
    b = list(set(b))

    j = list(set(a+b))
    
    temp.append(len(a) + len(b) - len(j))
    

print(max(temp))
Problem p03435 (python)

Fixed submission:
import sys  
import numpy as np
N1 = list(map(int, input().split()))
N2 = list(map(int, input().split()))
N3 = list(map(int, input().split()))

temp = []
for i in range(3):
    a  = N1[i] + N2[i] - 2*N3[i]
    temp.append(a)
temp2 = []

temp2.append(N1[0] + N1[1] - 2*N1[2])

temp2.append(N2[0] + N2[1] - 2*N2[2])

temp2.append(N3[0] + N3[1] - 2*N3[2])


if len(list(set(temp))) == 1 & len(list(set(temp2))) == 1:
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)
Problem p03611 (python)

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * (max(a)+1)

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] + k[2:]):
    ans = max(ans, q+r+s)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))

a_ = list(set(a))
temp2 = []

for i in a_:
    temp2.appned(a.count(a_))

temp = []
for i in range(1,len(temp2)):
    temp = temp2[i-1] + temp2[i] + temp2[i+1]

print(max(temp))
Problem p03694 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
print(abs(max(a)-min(a)))

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

print(abs(max(a)-min(a))
Problem p04043 (python)

Fixed submission:
A = list(map(int, input().split()))
A.sort()
if A == [5,5,7]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
if A.sort() == [5,5,7]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
if A.sort() == [5,5,7]:
  print("YES")
eles:
  print("NO")

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
if A.sort() == [5,7,7]:
  print("YES")
eles:
  print("NO")

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
if A.sort() = [5,7,7]:
  print("YES")
eles:
  print("NO")
Problem p02971 (python)

Fixed submission:
a = int(input()) 
b = [int(input()) for i in range(a)] 
 
m=max(b)
sorted(b)
s=sorted(b)[-2]
for i in range(a):
  if m>b[i]:
    print(m)
  else:
    print(s)

Buggy submission (verdict: Runtime Error):
a = int(input()) 
b = [int(input()) for i in range(a)] 
 
m=max(b)
for i in range(a):
  if m>b[i]:
    print(m)
  else:
    d=b[i]
  	b.pop(i)
  	print(max(b))
  	b.insert(i,d)

Buggy submission (verdict: Runtime Error):
a = int(input()) 
b = [int(input()) for i in range(n)] 
for i in range(a):
  d=b[i]
  b.pop(i)
  print(max(b))
  b.insert(i,d)

Buggy submission (verdict: Runtime Error):
a = int(input()) 
b = [int(input()) for i in range(n)] 
for i in range(a):
  d=b[i-1]
  c=pop(b.i-1)
  print(max(c))
  b.insert(i-1.d)

Buggy submission (verdict: Runtime Error):
a = int(input()) 
b = [int(input()) for i in range(n)] 
for i in range(a):
  c=pop(b.i-1)
  print(max(c))
Problem p03095 (python)

Fixed submission:
import collections

n = int(input())
s = input()
cnt = 0
dictionary = {}

for i in range(n)[::-1]:
  if s[i] in dictionary.keys():
    dictionary[s[i]] += 1
  else:
    dictionary[s[i]] = 1
  ch = s[i:]
  tmp_cnt = 1
  for k,v in dictionary.items():
    if k != s[i]:
      tmp_cnt *= (v+1)
  cnt += tmp_cnt % (10**9+7)
print(cnt % (10**9+7))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = raw_input()
cnt = 0
dictionary = {}

for i in range(n)[::-1]:
  if s[i] in dictionary.keys():
    dictionary[s[i]] += 1
  else:
    dictionary[s[i]] = 1
  ch = s[i:]
  tmp_cnt = 1
  for k,v in dictionary.items():
    if k != s[i]:
      tmp_cnt *= (v+1)
  cnt += tmp_cnt %(10**9+7)
print(cnt%(10**9+7))
Problem p03715 (python)

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

def solve(h,w):
    ans = min(h,w)
    for i in range(1,h):
        p1 = w*i
        p2 = (h-i)*(w//2)
        p3 = h*w-p1-p2
        ans = min(ans, max(p1,p2,p3)-min(p1,p2,p3))
    return ans 

ans = min(solve(h,w), solve(w,h))
if h*w % 3 == 0:
    ans = 0

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
array = [int(i) for i in input().split()]
ans=-1e14

for i in range(n, 2*n+1):
    l_array = sorted(array[:i])
    r_array = sorted(array[i:])
    ans = max(ans, sum(l_array[i-n:])-sum(r_array[:n]))

print(ans)
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
if  X >= A:
    print(10)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
    X, A = map(int, input().split())
    if  X >= A:
        print(10)
    else:
        print(0)
Problem p03037 (python)

Fixed submission:
def prison():
    N, M = (int(i) for i in input().split())
    L_max = 0
    R_min = float("inf")
    for _ in range(M):
        L, R = (int(i) for i in input().split())
        L_max = max(L, L_max)
        R_min = min(R, R_min)
        result = max(R_min - L_max + 1, 0)
    return result


print(prison())

Buggy submission (verdict: Runtime Error):
def prison():
    N, M = (int(i) for i in input().split())
    L_max = 0
    R_min = float("inf")
    for _ in range(M):
        L, R = (int(i) for i in input().split())
        L_max = max(L, L_max)
        R_min = min(R, R_min)
	result = max(R_min - L_max + 1, 0)
    return result


print(prison())
Problem p03050 (python)

Fixed submission:
#DivRem number
N  = int(input())
ans = 0
def divisor(N):
    div_lst = [N] if N != 1 else []
    for n in range(2, int(N ** 0.5 + 1)):
        if N % n == 0:
            if  n == N // n:
                div_lst.append(n)
            else:
                div_lst.append(n)
                div_lst.append(N // n)

    return div_lst

div_lst = divisor(N)
for m in div_lst:
    m = m - 1
    if N // m == N % m:
        ans += m
print(ans)

Buggy submission (verdict: Runtime Error):
#DivRem number
N  = int(input())
ans = 0
def divisor(N):
    div_lst = [N]
    for n in range(2, int(N ** 0.5 + 1)):
        if N % n == 0:
            if  n == int(N / n):
                div_lst.append(n)
            else:
                div_lst.append(n)
                div_lst.append(int(N / n))

    return div_lst

div_lst = divisor(N)
for m in div_lst:
    m = m - 1
    if int(N / m) == N % m:
        ans += m
print(ans)
Problem p03337 (python)

Fixed submission:
a,b=map(int, input().split())
ab_sum=a+b
ab_dif=a-b
ab_pro=a*b
ab_max=max(ab_sum,ab_dif,ab_pro)
print(ab_max)

Buggy submission (verdict: Runtime Error):

N=int(input())
S=list(input())
change_min=N
for leader in range(N):
    S_west=S[:leader]
    S_east=S[leader+1:N]
    change=S_west.count("W")+S_east.count("E")
    if change<=change_min:
        change_min=change
print(change_min)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
S_list=list(S)
S_max=0
for n in range(N):
    S_list_former=set(S_list[:n])
    S_list_latter=set(S_list[n:N])
    S_list_com=len(S_list_former & S_list_latter)
    if S_list_com>=S_max:
        S_max=S_list_com
print(S_max)
Problem p03166 (python)

Fixed submission:
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_g

G - Longest path

"""
import collections
import functools
import sys
sys.setrecursionlimit(1000000)


def get_adj_list(pairs):
    adj = collections.defaultdict(list)
    for (i, j) in pairs:
        adj[i].append(j)
    return adj


def solve(pairs):
    adj_list = get_adj_list(pairs)

    @functools.lru_cache(1000000)
    def dfs(u):
        res = -1
        for v in adj_list[u]:
            res = max(res, dfs(v))
        return 1 + res

    # depths = [dfs(u) for u in range(1, N+1)]
    # print(depths)
    depths = (dfs(u) for u in range(1, N+1))
    return max(depths, default=0)


N, M = map(int, input().split())
pairs = [[int(s) for s in input().split()] for _ in range(M)]
res = solve(pairs)
print(res)

Buggy submission (verdict: Runtime Error):
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_g

G - Longest path

"""
import collections
import functools
import sys
sys.setrecursionlimit(100007)


def get_adj_list(pairs):
    adj = collections.defaultdict(list)
    for (i, j) in pairs:
        adj[i].append(j)
    return adj


def solve(pairs):
    adj_list = get_adj_list(pairs)

    @functools.lru_cache(100007)
    def dfs(u):
        res = -1
        for v in adj_list[u]:
            res = max(res, dfs(v))
        return 1 + res

    # depths = [dfs(u) for u in range(1, N+1)]
    # print(depths)
    depths = (dfs(u) for u in range(1, N+1))
    return max(depths, default=0)


N, M = map(int, input().split())
pairs = [[int(s) for s in input().split()] for _ in range(M)]
res = solve(pairs)
print(res)

Buggy submission (verdict: Runtime Error):
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_g

G - Longest path

"""
import collections
import functools
import sys
sys.setrecursionlimit(10000)


def get_adj_list(pairs):
    adj = collections.defaultdict(list)
    for (i, j) in pairs:
        adj[i].append(j)
    return adj


def solve(pairs):
    adj_list = get_adj_list(pairs)
    seen = set()

    @functools.lru_cache(10000)
    def dfs(u):
        seen.add(u)
        res = -1
        for v in adj_list[u]:
            if v not in seen:
                res = max(res, dfs(v))
        return 1 + res

    depths = [dfs(u) for u in range(1, N+1)]
    return max(depths)


N, M = map(int, input().split())
pairs = [[int(s) for s in input().split()] for _ in range(M)]
res = solve(pairs)
print(res)
Problem p03173 (python)

Fixed submission:
# https://atcoder.jp/contests/dp/tasks/dp_n

import itertools as it

INF = 1 << 62
N = int(input())
xs = [int(s) for s in input().split()]
acc = list(it.accumulate([0] + xs))

dp = [[INF] * (N + 1) for _ in range(N)]

for i in range(N):
    dp[i][i + 1] = 0

for w in range(2, N + 1):
    for i in range(N - w + 1):
        j = i + w
        subcost = min(dp[i][k] + dp[k][j] for k in range(i + 1, j))
        dp[i][j] = subcost + acc[j] - acc[i]

print(dp[0][N])

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/dp/tasks/dp_n
import functools
import itertools as it

N = int(input())
xs = [int(s) for s in input().split()]
acc = [0] + list(it.accumulate(xs))

@functools.lru_cache(None)
def f(i, j):
    if (j == i + 1):
        return 0

    return min(f(i, k) + f(k, j) + acc[j] - acc[i] for k in range(i + 1, j))

print(f(0, N))
Problem p03273 (python)

Fixed submission:
import numpy as np
h, w = list(map(int, input().split()))
loc_array = [list(input().replace("#", "1").replace(".", "0")) for _ in range(h)]
loc_array = np.array([list(map(int, l)) for l in loc_array])
row_sum = loc_array.sum(axis=1)
col_sum = loc_array.sum(axis=0)
while 0 in row_sum or 0 in col_sum:
  row_rm = [i for i, r in enumerate(row_sum) if r == 0]
  loc_array = np.delete(loc_array, row_rm, axis=0)
  col_rm = [i for i, c in enumerate(col_sum) if c == 0]
  loc_array = np.delete(loc_array, col_rm, axis=1)
  row_sum = loc_array.sum(axis=1)
  col_sum = loc_array.sum(axis=0)

loc_str = [list(map(str, loc_array[i,:])) for i in range(loc_array.shape[0])]
loc_str = ["".join(l).replace("1", "#").replace("0", ".") for l in loc_str]
for l in loc_str:
  print(l)

Buggy submission (verdict: Runtime Error):
import numpy as np
h, w = list(map(int, input().split()))
loc_array = [list(input().replace("#", "1").replace(".", "0")) for _ in range(h)]
loc_array = np.array([list(map(int, l)) for l in loc_array])
row_sum = loc_array.sum(axis=1)
col_sum = loc_array.sum(axis=0)
while 0 in row_sum or 0 in col_sum:
  for i, r in enumerate(row_sum):
    if r == 0:
      loc_array = np.delete(loc_array, i, axis=0)
  for i, c in enumerate(col_sum):
    if c == 0:
      loc_array = np.delete(loc_array, i, axis=1)
  row_sum = loc_array.sum(axis=1)
  col_sum = loc_array.sum(axis=0)

loc_str = [list(map(str, loc_array[i,:])) for i in range(loc_array.shape[0])]
loc_str = ["".join(l).replace("1", "#").replace("0", ".") for l in loc_str]
for l in loc_str:
  print(l)