Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

while N != X:
    X += 1 
    ans += 1
    if N == X:
        break
    for i in range(min([si-1,N-X])):
        if s[X + i] <= s[X-1] + ti:
            X += 1
        else:
            break

print(ans)

Fixed submission:
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

while N != X:
    X += 1 
    ans += 1
    if N == X:
        break
    for i in range(min([si-1,N-X])):
        if s[X + i] < s[X-1] + ti:
            X += 1
        else:
            break

print(ans)

Fixed submission:
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

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

Fixed submission:
k = int(input())
a = "ACL"
print(a * k)

Buggy python submission (verdict: Runtime Error):
k = int(input)
a = 'ACL'
print(a ** k)

Fixed submission:
k = int(input())
a = "ACL"
print(a * k)

Buggy python submission (verdict: Runtime Error):
k = int(input))
a = 'ACL'
print(a ** k)

Fixed submission:
k = int(input())
a = "ACL"
print(a * k)
Buggy python submission (verdict: Runtime Error):
S = input()
if S.endswith('s'):
  print(S+'es')
else
 print(S+'s')

Fixed submission:
S = input()
if S.endswith('s'):
  print(S+'es')
else:
 print(S+'s')

Buggy python submission (verdict: Runtime Error):
a = input().split()
if a.endswith('e') :
 print(a+'s')
elif  a.endswith('s'):
 print(a+'es')
else:
 print(a)

Fixed submission:
S = input()
if S.endswith('s'):
  print(S+'es')
else:
 print(S+'s')

Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
if a.endswith('e'):
 print(a+'s')
elif  a.endswith('s'):
 print(a+'es')
else:
 print(a)

Fixed submission:
S = input()
if S.endswith('s'):
  print(S+'es')
else:
 print(S+'s')
Buggy python submission (verdict: Runtime Error):
x = list[map(int,input().split())]
print(x.index(0) + 1)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0) + 1)
Buggy python submission (verdict: Runtime Error):
a, b = int(input())
print('Even' if a*b % 2 == 0 else 'Odd')

Fixed submission:
a, b = map(int,input().split())
print('Even' if a*b % 2 == 0 else 'Odd')
Buggy python submission (verdict: Runtime Error):
s = input()
print(s.count(1))

Fixed submission:
s = input()
print(s.count("1"))
Buggy python submission (verdict: Runtime Error):
s = input()
print(s[0]+str(lent(s)-2)+s[-1])

Fixed submission:
s = input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy python submission (verdict: Runtime Error):
s = input()
print(s[0]+s.str(lent(s)-2)+s[-1])

Fixed submission:
s = input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy python submission (verdict: Runtime Error):
print(s[0]+s.count(s-2)+s[-1])

Fixed submission:
s = input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy python submission (verdict: Runtime Error):
s = input()
print(s[0]+count(s-2)+s[-1])

Fixed submission:
s = input()
print(s[0]+str(len(s)-2)+s[-1])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
 
def is_prime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
N= int(input())
A = input().split()
ANS = 0
for i in range(N):
  C = A[i]
  if A.count(C) == 1:
    if is_prime(i) == True:
      ANS += 1
print(ANS)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a,b,c,d,e = map(int, input().split())
if a == 0:
  print (1)
elif b == 0:
  print (2)
elif c == 0:
  print (3)
elif d == 0:
  print (4)
else:
  print (5)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])
p = min(K,50)
for m in range(1,p+1,1):
  for o in range(N):
    if AK[0][o] == N:
      AK[1] = AK[1]+1
    else:
      for x in range(N):
        if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
          AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
# 出力
print(s[0:3])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])
p = min(K,40)
for m in range(1,p+1,1):
  for o in range(N):
    for x in range(N):
      if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
        AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
# 出力
print(s[0:3])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split())) 

kabu = 0
money = 1000
for i in range(n):
    if i == n-1:
        money += kabu*a[i]
        kabu = 0
    elif a[i] < a[i+1]:
        while money >= a[i]:
            kabu += 1
            money -= a[i]
    else:
        money += kabu*a[i]
        kabu = 0
    
print(money)
    

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

kabu = 0
money = 1000
for i in range(n):
    if i == n-1:
        money += kabu*a[i]
        kabu = 0
    elif a[i] < a[i+1]:
        if money >= a[i]:
            kabu = money // a[i]
            money = money - a[i]*kabu
    else:
        money += kabu*a[i]
        kabu = 0
    
print(money)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split)
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)

new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)
    

Fixed submission:
n,k = map(int,input().split())
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)
 
new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)

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

s = input().rstrip().split(' ')
a = int(s[0]) 
sorted = []
sorted.append(a)

for i in range(1,n):
  a = int(s[i]) 
  sorted.append(a)
  
  main = i
  sub = i-1
  while main = 0:
    if(sorted[sub] > sorted[main]):
      stock = sorted[sub]
      sorted[sub] = sorted[main]
      sorted[main] = stock
    else:
      break
     
    main -= 1
    sub -= 1

sum = 0
for j in range(0,k):
  sum += sorted[j]
  
print(sum)
    

Fixed submission:
n,k = map(int,input().split())
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)
 
new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
  		d[b] = 0
    print(sums)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)

Buggy python submission (verdict: Runtime Error):
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
  
    print(sums)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = 0

for i in range(q):
  sums = 0
  b,c = map(int, input().split())
  for j in range((len(a))):
    if a[j] == b:
      a[j] = c
    sums += a[j]
    
  print(sums)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = 0

for i in range(q):
  b,c = map(int, input().split())
  for j in range((len(a))):
    if a[j] == b:
      a[j] = c
  
  sums = sum(a)
  print(sums)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)
Buggy python submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
c_a = []
for i in range(n):
      c_a.append(list(map(int, input().split())))

min_sum_answer = 0
for i in range(n**2):
      min_sum = 0
      get_score = []
      for m in range(m):
         get_score.append(0)   
      for j in range(n):
            if i >> j % 2 ==1:
                  mun_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
           
      pre = 0 
      for s in range(m):
            if(get_score[s} < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == 0:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)

Fixed submission:
n,m,x = map(int, input().split())
c_a = []
for i in range(n):
      c_a.append(list(map(int, input().split())))

min_sum_answer = -1
for i in range(2**n):
      min_sum = 0
      get_score = []
      for v in range(m):
         get_score.append(0)   
      for j in range(n):
            if (i >> j) & 1 ==1:
                  min_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
     
      #print(i)
      #print(min_sum)
      pre = 0 
      for s in range(m):
            if(get_score[s] < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == -1:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
if N%K == 0:
    print("0")
else:
    print("1")

Fixed submission:
N, K = map(int,input().split())
if N%K == 0:
    print("0")
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
g = []
for i in range(len(s)-len(t)):
  n = 0
  for j in range(len(t)):
    if s[i+j]==t[j]:
      n+=1
  g.append(len(t)-n)
print(min(g))

Fixed submission:
s = input()
t = input()
if len(s) == len(t):
  a = 0
  for i in range(len(t)):
    if s[i] == t[i]:
      a+=1
  print(len(s)-a)
  exit(0)
g = []
for i in range(len(s)-len(t)):
  n = 0
  for j in range(len(t)):
    if s[i+j]==t[j]:
      n+=1
  g.append(len(t)-n)
print(min(g))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = [0]*(n+1)
def dfs(x,y):
  for i in g[x]:
    if v[i] == -1:
      v[i]=1
      ans[y]+=1
      dfs(i,y)
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  dfs(i,i)
print(max(ans)+1)

Fixed submission:
from collections import deque
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = []
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  an=1
  d = deque([i])
  while len(d):
    x = d.popleft()
    for i in g[x]:
      if v[i] == -1:
        d.append(i)
        v[i]=1
        an+=1
  ans.append(an)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = [0]*n
def dfs(x,y):
  for i in g[x]:
    if v[i] == -1:
      v[i]=1
      ans[y]+=1
      dfs(i,y)
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  dfs(i,i)
print(max(ans)+1)

Fixed submission:
from collections import deque
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = []
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  an=1
  d = deque([i])
  while len(d):
    x = d.popleft()
    for i in g[x]:
      if v[i] == -1:
        d.append(i)
        v[i]=1
        an+=1
  ans.append(an)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  if not b-1 in g[a-1]:
    g[a-1].append(b-1)
  if not a-1 in g[b-1]:
    g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = [0]*n
def dfs(x,y):
  for i in g[x]:
    if v[i] == -1:
      v[i]=v[x]+1
      ans[y]+=1
      dfs(i,y)
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  dfs(i,i)
print(max(ans)+1)

Fixed submission:
from collections import deque
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = []
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  an=1
  d = deque([i])
  while len(d):
    x = d.popleft()
    for i in g[x]:
      if v[i] == -1:
        d.append(i)
        v[i]=1
        an+=1
  ans.append(an)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())

def change(): #ここに数字からアルファベットを1体1で対応させれば終わり

p=[]
while n>0:
  a=n%26
  p.append(a)
  n=n//26

for i in range(len(p)):
  p[i]=change(p[i])

p.reverse()  

b=''

for i in range(len(p)):
  b += p[i]
  
print(b)

Fixed submission:
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
b = ''
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = a[X_dumy%n-1]+out
        if a[X_dumy%n-1] == 'z':
          X_dumy -= 26
        X_dumy = X_dumy//n
    return out

z = Base_10_to_n(n, 26)
print(z)
Buggy python submission (verdict: Runtime Error):
x,n= map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = [int(x) for x in input().split()]
pp = []
for i in range(1,101):
  if not i in p:
    pp.append(i)
a = []
for i in pp:
  a.append(abs(x-i))
b = min(a)
c = []
for i,j in enumerate(a):
  if b == j:
    c.append(pp[i])
print(min(c))

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

if n == 0:
  print(x)
  exit(0)
  
p = [int(x) for x in input().split()]

a = x
b = x

if x not in p:
  print(x)
  exit(0)

for i in range(1,101):
  a = a + 1
  b = b - 1
  if b not in p:
    print(b)
    exit(0)
  elif a not in p:
    print(a)
    exit(0)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)

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

print(int(A)*int(B))
Buggy python submission (verdict: Runtime Error):
t = list(input())
for i in range(len(t)):
  if t[i] == '?':
    if i == 0:
      if t[1] == 'P':
        t[i] = 'D'
      else:
        t[i] = 'P'
    if i == len(t)-1:
        t[i] = 'D'
    else:
      if t[i-1] == 'P':
        t[i] = 'D'
      else:
        if t[i+1] == 'P':
          t[i] = 'D'
        else:
          t[i] = 'P'
a = ''
for i in range(len(t)):
  a += t[i]
        
print(a)

Fixed submission:
t = list(input())    
for i in range(len(t)):

  if t[i] == '?':
    if len(t) == 1:
      if t[i] == '?':
        t[i] = 'D'
      break
    if i == 0:
      if t[1] == 'P':
        t[i] = 'D'
      else:
        t[i] = 'P'
    if i == len(t)-1:
        t[i] = 'D'
    else:
      if t[i-1] == 'P':
        t[i] = 'D'
      else:
        if t[i+1] == 'P':
          t[i] = 'D'
        else:
          t[i] = 'P'
a = ''
for i in range(len(t)):
  a += t[i]
        
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
c = [0]
for i in range(k):
  b = a[b]-1
  if b in c:
    d = c.index(b)
    e = i-d+1
    k = k - len(c)+e
    c = c[-e:]
    print(c[k%e]+1)
    exit(0)
  else:
    c.append(b)
print(b+1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)

Buggy python submission (verdict: Runtime Error):
NK = list(map(int, input().split())) 
A = list(map(int, input().split())) 
e = 0
N = NK[0]
K = NK[1]
town= 1
list = []
for i in range(N+1):
  town = A[town-1]
  list.append(town)
  if i > 0 and town == list[0]:
    e += 1
    break
if e == 1:
  print(list[-1])
else:
  d = K % len(list[:-1])
  print(list1[d-1])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)

Buggy python submission (verdict: Time Limit Exceeded):
NK = list(map(int, input().split())) 
A = list(map(int, input().split())) 

N = NK[0]
K = NK[1]

town = 1
for i in range(K):
  town = A[town-1]
  
print(str(town))

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)

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

N = NK[0]
K = NK[1]

town = 0
for i in range(K-1):
  town = A[town]
  
print(str(town))

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split())) 
cnt = 0
b = []
for i in range(1,n+1):
  b.append(i-a[i-1])
for i in range(n):
  c = a[i]+ i+1
  cnt += b.count(c)
print(cnt)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split())) 
cnt = 0
c = defaultdict(int)
for i in range(n):
  c[i+1-a[i]] += 1
for i in range(n):
  cnt += c[a[i]+i+1]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
q=[1,2,3,4,5,6,7,8,9]
for i in range(k):
    l=q.pop(0)
    if l%10!=0:
        q.append(10*l+l%10-1)
    q.append(10*l+l%10)
    if l%10!=9:
        q.append(10*l+l%10+1)
print(l)

Fixed submission:
k=int(input())
q=[1,2,3,4,5,6,7,8,9]
for i in range(k):
    l=q.pop(0)
    if l%10!=0:
        q.append(10*l+l%10-1)
    q.append(10*l+l%10)
    if l%10!=9:
        q.append(10*l+l%10+1)
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = map(int, input().split())

list =[]
for i in range(n):
  for j in range(i):
    b = i+1
    a = j+1
    if a<=x and b>=y:
      list.append(b-y+x-a+1)
    elif a>x and b>=y:
      d =min(a-x+1,y-a)
      list.append(d+b-y)
    elif a<=x and b<y:
      d =min(b-x,y-b+1)
      list.append(x-a+d)
    elif a>x and b<y:
      list.append(min(b-a,y-b+a-x+1))
    else:
      list.append(b-a)
for i in range(n-1):
  print(list.count(i+1))

Fixed submission:
n,x,y=map(int,input().split())
 
ans=[0]*n
 
list =[]
for i in range(n):
  for j in range(i):
    b = i+1
    a = j+1
    if a<=x and b>=y:
      k =b-y+x-a+1
    elif a>x and b>=y:
      d =min(a-x+1,y-a)
      k =d+b-y
    elif a<=x and b<y:
      d =min(b-x,y-b+1)
      k =x-a+d
    elif a>x and b<y:
      k = min(b-a,y-b+a-x+1)
    ans[k]+=1
    
for i in range(1,n):
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k= map(int, input().split())
p = list(map(int, input().split()))
q = []
for i in range(n-k+1):
  q.append(sum(p[i:i+k]))
print((max(q)+k)/2)

Fixed submission:
n,k= map(int, input().split())
p = list(map(int, input().split()))
ans = sum(p[:k])
q = [ans]
for i in range(k,n):
  ans = ans+p[i]-p[i-k]
  q.append(ans)
print((max(q)+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans=0
for i in range(60):
  g = [0,0]
  for j in a:
    g[(j>>i)%2]+=1
  ans+=2**i*g[0]*g[1]
  ans%=10**9+7
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(60):
  j = 1<<i
  cnt = sum((k & j) >> i for k in a)
  ans += (cnt*(n-cnt))<<i
  ans%= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(60):
  j = 1<<i
  cnt = 0
  for k in a:
    if j == k&j:
      cnt += 1
  ans += (cnt*(n-cnt))<<i
  ans%= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(60):
  j = 1<<i
  cnt = sum((k & j) >> i for k in a)
  ans += (cnt*(n-cnt))<<i
  ans%= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(60):
  j = 2**i
  cnt = 0
  for k in a:
    if j == k&j:
      cnt += 1
  ans += j*cnt*(len(a)-cnt)
  ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(60):
  j = 1<<i
  cnt = sum((k & j) >> i for k in a)
  ans += (cnt*(n-cnt))<<i
  ans%= mod
print(ans)