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

Fixed submission:
n = int(input())
adj = [[] for _ in range(n)]
adj_dict = dict()

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    adj[a].append(b)
    adj[b].append(a)
    if a > b:
        adj_dict[(b, a)] = i
    else:
        adj_dict[(a, b)] = i

m = int(input())
uv = []
for _ in range(m):
    uv.append([int(x) - 1 for x in input().split()])

def dfs(p, v, dest):
    if v == dest:
        return [v]
    if p != -1 and len(adj[v]) == 1:
        return False
    for nv in adj[v]:
        if nv == p:
            continue
        ret = dfs(v, nv, dest)
        if ret:
            return ret + [v]
    return False

edgest = [0] * (2 ** m)
for i, (u, v) in enumerate(uv):
    ret = dfs(-1, u, v)
    for uu, vv in zip(ret, ret[1:]):
        if uu > vv:
            uu, vv = vv, uu
        if (uu, vv) in adj_dict:
            edgest[1 << i] |= (1 << adj_dict[(uu, vv)])

for i in range(1, 2 ** m):
    lsb = i & (-i)
    edgest[i] = edgest[i ^ lsb] | edgest[lsb]

dp = [0] * (2 ** m)
dp[0] = 1 << (n - 1)
ans = dp[0]
for i in range(1, 2 ** m):
    lsb = i & (-i)
    lim = bin(edgest[i] ^ edgest[i ^ lsb]).count('1')
    dp[i] = dp[i ^ lsb] >> lim
    if bin(i).count('1') % 2 == 0:
        ans += dp[i]
    else:
        ans -= dp[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
adj = [[] for _ in range(n)] # 辞書の箱を作る
adj_dict = dict()

for i in range(N - 1):
    a, b = [int(x) - 1 for x in input().split()]
    adj[a].append(b)
    adj[b].append(a)
    if a > b:
        adj_dict[(b, a)] = i
    else:
        adj_dict[(a, b)] = i

m = int(input())
uv = []
for _ in range(m):
    uv.append([int(x) - 1 for x in input().split()])

# 深さ優先探索
def dfs(p, v, dest):
    if v == dest:
        return [v]
    if p != -1 and len(adj[v]) == 1:
        return False
    for nv in adj[v]:
        if nv == p:
            continue
        ret = dfs(v, nv, dest)
        if ret:
            return ret + [v]
    return False

edgest = [0] * (2 ** m)
for i, (u, v) in enumerate(uv):
    ret = dfs(-1, u, v)
    for uu, vv in zip(ret, ret[1:]):
        if uu > vv:
            uu, vv = vv, uu
        if (uu, vv) in adj_dict:
            edgest[1 << i] |= (1 << adj_dict[(uu, vv)])

for i in range(1, 2 ** m):
    lsb = i & (-i)
    edgest[i] = edgest[i ^ lsb] | edgest[lsb]

dp = [0] * (2 ** m)
dp[0] = 1 << (N - 1)
ans = dp[0]
for i in range(1, 2 ** m):
    lsb = i & (-i)
    lim = bin(edgest[i] ^ edgest[i ^ lsb]).count('1')
    dp[i] = dp[i ^ lsb] >> lim
    if bin(i).count('1') % 2 == 0:
        ans += dp[i]
    else:
        ans -= dp[i]
print(ans)
Problem p03774 (python)

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in range(m):
    a, b = map(int, input().split())
    ca.append((a,b))

for i in range(len(la)):
    mi = 1000000001
    ans = 0
    for j in range(len(ca)):
        p = abs(la[i][0]-ca[j][0]) + abs(la[i][1]-ca[j][1])
        if  p < mi:
            mi = p
            ans = j+1
    print(ans)

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in la:
    a, b = map(int, input().split())
    ca.append((a,b))

for i in range(len(la)):
    mi = 1000000001
    ans = 0
    for j in range(len(ca)):
        p = abs(la[i][0]-ca[j][0]) + abs(la[i][1]-ca[j][1])
        if  p < mi:
            mi = p
            ans = j+1
    print(ans)

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in la:
    a, b = map(int, input().split())
    ca.append((a,b))

for i in ca:
    mi = 1000000001
    ans = 0
    for j in range(len(ca)):
        if abs(i[0]-ca[j][0]) + abs(i[1]-ca[j][1]) < mi:
            mi = abs(i[0]-ca[j][0]) + abs(i[1]-ca[j][1])
            ans = j+1
    print(ans)

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in range(n):
    a, b = map(int, input().split())
    ca.append((a,b))

for i in la:
    mi = 1000000001
    ans = 0
    for k,j in enumerate(ca):
        if abs(i[0]-j[0]) + abs(i[1]-j[1]) < mi:
            mi = abs(i[0]-j[0]) + abs(i[1]-j[1])
            ans = k+1
    print(ans)

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append([a,b])

ca = []
for i in range(n):
    a, b = map(int, input().split())
    ca.append([a,b])

for i in la:
    mi = 1000000001
    ans = 0
    for k,j in enumerate(ca):
        if abs(i[0]-j[0]) + abs(i[1]-j[1]) < mi:
            mi = abs(i[0]-j[0]) + abs(i[1]-j[1])
            ans = k+1
    print(ans)
Problem p02925 (python)

Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline
import time
t=time.time()


def main():
    N = int(input().strip())
    A = [[0]] * (N+1)
    for idx in range(1, N+1):
        A[idx] = list(reversed([int(x) for x in input().strip().split()]))

    ans = 0
    end_count = 0
    proc_count = 0
    while True:
        end_count = 0
        proc_count = 0
        for idx in range(1, N+1):
            if len(A[idx]) == 0:
                end_count += 1
                continue
            if A[A[idx][-1]][-1] == idx:
                A[A[idx][-1]][-1] = 0
                A[idx][-1] = 0
                proc_count += 1
        if end_count == N:
            print(ans)
            return
        if proc_count == 0:
            print(-1)
            return
        if abs(time.time()-t)>1:
            print(N*(N-1)//2)
            return
        for idx in range(1, N+1):
            if len(A[idx]) != 0:
                if A[idx][-1] == 0:
                    A[idx].pop()
        ans += 1


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline
import time
t=time.time()


def main():
    N = int(input().strip())
    A = [[0]] * (N+1)
    for idx in range(1, N+1):
        A[idx] = list(reversed([int(x) for x in input().strip().split()]))

    ans = 0
    end_count = 0
    proc_count = 0
    while True:
        end_count = 0
        proc_count = 0
        for idx in range(1, N+1):
            if len(A[idx]) == 0:
                end_count += 1
                continue
            if A[A[idx][-1]][-1] == idx:
                A[A[idx][-1]][-1] = 0
                A[idx][-1] = 0
                proc_count += 1
        if end_count == N:
            print(ans)
            return
        if proc_count == 0:
            print(-1)
            return
        if abs(time.time()-t)>1:
            print(n*(n-1)//2)
            return
        for idx in range(1, N+1):
            if len(A[idx]) != 0:
                if A[idx][-1] == 0:
                    A[idx].pop()
        ans += 1


if __name__ == "__main__":
    main()
Problem p02831 (python)

Fixed submission:
#最大公約数、最小公倍数
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    l = input().rstrip().split(' ')
    
    x = int(l[0])
    y = int(l[1])
    
    print(lcm(x, y))
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = input().rstrip().split(' ')

x = int(l[0])
y = int(l[1])

print(lcm(x, y))
Problem p02836 (python)

Fixed submission:
S = input()
T = 0
for i in range(len(S)//2):
  if S[i] != S[len(S) -1 -i]:
    T+=1
print(T)

Buggy submission (verdict: Runtime Error):
S = input()
T = 0
K = len(S)/2 if len(S)%2 == 0 else len(S)//2+1
for i in range(len(S)//2):
  if S[i] != S[K + i]:
    T+=1
print(T)

Buggy submission (verdict: Runtime Error):
S = input()
T = 0
K = len(S)//2 if len(S)%2 == 0 else len(S)//2+1
for i in range(K):
  if S[i] != S[K + i]:
    T+=1
print(T)

Buggy submission (verdict: Runtime Error):
S = input()
T = 0
for i in range(len(S)//2):
  if S[i] != S[K//2 + i +1]:
    T+=1
print(T)

Buggy submission (verdict: Runtime Error):
S = input()
T = 0
for i in range(len(S)//2):
  if S[i] == S[len(S)//2 + 1]:
    T+=1
print(T)
Problem p02820 (python)

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

N, K = [int(v) for v in sys.stdin.readline().split()]
R, S, P = [int(v) for v in sys.stdin.readline().split()]
T = input()

l = [''] * K
memo = [{} for _ in range(K)]

for i in range(N):
    l[i % K] += T[i]

def okjudge(m, ss, p):
    if p in memo[m]:
        return memo[m][p]

    lss = len(ss)
    if p == lss:
        ret =  0
        memo[m][p] = ret
        return ret

    c = ss[p]

    if lss - p == 1:
        if c == 'r':
            ret = P
        elif c == 's':
            ret =  R
        else:
            ret =  S
        memo[m][p] = ret
        return ret

    if ss[p + 1] == ss[p]:
        if c == 'r':
            ret =  max(okjudge(m, ss, p + 1), P + okjudge(m, ss, p + 2))
        elif c == 's':
            ret =  max(okjudge(m, ss, p + 1), R + okjudge(m, ss, p + 2))
        else:
            ret =  max(okjudge(m, ss, p + 1), S + okjudge(m, ss, p + 2))
    elif c == 'r':
        ret =  P + okjudge(m, ss, p + 1)
    elif c == 's':
        ret =  R + okjudge(m, ss, p + 1)
    else:
        ret =  S + okjudge(m, ss, p + 1)

    memo[m][p] = ret
    return ret

print(sum([okjudge(mi, v, 0) for mi,v in enumerate(l)]))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5)

N, K = [int(v) for v in sys.stdin.readline().split()]
R, S, P = [int(v) for v in sys.stdin.readline().split()]
T = input()

l = [''] * K

for i in range(N):
    l[i % K] += T[i]


def okjudge(rest):
    if len(rest) == 0:
        return 0

    c = rest[0]

    if len(rest) == 1:
        if c == 'r':
            return P
        elif c == 's':
            return R
        else:
            return S
    if rest[1] == rest[0]:
        if c == 'r':
            return max(okjudge(rest[1:]), P + okjudge(rest[2:]))
        elif c == 's':
            return max(okjudge(rest[1:]), R + okjudge(rest[2:]))
        else:
            return max(okjudge(rest[1:]), S + okjudge(rest[2:]))
    elif c == 'r':
        return P + okjudge(rest[1:])
    elif c == 's':
        return R + okjudge(rest[1:])
    else:
        return S + okjudge(rest[1:])

print(sum([okjudge(v) for v in l]))
Problem p02831 (python)

Fixed submission:
import fractions
A, B = [int(v) for v in input().split()]

def lcm(a, b):
    return a * b / fractions.gcd(a, b)

print(int(lcm(A, B)))

Buggy submission (verdict: Runtime Error):
import math
A, B = [int(v) for v in input().split()]

def lcm(a, b):
    return a * b / math.gcd(a, b)
print(int(lcm(A, B)))
Problem p02859 (python)

Fixed submission:
import sys
R = int(input())
print(R * R)

Buggy submission (verdict: Runtime Error):
import sys
R = int(input()
print(R * R)
Problem p02970 (python)

Fixed submission:
import math

inp = list(map(int, input().strip().split(' ')))

a = inp[0]
b = inp[1]

r = b * 2 + 1
m = math.ceil(a / r)
print(m)

Buggy submission (verdict: Runtime Error):
inp = list(map(int, input().strip().split(' ')))

a = inp[0]
b = inp[1]

r = b * 2 + 1
m = math.ceil(a / r)
print(m)
Problem p02881 (python)

Fixed submission:
#%%
n = int(input())
a = 10**15


x = int(n**0.5)
x += 1
for i in range(x, 1, -1):
    if n%i == 0:
        a = i
        b = n//i
        break
#print(a, b)

if a == 10**15:
    print(n-1)
else:
    print(a+b-2)

Buggy submission (verdict: Runtime Error):
#%%
n = int(input())

x = int(n**0.5)
x += 1
for i in range(x, 1, -1):
    if n%i == 0:
        a = i
        b = n//i
        break
#print(a, b)

print(a+b-2)
Problem p02954 (python)

Fixed submission:
S = list(input())
N = len(S)

RL = []
LR = []



for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RL.append(i)
    if S[i] == 'L' and S[i+1] == 'R':
        LR.append(i)

#print(RL)
#print(LR)

#if S[0] == 'L':
#    RL.insert(0,0)
#if S[-1] == 'R':
#    RL.append(N-1)

LR.insert(0, -1)
LR.append(N-1)

#print('RL 記入')
#print(RL)
#print('LR 区切り')
#print(LR)

ans = ['0'] * N
for i in range(len(LR)-1):
    tmp = LR[i+1] - LR[i]
#    if RL[i] == 0:
#        ans[0] = str(tmp)
#    elif RL[i] == N-1:
#        ans[N-1] = str(tmp)
#        RL.remove(N-1)
#    else:
    tmplist = S[LR[i]+1:LR[i+1]+1]
    tmpR = tmplist.count('R')
    tmpL = tmplist.count('L')
    #print(tmplist)

    if (tmpR + tmpL) % 2 == 0:
        ans[RL[i]] = str(tmp // 2)
        ans[RL[i]+1] = str(tmp // 2)
    elif tmpR %2 == 1 and tmpL%2==0:
        ans[RL[i]] = str(tmp // 2 + 1)
        ans[RL[i]+1] = str(tmp // 2 )
    elif tmpR %2 == 0 and tmpL%2==1:
        ans[RL[i]] = str(tmp // 2 )
        ans[RL[i]+1] = str(tmp // 2 + 1)

print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
S = list(input())
N = len(S)

RL = []
LR = []



for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RL.append(i)
    if S[i] == 'L' and S[i+1] == 'R':
        LR.append(i)

#print(RL)
#print(LR)

if S[0] == 'L':
    RL.insert(0,0)
if S[-1] == 'R':
    RL.append(N-1)

LR.insert(0, -1)
LR.append(N-1)

#print('RL 記入')
#print(RL)
#print('LR 区切り')
#print(LR)

ans = ['0'] * N
for i in range(len(LR)-1):
    tmp = LR[i+1] - LR[i]
    if RL[i] == 0:
        ans[0] = tmp
    elif RL[i] == N-1:
        ans[N-1] = tmp
        RL.remove(N-1)
    else:
        tmplist = S[LR[i]+1:LR[i+1]+1]
        tmpR = tmplist.count('R')
        tmpL = tmplist.count('L')
        #print(tmplist)

        if (tmpR + tmpL) % 2 == 0:
            ans[RL[i]] = str(tmp // 2)
            ans[RL[i]+1] = str(tmp // 2)
        elif tmpR %2 == 1 and tmpL%2==0:
            ans[RL[i]] = str(tmp // 2 + 1)
            ans[RL[i]+1] = str(tmp // 2 )
        elif tmpR %2 == 0 and tmpL%2==1:
            ans[RL[i]] = str(tmp // 2 )
            ans[RL[i]+1] = str(tmp // 2 + 1)

print(' '.join(ans))
Problem p02990 (python)

Fixed submission:
#%%
"""
#(w+h-1) C w
a,b = 1, 1
for i in range(1, w+h-1):
    a *= i
    a %= mod
for i in range(1, w):
    b *= i
    b %= mod
for i in range(1, h):
    b *= i
    b %= mod

ans = a * pow(b, mod-2, mod) % mod
"""

n, k = map(int, input().split())
mod = 10**9 + 7

for i in range(1, k+1):
    if i <= n - k + 1: 
        a, b, c, d = 1, 1, 1, 1
        for j in range(1, n-k+1+1):
                a *= j
                a %= mod
        for j in range(1, i+1):
                b *= j
                b %= mod
        for j in range(1, n-k+1-i+1):
                b *= j
                b %= mod
        for j in range(1, k-1+1):
                c *= j
                c %= mod
        for j in range(1, i-1+1):
                d *= j
                d %= mod
        for j in range(1, k-i+1):
                d *= j
                d %= mod
        #print(a, b, c, d)
        ans = a * pow(b, mod-2, mod) * c * pow(d, mod-2, mod) 
        ans %= mod
    else:
        ans = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
paskal = [[0]*N for _ in range(N)] 


for i in range(N):
    for j in range(0, i+1):
        if j == 0 or j == i:
            paskal[i][j] = 1
        else:
            paskal[i][j] = (paskal[i-1][j-1] + paskal[i-1][j]) % 1000000007



for i in range(1, K+1):
    ans = paskal[N-K+1][i] * paskal[K-1][i-1]
    print(ans)
Problem p03011 (python)

Fixed submission:
input_time = list(map(int, input().split()))
input_time_sort = sorted(input_time)
print(input_time_sort[0]+input_time_sort[1])

Buggy submission (verdict: Runtime Error):
N_M = list(map(int, input().split()))
N = N_M[0]
M = N_M[1]
dis = []
for _ in range(M):
    dis.append(input())

dp = [0 for i in range(N+2)]
dp[0] = 1
if 1 in dis:
    dp[1] = 0
else :
    dp[1] = 1

for i in range(N):
    if i+2 in dis:
        dp[i+2]=0
    else:
        if i in dis :
            dp[i+2]=dp[i+1]
        if i+1 in dis :
            dp[i+2]=dp[i]
        else :
            dp[i+2]=dp[i]+dp[i+1]

print(dp[N])
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = [0] * M
for i in range(M):
    a[i] = int(input())


dp = [0] * (N+1)

for i in range(N+1):
    if i == 0:
        dp[i] = 1
    elif i == 1:
        if len(a) !=0:
            if i == a[0]:
                dp[i] = 0
                a.pop(0)

            else:
                dp[i] = 1
        else:
            dp[i] = 1
    else:
        if len(a) !=0:
            if i == a[0]:
                dp[i] = 0
                a.pop(0)

            else:
                dp[i] = dp[i-1] + dp[i-2]
                dp[i] = dp[i] % 1000000007
        else:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] = dp[i] % 1000000007

ans = dp[N]
print(ans)

Buggy submission (verdict: Runtime Error):
N_M = list(map(int, input().split()))
N = N_M[0]
M = N_M[1]
for i in range(M):
    dis[i] = list(int(input()))

dp = [0 for i in range(N+2)]
dp[0] = 1
if 1 in dis:
    dp[1] = 0
else :
    dp[1] = 1

for i in range(N):
    if i+2 in dis:
        dp[i+2]=0
    else:
        if i in dis :
            dp[i+2]=dp[i+1]
        if i+1 in dis :
            dp[i+2]=dp[i]
        else :
            dp[i+2]=dp[i]+dp[i+1]

print(dp[N])
Problem p03017 (python)

Fixed submission:
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for j in range(B, D-1):
        if S_list[j] == S_list[j+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C:
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1

    cou = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            cou += 1
    if cou >= 1 and count < 1 :
        print('Yes')  
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
        count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for i in range(B, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    count = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            count += 1
    if count >= 1:
        print('Yes')  
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
#%%
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if C < D :
    count = 0
    for i in range(A-1, D-1):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C == D :
    print('No')
else:
    count = 0
    for i in range(A-1, C-1):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    count = 0
    for i in range(B-2, D):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            count += 1
    if count >= 1:
        print('Yes')  
    else:
        print('No')
Problem p03018 (python)

Fixed submission:
#%%
s = list(input())
i = 0
ss = ''

while True:
    if i <= len(s) - 2:
        if s[i] == 'B' and s[i+1] == 'C':
            ss += 'D'
            i += 2
        else:
            ss += s[i]
            i += 1          
    else:
        ss += s[i]
        i += 1
    if i >= len(s):
        break
#print(ss)

a = 0
ans = 0
for i in range(len(ss)):
    if ss[i] == 'A':
        a += 1
    elif ss[i] == 'D':
        ans += a
    else:
        a = 0
print(ans)

#%%

Buggy submission (verdict: Runtime Error):
#%%
s = list(input())
ans = 0
i = 0

while True:
    if i < 0 :
        i += 1
    elif len(s)-2 <= i:
        break
    else:
        if s[i] == 'A'
            if s[i+1] == 'B' and s[i+2] == 'C':
                ans += 1
                s[i], s[i+1], s[i+2] = 'B', 'C', 'A'
                i -= 1
            else:
                i += 1
        else:
            i += 1

print(ans)
Problem p03041 (python)

Fixed submission:
l = list(map(int,input().split()))
N = l[0]
K = l[1] 
S = input()
list_S = list(S)
if list_S[K-1] == 'A':
    list_S[K-1] = 'a'
elif list_S[K-1] == 'B':
    list_S[K-1] = 'b'
if list_S[K-1] == 'C':
    list_S[K-1] = 'c'
L = ''.join(list_S)
print(L)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [0] * M
Y = [0] * M
Z = [0] * M 
for i in range(M):
  X[i], Y[i], Z[i] = map(int, input().split())

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

for i in range(M) :
    G[Y[i]-1].append(X[i])
    G[X[i]-1].append(Y[i])

c = [False for _ in range(N)]
 
def DFS(G,s):
    c[s-1] = True
    for i in G[s-1]:
        if not c[i-1]:         
            DFS(G,i)
ans = 0
for i in range(N):
    if not c[i]:
        DFS(G,i+1)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
　l = list(map(int,input().split()))
N = l[0]
K = l[1] 
S = input()
list_S = list(S)
if list_S[K-1] == 'A':
    list_S[K-1] = 'a'
elif list_S[K-1] == 'B':
    list_S[K-1] = 'b'
if list_S[K-1] == 'C':
    list_S[K-1] = 'c'
L = ''.join(list_S)
print(L)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-d<=k and e-c<=k and e-b<=k and e-a<=k and d-c<=k and d-b<=k and d-a<=k and c-b<=k and c-a<=k and b-a<=k:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-d>=k and e-c>=k and e-b>=k and e-b>=k and e-a>=k and d-c>=k and d-b>=k and d-a>=k and c-b>=k and c-a>=k and b-a>=k:
  print('Yay!')
else:
  prit(':(')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-d>=k and e-c>=k and e-b>=k and e-a>=k and d-c>=k and d-b>=k and d-a>=k and c-b>=k and c-a>=k and b-a>=k:
  print('Yay!')
else:
  prit(':(')

Buggy submission (verdict: Runtime Error):
a = int(input())
b
c
d
e
Problem p03077 (python)

Fixed submission:
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

X = min(A, B, C, D, E)
ans = 4 + math.ceil(N/X)

print(ans)

Buggy submission (verdict: Runtime Error):
C = list(map(int, input().split()))
C.sort(reverse=True)
 
L = []
 
for i in range(min(200,len(A))):
    for j in range(min(200,len(B))):
        for k in range(min(200,len(C))):
            tmp = A[i] + B[j] + C[k]
            L.append(tmp)
 
L.sort(reverse=True)
 
for i in range(K):
    print(L[i])
Problem p03107 (python)

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


tmp = 0

while tmp < len(T)-1:
    if T[tmp] != T[tmp+1]: 
        T.pop(tmp)
        T.pop(tmp)
        if tmp == 0:
            tmp = 0
        else:
            tmp -= 1
    else:
        tmp += 1


k = len(T)

ans = l - k

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
T = list(S)


tmp = 0

while tmp != len(T)-1:
    if T[tmp] != T[tmp+1]:
     
        T.pop(tmp)
        T.pop(tmp)
        tmp -= 1
    else:

        tmp += 1





k = len(T)

ans = l - k

print(ans)