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

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    t = []
    for i,si in enumerate(s):
        if si != "x":
            t.append((i,si))
    q = [i[1] for i in t]
    if q != q[::-1]:
        print(-1)
        return
    n = len(t)
    if not n:
        print(0)
        return
    m = n >> 1
    l = t[m-(1-(n&1))][0]
    r = t[m][0]
    ans = 0
    while l >= 0 or r < len(s):
        if l < 0:
            r += 1
            ans += 1
        elif r >= len(s):
            l -= 1
            ans += 1
        elif s[l] == s[r]:
            l -= 1
            r += 1
        elif s[l] == "x":
            l -= 1
            ans += 1
        else:
            r += 1
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    t = []
    for i,si in enumerate(s):
        if si != "x":
            t.append((i,si))
    q = [i[1] for i in t]
    if q != q[::-1]:
        print(-1)
        return
    n = len(t)
    m = n >> 1
    l = t[m-(1-(n&1))][0]
    r = t[m][0]
    ans = 0
    while l >= 0 or r < len(s):
        if l < 0:
            r += 1
            ans += 1
        elif r >= len(s):
            l -= 1
            ans += 1
        elif s[l] == s[r]:
            l -= 1
            r += 1
        elif s[l] == "x":
            l -= 1
            ans += 1
        else:
            r += 1
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()
Problem p03854 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
s = input()
while s:
    if s[:11] == "dreameraser":
        s = s[11:]
    elif s[:10] == "dreamerase":
        s = s[10:]
    elif s[:7] == "dreamer":
        s = s[7:]
    elif s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "dream":
        s = s[5:]
    elif s[:5] == "erase":
        s = s[5:]
    else:
        print("NO")
        quit()
print("YES")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
s = S()
while s:
    if s[:7] == list("dreamer"):
        i = 5
        while s[i:i+5] == list("erase"):
            i += 5
        if s[i] == "r":i+=1
        s = s[i:]
    elif s[:6] == list("eraser"):
        while s[i:i+5] == list("erase"):
            i += 5
        if s[i] == "r":i+=1
        s = s[i:]
    elif s[:5] == list("dream"):
        s = s[5:]
    elif s[:5] == list("erase"):
        s = s[5:]
    else:
        print("NO")
        quit()
print("YES")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T
Problem p03861 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
s = LS()[1]
print("A"+s[0]+"C")
"""
#B
a,b,x = LI()
print(b//x-(a-1)//x)
#C
"""
n,x = LI()
a = LI()
ans = 0
for i in range(n-1):
    if a[i]+a[i+1] > x:
        ans += a[i+1]+a[i]-x
        if x > a[i]:
            a[i+1] = x-a[i]
        else:
            a[i+1] = 0
            a[i] = x
print(ans)
"""

#D
"""
s = S()
l = len(s)
k = (s[0] == s[-1])
if (l%2)^k:
    print("First")
else:
    print("Second")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
s = LS()[1]
print("A"+s[0]+"C")
"""
#B
a,b,x = LI()
print(x//b-x//(a-1))
#C
"""
n,x = LI()
a = LI()
ans = 0
for i in range(n-1):
    if a[i]+a[i+1] > x:
        ans += a[i+1]+a[i]-x
        if x > a[i]:
            a[i+1] = x-a[i]
        else:
            a[i+1] = 0
            a[i] = x
print(ans)
"""

#D
"""
s = S()
l = len(s)
k = (s[0] == s[-1])
if (l%2)^k:
    print("First")
else:
    print("Second")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T
Problem p03994 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    ans = []
    k = I()
    for i,si in enumerate(s):
        if si == "a":
            ans.append(si)
            continue
        j = (ord("a")-ord(si))%26
        if j <= k:
            k -= j
            ans.append("a")
        else:
            ans.append(si)
    k %= 26
    ans[-1] = chr(ord(ans[-1])+k)
    print(*ans,sep="")
    return

#Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    ans = ""
    k = I()
    for i,si in enumerate(s):
        if si == "a":
            ans += si
            continue
        j = (ord("a")-ord(si))%26
        if j <= k:
            k -= j
            ans += "a"
        else:
            ans += si
    k %= 26
    print(ans[:-1]+chr(ord(ans[-1])+k))
    return

#Solve
if __name__ == "__main__":
    solve()
Problem p02555 (python)

Fixed submission:
S = int(input())
mod = 10**9+7

ans = 0

x = [0]*(2020)
x[3] = 1
x[4] = 1
x[5] = 1
for i in range(6, S+1):
    x[i] += 1
    for j in range(3, i-2):
        x[i] += x[j]
        x[i] %= mod

print(x[S])

Buggy submission (verdict: Runtime Error):
S = int(input())
mod = 10**9+7

ans = 0

x = [0]*(S+1)
x[3] = 1
x[4] = 1
x[5] = 1
for i in range(6, S+1):
    x[i] += 1
    for j in range(3, i-2):
        x[i] += x[j]
        x[i] %= mod

print(x[S])
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
if S == T[:len(S)]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S, T = input().split()
if S == T[:len(S)-1]:
  print("Yes")
else:
  print("No")
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, ("0 "+input()).split()))


c = [0]*(N+1)
i = 1
cnt = 0
f = True

while cnt < K:
    if f and (c[A[i]] or A[i]==1):
        loop = cnt-c[A[i]]+1
        cnt += (K-cnt-1)//loop*loop
        f = False

    cnt += 1
    i = A[i]
    c[i] = cnt

print(i)

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


c = [0]*(N+1)
i = 1
cnt = 0
f = True

while cnt < K:
    if f and c[A[i]]:
        loop = cnt-c[A[i]]
        cnt += (K-cnt-1)//loop*loop
        f = False

    cnt += 1
    i = A[i]
    c[i] = cnt

print(i)

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


c = [0]*(N+1)
i = 1
cnt = 0
f = True

while cnt < K:
    if f and c[A[i]]:
        print(cnt, i, c)
        loop = cnt-c[A[i]]
        cnt += (K-cnt-1)//loop*loop
        if cnt == K:
            break
        f = False

    cnt += 1
    i = A[i]
    c[i] = cnt

print(i)
Problem p02702 (python)

Fixed submission:
S = list(map(int, list(input())))
S.reverse()
a = [0]*len(S)
y = 2019
x = 1
t = 0
cnt = [0]*y
res = 0
for i in range(len(S)):
    cnt[t] += 1
    t += S[i]*x
    t %= y
    res += cnt[t]
    x = x*10%y
print(res)

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

fl = [False]*len(S)
l = 0
res = 0

for i in range(len(S)-3):
    if fl[i]:
        continue
    
    x = int(S[i:i+3])
    cnt = 0
    for j in range(i+3, len(S)):
        x *= 10
        x += int(S[j])
        x %= 2019
        if x == 0:
            cnt += 1
            fl[l] = True
            l = j+1
    
    res += (cnt+1)*cnt//2

print(res)
Problem p02797 (python)

Fixed submission:
N, K, S = map(int, input().split())

x = 10**9
for i in range(2, S):
    if S % i != 0:
        x = i
        break

res = [S]*K + [x]*(N-K)
print(" ".join(map(str, res)))

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

for i in range(2, S):
    if S % i != 0:
        x = i
        break

res = [S]*K + [x]*(N-K)
print(" ".join(map(str, res)))
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print(T+S)

Buggy submission (verdict: Runtime Error):
S, T = map(int, input().split())
print(T+S)
Problem p02865 (python)

Fixed submission:
N = int(input())
print((N-1)//2)

Buggy submission (verdict: Runtime Error):
N = input()
print((N-1)//2)
Problem p02936 (python)

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)
    w[B].append(A)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

flag = [False]*(N+1)

q = [1]
while q:
    n = q.pop()
    flag[n] = True
    for i in w[n]:
        if flag[i]:
            continue
        flag[i] = True
        cnt[i] += cnt[n]
        q.append(i)

print(" ".join([str(c) for c in cnt[1:]]))

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)
    w[B].append(A)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

flag = [False]*(N+1)
cnt_sum = [0]*(N+1)

def f(i, n):
    if flag[i]:
        return
    flag[i] = True
    cnt_sum[i] = n+cnt[i]
    for t in w[i]:
        f(t, cnt_sum[i])

f(1, 0)

print(" ".join([str(c) for c in cnt_sum[1:]]))

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

cnt_sum = [0]*(N+1)

def f(i, n):
    cnt_sum[i] = n+cnt[i]
    for t in w[i]:
        f(t, cnt_sum[i])
    return

f(1, 0)

print(" ".join([str(c) for c in cnt_sum[1:]]))

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

cnt_sum = [0]*(N+1)

def f(i, n):
    cnt_sum[i] = n+cnt[i]
    for t in w[i]:
        f(t, cnt_sum[i])

f(1, 0)

print(" ".join([str(c) for c in cnt_sum[1:]]))

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

cnt_sum = [0]*(N+1)

def f(i, n):
    cnt_sum[i] = n+cnt[i]
    for t in w[i]:
        f(t, n+cnt[i])

f(1, 0)

print(" ".join([str(c) for c in cnt_sum[1:]]))
Problem p02975 (python)

Fixed submission:
from collections import Counter

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

cnt = Counter(A)

try:
    if cnt[0] == N:
        print("Yes")
    else:
        if N % 3 != 0:
            print("No")
        else:
            if cnt.most_common(1)[0][1] == N*2//3 and cnt[0] == N//3:
                print("Yes")
            else:
                x = cnt.most_common(3)
                if x[0][1] == x[1][1] == x[2][1] == N//3:
                    if x[0][0]^x[1][0]^x[2][0] == 0:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
except:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

cnt = Counter(A)

if cnt[0] == N:
    print("Yes")
else:
    if N % 3 != 0:
        print("No")
    else:
        if cnt.most_common(1)[0][1] == N*2//3 and cnt[0] == N//3:
            print("Yes")
        else:
            x = cnt.most_common(3)
            if x[0][1] == x[1][1] == x[2][1]:
                if x[0][0]^x[1][0]^x[2][0] == 0:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")

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

flag = [False]*N
res = []

def f():
    if len(res) == len(A):
        if res[-1]^res[-2] == res[0]:
            print("Yes")
            exit()
        return

    for i in range(len(A)):
        if flag[i]:
            continue
        if res[-1]^res[-2] != A[i]:
            continue
        flag[i] = True
        res.append(A[i])
        f()
        flag[i] = False
        res.pop()
        return

flag[0] = True
res.append(A[0])

for i in range(1, N):
    flag[i] = True
    res.append(A[i])
    f()
    flag[i] = False
    res.pop()

print("No")

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

flag = [False]*N
res = []

def f():
    if len(res) == len(A):
        if res[-1]^res[-2] == res[0]:
            print("Yes")
            exit()

    for i in range(len(A)):
        if flag[i]:
            continue
        if res[-1]^res[-2] != A[i]:
            continue
        flag[i] = True
        res.append(A[i])
        f()
        flag[i] = False
        res.pop()
        return

flag[0] = True
res.append(A[0])

for i in range(1, N):
    flag[i] = True
    res.append(A[i])
    f()
    flag[i] = False
    res.pop()

print("No")
Problem p02995 (python)

Fixed submission:
A, B, C, D = map(int,input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

lcm = int(C*D / gcd(C, D))

def func(x):
    return x - int(x//C) - int(x//D) + int(x//lcm)

print(func(B) - func(A-1))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int,input().split())

E = C*D / math.gcd(C, D)

Anum = A-1 - (int((A-1)/C) + int((A-1)/D) - int((A-1)/E))
Bnum = B - (int(B/C) + int(B/D) - int(B/E))

print(Bnum - Anum)
Problem p03007 (python)

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

xy = [0]*(N-1)
idx = 0

n = A.pop()

for i in range(N-1):
    a = A.pop()
    if a > 0:
        xy[idx] = [A[0], a]
        A[0] -= a
    else:
        xy[idx] = [n, a]
        n -= a
        idx += 1
        for j in A:
            xy[idx] = [n, j]
            n -= j
            idx += 1
        break

    idx += 1

print(n)
for x, y in xy:
    print(x,y)

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

xy = [0]*N-1
idx = 0

for i in range(N-1):
    if A[-2] > 0:
        y = A.pop()
        x = A[0]

        xy[idx] = [x,y]

        A[0] = x-y

    else:
        x = A.pop()
        y = A.pop(0)

        xy[idx] = [x,y]

        A.append(x-y)
    
    idx += 1

print(A[0])
for x, y in xy:
    print(x,y)
Problem p03037 (python)

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

Nmin = 1
Nmax = N

for i in range(M):
    L, R = list(map(int,input().split()))
    Nmin = max(L,Nmin)
    Nmax = min(R,Nmax)

print(max(Nmax-Nmin+1,0))

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

Nmin = 1
Nmax = N

for i in range(M):
    L, R = list(map(int,input().split()))
    Nmin = max(L,Nmin)
    Nmax = min(R,Nmax)

print(max(Nmax-Nmin+1),0)
Problem p03050 (python)

Fixed submission:
N = int(input())

ans = 0
if N > 3:
    ans += N-1

for i in range(2, int(N**0.5)+1):
    if N%i == 0:
        a = i-1
        if N//a == N%a:
            ans += a
        a = N//i-1
        if N//a == N%a:
            ans += a

print(ans)

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

sum = 0

b = 0
for i in range(1,N):
    N2 = int(N/i)
    if int(N/(N2-1)) != i:
        b += 1
        if b > 1000000:
            break
    else:
        if N%(N2-1) == i:
            sum += N2-1

print(sum)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

gcdl = [1]*N
gcdl[0] = A[0]

gcdr = [1]*N
gcdr[-1] = A[-1]

for i in range(1, N):
    gcdl[i] = gcd(gcdl[i-1], A[i])
    gcdr[N-i-1] = gcd(gcdr[N-i], A[N-i-1])

res = max(gcdl[N-2], gcdr[1])

for i in range(1, N-1):
    res = max(gcd(gcdl[i-1], gcdr[i+1]), res)

print(res)

Buggy submission (verdict: Runtime Error):
import copy

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

result = 0

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(nums):
    x = gcd(nums[0],nums[1])
    for i in range(2,len(nums)):
        x = gcd(nums[i],x)
    return x

for i in range(N):
    a = copy.deepcopy(A)
    del a[i]
    result = max(gcd_list(a),result)

print(result)

Buggy submission (verdict: Runtime Error):
import math
import copy

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

result = 0

def gcd_list(nums):
    x = math.gcd(nums[0],nums[1])
    for i in range(2,len(nums)):
        x = math.gcd(nums[i],x)
    return x

for i in range(N):
    a = copy.deepcopy(A)
    del a[i]
    result = max(gcd_list(a),result)

print(result)
Problem p03086 (python)

Fixed submission:
S = input()
ans = 0
now = 0
for i in S:
  if i in "ACGT":
    now += 1
  else:
    ans = max(ans,now)
    now = 0
ans = max(ans,now)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
now = 0
for i in S:
  if i in "ACGT":
    now += 1
  else:
    ans = max(now)
    now = 0
print(ans)
Problem p03089 (python)

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

res = []
for i in range(N):
    for j in range(N-i-1, -1, -1):
        if B[j] == j+1:
            res.append(j+1)
            B = B[:j]+B[j+1:]
            break
    else:
        break

if len(res) == N:
    res.reverse()
    for r in res:
        print(r)
else:
    print(-1)

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

b_order = [-1]*N

def f():
    
    for i in range(N,0,-1):
        i_order = N - (i - b[i-1])

        while b_order[i_order - 1] != -1:
            i_order -= 1
            if i_order < 0:
                print(-1)
                return

        b_order[i_order - 1] = b[i-1]

    for i in b_order:
        print(i)

f()
Problem p03103 (python)

Fixed submission:
N,M = list(map(int, input().split()))
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB = sorted(AB)

n = 0
result = 0

while M > 0:
    if AB[n][1] <= M:
        result += AB[n][0] * AB[n][1]
        M -= AB[n][1]
        n += 1
    else:
        result += AB[n][0] * M
        break

print(result)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split()))
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB = sorted(AB)

n = 0
result = 0

while True:
    if AB[n][1] <= M:
        result += AB[n][0] * AB[n][1]
        M -= AB[n][1]
        n += 1
    else:
        result += AB[n][0] * M
        break

print(result)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split()))
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB = sorted(AB)

n = 0
result = 0

while True:
    if AB[n][1] <= M:
        result += AB[n][0] * AB[n][1]
        M -= AB[n][1]
        n += 1
    else:
        result += AB[n][0] * M
        break

print(result)