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

Fixed submission:
from heapq import *

N=int(input())
A=[int(input()) for i in range(N)]
h=[]
for i in A:
    heappush(h, -i)
maxh = -heappop(h)
secondh = -heappop(h)
for i in A:
    print(maxh if i != maxh else secondh)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
for i in range(N):
  b = a
  del b[i]
  sorted(b)
  print(b[0])
Problem p02972 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    l2=[]
    ans=0
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(2,N//z+1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
            ans+=1
            l2.append(N-i)
    print(ans)
    print(*l2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z = N-i-1
    while z <= N-1:
        a[N-1-i] += b[z]
        z=(z+1)*2-1
print(sum(a))
if sum(a) != 0:
    s = ''
    for i in a:
        s += str(i) + ' ' if i != 0 else ''
print(s.rstrip())
Problem p02999 (python)

Fixed submission:
a = list(map(int,input().split()))
print(0 if a[0]<a[1] else 10)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
print(0 if x[0]<a[1] else 10)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
print(0 if x<a else 10)
Problem p03000 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,X=map(int,input().split())
    L=list(map(int,input().split()))
    ans=1
    D=0
    for i in L:
        D+=i
        if D<=X:
            ans+=1
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
d = 0
count = 0
while d <= a[1]:
  count += 1
  d += b[count]
print(count)
Problem p03001 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W/2 and y==H/2 else 0
    print(str(S)+' '+str(b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'%s %s' % (S, b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'{S} {b}'.format(S=S, b=b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'{S} {b}')

if __name__ == '__main__':
    main()
Problem p03046 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    M,K=map(int,input().split())
    if K>2**M-1:
        print(-1)
    elif M==1:
        if K==0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        ans=[i for i in range(2**M) if i!=K]+[K]+[i for i in range(2**M-1,-1,-1) if i!=K]+[K]
        print(*ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from itertools import permutations
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    M,K=map(int,input().split())
    if K!=0:
        raise Exception

if __name__ == '__main__':
    main()
Problem p03074 (python)

Fixed submission:
import sys
from heapq import heappush,heappop
sys.setrecursionlimit(10**9)
INF = 10**18


def input():
    return sys.stdin.readline().rstrip()


def main():
    N,K=map(int,input().split())
    S=list(map(int,list(input())))
    f=S[0]
    left1=0
    for i,x in enumerate(S):
        if x==0:
            break
        else:
            left1+=1
    l=[left1]
    tmp=0
    pre=1
    for i,x in enumerate(S[left1:]):
        if pre!=x:
                l.append(tmp)
                tmp=0
        tmp+=1
        pre=x
    l.append(tmp)
    A=[0]*(len(l)+1)
    for i in range(len(l)):
        A[i+1]=A[i]+l[i]
    ans=0
    for i in range(len(l)+1):
        if i%2:
            ans=max(ans,A[i]-A[max(0,i-K*2)])
        else:
            ans=max(ans,A[i]-A[max(0,i-K*2-1)])
    print(ans)
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from heapq import heappush,heappop
sys.setrecursionlimit(10**9)
INF = 10**18


def input():
    return sys.stdin.readline().rstrip()


def main():
    N,K=map(int,input().split())
    S=list(map(int,list(input())))
    first=S[0]
    l=[]
    c=1
    for i in range(N-1):
        if S[i+1] == S[i]:
            c+=1
        else:
            l.append(c)
            c=1
    l.append(c)
    if K%2==1:
        if len(l) > K*2:
            ans = sum(l[:K*2])
            op=ans
            for i in range(len(l)-K*2):
                op = op-l[i]+l[K*2+i]
                ans=max(ans,op)
        else:
            ans = sum(l)
    else:
        if len(l) > K*2+1:
            ans=sum(l[:K*2+1])
            op=ans
            for i in range(not(first),len(l)-(K*2+1),2):
                op = op-(l[i]+l[i+1])+l[K*2+1+i]+l[K*2+1+i+1]
                ans = max(ans, op)
        else:
            ans=sum(l)
    print(ans)

if __name__ == '__main__':
    main()
Problem p03165 (python)

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

dp = [[0]*(len(T)+1) for i in (range(len(S)+1))]

for s in range(len(S)):
    for t in range(len(T)):
        if S[s] == T[t]:
            dp[s+1][t+1] = max(dp[s][t]+1,dp[s][t+1],dp[s+1][t])
        else:
            dp[s+1][t+1] = max(dp[s][t+1],dp[s+1][t])

def checkdpn(x,y):
    if dp[x][y] == dp[x-1][y] + 1 and dp[x][y] == dp[x][y-1] + 1:
        return True
    else:
        return False

x = len(S)
y = len(T)
str = ''

while(True):
    if checkdpn(x,y):
        str = S[x-1] + str
        x -= 1
    else:
        if dp[x][y] == dp[x][y-1] + 1:
            x -= 1
        else:
            y -= 1
    if dp[x][y] == 0:
        break
print(str)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    S=input()
    T=input()
    dp=[[0]*(len(T)+1) for _ in range(len(S)+1)]
    dp2=[[()]*(len(T)+1) for _ in range(len(S)+1)]
    for s in range(len(S)):
        for t in range(len(T)):
            if S[s]==T[t]:
                dp[s+1][t+1]=dp[s][t]+1
                dp2[s+1][t+1]=(s,t)
            else:
                if dp[s+1][t]>dp[s][t+1]:
                    dp[s+1][t+1]=dp[s+1][t]
                    dp2[s+1][t+1]=dp2[s+1][t]
                else:
                    dp[s+1][t+1]=dp[s][t+1]
                    dp2[s+1][t+1]=dp2[s][t+1]
    tmp=dp2[len(S)][len(T)]
    ans=deque()
    ans.appendleft(S[tmp[0]])
    for _ in range(dp[len(S)][len(T)]-1):
        tmp=dp2[tmp[0]][tmp[1]]
        ans.appendleft(S[tmp[0]])
    print(''.join(ans))

if __name__ == '__main__':
    main()
Problem p03543 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=input()
    YesNo(int(N[:3])%111==0 or int(N[1:])%111==0)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    YesNo(int(N:=input()[:3])%111==0 or int(N[1:])%111==0)

if __name__ == '__main__':
    main()
Problem p03592 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,K=map(int,input().split())
    A=list(range(0,N*M+1,N))
    s=set()
    for i in range(M+1):
        for j in range(N+1):
            if A[i]+(M-i*2)*j==K:
                YesNo(1)
                exit()
    YesNo(0)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,K=map(int,input().split())
    A=list(range(0,N*M+1,N))
    s=set()
    for i in range(N+1):
        for j in range(M+1):
            if A[i]+(M-i*2)*j==K:
                YesNo(1)
                exit()
    YesNo(0)


if __name__ == '__main__':
    main()
Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
w_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=100*a
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if i==0 and j==0:
            w=min(100*a,100*b)
            s_m=f-w
        for k in range(s_m//c+1):
            for l in range((s_m-k*c)//d+1):
                s=k*c+l*d
                if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                    answ=w
                    anss=s
print(answ+anss,anss)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
w_m=(f*100/(100+e))//100*100
s_m=f*e//(100+e)
answ=float('inf')
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w!=0:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                        answ=w
                        anss=s
print(answ+anss,anss)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
w_m=f//(100+e)*100
s_m=f//(100+e)*e
w=w_m//(100*a)*(100*a)
s=s_m//c*c
wn=w_m//(100*b)
sc=s_m//c
sd=s_m//d
noudo=0
answ=0
anss=0
for i in range(wn+1):
    for j in range(sc+1):
        for k in range((s_m-j*c)//d+1):
            s=j*c+k*d
            if (noudo<s/(s+w)) and (s/(s+w)<=e/(100+e)):
                noudo=s/(s+w)
                answ=w
                anss=s
    w+=b*100
    while w<=w_m:
        w-=a*100

print(answ+anss,anss)
Problem p04000 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,N=map(int,input().split())
    s=set()
    for i in range(N):
        s.add(tuple(map(int1,input().split())))
    ans=[0]*10
    used=set()
    for y,x in s:
        for dy in range(-1,2):
            for dx in range(-1,2):
                if 0>y+dy-1 or y+dy+1>=H or 0>x+dx-1 or x+dx+1>=W or (y+dy,x+dx) in used:
                    continue
                tmp=0
                used.add((y+dy,x+dx))
                for ddy in range(-1,2):
                    for ddx in range(-1,2):
                        if (y+dy+ddy,x+dx+ddx) in s:
                            tmp+=1
                ans[tmp]+=1
    ans[0]=(H-2)*(W-2)-sum(ans[1:])
    for row in ans:
        print(row)
    
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,N=map(int,input().split())
    a,b=[0]*N,[0]*N
    for i in range(N):
        a[i],b[i]=map(int1,input().split())
    unique_a=list(set(a))
    unique_b=list(set(b))
    unique_a.sort()
    unique_b.sort()
    d_a,d_b={},{}
    tmp_a=0
    if unique_a:
        d_a[unique_a[0]]=tmp_a
        for i in range(len(unique_a)-1):
            tmp_a+=min(unique_a[i+1]-unique_a[i],3)
            d_a[unique_a[i+1]]=tmp_a
    tmp_b=0
    if unique_b:
        d_b[unique_b[0]]=tmp_b
        for i in range(len(unique_b)-1):
            tmp_b+=min(unique_b[i+1]-unique_b[i],3)
            d_b[unique_b[i+1]]=tmp_b
    c=[[0]*(tmp_b+1) for _ in range(tmp_a+1)]
    for i in range(N):
        c[d_a[a[i]]][d_b[b[i]]]+=1
    s=[[0]*(tmp_b+2) for _ in range(tmp_a+2)]
    for i in range(tmp_a+1):
        for j in range(tmp_b+1):
            s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+c[i][j]
    ans=[0]*10
    for i in range(tmp_a-1):
        for j in range(tmp_b-1):
            ans[s[i+3][j+3]-s[i][j+3]-s[i+3][j]+s[i][j]]+=1
    ans[0]=(H-2)*(W-2)-sum(ans[1:])
    for row in ans:
        print(row)
    
    

if __name__ == '__main__':
    main()
Problem p02818 (python)

Fixed submission:
a, b, c = map(int, input().split(' '))
 
if c >= a:
  c -= a
  b = max(0, b-c)
  print(0, b)
else:
  print(a-c, b)

Buggy submission (verdict: Runtime Error):
a, b, c = list(map(int, input()))
 
if c >= a:
  c -= a
  b -= c
  print(0, b)
else:
  print(a-c, b)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input())

if c >= a:
  c -= a
  b -= c
  print(0, b)
else:
  print(a-c, b)
Problem p02963 (python)

Fixed submission:
n = int(input())
z = 1000000000
 
if n==z*z:
	print(z, 0, 0, z, 0, 0)
elif n > z:
    a = n//z
    b = n%z
    print(a+1, b, 0, z, 1, 0)
else:
    print(n, 0, 1, 1, 0, 0)

Buggy submission (verdict: Runtime Error):
n = int(input())
z = 1000000000
if n > z:
  	a = n//z
    b = n%z
	print(a, 0, z, b+1, 0, b)
else:
  	print(n, 0, 1, 1, 0, 0)
Problem p03000 (python)

Fixed submission:
n,k=map(int, input().split(' '))
a=list(map(int, input().split(' ')))
ans,s=0,0
for i in a:
  if s<=k: ans+=1
  else: break
  s+=i

if s<=k: ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split(' '))
a=list(map(int, input().split(' ')))
ans,s=0,0
for i in a:
  if s<=k: ans+=1
  else break
  s+=i
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split(' '))
a=list(map(int, input().split(' ')))
ans,s=0,0
for i in a:
  if(s<=k) ans+=1
  else break
  s+=i
print(ans)
Problem p03109 (python)

Fixed submission:
y, m, d = map(int, input().split('/'))
 
if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d <= 30):
		print("Heisei")
	else:
		print("TBD")
else:
	print("TBD")

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c)>0 else INF

    ans = INF
    ans = min(ans, dfs(cur+1, a, b, c))
    ans = min(ans, dfs(cur+1, a + l[cur], b, c)+10)
    ans = min(ans, dfs(cur+1, a, b+l[cur], c)+10)
    ans = min(ans, dfs(cur+1, a, b, c+l[cur])+10)
    return ans

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
y, m, d = map(int, input().split('/'))
 
if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d < 30):
     	print("Heisei")
	else:
    	print("TBD")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
y, m, d = map(int, input().splite('/'))
 
if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d < 30):
     	print("Heisei")
	else:
    	print("TBD")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
y, m, d = map(int, input().splite(' '))

if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d < 30):
     	print("Heisei")
	else:
    	print("TBD")
else:
    print("TBD")
Problem p03238 (python)

Fixed submission:
k = int(input())
if k==2:
  a = int(input())
  b = int(input())
  print(a+b)
else:
  print("Hello World")

Buggy submission (verdict: Runtime Error):
k = int(input())
if k==2:
  a,b=map(int, input().split(' '))
  print(a+b)
else:
  print("Hello World")
Problem p03243 (python)

Fixed submission:
n = input()
a = ['111','222','333','444','555','666','777','888','999']
 
for i in a:
    if i >= n:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n = input()
a = ['111','222','333','444','555','666','777','888','999']

for i in a:
	if i >= n:
    	print(i)
        break
Problem p03813 (python)

Fixed submission:
x = int(input())
if x >= 1200:
	print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
x = int(input())
if x >= 1200:
	pirnt('ARC')
else:
    print('ABC')
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(float, input().split())

if a * a * b == x:
    print(0)
    exit(0)

if x * 2 <= a * a * b:
    P = (2 * x) / (a * b)
    Q = b
else:
    P = a
    Q = (2 * (a * a * b - x)) / (a * a)

R = math.sqrt(P * P + Q * Q)
cosp = (Q * Q + R * R - P * P) / (2 * Q * R)
print(90 - math.degrees(math.acos(cosp)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(float, input().split())

if x * 2 <= a * a * b:
    P = (2 * x) / (a * b)
    Q = b
else:
    P = a
    Q = (2 * (a * a * b - x)) / (a * a)

R = math.sqrt(P * P + Q * Q)
cosp = (Q * Q + R * R - P * P) / (2 * Q * R)
print(90 - math.degrees(math.acos(cosp)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(float, input().split())

if x * 2 <= a * a * b:
    P = (2 * x) / (a * b)
    Q = b
else:
    P = a
    Q = (2 * (a * a * b - x)) / (a * a)

R = math.sqrt(P * P + Q * Q)
cosp = (Q * Q + R * R - P * P) / (2 * Q * R)
print(90 - math.degrees(math.acos(cosp)))
Problem p02963 (python)

Fixed submission:
s = int(input())
v = 10 ** 9
x1 = 0
y1 = 0
x2 = v
y2 = 1
x3 = (v - s % v) % v
y3 = (s + x3) // v
print(x1, y1, x2, y2, x3, y3)

Buggy submission (verdict: Runtime Error):
s = int(input())
v = 10 ** 9
x1 = 0
y1 = 0
x2 = v
y2 = 1
x3 = (v - s % v) % v
y3 = (s + x) // v
print(x1, y1, x2, y2, x3, y3)
Problem p03050 (python)

Fixed submission:
n = int(input())

factors = set()
factor = 1
while factor * factor <= n:
    if n % factor == 0:
        factors.add(factor)
        factors.add(n // factor)
    factor += 1

total = 0
for factor in factors:
    k = factor - 1
    if k <= 0:
        continue

    div = n // k
    mod = n % k
    if div == mod:
        total += k

print(total)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

factors = set((n, ))
for factor in range(2, math.ceil(math.sqrt(n))):
    if n % factor == 0:
        factors.add(factor)
        factors.add(n // factor)

total = 0
for factor in factors:
    k = factor - 1
    div = n // k
    mod = n % k
    if div == mod:
        total += k

print(total)
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    a, b = min(a, b), max(a, b)
    while b % a != 0:
        a, b = b % a, a
    return a


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

# s = [-1, *a[:-1]]
# t = [*a[1:], -1]
s = [-1] * n
t = [-1] * n
for x in range(0, n - 1):
    s[x + 1] = a[x]
for x in range(1, n):
    t[x - 1] = a[x]

for x in range(1, n - 1):
    s[x + 1] = gcd(s[x + 1], s[x])
for x in range(n - 2, 0, -1):
    t[x - 1] = gcd(t[x - 1], t[x])

ans = -float('inf')
for x, y in zip(s, t):
    if x == -1:
        ans = max(ans, y)
    elif y == -1:
        ans = max(ans, x)
    else:
        ans = max(ans, gcd(x, y))
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

# s = [-1, *a[:-1]]
# t = [*a[1:], -1]
s = [-1] * n
t = [-1] * n
for x in range(0, n - 1):
    s[x + 1] = a[x]
for x in range(1, n):
    t[x - 1] = a[x]

for x in range(1, n - 1):
    s[x + 1] = math.gcd(s[x + 1], s[x])
for x in range(n - 2, 0, -1):
    t[x - 1] = math.gcd(t[x - 1], t[x])

ans = -float('inf')
for x, y in zip(s, t):
    if x == -1:
        ans = max(ans, y)
    elif y == -1:
        ans = max(ans, x)
    else:
        ans = max(ans, math.gcd(x, y))
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

s = [-1, *a[:-1]]
t = [*a[1:], -1]
for x in range(1, n - 1):
    s[x + 1] = math.gcd(s[x + 1], s[x])
for x in range(n - 2, 0, -1):
    t[x - 1] = math.gcd(t[x - 1], t[x])

ans = -float('inf')
for x, y in zip(s, t):
    if x == -1:
        ans = max(ans, y)
    elif y == -1:
        ans = max(ans, x)
    else:
        ans = max(ans, math.gcd(x, y))
    
print(ans)
Problem p03166 (python)

Fixed submission:
import collections, sys

n, m = map(int, input().split())
pres = collections.defaultdict(list)
nxts = collections.defaultdict(list)
for line in sys.stdin:
    x, y = map(int, line.split())
    pres[y].append(x)
    nxts[x].append(y)

stack, count, nodes = [], [0], []
for node in range(1, n + 1):
    count.append(len(pres[node]))
    if count[node] == 0:
        stack.append(node)

while stack:
    node = stack.pop()
    nodes.append(node)
    for nxt in nxts[node]:
        count[nxt] -= 1
        if count[nxt] == 0:
            stack.append(nxt)

dp = [0] * (n + 1)
for node in nodes:
    for pre in pres[node]:
        dp[node] = max(dp[node], dp[pre] + 1)

print(max(dp))

Buggy submission (verdict: Runtime Error):
import collections, sys

n, m = map(int, input().split())
nxts = collections.defaultdict(list)
for line in sys.stdin:
    x, y = map(int, line.split())
    nxts[x].append(y)

memo = {}

def solve(x):
    if not x in memo:
        ans = 0
        for nxt in nxts[x]:
            ans = max(ans, solve(nxt) + 1)
        memo[x] = ans
    return memo[x]

print(max(solve(x) for x in range(1, n + 1)))
Problem p03401 (python)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

total = sum(abs(a[i] - a[i + 1]) for i in range(0, n + 1))
for i in range(1, n + 1):
    print(total - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0, *map(int, input().split()), 0]

total = sum(abs(a[i] - a[i + 1]) for i in range(0, n + 1))
for i in range(1, n + 1):
    print(total - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]))

Buggy submission (verdict: Runtime Error):
import itertools

def f(i1, i2, c):
    return itertools.islice(((x, y) for x, y in itertools.product(i1, i2) if x % 2 == y % 2), c)

a, b = map(int, input().split())
k = 100
grid = [['#' if x < k else '.' for _ in range(k * 2)] for x in range(k * 2)]

for x, y in f(range(0, k - 1), range(k * 2), a - 1):
    grid[x][y] = '.'

for x, y in f(range(k + 1, k * 2), range(k * 2), b - 1):
    grid[x][y] = '#'

for row in grid:
    print(''.join(row))