Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
edges = defaultdict(set)

for _ in range(M):
    a, b = map(lambda x:int(x)-1, input().split())
    edges[a].add(b)
    edges[b].add(a)

ans = 0
visited = [False] * N

def dfs(i):
    if visited[i]:
        return 0
    ans = 1
    visited[i] = True
    for dest in edges[i]:
        ans += dfs(dest)
    return ans

for i in range(N):
    ans = max(ans, dfs(i))
print(ans)



Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())
edges = defaultdict(set)

for _ in range(M):
    a, b = map(lambda x:int(x)-1, input().split())
    edges[a].add(b)
    edges[b].add(a)

ans = 0
visited = [False] * N

def dfs(i):
    stack = [i]
    ans = 0
    while stack:
        i = stack.pop()
        if visited[i]:
            continue
        ans += 1
        visited[i] = True
        for dest in edges[i]:
            stack.append(dest)
    return ans

for i in range(N):
    ans = max(ans, dfs(i))
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

def test(m):
    needed = 0
    for a in A:
        needed += (a-1)//m
        if needed > K:
            return False
    return True

lb = 1
ub = max(A)

while True:
    m = (lb + ub) // 2
    if test(m):
        if test(m-1):
            ub = m - 1
        else:
            print(m)
            exit()
    else:
        lb = m + 1

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

def test(m):
    if m <= 0:
        return False
    needed = 0
    for a in A:
        needed += (a-1)//m
        if needed > K:
            return False
    return True

lb = 1
ub = max(A)

while True:
    m = (lb + ub) // 2
    if test(m):
        if test(m-1):
            ub = m - 1
        else:
            print(m)
            exit()
    else:
        lb = m + 1
Buggy python submission (verdict: Runtime Error):
import heapq  
def priority(klr):
    return abs(klr[1]-klr[2])
              
def process(KLR):
    ans = 0   
    q = []    
    for klr in KLR:
        pr = priority(klr)
        if klr[0] < len(q) and q[0][0] < pr:
            tmp = heapq.heappop(q)
            ans += min(tmp[1], tmp[2])
        if klr[0] >= len(q):
            heapq.heappush(q, (pr, klr))
    for pr, klr in q:
        ans += max(klr[1], klr[2])
    return ans
              
              
def solve():  
    N = int(input())
    KLR = []  
    for _ in range(N):
        klr = list(map(int, input().split()))
        klr[0] -= 1 # convert to 0-based index to avoid confusion                                                                                                                                           
        KLR.append(klr)
    ans = 0   
    KLR_L = []
    KLR_R = []
    for klr in KLR:
        if klr[1] > klr[2]:
            KLR_L.append(klr)
        elif klr[1] < klr[2]:
            klr[0] = N-1-klr[0]-1
            if klr[0] < 0:
                ans += min(klr[1], klr[2])
            else:
                KLR_R.append(klr)
        else: 
            ans += klr[1]
    KLR_L.sort(key=lambda klr: klr[0])
    KLR_R.sort(key=lambda klr: klr[0])
    ans += process(KLR_L)
    ans += process(KLR_R)
    print(ans)
              
T = int(input())
              
for _ in range(T):
    solve()   
             

Fixed submission:
import heapq  
def priority(klr):
    return abs(klr[1]-klr[2])
              
def process(KP):
    q = []    
    for kp in KP:
        if kp[0] < len(q) and len(q) > 0 and q[0] < kp[1]:
            heapq.heappop(q)
        if kp[0] >= len(q):
            heapq.heappush(q, kp[1])
    return sum(q)
              
def solve():  
    N = int(input())
    KLR = []  
    for _ in range(N):
        klr = list(map(int, input().split()))
        klr[0] -= 1 # convert to 0-based index to avoid confusion                                                                                                                                           
        KLR.append(klr)
    ans = 0   
    L = []    
    R = []    
    for klr in KLR:
        if klr[1] > klr[2]:
            ans += klr[2]
            L.append((klr[0], klr[1]-klr[2]))
        elif klr[1] < klr[2]:
            ans += klr[1]
            R.append((N-1-klr[0]-1, klr[2]-klr[1]))
        else: 
            ans += klr[1]
    L.sort(key=lambda kp: kp[0])
    R.sort(key=lambda kp: kp[0])
    ans += process(L)
    ans += process(R)
    print(ans)
              
T = int(input())
              
for _ in range(T):
    solve()
Buggy python submission (verdict: Runtime Error):
import sys

def read_int():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return int(l[0])

def read_int_list():
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                  
    return [int(i) for i in l]

N, M, K = tuple(read_int_list())                                                                      
A = read_int_list()                                                                                   
B = read_int_list()                                                                                   

def can_read(A, B, i, j, memo, k):                                                                    
    key = (i, j, k)                                                                                   
    if key in memo:                                                                                   
        return memo[key]                                                                              
    ans = 0
    if i < len(A) and A[i] <= k:                                                                      
        ans = max(ans, can_read(A, B, i+1, j, memo, k - A[i]) + 1)                                    
    if j < len(B) and B[j] <= k:                                                                      
        ans = max(ans, can_read(A, B, i, j+1, memo, k - B[j]) + 1)                                    
    memo[key] = ans                                                                                   
    return ans                                                                                        

memo = {}                                                                                             
print(can_read(A, B, 0, 0, memo, K))       

Fixed submission:
import sys

def read_int():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return int(l[0])

def read_int_list():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return [int(i) for i in l]

N, M, K = tuple(read_int_list())
A = read_int_list()
B = read_int_list()

ans = 0
sum_k =  0

ai = 0
bi = 0

for i in range(len(A)):
    if sum_k + A[i] > K:
        break
    sum_k += A[i]
    ai = i + 1

for i in range(len(B)):
    if sum_k + B[i] > K:
        break
    sum_k += B[i]
    bi = i + 1

ans = ai + bi

for i in range(ai - 1, -1, -1):
    sum_k -= A[i]
    ai = i
    while bi < len(B) and sum_k + B[bi] <= K:
        sum_k += B[bi]
        bi += 1
    ans = max(ans, ai+bi)
print(ans)
Buggy python submission (verdict: Runtime Error):
imports sys

c = sys.stdin.readline()

if ord(c) >= 'a' and ord(c) <= 'z':
  print('a')
else:
  print('A')

Fixed submission:
import sys

c = sys.stdin.readline().rstrip('\n')

if ord(c) >= ord('a') and ord(c) <= ord('z'):
  print('a')
else:
  print('A')
Buggy python submission (verdict: Runtime Error):
N = int(input())
I = list(map(int, input().split()))
ans = 1

kMax = 10**18

if 0 in I:
    print(0)
    exit()

for i in map(int, input().split()):
    ans *= i
    if ans > kMax:
        print(-1)
        exit()
print(ans)



Fixed submission:
N = int(input())
I = list(map(int, input().split()))
ans = 1

kMax = 10**18

if 0 in I:
    print(0)
    exit()

for i in I:
    ans *= i
    if ans > kMax:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))

cnts = [None] * N

pos = 0
cnt = 0

while cnt < K:
    if cnts[pos] != None:
        loop_size = cnt - cnts[pos]
        cnt += ((K-cnt) // loop_size - 1) * loop_size
        cnts = [None] * N
    cnts[pos] = cnt
    pos = A[pos]
    cnt += 1

print(pos+1)

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

cnts = [None] * N

pos = 0
cnt = 0

while cnt < K:
    if cnts[pos] != None:
        loop_size = cnt - cnts[pos]
        cnt += ((K-cnt-1) // loop_size) * loop_size
        cnts = [None] * N
    cnts[pos] = cnt
    pos = A[pos]
    cnt += 1

print(pos+1)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))

cnts = [None] * N

pos = 0
cnt = 0

while cnt < K:
    print(cnts)
    if cnts[pos] != None:
        loop_size = cnt - cnts[pos]
        cnt += ((K-cnt) // loop_size - 1) * loop_size
        cnts = [None] * N
    cnts[pos] = cnt
    pos = A[pos]
    cnt += 1

print(pos+1)

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

cnts = [None] * N

pos = 0
cnt = 0

while cnt < K:
    if cnts[pos] != None:
        loop_size = cnt - cnts[pos]
        cnt += ((K-cnt-1) // loop_size) * loop_size
        cnts = [None] * N
    cnts[pos] = cnt
    pos = A[pos]
    cnt += 1

print(pos+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

S = input()

ans = 0

kTarget = 2019

carries = {0:1}

ord_z = ord('0')
for d in S[::-1]:
    d = ord(d) - ord_z
    next_carries = defaultdict(int)
    for carry, cnt in carries.items():
        x = carry - d
        mult = x%10
        x += mult*kTarget
        if carry != 0 and x == 0:
            ans += cnt
        x //= 10
        x %= kTarget
        next_carries[x] += cnt
    next_carries[0] += 1
    carries = next_carries
print(ans)



Fixed submission:
from collections import defaultdict

S = input()
kTarget = 2019

mod2cnt = defaultdict(int)
mod2cnt[0] += 1

ord_z = ord('0')
res = 0
for i in range(len(S)-1, -1, -1):
    d = ord(S[i]) - ord_z
    res = (res+d*pow(10, len(S)-1-i, kTarget))%kTarget
    mod2cnt[res] += 1

ans = 0
for cnt in mod2cnt.values():
    ans += cnt*(cnt-1)
print(ans//2)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(sys.stdin.readline())
nums = [int(x) for x in sys.stdin.readline().split]

ans = 0
_min = float('inf')
for num in nums:
  if _min >= num:
    ans += 1
  _min = min(_min, num)
print(ans)

Fixed submission:
import sys
N = int(sys.stdin.readline())
nums = [int(x) for x in sys.stdin.readline().split()]
 
ans = 0
_min = float('inf')
for num in nums:
  if _min >= num:
    ans += 1
  _min = min(_min, num)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import defaultdict
N = int(sys.stdin.readline())
cnt = defaultdict(int)
for i in range(1, N+1):
  str_i = str(i)
  cnt[(str_i[0], str_i[-1])] += 1

ans = 0
for d1 in range(9):
  for d2 in range(9):
    ans += cnt[(d1, d2)] * cnt[(d2, d1)]
return ans
    

Fixed submission:
import sys
from collections import defaultdict
N = int(sys.stdin.readline())
cnt = defaultdict(int)
for i in range(1, N+1):
  str_i = str(i)
  cnt[(str_i[0], str_i[-1])] += 1
 
ans = 0
for d1 in range(1, 10):
  for d2 in range(1, 10):
    d1, d2 = str(d1), str(d2)
    ans += cnt[(d1, d2)] * cnt[(d2, d1)]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (int(a) * 3 + p) //2
print(pies)

Fixed submission:
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (int(a) * 3 + int(p)) //2
print(pies)

Buggy python submission (verdict: Runtime Error):
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (3*a+p)//2
print(pies)

Fixed submission:
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (int(a) * 3 + int(p)) //2
print(pies)
Buggy python submission (verdict: Runtime Error):
import sys
 
l1 = sys.stdin.readline()
l2 = sys.stdin.readline()
 
nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)
 
out = max(nums)
 
for i in xrange(l2):
  out *= 2
print out + sum(nums) - max(nums)

Fixed submission:
import sys

for l in sys.stdin:
  items = [int(x) for x in l.split(' ')]
  a = items[0]
  b = items[1]
  if a <= b:
    print a
  else:
    print a - 1

Buggy python submission (verdict: Runtime Error):
import sys

for l in sys.stdin:
  items = [int(x) for x in l.split(' ')]
  a = items[0]
  b = items[1]
  if a <= b:
    return a
  else:
    return a - 1

Fixed submission:
import sys

for l in sys.stdin:
  items = [int(x) for x in l.split(' ')]
  a = items[0]
  b = items[1]
  if a <= b:
    print a
  else:
    print a - 1
Buggy python submission (verdict: Runtime Error):
import sys

l1 = sys.stdin.readline()
l2 = sys.stdin.readline()

nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)

out = max(nums)

for i in xrange(l2):
  out *= 2
print out + sum(l1) - max(nums)


Fixed submission:
import sys
 
l1 = sys.stdin.readline()
l2 = sys.stdin.readline()
 
nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)
 
out = max(nums)
 
for i in xrange(l2):
  out *= 2
print out + sum(nums) - max(nums)

Buggy python submission (verdict: Runtime Error):
File Edit Options Buffers Tools Python Help
import sys

l1 = sys.stdin.readline()
l2 = sys.stdin.readline()

nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)

out = max(nums)

for i in xrange(l2):
  out *= 2
print out

Fixed submission:
import sys
 
l1 = sys.stdin.readline()
l2 = sys.stdin.readline()
 
nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)
 
out = max(nums)
 
for i in xrange(l2):
  out *= 2
print out + sum(nums) - max(nums)

Buggy python submission (verdict: Runtime Error):
import sys

l1 = sys.stdin.readline()
l2 = sys.stdin.readline()

nums = [int(x) for x in l1.rstrip('¥n').split(' ')]
l2 = int(l2)

out = max(nums)

for i in xrange(l2):
  out *= 2
print out

Fixed submission:
import sys
 
l1 = sys.stdin.readline()
l2 = sys.stdin.readline()
 
nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)
 
out = max(nums)
 
for i in xrange(l2):
  out *= 2
print out + sum(nums) - max(nums)
Buggy python submission (verdict: Runtime Error):
imports sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] != '#':
    return False
  return True

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if not sub(field, _x, _y):
      return False
  return True
    
l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('¥n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline())
 
for y in len(field):
  for x in len(field[y]):
    if not isok(field, x, y):
      print 'No'
print 'Yes'


Fixed submission:
import sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] == '#':
    return True
  return False

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if sub(field, _x, _y):
      return True
  return False


l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('\n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline().rstrip('\n'))

for y in xrange(len(field)):
  for x in xrange(len(field[y])):
    if field[y][x] == '#' and not isok(field, x, y):
      print 'No'
      exit()
print 'Yes'

Buggy python submission (verdict: Runtime Error):
imports sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] != '#':
    return False
  return True

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if not sub(field, _x, _y):
      return False
  return True
    
l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('¥n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline())
 
for y in len(field):
  for x in len(field[y]):
    if not isok (field, x, y):
      print 'No'
print 'Yes'


Fixed submission:
import sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] == '#':
    return True
  return False

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if sub(field, _x, _y):
      return True
  return False


l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('\n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline().rstrip('\n'))

for y in xrange(len(field)):
  for x in xrange(len(field[y])):
    if field[y][x] == '#' and not isok(field, x, y):
      print 'No'
      exit()
print 'Yes'
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
import time

if n >= k:
    ans = -float('inf')
    for i in range(n):
        now = i
        score = []
        for j in range(k):
            now = p[now] - 1
            if j == 0:
                score.append(c[now])
            else:
                score.append(score[j-1] + c[now])
        ans = max(max(score), ans)
else:
	time.sleep(10)

Fixed submission:
s = input()


if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int,input().split()))

scores = []

s = 0
score = 1
for i in range(k):
    score *= a[i]

scores.append(score)
for i in range(k,n):
    score = score // a[s] * a[i]
    s += 1
    scores.append(score)

#print(scores)
for i in range(len(scores)-1):
    if scores[i+1] > scores[i]:
        print('Yes')
    else:
        print('No')

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

f = 0
for _ in range(n-k):
    if a[f] < a[f+k]:
        print('Yes')
    else:
        print('No')
    f += 1
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

high = max(a)
low = min(a)

if a[0] == high:
    print(1000)
else:
    s = a.index(high)
    a = a[:s+1]
    wallet = 1000
    stock = 0
    markets = []
    market = [a[0]]
    for i in range(n-1):
        if a[i+1] == a[i]:
            continue
        if a[i+1] > a[i]:
            market.append(a[i+1])
            markets.append(market)
            market = [a[i+1]]
        else:
            market.append(a[i+1])

    for i in range(len(markets)):
        if i == 0:
            stock += wallet // markets[i][0]
            wallet %= markets[i][0]
        elif i != 0:
            stock += wallet // markets[i][1]
            wallet %= markets[i][1]
        wallet += stock * markets[i][-1]
        stock = 0
    print(wallet)

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

wallet = 1000

for i in range(n-1):
    if a[i] < a[i+1]:
        stock = wallet // a[i]
        wallet += (a[i+1]-a[i]) * stock

print(wallet)
Buggy python submission (verdict: Runtime Error):
x, n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    print(x)
    quit()

check = [0] * max(p)
for i in range(n):
    check[p[i]-1] = 1

ans = []
d = 10**9
for i in range(1,len(check)+1):
    if d >= abs(i-x) and check[i-1] != 1:
        d = abs(i-x)
        ans.append([abs(i-x),i])

ans.sort()
print(ans[0][1])

Fixed submission:
x, n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    print(x)
    quit()

p.sort()
d = 10 ** 9
for i in range(-1000,1000):
    if d > abs(i-x) and i not in p:
        d = abs(i-x)
        ans = i
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
    print(0)
    quit()
f = factorization(n)
ans = 0
c = len(f)
for i in range(c):
    s = 0
    g = f[i][1]
    for j in range(g):
        s += j + 1
        f[i][1] -= j+1
        if s > g:
            break
        ans += 1
print(ans)


Fixed submission:
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
    print(0)
    quit()
f = factorization(n)
ans = 0
c = len(f)
for i in range(c):
    s = 0
    g = f[i][1]
    if g == 2:
        ans += 1
    else:
        for j in range(g):
            s += j + 1
            f[i][1] -= j+1
            if s > g:
                break
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Fixed submission:
n = input()


if n[-1] == '3':
    print('bon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = list(map(int,input().split()))

s = [True] * n
c = [1]
now = 0
while s[now]:
    s[now] = False
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

Fixed submission:
s = input()
t = input()

n = len(t)
if s == t[:n-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = list(map(int,input().split()))

s = [True] * n
c = [1]
now = 0
while s[now]:
    s[now-1] = False
    now = a[now]
    c.append(now)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)
    t += 1

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

s = [-1] * n
c = [1]
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)
    t += 1

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])
Buggy python submission (verdict: Runtime Error):
x = int(input())

for i in range(-200,200):
    for j in range(-200,200):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()


Fixed submission:
s = input()

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