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

Fixed submission:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

#素因数分解
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a



#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])


for i in reversed(range(math.floor(M/N)+1)):
  f = M/i
  if(f.is_integer() == True):
    if(N*i<=M):
      ans = i
      break


print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])

for i in reversed(range(1,M)):
  f = M/i
  if(f.is_integer() == True):
    #print(i)
    if(N*i<=M):
      ans = i
      break


print(ans)
Problem p03436 (python)

Fixed submission:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#幅優先探索（別ver）
def bfs(sx, sy):
  que = deque([[sy,sx]])
  D =  [(0,1), (1,0), (0,-1), (-1,0)]
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "#"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
  return


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

H,W = map(int,input().split())
G = [list(map(str, input())) for i in range(H)]
ans = 0
n = 0

#print(S)

for i in range(H):
    for j in range(W):
        if(G[i][j]=="."):
            n += 1
#print(n)
G[0][0] = 0
bfs(0,0)
#print(S)

if(type(G[H-1][W-1]) is str):
    ans = -1
else:
    ans = n - G[H-1][W-1]-1


print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = xytuple[2] +1 #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = xytuple[2] +1 #探索した場所は探索できないようにする
        q.append(temptuple)
      #print(q)
  return mlength


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

H,W = map(int,input().split())
S = [list(map(str, input())) for i in range(H)]
ans = 0
n = 0

#print(S)

for i in range(H):
    for j in range(W):
        if(S[i][j]=="."):
            n += 1
#print(n)
bfs(S,0,0,H,W)
#print(S)
ans = n - S[H-1][W-1]

if(type(S[H-2][W-2]) is str and type(S[H-2][W-1]) is str and type(S[H-1][W-2]) is str):
    ans = -1



print(ans)
Problem p02678 (python)

Fixed submission:
import collections
import itertools
N, M = list(map(int, input().split()))
ABs = [list(map(int, input().split())) for _ in range(M)]

loads = [[] for _ in range(N+1)]

for AB in ABs:
    loads[AB[0]].append(AB[1])
    loads[AB[1]].append(AB[0])


dq = collections.deque()

dq.append(1)
ans_list = [0 for _ in range(N+1)]

#print(loads)
print("Yes")
while len(dq) != 0:
    i = dq.popleft()

    for vec in loads[i]:
#        print(vec)
        if(ans_list[vec] == 0):
            ans_list[vec] = i
            dq.append(vec)
#        print(ans_list)
#        print(dq)


for ans in ans_list[2:]:
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import itertools
N, M = list(map(int, input().split()))
ABs = [list(map(int, input().split())) for _ in range(M)]

ans_list = [0] * (N+1)

dq = collections.deque()

dq.append(1)

for hoge in range(500000)
    i = dq.popleft()
    iList = [temp for temp in ABs if i in temp]

    iList = list(itertools.chain.from_iterable(iList))
    iList = [temp for temp in iList if iList !=i]

    for hoge in iList:
        if(ans_list[hoge] == 0):
            ans_list[hoge] = i
        dq.append(hoge)

    if(0 not in ans_list[2:]):
        break

for ans in ans_list[2:]:
    print(ans)
Problem p02691 (python)

Fixed submission:
from collections import defaultdict
import numpy as np
import collections

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

B = defaultdict(int)

ans = 0

for index, A in enumerate(As):
    ans += B[index-A]
    
    B[index+A] += 1
#    print(B)
#    print(list(B[:20]))

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

B = np.zeros(11 * 10**8, dtype = "uint32")

ans = 0

for index, A in enumerate(As):
    if(index - A >= 0):
        ans += B[index-A]

    B[index+A] += 1
#    print(list(B[:20]))

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

B = np.zeros(3 * 10**9, dtype = "int32")

ans = 0

for index, A in enumerate(As):
    ans += B[index-A]

    B[index+A] += 1
#    print(list(B[:20]))

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

B = np.zeros(2 * 10**9, dtype = int)

ans = 0

for index, A in enumerate(As):
    if(index - A >= 0):
        ans += B[index-A]

    B[index+A] += 1
#    print(list(B[:20]))

print(ans)
Problem p02705 (python)

Fixed submission:
R = int(input())
ans = R * 2 * 3.1415
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

print(sum)
Problem p02706 (python)

Fixed submission:
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
#print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

#print(sum)

ans = N - sum
if(ans >= 0):
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
#print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

#print(sum)

ans = N - sum
if(ans > = 0):
    print(ans)
else:
    print(-1)
Problem p02714 (python)

Fixed submission:
import collections

N = int(input())
S = input()

CountRGB = collections.Counter(S)

ans = CountRGB["R"] * CountRGB["G"] * CountRGB["B"]

tmp = 0
for i in range(N-2):
    for j in range(i+1, N-1):

        if(2 * j - i > N - 1):
            break

        checker = []
        checker.append(S[i])
        checker.append(S[j])
        checker.append(S[2 * j - i])

        c = collections.Counter(checker)

        if(c["R"] == 1 and c["G"] == 1 and c["B"] == 1):
            tmp +=1

print(ans - tmp)

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

#S = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"

Slist = list(S)

count = 0
for i in range(len(Slist)):
    for j in range(i+1, len(Slist)):
        for k in range(j+1, len(Slist)):
            if(Slist[i] == Slist[j]):
                break
            notEqualColor = (Slist[i] == Slist[j] or Slist[j] == Slist[k] or Slist[k] == Slist[i])
            notEqualDistance = (j - i == k - j)

            if((notEqualColor or notEqualDistance) == False):
                count += 1

print(count)
Problem p02719 (python)

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

print(min(n % k, abs(k - (n % k))))

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

print(min(n % k, abs(k - (n % k))))
Problem p02791 (python)

Fixed submission:
import math

N = int(input())

tmp = 10 ** 30
ans = 0
for P in list(map(int,input().split())):
    if P <= tmp:
        tmp = P
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

tmp = math.inf
ans = 0
for P in list(map(int,input().split())):
    if P <= tmp:
        tmp = P
        ans += 1

print(ans)
Problem p02911 (python)

Fixed submission:
N,K,Q = list(map(int , input().split()))
As = [int(input()) for _ in range(Q)]

#特典初期設定
Score = [0 for _ in range(N)]

for A in As:
    Score[A-1] +=1

for ans in Score:
    if(K + ans - Q > 0):
        print("Yes")
    
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N,K,Q = list(map(int , input().split()))
As = [int(input()) for _ in range(Q)]

#特典初期設定
Score = [K for _ in range(N)]

for A in As:
    Score -= 1
    Score[A - 1] += 1

for ans in Score:
    if(ans > 0):
        print("Yes")
    
    else:
        print("No")
Problem p02945 (python)

Fixed submission:
# -*- config: utg-8 -*-

i = list(map(int, input().split()))

a = i[0]
b = i[1]

wa = a + b
sa = a- b
seki = a * b

print(max(wa,sa,seki))

Buggy submission (verdict: Runtime Error):
# -*- config: utg-8 -*-

n = int(input())
s = [input() for i in range(n)]

sort_list = []

for i in s:
	str_sort_list = sorted(i)
	new_str = ''.join(str_sort_list)
	sort_list.append(new_str)

count = 0
for i in sort_list[:]:
  hoge = sort_list.pop(0)
  chohuku_count = sort_list.count(hoge)
  
  count += chohuku_count
  

print(count)
Problem p02947 (python)

Fixed submission:
import collections
N = (int(input()))

ans = 0
counter_list = []

for _ in range(N):
    s = input()
    counter_list.append("".join(sorted(s)))

ans = 0
wordcount = {}
for word in counter_list:
    if word in wordcount:
        wordcount[word] += 1
        ans += (wordcount[word])
    else:
        wordcount[word] = 0

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- config: utg-8 -*-

n = int(input())
s = [input() for i in range(n)]

sort_list = []

for i in s:
	str_sort_list = sorted(i)
	new_str = ''.join(str_sort_list)
	sort_list.append(new_str)

count = 0
for i in sort_list:
  hoge = sort_list.pop(0)
  chohuku_count = sort_list.count(hoge)
  sort_list.remove(hoge)
  
  sum = 0
  for i in range(chohuku_count+1):
    sum += i
  count += sum
  

print(count)

Buggy submission (verdict: Runtime Error):
# -*- config: utg-8 -*-

n = int(input())
s = [input() for i in range(n)]

sort_list = []

for i in s:
	str_sort_list = sorted(i)
	new_str = ''.join(str_sort_list)
	sort_list.append(new_str)

count = 0
for i in sort_list:
  hoge = sort_list.pop(0)
  chohuku_count = sort_list.count(hoge)
  sort_list.remove(hoge)
  
  sum = 0
  for i in range(chohuku_count+1):
    sum += i
  count += chohuku_count
  

print(count)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])-1] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])-1] == True and collect[int(Alist[j][0])-1] == False:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])] == True:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
for j in range(M):
  if collect[int(Alist[j][0])] == False and Alist[j][1] == 'WA':
    NP += 1
  elif collect[int(Alist[j][0])] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])] = True

print(NAC, " ", NP)
Problem p02600 (python)

Fixed submission:
X=int(input())
if X<=599:
    k=8
elif 600<=X<=799:
    k=7
elif 800<=X<=999:
    k=6
elif 1000<=X<=1199:
    k=5
elif 1200<=X<=1399:
    k=4
elif 1400<=X<=1599:
    k=3
elif 1600<=X<=1799:
    k=2
else:
    k=1
print(k)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyoutei=[0]*(N+1)
for i in range(K,N):#K+1-N
    if A[i]/A[i-K]>1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
X=int(input())
if X<599:
    k=8
elif 600<=X<799:
    k=7
elif 800<=X<999:
    k=6
elif 1000<=X<1199:
    k=5
elif 1200<=X<1399:
    k=4
elif 1400<=X<1599:
    k=3
elif 1600<=X<1799:
    k=2
elif 1800<=X:
    k=1

print(k)
Problem p02602 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyoutei=[0]*(N+1)
for i in range(K,N):#K+1-N
    if A[i]/A[i-K]>1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyoutei=[0]*(N+1)
for i in range(K,N):#K+1-N
    if A[i]/A[i-K]>1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyoutei=[0]*(N+1)
import numpy as np
for i in range(K,N+1):#K学期からN学期までの評定を計算
    hyoutei[i]=np.prod(np.array(A[i-K:i]))##K回目＝1回目ーK回目
    if i>K and hyoutei[i]>hyoutei[i-1]:
        print("Yes")
    elif i>K and hyoutei[i]<=hyoutei[i-1]:
        print("No")
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np
N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
money=9000000000
count=1
for i in range(1,N+1):
  test=itertools.combinations(CA,i)
  for j in test:#組み合わせごとに計算
    pre_ans=np.sum(j, axis=0)
    if pre_ans[0]<money and np.all(pre_ans[1:]>=X):
      money=pre_ans[0]
      count=0
if count==0:
  print(money)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
money=100000000000
count=1
for i in range(1,N):
  test=itertools.combinations(CA,i)
  for j in test:#組み合わせごとに計算
    pre_ans=np.sum(j, axis=0)
    if pre_ans[0]<money and np.all(pre_ans[1:]>=X):
      money=pre_ans[0]
      count=0
if count==0:
  print(money)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
#CA=sorted(CA, key=lambda x:sum(x[1:]))
money=100000000000000000000000000000
count=1
for i in range(1,N):
  test=itertools.combinations(CA,i)
  for j in test:#組み合わせごとに計算
    pre_ans=np.sum(j, axis=0)
    if pre_ans[0]<money and np.all(pre_ans[1:]>=X):
      money=pre_ans[0]
      count=0
if count==0:
  print(money)
else:
  print(-1)
Problem p02684 (python)

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

visited=[0]*N#訪問フラグ
ima_pos=0#現在地
mirai_pos=0#移動先

count_first=0#一巡目のループ
first_DP=[]
while(visited[ima_pos]==0):
  visited[ima_pos]=1#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  first_DP.append(ima_pos)#何番目のインデックスに移動するか
  count_first+=1#何回移動したか

second_start=ima_pos#2巡目ループのスタート地点
count_second=0#2巡目以降のループ
second_DP=[]

while(True):#スタート地点に戻ってきたら抜ける
  visited[ima_pos]=2#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  second_DP.append(ima_pos)
  count_second+=1#何回移動したか
  if ima_pos==second_start:
    break

#各DPには何番目(0から)スタートの町に行くか　が書かれている
if K<=count_first:
  print(first_DP[K-1]+1)
elif K>count_first:
  cc=K-count_first#残り何回移動するか
  if cc%count_second==0:
    print(second_DP[-1]+1)
  else:
    print(second_DP[cc%count_second-1]+1)

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

visited=[0]*N#訪問フラグ

ima_pos=0#現在地
mirai_pos=0#移動先

count_first=0#一巡目のループ
first_DP=[]

while(visited[ima_pos]==0):
  visited[ima_pos]=1#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  first_DP.append(ima_pos)
  count_first+=1#何回移動したか

second_start=ima_pos#2巡目ループのスタート地点
count_second=0#2巡目以降のループ
second_DP=[]

while(True):#スタート地点に戻ってきたら抜ける
  visited[ima_pos]=2#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  second_DP.append(ima_pos)
  count_second+=1#何回移動したか
  if ima_pos==second_start:
    break

if K<=count_first:
  print(first_DP[K]+1)
else:
  cc=K-count_first
  print(second_DP[cc%count_second-1]+1)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
DP=[[0,0] for i in range(N)]

visited=[0]*N#訪問フラグ
ima_pos=0#現在地
mirai_pos=0#移動先

count_first=0#一巡目のループ
first_DP=[]
count_second=0#2巡目以降のループ
second_DP=[]

while(visited[ima_pos]==0):
  visited[ima_pos]=1#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  first_DP.append(ima_pos)
  count_first+=1#何回移動したか

second_start=ima_pos#2巡目ループのスタート地点

while(True):#スタート地点に戻ってきたら抜ける
  visited[ima_pos]=2#訪れたら更新
  mirai_pos=A[ima_pos]-1
  ima_pos=mirai_pos
  second_DP.append(ima_pos)
  count_second+=1#何回移動したか
  if ima_pos==second_start:
    break

if K<=len(first_DP):
  print(first_DP[K]+1)
else:
  cc=K-len(first_DP)
  print(second_DP[ cc%len(second_DP)-1 ]+1)
Problem p02687 (python)

Fixed submission:
S=input()
if S=="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
import itertools
X=int(input())
li=[i**5 for i in range(128)]#
for v in itertools.permutations(li, 2):
    v=list(v)
    v.sort()
    if v[1]-v[0]==X:#両方プラスの時
        A=v[0]**0.2
        B=v[1]**0.2
        print(str(int(A))+" "+str(int(B)))
        break
    elif v[0]+v[1]==X:#v[1]がマイナスの時
        A=v[0]**0.2
        B=-1*((v[1])**0.2)
        print(str(int(A))+" "+str(int(B)))
        break
#ans=(i-j)*(i**4+(i**3)*j+(i**2)*(j**2)+i*(j**3)+j**4)
#(ａ－ｂ)(ａ⁴＋ａ³ｂ＋ａ²ｂ²＋ａｂ³＋小さい
Problem p02732 (python)

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

d = {}
for a in A:
  if a in d:
    d[a] += 1
  else:
    d[a] = 1

s = 0
for k in d:
    s += d[k] * (d[k] - 1) // 2

for i in range(N):
    t = d[A[i]]
    print(s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)

Buggy submission (verdict: Runtime Error):
N=int(input())
li = list(map(int,input().split()))
num=[None]*N
num_ans=[None]*N

for i in range(min(li),max(li)+1):
  num_ans[i]=(li.count(i)*(li.count(i)-1))/2
ans=sum(num_ans)

for k in range(N):
  before=li.count(li[k])*(li.count(li[k])-1)/2
  after=(li.count(li[k])-2)*(li.count(li[k])-1)/2
  print(int(ans-before+after))

Buggy submission (verdict: Runtime Error):
N=int(input())
li = list(map(int,input().split()))
num=[0]*N
num_ans=[0]*N

for i in range(max(li)+1):
  num[i]=li.count(i)
  num_ans[i]=(num[i]*(num[i]-1))/2
ans=sum(num_ans)

for k in range(N):
  num_k = li.count(li[k])
  before=num_k*(num_k-1)/2
  after=(num_k-2)*(num_k-1)/2
  print(int(ans-before+after))

Buggy submission (verdict: Runtime Error):
N=int(input())
li = list(map(int,input().split()))
num=[0]*N
num_ans=[0]*N

for i in range(max(li)+1):
  num[i]=li.count(i)
  num_ans[i]=(num[i]*(num[i]-1))/2
ans=sum(num_ans)

for k in range(N):
  li2=(li[:k]+li[k+1:])
  num_k = li.count(li[k])
  before=num_k*(num_k-1)/2
  after=(num_k-2)*(num_k-1)/2
  print(int(ans-before+after))
Problem p02761 (python)

Fixed submission:
import sys
n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]
for i in range(10**n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[j[0]-1]!=str(j[1]):
        tf=False
        break
    if tf:#全ループ終わって条件を満たしていれば
      print(i)
      sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd

n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]

for i in range(10^n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[j[0]]!=j[1]:
        tf=False
    if tf:
      print(i)
      sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd

n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]

for i in range(10^n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[SCs[0]]!=SCs[1]:
        tf=False
    if tf:
      print(i)
      sys.exit()
print(-1)