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

Fixed submission:
from queue import Queue

H, W = [int(x) for x in input().split()]
realH = H + 2
realW = W + 2
s = ["#" + input() + "#" for x in range(H)]
wall = "#" * (realW)
s.insert(0, wall)
s.append(wall)
dxy = [0, 1, 0, -1, 0]
inf = float("inf")

visited = [[False] * realW for x in range(realH)]
depth = [[inf] * realW for x in range(realH)]
depth[1][1] = 1
q = Queue()
q.put((1,1))

while not q.empty():
    place = q.get()
    if place == (H, W):
        break
    for i in range(4):
        nxt = (place[0] + dxy[i], place[1] + dxy[i+1])
        if s[nxt[0]][nxt[1]] == "." and not visited[nxt[0]][nxt[1]]:
            q.put(nxt)
            depth[nxt[0]][nxt[1]] = depth[place[0]][place[1]] + 1
            visited[nxt[0]][nxt[1]] = True

if depth[H][W] == inf:
    print(-1)
else:
    print(realH * realW - sum(map(lambda x: x.count("#"), s)) - depth[H][W])

Buggy submission (verdict: Runtime Error):
from queue import Queue

H, W = [int(x) for x in input().split()]
realH = H + 2
realW = W + 2
s = ["#" + input() + "#" for x in range(H)]
wall = "#" * (realW)
s.insert(0, wall)
s.append(wall)
dxy = [0, 1, 0, -1, 0]
inf = float("inf")

visited = [[False] * realW for x in range(realH)]
depth = [[inf] * realW for x in range(realH)]
depth[1][1] = 1
q = Queue()
q.put((1,1))

while not q.empty():
    place = q.get()
    if place == (H, W):
        break
    for i in range(4):
        nxt = (place[0] + dxy[i], place[1] + dxy[i+1])
        if s[nxt[0]][nxt[1]] == "." and not visited[nxt[0]][nxt[1]]:
            q.put(nxt)
            depth[nxt[0]][nxt[1]] = depth[place[0]][place[1]] + 1
            visited[nxt[0]][nxt[1]] = True

if depth[H][W] == inf:
    print(-1)
elif:
    print(realH * realW - sum(map(lambda x: x.count("#"), s)) - depth[H][W])
Problem p02582 (python)

Fixed submission:
s=input()
if s=="SSS":
  print(0)
elif s=="RRS" or s== "SRR":
  print(2)
elif s== "RRR":
  print(3)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="SSS":
  print(0)
else if s=="RRS" or s== "SRR":
  print(2)
else if s== "RRR":
  print(3)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="SSS":
  print(0)
else if s=="RRS" or s= "SRR":
  print(2)
else if s= "RRR":
  print(3)
else:
  print(1)
Problem p02995 (python)

Fixed submission:

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

#N = int(input())

#list(map(int,input().split()))

cnt = B-A+1

import fractions
E = C*D // fractions.gcd(C, D)


A_C = A//C
A_dC = A%C

B_C = B//C
#B_dC = B%C

A_D = A//D
A_dD = A%D

B_D = B//D
#B_dD = B%D

A_E = A//E
A_dE = A%E

B_E = B//E
#B_dE = B%E

C_cnt = B_C - A_C
if A_dC == 0:
    C_cnt += 1
D_cnt = B_D - A_D
if A_dD == 0:
    D_cnt += 1
E_cnt = B_E - A_E
if A_dE == 0:
    E_cnt += 1  

ans = cnt - C_cnt - D_cnt + E_cnt
print(int(ans))

Buggy submission (verdict: Runtime Error):

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

#N = int(input())

#list(map(int,input().split()))

cnt = B-A+1

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


A_C = A//C
A_dC = A%C

B_C = B//C
#B_dC = B%C

A_D = A//D
A_dD = A%D

B_D = B//D
#B_dD = B%D

A_E = A//E
A_dE = A%E

B_E = B//E
#B_dE = B%E

C_cnt = B_C - A_C
if A_dC == 0:
    C_cnt += 1
D_cnt = B_D - A_D
if A_dD == 0:
    D_cnt += 1
E_cnt = B_E - A_E
if A_dE == 0:
    E_cnt += 1  

ans = cnt - C_cnt - D_cnt + E_cnt
print(int(ans))
Problem p03007 (python)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l.sort()
sousa = []
next_m = l[0]
next_p = l[N-1]
for i in range(1,N-1):
    if l[i] > 0:
        sousa.append([next_m,l[i]])
        next_m -= l[i]
    else:
        sousa.append([next_p,l[i]])
        next_p -= l[i]
ans = next_p - next_m
print(ans)
sousa.append([next_p,next_m])
for i in range(N-1):
    print(str(sousa[i][0])+" "+str(sousa[i][1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
# -*- coding: utf-8 -*-
#hq = []
#hq_inv = []#大きいもの
#import heapq
l = list(map(int,input().split()))
l.sort()
import bisect
index = bisect.bisect_right(l, 0)
if index == 0:
    print(sum(l)-l[0])
else:
    print(sum(l[index:]-sum(l[:index-1])))

Buggy submission (verdict: Runtime Error):
N = int(input())
# -*- coding: utf-8 -*-
#hq = []
#hq_inv = []#大きいもの
#import heapq
l = list(map(int,input().split()))
l.sort()
import bisect
index = bisect.bisect_right(l, 0)
if index == 0:
    print(sum(l)-l[0])
else:
    print(sum(l[index:]-sum(l[:index-1])))
Problem p03050 (python)

Fixed submission:
N = int(input())
import math
sq_N = int(math.sqrt(N))
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0:
        if N//k == N%k:
            ans += k

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
sq_N = int(math.sqrt(N))
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0 or N//k == N%k:
        ans += k

print(ans)
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)
Problem p03074 (python)

Fixed submission:
n,k = map(int,input().split())
s = list(input())
if s[0] == "1":
    cnt_list = []
else:
    cnt_list = [0]
cnt = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 1
cnt_list.append(cnt)
if s[-1] == '0':
    cnt_list.append(0)
#print(cnt_list)
sum_list = [0]
for i in range(len(cnt_list)):
    sum_list.append(sum_list[i] + cnt_list[i])
ans = 0
for i in range(0,len(sum_list),2):
    right = min(i+2*k+1,len(sum_list)-1)
    ans = max(ans,sum_list[right]-sum_list[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(input())
if s[0] == "1":
    cnt_list = []
else:
    cnt_list = [0]
cnt = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 1
cnt_list.append(cnt)
if s[-1] == '0':
    cnt_list.append(0)
#print(cnt_list)
sum_list = [0]
for i in range(len(cnt_list)):
    sum_list.append(sum_list[i] + cnt_list[i])
left = 0
right = max(len(sum_list)-2*k, 1)
ans = 0
for i in range(0,right,2):
    ans = max(ans,sum_list[i+2*k+1]-sum_list[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(input())
if s[0] == "1":
    cnt_list = []
else:
    cnt_list = [0]
cnt = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 1
cnt_list.append(cnt)
if s[-1] == '0':
    cnt_list.append(0)
print(cnt_list)
sum_list = [0]
for i in range(len(cnt_list)):
    sum_list.append(sum_list[i] + cnt_list[i])
left = 0
right = max(len(sum_list)-2*k, 1)
ans = 0
for i in range(0,right,2):
    ans = max(ans,sum_list[i+2*k+1]-sum_list[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(input())
if s[0] == "1":
    cnt_list = []
else:
    cnt_list = [0]
cnt = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 1
cnt_list.append(cnt)

sum_list = []
for i in range(0,len(cnt_list)-2*k):
    sum_list.append(sum(cnt_list[i:i+2*k+1]))
print(max(sum_list))
Problem p03076 (python)

Fixed submission:
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
amari = [abcde[i]%10 for i in range(5) if abcde[i]%10 != 0]
if len(amari) == 0:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
else:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])-10+min(amari)
    
print(ans)

Buggy submission (verdict: Runtime Error):
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)]) + min([abcde[i]%10 for i in range(5) if abcde[i]%10 != 0])-10
print(ans)

Buggy submission (verdict: Runtime Error):
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([(abcde[i]//10+1)*10 for i in range(5)]) + min([abcde[i]%10 for i in range(5) if abcde[i]%10 != 0])-10
print(ans)
Problem p03101 (python)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())

print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
ap(int,input().split())
Problem p03111 (python)

Fixed submission:
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
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
    
    return min(ret0,ret1,ret2,ret3)

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

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
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l(cur),b,c)
    ret2 = dfs(cur+1,a,b+l(cur),c)
    ret3 = dfs(cur+1,a,b,c+l(cur))
    
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_left(s, x), bisect.bisect_left(t, x)
    res = INF
    for S in [s[b + 1], s[b]]:
        for T in [t[d + 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
Problem p03210 (python)

Fixed submission:
x = int(input())
if x == 7:
  ans = 'YES'
elif x == 5:
  ans = 'YES'
elif x == 3:
  ans = 'YES'
else:
  ans = 'NO'
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
if x == 7:
  ans = 'YES'
elif x == 5:
  ans = 'YES
elif x == 3:
  ans = 'YES'
else:
  ans = 'NO'
print(ans)
Problem p03212 (python)

Fixed submission:
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #

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

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #
Problem p02582 (python)

Fixed submission:
str =list(input())
counter =0
max=0
for s in str:
    if s =='S':
        counter =0
    else :
       counter +=1
       if max <counter:
          max =counter
print(max)

Buggy submission (verdict: Runtime Error):
str =list(input())
counter =0
max=0
for s in str:
    if s ='S':
        counter =0
    else 
       counter +=1
       if max <counter
          max =counter
print(max)
Problem p02582 (python)

Fixed submission:
str = input()
splited = list(str)

cccount = 0
count = 0
for s in splited:
  if s == 'R':
    count = count + 1
    if count > cccount:
      cccount = count
  else:
      count = 0
    
print(cccount)

Buggy submission (verdict: Runtime Error):
str = input()
splited = str.split('')
print(splited)
Problem p02760 (python)

Fixed submission:
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)
ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][0] + bingo[1][0] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][1] + bingo[1][1] + bingo[2][1]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][2] + bingo[2][2]) == -3:
  ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)
ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][0] + bingo[1][0] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][1] + bingo[1][1] + bingo[2][1]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][2] + bingo[2][2]) == -3:
  ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)
ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
  	if col == -3:
    	ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"
print(ans)
Problem p02767 (python)

Fixed submission:
n = input()
l = input().split()
data = []
for i in range(int(min(l)), int(max(l))+1):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (int(l[j])-i)**2
    data.append(sum_l)

print(min(data))

Buggy submission (verdict: Runtime Error):
n = input()
l = input().split()
data = []
for i in range(int(min(l)), int(max(l))):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (int(l[j])-i)**2
    data.append(sum_l)

print(min(data))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = input()
data = []
for i in range(min(l), max(l)+1):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (l[j]-i)**2
    data.append(sum_l)

print(min(data))
Problem p02608 (python)

Fixed submission:
n = int(input())
t = []
ans = [0]*(10**4+5)
def calc(x, y, z):
    return x**2+y**2+z**2 + x*y + y*z + z*x

for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            t.append(calc(x,y,z))

for i in t:
    if i < 10**4+5:
        ans[i] += 1
for i in range(1,n+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import itertools as it
n = int(input())
t = []
ans = [0]*10**4
def calc(x, y, z):
    return x**2+y**2+z**2 + x*y + y*z + z*x

for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            t.append(calc(x,y,z))

for i in t:
    if i < 10**4:
        ans[i] += 1
for i in range(1,n+1):
    print(ans[i])
Problem p02678 (python)

Fixed submission:
from collections import deque
 
n,m = map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
path = [[] for _ in range(n+1)]
 
for a,b in ab:
    path[a].append(b)
    path[b].append(a)
 
q = deque([1])
ans = [0] * (n+1)
while q:
    v = q.popleft()
    for w in path[v]:
        if ans[w] == 0:
            ans[w] = v
            q.append(w)
 
print('Yes')
print(*ans[2:], sep="\n")

Buggy submission (verdict: Runtime Error):
# d
import numpy as np
n, m = [int(i) for i in input().split()]
a = np.array([0]*m)
b = np.array([0]*m)
ans = np.array([0]*(n))
count =  np.array([0]*n)
roop = 0
Checks =  np.array([0]) # チェックする部屋の番号
Next =  np.array([]) # 次チェックする部屋番号をリストアップする
Li = np.array([1]*n)
for i in range(m):
    a[i], b[i] = [int(j)-1 for j in input().split()]

# 入力の受け取り完了
while np.sum(Li) != 0:
    roop += 1
    for check in Checks:
        if np.any(a == check):
            ind = np.where(a == check)
            nex = b[ind]
            ans[nex] = check+1
            Li[nex] = 0
#             print(nex)
        if np.any(b == check):
            ind = np.where(b == check)
            nex2 = a[ind]
            ans[nex2] = check+1
            Li[nex2] = 0
#             print(nex2)
    
    Next = np.append(Next, nex)
    Next = np.append(Next, nex2)
    Checks = []
    Checks = Next
#     print("roop = " + str(roop))
#     print(Next)
    # 初期化
    nex = []
    nex2 = []
    
    if roop == 1000:
        break
# print('ans')
print(ans[1:])
Problem p02687 (python)

Fixed submission:
s = input()
a = ["ABC", "ARC"]
print(a[(a.index(s)+1)%len(a)])

Buggy submission (verdict: Runtime Error):

S = input('=')

if S == 'ABC':
    print('ARC')
else S == 'ARC':
    print('ABC')

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

if S == 'ABC':
    print('ARC')
else S == 'ARC':
    print('ABC')

Buggy submission (verdict: Runtime Error):
if S == 'ABC':
    print('ARC')
else S == 'ARC':
    print('ABC')

Buggy submission (verdict: Runtime Error):

if S == 'ABC':
    print('ARC')
elif S== 'ARC':
    print('ABC')
else:
    print(' ')

Buggy submission (verdict: Runtime Error):

var S = input('先週開催されたコンテストは？')

if S == 'ABC':
  print('ARC')
elif S == 'ARC':
  print('ABC')
Problem p02732 (python)

Fixed submission:
import collections
import math

n = int(input())
a = [int(i) for i in input().split()]

def com(n, r):
    if n > 1:
        ann = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        ann = 0
    return ann

b = collections.Counter(a)
ans = []
for i in b:
    ans.append(com(b[i],2))
anss = sum(ans)

for i in range(n):
    t = b[a[i]]
    print(anss - (t-1))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = [int(i) for i in input().split()]

def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(n):
    ans = 0
    b = a.copy()
    del b[i]
    bb = collections.Counter(b)
    for j in bb:
        if bb[j] > 1:
            ans += com(bb[j],2)
    print(ans)
Problem p02755 (python)

Fixed submission:
import math
a,b = [float(i) for i in input().split()]
ans = 1000000000
flag = False

for i in range(1,10000):
    ans8 = int(math.floor(i*0.08))
    ans10 = int(math.floor(i*0.1))
#     print(ans8,ans10)
    if ans8 == a and ans10 == b:
        ans = min(ans, i)
        flag = True

if flag is True:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math
a,b = [float(i) for i in input().split()]
ans = 1000000000
Flag = False

for i in range(1,10000):
    ans8 = int(math.floor(i*0.08))
    ans10 = int(math.floor(i*0.1))
#     print(ans8,ans10)
    if ans8 == a and ans10 == b:
        ans = min(ans, i)
        flag = True

if flag:
    print(ans)
else:
    print(-1)
Problem p02818 (python)

Fixed submission:
a, b, k = [int(i) for i in input().split()]
if k <= 0:
    taka = a
    aoki = b
elif k <= a:
    taka = a-k
    aoki = b
elif k > a and k <= a+b:
    taka = 0
    aoki = b-(k-a)
elif k > a+b:
    taka = 0
    aoki = 0
print(taka, aoki)

Buggy submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split()]
if k <= 0:
    taka = a
    aoki = b
elif k <= a:
    taka = a-k
    aoki = b
elif k > a && k <= a+b:
    taka = 0
    aoki = b-(k-a)
elif k > a+b:
    taka = 0
    aoki = 0
print(taka, aoki)

Buggy submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split()]
elif k == 0:
    taka = a
    aoki = b
elif k <= a:
    taka = 0
    aoki = b
elif k > a:
    taka = 0
    aoki = b-(k-a)
elif k > a+b:
    taka = 0
    aoki = 0
print(taka, aoki)
Problem p02630 (python)

Fixed submission:
n = int(input())
numlist = list(map(int,input().split()))
numcount = [0]*10**6

numset = set()
for num in numlist:
    numcount[num] += 1
    numset.add(num)
n = int(input())
anslist = []
result = 0
for num in list(numset):
    result += numcount[num]*num
    
for i in range(n):
    b,c = map(int,input().split())
    numcount[c] += numcount[b]
    result += (c-b)*numcount[b]
    anslist.append(result)

    numcount[b] = 0
    numset.add(c)
    numset.discard(b)

for ans in anslist:
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
numlist = list(map(int,input().split()))
numcount = [0]*10**5
for num in numlist:
    numcount[num] += 1
n = int(input())
anslist = []
for i in range(n):
    b,c = map(int,input().split())
    numcount[c] += numcount[b]
    numcount[b] = 0
    result = 0
    for i,num in enumerate(numcount):
        result += i*num
    anslist.append(result)

for ans in anslist:
    print(ans)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
alist = list(map(int,input().split()))
memo = []
p = 1
vis = ['.']*n
while vis[p-1] == '.':
    memo.append(p)
    vis[p-1] = 'v'
    p = alist[p-1]

loop = memo.index(p)
if k < len(memo):
    print(memo[k])
else:
    print(memo[loop+(k-loop)%(len(memo)-loop)])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
alist = list(map(int,input().split()))
memo = []
p = 1
vis = ['.']*n
while vis[p-1] == '.':
    memo.append(p)
    vis[p-1] = 'v'
    p = alist[p-1]

loop = memo.index(p)
if k < len(alist):
    print(memo[k])
else:
    print(memo[loop+(k-loop)%(len(memo)-loop)])

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

memo = []
p = 1
vis = ['.']*n

while vis[p-1] == '.':
    memo.append(p)
    vis[p-1] = 'v'
    p = alist[p-1]

loopstart = memo.index(p)
if k < len(alist):
    print(memo[k])
else:
    print(memo[loopstart+(k-loopstart)%(len(memo)-loopstart)])

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

memo = []
p = 1
vis = ['.']*n

while vis[p-1] == '.':
    memo.appened(p)
    vis[p-1] = 'v'
    p = alist[p-1]

loopstart = alist.index(p)
if k < len(alist):
    print(memo[k])
else:
    print(memo[loopstart+(k-loopstart)%(len(alist)-loopstart)])

Buggy submission (verdict: Runtime Error):
from collections import deque
n,k = map(int,input().split())
alist = list(map(int,input().split()))


flag = ['.']*(n+1)
flag[1] = 'v'

been = [1]

for i in range(k):
    goto = alist[been[-1]-1]
    if flag[goto] == '.':
        been.append(goto)
        flag[goto] = 'v'
    else:
        loopstart = goto
        break
loop = been[been.index(loopstart):]

print(loop[(k+1-loopstart)%(len(loop)+been.index(loopstart))])

Buggy submission (verdict: Runtime Error):
from collections import deque
n,k = map(int,input().split())
alist = list(map(int,input().split()))


flag = ['.']*(n+1)
flag[1] = 'v'

been = [1]

for i in range(k):
    goto = alist[been[-1]-1]
    if flag[goto] == '.':
        been.append(goto)
        flag[goto] = 'v'
    else:
        loopstart = goto
        break
loop = been[been.index(loopstart):]
print(loop[(k-loopstart)%len(loop)])