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

Fixed submission:
H, W  = map(int,input().split())
S = [list(map(str,input().split())) for i in range(H)]
char = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(H):
    for j in range(W):
        if S[i][j] == "snuke":
            tmp = [i,j]
ans = str(char[tmp[1]]) + str(tmp[0]+1)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W  = map(int,input().split())
S = [list(map(str,input().split())) for i in range(H)]
char = "ABCDEFGHIJ"
for i in range(H):
    for j in range(W):
        if S[i][j] == "snuke":
            tmp = [i,j]
ans = str(char[tmp[1]]) + str(tmp[0]+1)
print(ans)
Problem p03944 (python)

Fixed submission:
W,H,N = map(int,input().split())
bo = [[0]*W]*H
for i in range(N):
    x,y,z = map(int,input().split())
    if z == 1:
        for j in range(H):
            for k in range(x):
                bo[j][k] = 1
    elif z == 2:
        for j in range(H):
            for k in range(x,W,1):
                bo[j][k] = 1
    elif z == 3:
        for j in range(y):
            bo[j] = [1]*W
    else:
        for j in range(H-1,y-1,-1):
            bo[j] = [1]*W

sum = 0

for i in range(H-1,-1,-1):
    sum += bo[i][:].count(1)
print((W*H)-sum)

Buggy submission (verdict: Runtime Error):
W,H,N = map(int,input().split())
bo = [[0]*W]*H
li = [list(map(int,input().split())) for i in range(N)]
for i in range(N):
    if li[i][2] == 1:
        for j in range(li[i][0]):
            bo[i][j] = 1
    elif li[i][2] == 2:
        for j in range(li[i][0],W,1):
            bo[i][j] = 1
    elif li[i][2] == 3:
        for j in range(li[i][1]):
            bo[j] = [1]*W
    else:
        for j in range(H-1,li[i][1]-1,-1):
            bo[j] = [1]*W

sum = 0

for i in range(H):
    sum += bo[i][:].count(1)
print((W*H)-sum)
Problem p02731 (python)

Fixed submission:
sum_ = float(input())
taiseki = float((sum_/3)**3)
print('%.7f'%taiseki)

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

b_l = list(range(int(b/0.1), int((b+0.99)//0.1+1)))
for b_ in b_l:
  s = int(b_*0.08//1)
  if s==a:
    print(str(b_))
    exit(0)
print(-1)
Problem p02732 (python)

Fixed submission:
inp = int(input())
lis = list(map(int, input().split()))

dic = {}

#count
for l in lis:
  if l in dic: dic[l] += 1
  else: dic[l] = 1

#dic_sum = dic.copy()
s = 0
#calcurate
for d in dic:
  s += int(dic[d]*(dic[d]-1)//2)
  
for i in range(inp):
  #dic_sum_n = dic_sum.copy()
  t = dic[lis[i]]
  print(s-int(t*(t-1)//2)+int((t-1)*(t-2)//2))

Buggy submission (verdict: Runtime Error):
#count
for l in lis:
  if l in dic: dic[l] += 1
  else: dic[l] = 1

#dic_sum = dic.copy()
s = 0
#calcurate
for d in dic:
  s += int(dic[d]*(dic[d]-1)/2)
  
for i in range(inp):
  #dic_sum_n = dic_sum.copy()
  t = dic[lis[i]]
  print(s-int(t*(t-1)/2)+int((t-1)*(t-2)/2))
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split(' '))

b_l = list(range(int(b/0.1), int((b+0.99)//0.1+1)))
for b_ in b_l:
  s = int(b_*0.08//1)
  if s==a:
    print(str(b_))
    exit(0)
print('-1')

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

b_l = list(range(int(b/0.1), int((b+0.99)//0.1+1)))
for b_ in b_l:
  s = int(b_*0.08//1)
  if s==a:
    print(str(b_))
    exit(0)
prin('-1')
Problem p03147 (python)

Fixed submission:
le = int(input())
ll = list(map(int, input().split()))
 
res = ll[0]
for i in range(1, le):
    if(ll[i-1] < ll[i]): res += ll[i]-ll[i-1]
print(res)

Buggy submission (verdict: Runtime Error):
le = int(input())
ll = list(map(int, input().split()))
 
res = h[0]
for i in range(1, ll):
    if(ll[i-1] < ll[i]): res += ll[i]-ll[i-1]
print(res)
Problem p03773 (python)

Fixed submission:
A,B = (map(int, input().split()))
print (A + B if A + B < 24 else A + B - 24)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = 10

for i in reversed(range(1,int(math.sqrt(N)) + 1)):
    if N % i == 0:
        A = len(str(i))
        B = len(str(N //  i))
        print (N // i)
        ans = min(ans,max(A,B))

print(ans)
Problem p03861 (python)

Fixed submission:
a,b,x = map(int, raw_input().split())
print b / x - (a-1) / x

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
cnt = 0
if b > 10 ** 9:
        cnt = (b-a) / c
        print (cnt)
else:
    for i in range(a,b+1):
        if i % c == 0:
            cnt += 1
    print (cnt)
Problem p02823 (python)

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

center = abs(a-b) // 2
# restore
if abs(a-b) % 2 == 0:
    print(center)
else:
    leftside = a - 1
    rightside = n - b
    
    print(min(leftside,rightside) + 1 + (b-a-1)//2)

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

center = abs(a-b) // 2
# restore
if abs(a-b) % 2 == 0:
    print(center)
else:
    leftside = a - 1
    rightside = n - b
    
    print(min(leftside,rightside) + 1 + (B-A-1)//2)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
ACed = [0] * (N + 1)
WAed = [0] * (N + 1)
WA_count = 0
AC_count = 0
WA_sum = 0

for i in range(M):
    p, s = input().split()
    p = int(p)

    if s == 'WA':
        WAed[p] += 1

    if s == 'AC' and ACed[p] == 0:
        ACed[p] = 1
        AC_count += 1
        WA_sum += WAed[p]

print(AC_count, WA_sum)

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

answerd = [0] * 10010
WA_count = 0
AC_count = 0

for i in range(M):
    p, s = input().split()
    p = int(p)

    if s == 'WA' and answerd[p] == 0:
        WA_count += 1

    elif s == 'AC' and answerd[p] == 0:
        AC_count += 1
        answerd[p] = 1

print(AC_count, WA_count)
Problem p02705 (python)

Fixed submission:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

R = intinput()
print(2*R*3.1415)

Buggy submission (verdict: Runtime Error):
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

R = intinput()
print(2*R*3.1415)

Buggy submission (verdict: Runtime Error):
R = intinput()
print(2*R*3.1415)
Problem p02756 (python)

Fixed submission:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

s = deque()
s.append(input())
Q = int(input())
rev_count = 0

for i in range(Q):
    a = input()
    if a[0] == "1":
        rev_count += 1
    else:
        b = a.split()
        if rev_count % 2 == 0:
            if b[1] == "1":
                s.appendleft(b[2])
            else:
                s.append(b[2])
        else:
            if b[1] == "1":
                s.append(b[2])
            else:
                s.appendleft(b[2])

if rev_count % 2 == 0:
    print(''.join(s))
else:
    a = ''.join(s)
    print(a[::-1])

Buggy submission (verdict: Runtime Error):
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

s = input()
Q = intinput()
rev_count = 0

for i in range(Q):
    a = input()
    if a[0] == "1":
        rev_count += 1
    else:
        b = a.split()
        if rev_count % 2 == 0:
            if b[1] == "1":
                s = b[2] + s
            else:
                s = s + b[2]
        else:
            if b[1] == "1":
                s = s + b[2]
            else:
                s = b[2] + s

if rev_count % 2 == 0:
    print(s)
else:
    print(s[::-1])
Problem p02803 (python)

Fixed submission:
from collections import deque    
H,W = map(int, input().split())
maze = []
ans = 0
dist =[]
q = deque([])
tmp = 0

for i in range(H):
    maze.append(input())

for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            continue
        dist = [[-1]*W for i in range(H)] # 配列の初期化
        q.append([i,j]) #初期値挿入
        dist[i][j] = 0
        while(q):
            a,b = q.popleft()
            if a + 1 < H:
                if maze[a+1][b] == '.' and dist[a+1][b] == -1:
                    q.append([a+1, b])
                    dist[a+1][b] = dist[a][b] + 1
                    tmp = dist[a+1][b] 
            if a > 0:
                if maze[a-1][b] == '.' and dist[a-1][b] == -1:
                    q.append([a-1, b])
                    dist[a-1][b] = dist[a][b] + 1
                    tmp = dist[a-1][b]
            if b + 1 < W:
                if maze[a][b+1] == '.' and dist[a][b+1] == -1:
                    q.append([a, b+1])
                    dist[a][b+1] = dist[a][b] + 1
                    tmp = dist[a][b+1]
            if b > 0:
                if maze[a][b-1] == '.' and dist[a][b-1] == -1:
                    q.append([a, b-1])
                    dist[a][b-1] = dist[a][b] + 1
                    tmp = dist[a][b-1]
        ans = max(ans,tmp)


print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque    
H,W = map(int, input().split())
maze = []
ans = 0
dist =[]
q = deque([])

for i in range(H):
    maze.append(input())

for i in range(H):
    for j in range(W):
        dist = [[-1]*W for i in range(H)] # 配列の初期化
        q.append([i,j]) #初期値挿入
        dist[i][j] = 0
        while(q):
            a,b = q.popleft()
            if a + 1 < H:
                if maze[a+1][b] == '.' and dist[a+1][b] == -1:
                    q.append([a+1, b])
                    dist[a+1][b] = dist[a][b] + 1
                    tmp = dist[a+1][b] 
            if a > 0:
                if maze[a-1][b] == '.' and dist[a-1][b] == -1:
                    q.append([a-1, b])
                    dist[a-1][b] = dist[a][b] + 1
                    tmp = dist[a-1][b]
            if b + 1 < W:
                if maze[a][b+1] == '.' and dist[a][b+1] == -1:
                    q.append([a, b+1])
                    dist[a][b+1] = dist[a][b] + 1
                    tmp = dist[a][b+1]
            if b > 0:
                if maze[a][b-1] == '.' and dist[a][b-1] == -1:
                    q.append([a, b-1])
                    dist[a][b-1] = dist[a][b] + 1
                    tmp = dist[a][b-1]
        ans = max(ans,tmp)


print(ans)
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    if S[i:i+3] == 'ABC':
       ans += 1 
print(ans)

Buggy submission (verdict: Runtime Error):
33
ABCCABCBABCCABACBCBBABCBCBCBCABCB
Problem p02927 (python)

Fixed submission:
m, d = map(int,input().split())
ans = 0

for i in range(1,m+1):
    for j in range(1, d + 1):
        if i == int(j/10)*int(j%10) and int(j%10) >= 2 and int(j/10) >= 2:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):

from decimal import *
getcontext().prec = 28
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = Decimal(0)
outer = Decimal(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

b = (Decimal(Decimal(inner) * Decimal(k)) + Decimal(Decimal(outer) * Decimal(Decimal(k) * Decimal(k-1)) / 2))
print(Decimal(Decimal(b)%Decimal(1000000007)))

Buggy submission (verdict: Runtime Error):
import sys
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = float(0)
outer = float(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

b = (int(inner * int(k)) + int(outer * int(k) * int(k-1) / 2))
print(int(b%int(1000000007)))
Problem p02928 (python)

Fixed submission:
from decimal import *
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = 0
outer = 0
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

print((Decimal(((inner) * (k)) + Decimal((outer) * Decimal((k) * (k-1)) / 2))%(1000000007)))

Buggy submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 20
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = Decimal(0)
outer = Decimal(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

print((Decimal(((inner) * (k)) + ((outer) * (Decimal(k) * (k-1)) / 2))%(1000000007)
Problem p02945 (python)

Fixed submission:
a, b =  map(int,input().split())
c = a + b
if c < a - b:
	c = a - b
if c < a * b:
	c = a * b
print(c)

Buggy submission (verdict: Runtime Error):
a, b =  map(int,input().split())
c = A + B
if c < A - B:
	c = A - B
if c < A * B:
	c = A * B
print(c)

Buggy submission (verdict: Runtime Error):
a, b =  map(int,input().split())
c = A + B
if c < A - B:
	c = A - B
if c < A * B:
	c = A * B:
print(c)

Buggy submission (verdict: Runtime Error):
a, b =  map(int,input().split())
c = A + B
if c < A - B:
  c = A - B
if c < A * B:
  c = A * B:
print(c)
Problem p03079 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b and b == c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a = b and b = c:
    print('Yes')
else:
    print('No')
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(0,a+1):
    if x < 500 * i:
        break
    if x == 500 * i:
        ans += 1
        break
    for j in range(0,b+1):
        if x < 500 * i + 100 * j:
            break
        if x == 500 * i + 100 * j:
            ans += 1
            break
        for k in range(0,c+1):
            if x < 500 * i + 100 * j + 50 * k:
                break
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
                break

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(0,a):
    if x < 500 * i:
        break
    if x == 500 * i:
        ans += 1
        break
    for j in range(0,b):
        if x < 500 * i + 100 * j:
            break
        if x == 500 * i + 100 * j:
            ans += 1
            break
        for k in range(0,c)
            if x < 500 * i + 100 * j + 50 * k:
                break
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
                break

print(ans)
Problem p03494 (python)

Fixed submission:
n = int(input())
a = map(int,input().split())
ans = 1000
tmp = 0
for i in a:
    tmp = 0
    while i % 2 == 0:
        i = i / 2
        tmp += 1
    if ans > tmp:
        ans = tmp
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
ans = 1000
tmp = 0
for i in a:
    tmp = 0
    while i % 2 == 0:
        i = i / 2
        tmp += 1
    if max > tmp:
        ans = tmp
print(ans)
Problem p03502 (python)

Fixed submission:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
tmp = N
divs = 0

while tmp:
    divs += tmp % 10
    tmp = int(tmp/10)

if N % divs == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

N = intinput()
tmp = N
divs = 0

while tmp:
    divs += tmp % 10
    tmp = int(tmp/10)

if N % divs == 0:
    print('Yes')
else:
    print('No')
Problem p03605 (python)

Fixed submission:
x=input()
if x[0] =='9' or x[1] == '9':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
x, a, b = map(int,input().split())
if b < a:
    print('delicious')
elif b <= a + x:
    print('safe')
else:
    print('dangerous')
Problem p03635 (python)

Fixed submission:
n, m = map(int,input().split())
print((n - 1) * (m - 1))

Buggy submission (verdict: Runtime Error):
n, m = map(int,inpout().split())
print((n - 1) + (m * 1))
Problem p03814 (python)

Fixed submission:
s = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] == 'A':
        ans -= i
##        print('i')
        break

for j in reversed(range(0, n)):
    if s[j] == 'Z':
        ans += j
        break

print(ans + 1)

Buggy submission (verdict: Runtime Error):
m,n = map(int,input().split())
a = []*m
b = []*n
flag = False
for i in range(m):
    a.append(input())
for j in range(n):
    b.append(input())

for i in range(0, m-n):#比較開始を縦方向に動かす
    for j in range(0, m-n):#比較開始を横方向へ動かす
        for k in range(0,n):
            if b[k] != a[i][j:j+n]:
                break
            flag = True

if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
m,n = map(int,input().split())
a = []*m
b = []*n
flag = False
for i in range(m):
    a.append(input())
for j in range(n):
    b.append(input())

for i in range(0, m-n):#比較開始を縦方向に動かす
    for j in range(0, m-n):#比較開始を横方向へ動かす
        for k in range(0,n):
            if b[k] != a[i][j:j+n]:
                break
            flag = True

if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
m,n = map(int,input().split())
a = []*m
b = []*n
flag = False
for i in range(m):
    a.append(input())
for j in range(n):
    b.append(input())

for i in range(0, m-n):#比較開始を縦方向に動かす
    for j in range(0, m-n):#比較開始を横方向へ動かす
        for k in range(0,n):
            if b[k] != a[i][j:j+n]:
                break
            flag = True

if flag:
    print('Yes')
else:
    print('No')
Problem p03282 (python)

Fixed submission:
import sys
S = input()
K = int(input())
for k in range(K):
  if S[k] != "1":
    print(S[k])
    sys.exit()
print(1)

Buggy submission (verdict: Runtime Error):
print(input().replace("1","")[0])
Problem p02684 (python)

Fixed submission:
#import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N,K = LI()
A = LI()

#方針
#ループ検知でmod演算に移行
hist = []
now = 0
chk = [-1] * N
while True:
	hist.append(now+1)
	if chk[now] != -1:
		# ループ検知
		break
	chk[now] = len(hist)-1
	now = A[now]-1
#print("histpos[town]:",chk)
#print("hist:",hist)
loopstart = chk[hist[len(hist)-1]-1]+1
if K >= len(hist):
	K-=loopstart
	K%=len(hist)-loopstart
	print(hist[loopstart+K])
else:
	print(hist[K])

Buggy submission (verdict: Runtime Error):
#import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N,K = LI()
A = LI()

#方針
#ループ検知でmod演算に移行
hist = []
now = 0
chk = [-1] * N
while True:
	hist.append(now+1)
	if chk[now] != -1:
		# ループ検知
		break
	chk[now] = len(hist)-1
	now = A[now]-1
K-=chk[hist[len(hist)-1]-1]
cutlist = hist[hist[len(hist)-1]+1:]
K%=len(cutlist)
print(cutlist[K-1])
#print("histpos[town]:",chk)
#print("hist:",hist)
Problem p02755 (python)

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

a = [i for i in range(int((A-1)*100/8 ), int((A+1)*100/8 ))]
b = [i for i in range(int((B-1)*100/10), int((B+1)*100/10))]

a = [i for i in a if int(i*0.08) == A]
b = [i for i in b if int(i*0.10) == B]

ans = list(set(a) & set(b))
if ans and min(ans) > 0:
    print(min(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a = [i for i in range(int((A-1)*100/8 ), int((A+1)*100/8 ))]
b = [i for i in range(int((B-1)*100/10), int((B+1)*100/10))]

a = [i for i in a if int(i*0.08) == A]
b = [i for i in b if int(i*0.10) == B]

ans = list(set(a) & set(b))
if ans and min(ans) > 0:
    print(min(ans))
else:
    print(-1)
Problem p02802 (python)

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

Qa,Qw = {}, {}
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if p not in Qa:
        Qa[p] = 0

    if p not in Qw:
        Qw[p] = 0

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa.values()])
WA = sum([Qw[k] for k,v in Qa.items() if v > 0])
print( AC, WA)

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

Qa,Qw = [0 for _ in range(N)], [0 for _ in range(N)]
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa])
WA = sum([Qw[i] for i in Qa if Qa[i] > 0])
print( AC, WA)