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

Fixed submission:
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())

A1 *= T1
B1 *= T1
A2 *= T2
B2 *= T2

if A1+A2 > B1+B2: # Aを遅く
    A1,B1 ,A2,B2 = B1,A1 ,B2,A2

if A1+A2 == B1+B2:
    print("infinity")
    exit()

if A1 < B1:
    print(0)
    exit()

def nibu(l,r):
    if l >= r:
        return l
    c = (l+r+1)//2
    if (A1+A2)*(c-1)+A1 >= (B1+B2)*(c-1)+B1:
        return nibu(c,r)
    else:
        return(nibu(l,c-1))

ans = nibu(0,10**100)
if (A1+A2)*(ans-1)+A1 == (B1+B2)*(ans-1)+B1:
    print(ans*2-2)
else:
    print(ans*2-1)

Buggy submission (verdict: Runtime Error):
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = (A[0]-B[0])*T[0]
y = (B[0]-A[0])*T[0] + (B[1]-A[1])*T[1]

if x < 0:
    x *= -1
    y *= -1
if y == 0:
    print('infinity')
ans = -(-x//y)*2-1
if x%y == 0:
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = (A[0]-B[0])*T[0]
y = (B[0]-A[0])*T[0] + (B[1]-A[1])*T[1]

if x < 0:
    x *= -1
    y *= -1

ans = -(-x//y)*2-1
if x%y == 0:
    ans -= 1
print(ans)
Problem p02866 (python)

Fixed submission:
MOD = 998244353
N = int(input())
D = list(map(int,input().split()))
ans = [0]*N
for i in D:
    ans[i] += 1
ret = 1
for i in range(1,max(D)+1):
    ret *= (ans[i-1] ** ans[i])%MOD
    ret %= MOD
if ans[0] == 1 and D[0] == 0:
    print(ret)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
MOD = 998244353
N = int(input())
D = list(map(int,input().split()))
ans = [0]*N
for i in D:
    ans[i] += 1
ret = 1
for i in range(1,max(D)+1):
    ret *= pow(ans[i-1],ans[i],MOD)
    ret %= MOD
if ans[0] == 1:
    print(ret)
else:
    print(1/0)
Problem p02869 (python)

Fixed submission:
import math
N, K = map(int,input().split())
if (2*N)*(K+ K+2*N-1) > N*(K+2*N + K+3*N-1):
    print(-1)
    exit()
flag = [1]*(2*N)
for i in range(math.floor(N/2),N):
    a = K + i
    b = K + 2*N -1 -(i-math.floor(N/2))*2
    c = K + 3*N -1 -(i-math.floor(N/2))
    print(a,b,c)
for i in range(math.floor(N/2)):
    a = K + i
    b = K + 2*N -2 -i*2
    c = K + 3*N -1 -i-math.ceil(N/2)
    print(a,b,c)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
if (2*N)*(K+ K+2*N-1) > N*(K+2*N + K+3*N-1):
    print(-1)
else:
    print(1/0)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())2
if (2*N)*(K+ K+2*N-1) > N*(K+2*N + K+3*N-1):
    print(-1)
else:
    print(1/0)
Problem p02882 (python)

Fixed submission:
import math

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

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

if x <= a*a*b/2:
    S = x/a
    f = 2*S/b
    print(math.degrees(math.atan(b/f)))
else:
    S = a*b- x/a
    f = 2*S/a
    print(90-math.degrees(math.atan(a/f)))

Buggy submission (verdict: Runtime Error):
import math

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

if x <= a*a*b/2:
    S = x/a
    f = 2*S/b
    print(math.degrees(math.atan(b/f)))
else:
    S = a*b- x/a
    f = 2*S/a
    print(90-math.degrees(math.atan(a/f)))
Problem p02889 (python)

Fixed submission:
import sys
imput = sys.stdin.readline
def func(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d
N,M,L = map(int,input().split())
road = [[10**10]*N for i in range(N)]
for i in range(N):
    road[i][i] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c
road = func(road)
ans = [[10**5]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        if road[i][j] <= L:
            ans[i][j] = 1
ans = func(ans)
for i in range(int(input())):
    a,b = map(int,input().split())
    o = ans[a-1][b-1]
    if o == 10**5:
        print(-1)
    else:
        print(o-1)

Buggy submission (verdict: Runtime Error):
import sys

imput = sys.stdin.readline
N,M,L = map(int,input().split())
road = [[float('inf')]*N for i in range(N)]
for i in range(N):
    road[i][i] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    road[a-1][b-1] = c

for i in range(N):
    for j in range(N):
        for k in range(N):
            road[i][j] = min(road[i][j],road[i][k]+road[k][j])
ans = [[float("inf")]*N for i in range(N)]
for i in range(N):
    ans[i][i] = 0
for i in range(N):
    for j in range(N):
        if road[i][j] <= L:
            ans[i][j] = 1
for i in range(N):
    for j in range(N):
        for k in range(N):
            ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j])
for i in range(int(input()):
    a,b = map(int,input().split())
    o = ans[a-1][b-1]
    if o == float('inf'):
        print(-1)
    else:
        print(o-1)
Problem p02918 (python)

Fixed submission:
N,K = map(int,input().split())
S = list(input())
i = 1
if N == 1:
    print(0)
    exit()
while K >= 1 and i < N:
    if S[i] != S[0]:
        while i<N and S[i] != S[0]:
            S[i] = S[0]
            i += 1
        K -= 1
    i += 1
ans = 0
for i in range(1,N-1):
    if S[i] == "L" and S[i-1] == "L":
        ans += 1
    elif S[i] == "R" and S[i+1] == "R":
        ans += 1
if S[0] == "R" and S[1] == S[0]:
    ans += 1
if S[-1] == "L" and S[-2] == S[-1]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = list(input())
i = 1
while K >= 1 and i < N:
    if S[i] != S[0]:
        while i<N and S[i] != S[0]:
            S[i] = S[0]
            i += 1
        K -= 1
    i += 1
ans = 0
for i in range(1,N-1):
    if S[i] == "L" and S[i-1] == "L":
        ans += 1
    elif S[i] == "R" and S[i+1] == "R":
        ans += 1
if S[0] == "R" and S[1] == S[0]:
    ans += 1
if S[-1] == "L" and S[-2] == S[-1]:
    ans += 1
print(ans)
Problem p02920 (python)

Fixed submission:
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort(reverse = True)
    S.sort(reverse=True)
    ai = 0
    for j in range(2**i):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
    if len(slime) < 2**(i+1):
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort()
    S.sort(reverse=True)
    ai = 0
    for j in range(2**N):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
        if S[ai] == -1:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse = True)
for i in range(N):
    S[i] = -S[i]
for i in range(N):
    for j in range(2**i):
        if S[j] == S[j+2**i]:
            m = bisect.bisect_left(S[2**i:],S[j])+2**i
            if m == N:
                print("No")
                exit()
            else:
                S[j+2**i] , S[m] = S[m] ,S[j+2**i]
print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse = True)
for i in range(N):
    for i in range(2**i):
        if S[i] <= S[i+2**i]:
            print("No")
            exit()
print("Yes")
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    x += 1
    ans = max(ans,x)
  else:
    x = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N-1):
  if x[i] > x[i+1]:
    x += 1
    ans = max(ans,x)
  else:
    x = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(list(map(int,input().split())))
ans=0
hoge=0
for i in range(N-1):
  if A[i] >A[i+1]:
    hoge+=1
    ans=max(ans,hoge)
    else:
       hoge=0
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(list(map(int,input().split()))
ans=0
hoge=0
for i in range(N-1):
  if A[i] >A[i+1]:
    hoge+=1
    ans=max(ans,hoge)
    else:
       hoge=0
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
A=list(list(map(int,input().split()))
ans=0
hoge=0
for i in range(N-1):
  if A[i] >A[i+1]:
    hoge+=1
    ans=max(ans,hoge)
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
ans=0
hoge=0
for i in range(N-1):
  if A[i] >A[i+1]:
    hoge+=1
    ans=max(ans,hoge)
print(ans)
Problem p02937 (python)

Fixed submission:
import bisect
S,T = input(),input()
lenS = len(S)
alp = [[]for i in range(26)]

for i in range(len(S)):
    alp[ord(S[i])-97].append(i)

if alp[ord(T[0])-97] == []:
    print(-1)
    exit()

l = [alp[ord(T[0])-97][0]]
for c in T[1:]:
    A = alp[ord(c)-97]
    if A == []:
        print(-1)
        exit()
    l.append(A[bisect.bisect_left(A,l[-1]+1)%len(A)])

ans = 0
for i in range(len(l)-1):
    if l[i] >= l[i+1]:
        ans += 1
print(ans*lenS+l[-1]+1)

Buggy submission (verdict: Runtime Error):
import bisect
try:
    S,T = input(),input()
    lenS = len(S)
    alp = [[]for i in range(26)]
    for i in range(len(S)):
        alp[ord(S[i])-97].append(i)

    l = [alp[ord(T[0])-97][0]]
    for c in T[1:]:
        A = alp[ord(c)-97]
        l.append(A[bisect.bisect_left(A,l[-1])%len(A)])

    ans = 0
    for i in range(len(l)-1):
        if l[i] > l[i+1]:
            ans += lenS
    print(ans+l[-1]+1)
except IndexError:
    print(-1)
Problem p02949 (python)

Fixed submission:
N,M,P = map(int,input().split())
edge = []
cost = [-float('inf')]*N
cost[0] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,c-P])

for i in range(N-1):
    for a,b,c in edge:
        cost[b] = max(cost[b],cost[a]+c)


for a,b,c in edge:
    if cost[b] < cost[a]+c:
        cost[b] = float('inf')


for i in range(N-1):
    for a,b,c in edge:
        cost[b] = max(cost[b],cost[a]+c)

if cost[-1] == float('inf'):
    print(-1)
else:
    print(max(cost[-1],0))

Buggy submission (verdict: Runtime Error):
N,M,P = map(int,input().split())
edge = [[]for i in range(N)]
cost = [-float('inf')]*N
A = [-1]*N
cost[0] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    edge[a-1].append([b-1,c-P])

for i in range(N-1):
    for j in range(N):
        for b,c in edge[j]:
            if cost[b] < cost[j]+c:
                cost[b] = cost[j]+c
                A[b] = j

if A[0] != -1:
    print(-1)
    exit()
p = N-1
while p != -1 or p != N:
    A[p],p = N,A[p]
if p == -1:
    print(max(cost[-1],0))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M,P = map(int,input().split())
side = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    side[a-1].append([b-1,c-P])
node = [-float('inf')]*N
node[0] = 0

def DFS(p,l):
    if node[p] == float('inf'):
        return
    elif p in l:
        node[p] = float('inf')
        for i,v in side[p]:
            DFS(i,l+[p])
    else:
        for i,v in side[p]:
            if node[i] < node[p]+v:
                node[i] = node[p]+v
                DFS(i,l+[p])
    return

DFS(0,[])
if node[-1] == float('inf'):
    print(-1)
else:
    print(max(node[-1],0))
Problem p02960 (python)

Fixed submission:
S = input()
N = len(S)
DP =[0]*13
DP[0] = 1
A = 0
MOD = 10**9+7

T = [1,10,9,12,3,4]
A = 0
for i in range(N):
    A*=10
    if S[i] == "?":
        hoge = [0]*13
        for j in range(13):
            for k in range(10):
                hoge[(j+k*T[(N-i-1)%6])%13] = (hoge[(j+k*T[(N-i-1)%6])%13] + DP[j])%MOD
        DP = hoge[:]
    else:
        A += int(S[i])
    A = A%13
print(DP[(5-A)%13])

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
DP =[0]*13
DP[0] = 1
A = 0
MOD = 10**9+7

B = [[0]*13 for i in range(13)]
for i in range(13):
    for j in range(13):
        B[i][j] = (i*j)%13
T = [1,10,9,12,3,4]
A = 0
for i in range(N):
    A*=10
    if S[i] == "?":
        hoge = [0]*13
        for j in range(13):
            for k in range(10):
                hoge[(j+k*T[(N-i-1)%6])%13] = (hoge[(j+k*T[(N-i-1)%6])%13] + DP[j])%MOD
        DP = hoge.copy()
    else:
        A = (A+int(S[i]))%13
print(DP[(A+5)%13])
Problem p02997 (python)

Fixed submission:
N,K = map(int,input().split())
Ni = (N-1)*(N-2)//2
if Ni < K:
    print(-1)
    exit()
M = N-1+Ni-K
print(M)
for i in range(2,N+1):
    print(1,i)
for i in range(2,N):
    for j in range(i+1,N+1):
        if Ni-K <= 0:
            exit()
        print(i,j)
        Ni -= 1

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = [0]*(N+1)
for i in range(3,N+1):
    P[i] = (i-1)*(i-2)//2
ans =[]
l = 0
for i in range(N,2,-1):
    while P[i] <= K:
        ans.append(i-1)
        K -= P[i]
        N -= i-2
        l += 1
if N < 2:
    print(-1)
else:
    M = sum(ans)-len(ans)+1
    print(M)
    S = [[0,0]for i in range(M)]
    l,n = 0,2
    hoge = 1
    for i in range(ans[0]):
        u,v = hoge,n
        n += 1
        S[l] = [u,v]
        l += 1
    for i in ans[1:]:
        hoge = n-1
        for j in range(i-1):
            u,v = hoge,n
            n += 1
            S[l] = [u,v]
            l += 1
    for u,v in S:
        print(u,v)
Problem p03007 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0
hoge = sum(A)
p = 0
for i in range(N-1):
    hoge -= A[i]*2
    if hoge > ans:
        ans = hoge
        p = i
print(ans)
hoge = A[0]
for i in range(p+1,N-1):
    print(hoge,A[i])
    hoge -= A[i]
print(A[N-1],hoge)
hoge = A[N-1] - hoge
for i in range(1,p+1):
    print(hoge,A[i])
    hoge -= A[i]

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
p = N//2
ans =sum(A[p:])-sum(A[:p])
hoge = ans
for i in range(p,N-1):
    hoge -= A[i]*2
    if hoge > ans:
        p = i
        ans = hoge
print(ans)
B=[0]*N
l =0
hoge = A[p+1]
for i in range(p+2,N):
    print(A[l],hoge)
    hoge = A[l]-hoge
    l += 1
    print(A[i],hoge)
    hoge = A[i]-hoge
for i in range(l,p+1):
    print(hoge,A[i])
    hoge -= A[i]

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
p = N//2
ans =sum(A[p:])-sum(A[:p])
hoge = ans
for i in range(p,N-1):
    hoge -= A[i]*2
    if hoge > ans:
        p = i
        ans = hoge
print(hoge)
B=[0]*N
l =0
hoge = A[p+1]
for i in range(p+2,N):
    print(A[l],hoge)
    hoge = A[l]-hoge
    l += 1
    print(A[i],hoge)
    hoge = A[i]-hoge
for i in range(l,p+1):
    print(hoge,A[i])
    hoge -= A[i]

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
nega = []
for i in range(N):
    if A[0] < 0:
        nega.append(A.pop(0))
    else:
        break
N = len(A)
print( sum(A[N//2:]) - sum(A[:N//2]) - sum(nega))
B = [0]*N
l,r = 0,N-1
for i in range(N):
    if i%2 == 0:
        B[i] = A[r]
        r -= 1
    else:
        B[i] = A[l]
        l += 1
hoge = B[-1]
for i in range(N-1):
    print(B[N-i-2],hoge)
    hoge = B[N-i-2]-hoge
for i in nega:
    print(hoge,i)
    hoge -= i
Problem p03026 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)

N = int(input())
ab = list(list(map(int,input().split())) for i in range(N-1))
c = list(map(int,input().split()))
c.sort(reverse=True)
print(sum(c)-c[0])
tree = [[-1]for i in range(N)]
for a,b in ab:
    tree[a-1].append(b)
    tree[b-1].append(a)
def func(l):
    if tree[l-1][0] != -1:
        return
    tree[l-1][0] = c.pop(0)
    for i in tree[l-1][1:]:
        func(i)
func(1)
for i in tree:
    print(i[0],end = " ")

Buggy submission (verdict: Runtime Error):
N = int(input())
ab = list(list(map(int,input().split())) for i in range(N-1))
c = list(map(int,input().split()))
c.sort(reverse=True)
tree = [[-1]for i in range(N)]
for a,b in ab:
    tree[a-1].append(b)
    tree[b-1].append(a)
def func(l):
    if tree[l-1][0] != -1:
        return
    tree[l-1][0] = c.pop(0)
    for i in tree[l-1][1:]:
        func(i)
func(1)
for i in tree:
    print(i[0],end = " ")
Problem p03032 (python)

Fixed submission:
N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
for i in range(min(N,K)+1): # Dequeueからとる宝石の数
    for j in range(i+1):  # 左からとる宝石の数
        Juel = V[:j]+V[N-i+j:]
        Juel.sort()
        sum_v = 0
        for k in range(min(K-i,i)):
            Juel[k] = max(Juel[k],0)
        ans = max(ans,sum(Juel))
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
V = list(map(int,input().split()))
L,R = [0]*(K),[0]*(K)
L[0] = max(0,V[0])
R[0] = max(0,V[-1])
for i in range(min(N,K)+1):
    part = V[:i]
    part.sort()
    for j in range(min(K-i,i)):
        if part[0] < 0:
            part.pop(0)
        L[i+j] = max(L[i+j],sum(part))
V.reverse()
for i in range(min(N,K)+1):
    part = V[:i]
    part.sort()
    for j in range(min(K-i,i)):
        if part[0] < 0:
            part.pop(0)
        R[i+j] = max(R[i+j],sum(part))
R[-1] = max(0,sum(part())
ans = max(R[-1],L[-1])
for i in range(K-1):
    ans = max(ans,L[i]+R[-i-2])
print(L)
print(R)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
D = list(map(int,input().split()))
L, R = [0]*(K),[0]*K
for i in range(K+1):
    tmp = D[:i]
    tmp.sort()
    X = sum(tmp)
    for j in range(min(K-i,i)):
        if tmp[0] < 0:
            X-=tmp.pop(0)
        else:
            L[i+j] = max(L[i+j],X)
            break
        L[i+j] = max(L[i+j],X)

for i in range(K+1):
    tmp = D[N-i:]
    tmp.sort()
    X = sum(tmp)
    for j in range(min(K-i,i)):
        if tmp[0] < 0:
            X-=tmp.pop(0)
        else:
            R[i+j] = max(R[i+j],X)
            break
        R[i+j] = max(R[i+j],X)

ans = []
for i in range(K):
    ans.append(L[i]+R[-i-1])
print(max(ans))
Problem p03089 (python)

Fixed submission:
N = int(input())
b = list(map(int,input().split()))
tmp = b[:]
ans = []
i = N-1
while i >= 0:
    if tmp[i] == 1:
        tmp[i] = float('inf')
        ans.append(b[i])
        while i < N:
            tmp[i] -= 1
            i += 1
    i -= 1
if len(ans) == N:
    for i in ans:
        print(i)
else:
    print(-1)

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

def func(B,i,C):
    if(C[0:i].count(True) + 1 == B[i]): #左の入力済みを数える
        print(B[i])
        C[i] = True
        next = -1
        for j in range(N-1,-1,-1):
            if C[j] == False:
                next = j
                break
        if next == -1:
            return
        func(B,next,C)
    else:
        next = i - 1
        for j in range(i-1,-1,-1):
            if C[j] == False:
                next = j
                break
        func(B,next,C)

flag = 0
for i in range(N):
    if B[i] > i + 1:
        flag = -1
        break

if(flag == -1):
    print(-1)
else:
    C = [False] * N
    func(B,N-1,C)

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

def func(B,i,C):
    if(C[0:i].count(True) + 1 >= B[i]): #左の入力済みを数える
        print(B[i])
        C[i] = True
        next = -1
        for j in range(N-1,-1,-1):
            if C[j] == False:
                next = j
                break
        if next == -1:
            return
        func(B,next,C)
    else:
        for next in range(i-1,-1,-1):
            if C[j] == False:
                func(B,next,C)
                break
        

flag = 0
for i in range(N):
    if B[i] > i + 1:
        flag = -1
        break

if(flag == -1):
    print(-1)
else:
    C = [False] * N
    func(B,N-1,C)

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

def func(B,i,C):
    if(C[0:i].count(True) + 1 == B[i]):
        print(B[i])
        C[i] = True
        next = -1
        for j in range(N-1,-1,-1):
            if C[j] == False:
                next = j
                break
        if next == -1:
            return
        func(B,next,C)
    else:
        next = -1
        for j in range(i-1,-1,-1):
            if C[j] == False:
                next = j
                break
        func(B,next,C)

flag = 0
for i in range(N):
    if B[i] > i + 1:
        flag = -1
        break

if(flag == -1):
    print(-1)
else:
    C = [False] * N
    func(B,N-1,C)
Problem p03110 (python)

Fixed submission:
N = int(input())
x = []
u = []
Y = 0
for i in range(N):
    s = [i for i in input().split()]
    x.append(float(s[0]))
    u.append(s[1])

    if u[i] == 'BTC':
        Y += x[i]*380000
    else:
        Y += x[i]

print(Y)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = []
u = []
Y = 0
for i in range(N):
    s = [i for i in input().split()]
   	x.append(float(s[0]))
    u.append(s[1])

    if u[i] == 'BTC':
        Y += x[i]*380000
    else:
        Y += x[i]

print(Y)
Problem p03216 (python)

Fixed submission:
N = int(input())
S = list(input())
Q = int(input())
K = list(map(int,input().split()))
DP = [[0,0,0]]
C = []
for i in range(N):
    q = DP[i][:]
    if S[i] == "D":
        q[0] += 1
    elif S[i] == "M":
        q[1] += 1
        q[2] += q[0]
    elif S[i] == "C":
        C.append(i+1)
    DP.append(q)

for k in K:
    ans = 0
    for c in C:
        if c < k:
            ans += DP[c][2]
        else:
            ans += DP[c][2] - DP[c-k][2] - DP[c-k][0]*(DP[c][1] - DP[c-k][1])
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
Q = int(input())
K = list(map(int,input().split()))
DP = [[0,0,0]]
C = []
for i in range(N):
    q = DP[i].copy()
    if S[i] == "D":
        q[0] += 1
    elif S[i] == "M":
        q[1] += 1
        q[2] += q[0]
    elif S[i] == "C":
        C.append(i+1)
    DP.append(q)

for k in K:
    ans = 0
    for c in C:
        if c < k:
            ans += DP[c][2]
        else:
            ans += DP[c][2] - DP[c-k][2] - DP[c-k][0]*(DP[c][1] - DP[c-k][1])
    print(ans)
Problem p03241 (python)

Fixed submission:
N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)+1):
    if M%i == 0:
        a.append(i)
        a.append(int(M/i))
a.sort(reverse = True)
for i in a:
    if i <= M/N:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)):
    if M%i == 0:
        if i <= N:
            a.append(i)
        else:
            a.append(int(M/i))
print(max(a))
Problem p03289 (python)

Fixed submission:
S = input()
alp = "abcdefghijklmnopqrstuvwxyz"
alpC = "abcdefghijklmnopqrstuvwxyzC"

ans = "AC"
if S[0] != "A":
    ans = "WA"
countC = 0
for i in S[2:-1]:
    if i == "C":
        countC += 1
    if not i in alpC:
        ans = "WA"
if countC != 1:
    ans = "WA"
if not S[1] in alp:
    ans = "WA"
if not S[-1] in alp:
    ans = "WA"
print(ans)

Buggy submission (verdict: Runtime Error):

S = input()
alp = "abcdefghijklmnopqrstuvwxyz"
alpC = "abcdefghijklmnopqrstuvwxyzC"

ans = "AC"
if S[0] != "A":
    ans = "WA"
countC = 0
for i in S[2:-1]:
    if i == "C":
        countC += 1
    if not i in alpC:
        ans = "WA"
if countC != 1:
    ans = "WA"
if not S[1] in alp:
    ans = "WA"
if not S[-1] in alp:
    ans = "WA"
pirnt(ans)

Buggy submission (verdict: Runtime Error):
S = input()
alp = "abcdefghijklmnopqrstuvwxyzC"
ans = "AC"
if S[0] != "A":
    ans = "WA"
flag = 0
for C in S[2:-1]:
    if C == "C":
        flag+=1
    if not c in alp:
        ans = "WA"
if flag != 1:
    ans = "WA"
if not S[1] in alp[:-1]:
    ans = "WA"
if not S[-1] in alp[:-1]:
    ans = "WA"

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
alp = "abcdefghijklmnopqrstuvwxyzAC"
ans = "AC"
if S[0] != "A":
    ans = "WA"
flag = 0
for C in S[2:-1]:
    if C == "C":
        flag = 1
if flag == 0:
    ans = "WA"
for c in S:
    if alp.index(c) == -1:
        ans = "WA"
print(ans)