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

Fixed submission:

def main():
    N = int(input())
    cases = dict()
    for _ in range(N):
        s = input()
        cases[s] = cases.get(s, 0) + 1
    
    results = ["AC", "WA", "TLE", "RE"]

    for r in results:
        print(f"{r} x {cases.get(r, 0)}")
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    N = int(input())
    cases = dict()
    for _ in range(N):
        s = input()
        cases[s] = cases.get(s, 0) + 1
    
    results = ["AC", "WA", "TLE", "RE"]

    for r in results:
        print(f"{r} x {cases[r]}")
    

if __name__ == '__main__':
    main()
Problem p02614 (python)

Fixed submission:
from itertools import combinations as comb
from bisect import bisect_left

import numpy as np
def main():
    H, W, K = map(int, input().split())
    cells = []
    count = 0
    for _ in range(H):
        row = [w for w in input()]
        cells.append(row)

    original = np.copy(np.array(cells))
    black = np.count_nonzero(cells == '#')
    #print(f"black={black}")
    for i in range(H+1):
        for iconb in comb(range(H), i):
            for j in range(W+1):
                for jconb in comb(range(W), j):
                    cells = np.copy(original)
                    cells[iconb, :] = '-'
                    cells[:, jconb] = '-'
                    black = np.count_nonzero(cells == '#')
                    #print(f"black={black} iconb={iconb} jconb={jconb}")
                    if black == K:
                        count += 1
    print(count)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
    #print(f"black={black}")
    for i in range(H+1):
        for iconb in comb(range(H), i):
            for j in range(W+1):
                for jconb in comb(range(W), j):
                    cells = np.copy(original)
                    cells[iconb, :] = '-'
                    cells[:, jconb] = '-'
                    black = np.count_nonzero(cells == '#')
                    #print(f"black={black} iconb={iconb} jconb={jconb}")
                    if black == K:
                        count += 1
    print(count)

if __name__ == '__main__':
    main()
Problem p02684 (python)

Fixed submission:
def read_int():
    return int(input())

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

def read_lines(N):
    return [input() for i in range(N)]

def main():
    N, K = read_ints()
    towns = [int(t) -1  for t in input().split() ]
    #print(N, K , towns)

    loop = []
    loop_set = set()
    next_town = towns[0]
    while next_town not in loop_set:
        #print(f"next_t={next_town}")
        loop.append(next_town)
        loop_set.add(next_town)
        next_town = towns[next_town]

    i = loop.index(next_town)
    all_loop = loop
    pre_loop = loop[:i]
    loop = loop[i:]
    pre_length = len(pre_loop)
    loop_length = len(loop)

    """
    for k in range(1, 10):
        if k - 1  < len(all_loop):
            print(f"k={k}", all_loop[k-1] + 1)
        else:
            i = ((k -1 - len(pre_loop)) % loop_length)
            print(i, pre_loop, loop)
            print(f"k={k}", loop[i]+1)
    """

    #print(pre_loop, loop)
    if K - 1  < len(all_loop):
        print(all_loop[K-1] + 1)
    else:
        i = ((K -1 - pre_length) % loop_length)
        #print(i, pre_loop, loop)
        print(loop[i]+1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def read_int():
    return int(input())

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

def read_lines(N):
    return [input() for i in range(N)]

def main():
    N, K = read_ints()
    towns = np.array(list(read_ints())) - 1
    portals = {i: towns[i] for i in towns}

    loop = []
    next_town = 0
    while next_town not in loop:
        loop.append(next_town)
        next_town = portals[next_town]
    loop.append(next_town)

    i = loop.index(next_town)
    all_loop = loop
    pre_loop, loop = loop[:i], loop[i:]

    if K < len(pre_loop):
        print(pre_loop[K] + 1)
    elif len(pre_loop) <= K < len(all_loop):
        print(loop[K - len(pre_loop)] + 1)
    else:
        print(loop[(K - len(pre_loop)) % len(loop)] + 1)
        



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def read_int():
    return int(input())

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

def read_lines(N):
    return [input() for i in range(N)]

def main():
    N, K = read_ints()
    towns = [int(input()) - 1 for i in range(N)]
    portals = {i: towns[i] for i in towns}

    loop = []
    next_town = 0
    while next_town not in loop:
        loop.append(next_town)
        next_town = portals[next_town]
    loop.append(next_town)

    i = loop.index(next_town)
    all_loop = loop
    pre_loop, loop = loop[:i], loop[i:]

    if K < len(pre_loop):
        print(pre_loop[K] + 1)
    elif len(pre_loop) <= K < len(all_loop):
        print(loop[K - len(pre_loop)] + 1)
    else:
        print(loop[(K - len(pre_loop)) % len(loop)] + 1)
        



if __name__ == '__main__':
    main()
Problem p02731 (python)

Fixed submission:
L = float(input())
print((L/3)**3)

Buggy submission (verdict: Runtime Error):
L = int(input())
print((L/3)**3
Problem p02741 (python)

Fixed submission:
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(L[K-1])

Buggy submission (verdict: Runtime Error):
[a, b, c] = map(int, input().split())
if(a==0 | b==0):
    Left = a+b
    Right = c
else:
    Left = 4*a*b
    Right = (c-a-b)*(c-a-b)
if(Left < Right):
    print('Yes')
else:
    print('No')
Problem p02612 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,string
import sys
# sys.setrecursionlimit(1000000)
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 = I()
# A = [LI() for _ in range(N)]

l = len(str(N))

if l <= 3:
    a = 1000 - N
elif N % 1000 == 0:
    a = 0
else:
    a = 1000 - (N % 1000) 

print(a)

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
# sys.setrecursionlimit(1000000)
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 = I()
# A = [LI() for _ in range(N)]

l = len(str(N))

if l <= 3:
    a = 1000 - N
elif N % 1000 == 0:
    a = 0
else:
    a = 1000 - (N % 1000) 

print(a)
Problem p02614 (python)

Fixed submission:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

H, W, K = LI()
c = SRL(H)

ans=0
 
for i in range(2**H):
    seen=[]
    for n in range(H):
        if ((i>>n) & 1):
            seen.append(c[n])
    for j in range(2**W):
        count=0
        for m in range(W):
            if ((j>>m) & 1):
                for l in range(len(seen)):
                    if seen[l][m]=="#":
                        count+=1

        if count==K:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
A
H, W, K = LI()
c = SRL(H)

ans=0
 
for i in range(2**H):
    seen=[]
    for n in range(H):
        if ((i>>n) & 1):
            seen.append(c[n])
    for j in range(2**W):
        count=0
        for m in range(W):
            if ((j>>m) & 1):
                for l in range(len(seen)):
                    if seen[l][m]=="#":
                        count+=1

        if count==K:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

H, W, K = IR(3)
c = SRL(H)

ans=0
 
for i in range(2**H):
    seen=[]
    for n in range(H):
        if ((i>>n) & 1):
            seen.append(c[n])
    for j in range(2**W):
        count=0
        for m in range(W):
            if ((j>>m) & 1):
                for l in range(len(seen)):
                    if seen[l][m]=="#":
                        count+=1
]
        if count==K:
            ans+=1
print(ans)
Problem p02641 (python)

Fixed submission:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

X, N = LI()
P = LI()
# u = X
# d = X
# Pに含まれない整数（負も含まれる）で最もXに近くて最小の値を探す

if N == 0:
    print(X)
    sys.exit()

elif (N != 0) and (X not in P):
    print(X)
    sys.exit()

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda x: (abs(x - X), x))  # maspyさん解法
# python の min() は、順序比較のためのキーを指定できて、abs(x-X) が最小のもののうち x が最小のものをとるとかはこんな感じで書いたりできます。
print(ans)

Buggy submission (verdict: Runtime Error):
from _typeshed import ReadableBuffer
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

X, N = LI()
P = LI().sort()

# Pに含まれない整数（負も含まれる）で最もXに近くて最小の値を探す

if N == 0:
    print(X)
    sys.exit()

elif (X not in P) and (N != 0):
    print(X)
    sys.exit()

else:
    while X in P:
        X = X - 1
    print(X)
    sys.exit()
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
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())
from collections import defaultdict
n = I()

def primes(n):
    cnt = defaultdict(int)
    for i in range(2,int(n**0.5)+1): # range(3)だと、0,1,2が出てくる。
        while n % i == 0:
            cnt[i] += 1 # 同じ素数で何回割れるか辞書型で登録しておく
            n //= i # iで割り切った商で更新しておく
    if n > 1: # nの平方根より大きい値があった場合、追加
        cnt[n] += 1
    return cnt

prs = primes(n) #　素数の辞書
l = 0
ans = 0
for key in prs.keys(): #辞書から素数を抽出して、その素数の指数値をvとして格納する。
    v = prs[key]
    for i in range(100):
        if (i * (i+1)) // 2 <= v:
            ans += (i)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
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())
from collections import defaultdict
n = I()
n_z = n # n/z
p = 2 # 最初の素数
e = 1

def primes(n):
    cnt = defaultdict(int)
    for i in range(2,int(n**0.5)+1): # range(3)だと、0,1,2が出てくる。
        while n % i == 0:
            cnt[i] += 1 # 同じ素数で何回割れるか辞書型で登録しておく
            n //= i # iで割り切った商で更新しておく
    return cnt

prs = primes(n) #　素数の辞書
l = 0
ans = 0
for key in prs.keys(): #辞書から素数を抽出して、その素数の指数値をvとして格納する。
    v = prs[key]
    for i in range(100):
        if (i * (i+1)) // 2 <= v:
            ans += (i)
print(ans)

Buggy submission (verdict: Runtime Error):
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b.replace(".", ""))
output = a * b // 100
print(output)

Buggy submission (verdict: Runtime Error):
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b.replace(".", ""))
# floatをそのまま掛け算すると大きい計算で誤差が生じるため、.を消してintにする。
output = a * b // 100
# 小数点は2桁までで確定なので、100で切り捨て除算する。
print(output)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
import math
a, b = input().split()
c = int(math.floor(int(a) * float(b))
print(c)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(double, input().split())
c = int(math.floor(a * b))
print(c)
Problem p02658 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def input():
    return sys.stdin.readline()[:-1]
n = int(input())
l = list(map(int, input().split(" ")))
output = 1

if 0 in l:
    print(0)
    sys.exit()

for i in range(n):
    output = output * int(l[i])
    if output > 10 ** 18:
        output = -1
        break
print(output)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i] 
    if b > 10 ** 18:
        b = -1
    b = int(b)
    return b
b = multi(b,l)
print(b)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i] 
    if b > 10 ** 18:
        b = -1
    return b
b = int(multi(b,l))
print(b)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i-1] 
    if b > 10 ** 18:
        b = -1
    return b
b = multi(b,l)
print(b)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(b,l):
    for a in l:
        b = b * a 
    if b > 10 ** 18:
        b = -1
    return b
b = multi(b,l)
print(b)

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(1000000)
n = int(input())
l = list(map(int, input().split()))
b = 1
for a in l:
    b = b * a 
if b > 10 ** 18:
    b = -1
print(b)
Problem p02660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
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())
from collections import defaultdict
n = I()
def primes(n):
    cnt = defaultdict(int)
    for i in range(2,int(n**0.5)+1): # range(3)だと、0,1,2が出てくる。
        while n % i == 0:
            cnt[i] += 1 # 同じ素数で何回割れるか辞書型で登録しておく
            n //= i # iで割り切った商で更新しておく
    if n > 1: # nの平方根より大きい値があった場合、追加
        cnt[n] += 1
    return cnt
prs = primes(n) #　素数の辞書
ans = 0
for key in prs.keys(): #辞書から素数を抽出して、その素数の指数値をvとして格納する。
    v = prs[key]
    for i in range(100):
        # if (i * (i+1)) // 2 <= v:　これだと何度も足し算してしまう。
        if (i * (i + 1)) // 2 > v: # 指数eを超えた一つ前が目的の計数である。
            ans += (i-1)
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
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 = I()
n_z = n # n/z
prime_e = [] # 素数**自然数のリスト
p = 2 # 最初の素数
e = 1

def fermat_test(q):
    if q == 2: return True
    elif q < 2 or q & 1 == 0: return False   # q & 1 == 0 偶数の場合のFalseを返す意。 


if n == 1:
    print(0)
    sys.exit()


while p * p <= n: # 素数pの2乗がnより大きいと1回も割れない。
    if n_z % p == 0:
        z = p ** e
        while n_z % z == 0:
            if z not in prime_e:
                n_z = int(n_z / z)
                prime_e.append(z)
            e += 1
            z = p ** e
    p += 1
    e = 1
    while fermat_test(p) == False:
        p += 1
print(len(prime_e)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
n = int(input()) # 素数のリスト
n_z = n # n/z
prime_e = []
p = 2 # 最初の素数
e = 1

def fermat_test(q):
    q = abs(q)
    if q == 2: return True
    elif q < 2 or q & 1 == 0:    # q & 1 == 0 偶数の場合の意。 
    # x(int) & y(int)と表記すると2進数表記にしたときに、各桁のどこかが一致する場合は1、どこも一致しない場合は0を返す。
    # 例えば10→2進数:1010と1→2進数:1を比較するとドコモ一致しないので、0が帰ってくる。
    # 2進数表記の偶数は一番下の桁が0のため、2進数表記の1は一致しないため、0が返ってくる。
        return False

while p * p <= n: # 素数pの2乗がnより大きいと1回も割れない。
    # print("current n_z: {}".format(n_z))
    if n_z % p == 0:
        z = p ** e
        while n_z % z == 0:
            n_z = n_z / z
            prime_e.append(z)
            e += 1
            z = p ** e           
    p += 1
    e = 1
    while fermat_test(p) == False:
        # print("{} is Not Prime".format(p))
        p += 1
print(len(prime_e)#, prime_e)
Problem p02681 (python)

Fixed submission:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

s = S()
t = S()

if len(s) + 1 == len(t):
    for i in range(len(s)):
        if s[i] != t[i]:
            print("No")
            sys.exit()
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

S = S()
T = S()

if len(S + 1) == len(T):
    for i in len(S):
        if S[i] != T[i]:
            print("No")
            sys.exit()
    print("Yes")
Problem p03680 (python)

Fixed submission:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
a = IR(n)

# N個のボタンがあり、今1個のボタンが光っている。
# ボタンは1~Nまで番号があり、iが光っているときに押すと、iの光が消え、aiが光る。
# 光っていないボタンを押しても反応しない。
# ボタン１が光っている状態で開始、ボタン2が光っている状態で終了したい。
# そのようなことが不可能であれば－1、可能であれば最小回数を出力

#　普通にシミュレートしたらよい。
#　n回ボタン押したうえで、2にたどり着かなかったらどこかで同じボタンを2回押していることになる。

count = 0
cur = 1

while count < n:
    count += 1
    cur = a[cur-1]
    if cur == 2:
        print(count)
        sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
a = IR(n)

# N個のボタンがあり、今1個のボタンが光っている。
# ボタンは1~Nまで番号があり、iが光っているときに押すと、iの光が消え、aiが光る。
# 光っていないボタンを押しても反応しない。
# ボタン１が光っている状態で開始、ボタン2が光っている状態で終了したい。
# そのようなことが不可能であれば－1、可能であれば最小回数を出力

#　普通にシミュレートしたらよい。
#　n回ボタン押したうえで、2にたどり着かなかったらどこかで同じボタンを2回押していることになる。

count = 0
cur = 1

while count < n:
    count += 1
    cur = a[cur-1]
    if cur == 2:
        print(count)
        return
print(-1)
Problem p02865 (python)

Fixed submission:
n = int(input())
if(n%2 == 1):
  print(n//2)
else:
  print((n//2)-1)

Buggy submission (verdict: Runtime Error):
n = int(intput())
if(n%2 == 1):
  print(n//2)
else:
  print((n//2)-1)
Problem p02553 (python)

Fixed submission:
if __name__ == "__main__":

    a,b,c,d = (int(x) for x in input().split())

    if b <= 0 :
        if d <= 0:
            xy = a * c
        elif d > 0:
            if c > 0:
                xy = b * c
            elif c == 0:
                xy = 0
            elif c < 0:
                xy = a * c
    elif b > 0:
        if a >= 0:
            if d <= 0:
                xy = a * d
            elif d > 0:
                xy = b * d
        elif a < 0:
            if d <= 0:
                xy = a * c
            elif d > 0:
                if c >= 0:
                    xy = b * d
                elif c < 0:
                    if abs(a * c) > abs(b * d):
                        xy = a * c
                    else:
                        xy = b * d

    print(xy)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())

    if b <= 0 :
        if d <= 0:
            xy = a * c
        elif d > 0:
            if c > 0:
                xy = b * c
            elif c == 0:
                xy = 0
            elif c < 0:
                xy = a * c
    elif b > 0:
        if a >= 0:
            if d <= 0:
                xy = a * d
            elif d > 0:
                xy = b * d
        elif a < 0:
            if d <= 0:
                xy = a * c
            elif d > 0:
                if c >= 0:
                    xy = b * d
                elif c < 0:
                    if abs(a * c) > abs(b * d):
                        xy = a * c
                    else:
                        xy = b * d

    print(xy)