Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ind = 0
l = []
for i in range(k):
    if ind in l:
        break
    l.append(ind)
    ind = a[ind]-1
l = l[l.index(ind):]
for i in range((k-i)%len(l)):
    ind = a[ind]-1
print(ind+1)

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

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ind = 0
l = []
for i in range(k):
    if ind in l:
        break
    l.append(ind)
    ind = a[ind]-1
l = l[l.index(ind):]
for i in range((k-i)%len(l)):
    ind = a[ind]-1
print(ind+1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(1, n+1):
    d[i] = 0
l = [1]
x = 1
if n >= k:
    for i in range(k):
        x = a[x-1]
    print(x)
    exit()
for i in range(n):
    x = a[x-1]
    if d[x] == 1:
        k -= l.index(x)
        print(l[l.index(x):][k%(l.index(x)-len(l))])
        exit()
    l.append(x)
    d[x] += 1
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
x = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(i+1+x[i])
    b.append(i+1-x[i])
ans = 0
a, b = Counter(a), Counter(b)
for i in range(min(b), max(a)+1):
    ans += a[i]*b[i]
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
x = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(i+1+x[i])
    b.append(i+1-x[i])
ans = 0
a, b = Counter(a), Counter(b)
for i in range(min(a), max(b)+1):
    ans += a[i]*b[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(i+1+x[i])
    b.append(i+1-x[i])
ans = 0
for i in range(n):
    ans += b[i+1:].count(a[i])
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
x = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(i+1+x[i])
    b.append(i+1-x[i])
ans = 0
a, b = Counter(a), Counter(b)
for i in range(min(a), max(b)+1):
    ans += a[i]*b[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
pi = math.pi
a = int(input())
print(pi * a

Fixed submission:
import numpy as np
pi = np.pi
a = int(input())
print(2 * a * pi)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
  print(a.count(i))

Fixed submission:
a = int(input())
b = list(map(int, input().split()))
c = [0 for f in range(a)]
for i in b:
  c[i - 1] += 1
for g in c:
  print(g)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,, input().split()))
if a[0] == a[1] and a[0] != a[2]:
  print("Yes")
elif a[0] != a[1] and a[1] == a[2]:
  print("Yes")
elif a[0] == a[2] and a[0] != a[1]:
  print("Yes")
else:
  print("No")

Fixed submission:
a = list(map(int, input().split()))
if a[0] == a[1] and a[0] != a[2]:
  print("Yes")
elif a[0] != a[1] and a[1] == a[2]:
  print("Yes")
elif a[0] == a[2] and a[0] != a[1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
a = list(map(int, input().split()))
for i in a:
  if a % 2 == 0 and (a % 3 != 0 and a % 5 != 0):
    print("DENIED")
    sys.exit()
print("APPROVED")    

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  if i % 2 != 1 and i % 3 != 0 and i % 5 != 0:
    b += 1
if b != 0:
  print("DENIED")
else:
  print("APPROVED")
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = Counter(s)
c_values = c.values()
for j in c.items():
    if j[1] == max(c_values):
        print(j[0])

Fixed submission:
# coding: utf-8
# Your code here!

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c_max = max(c.values())
ans = [j[0] for j in c.items() if j[1] == c_max]
ans = sorted(ans)
for f in ans:
    print(f)
Buggy python submission (verdict: Runtime Error):
s, t = map(input().split())
a, b = map(int, input().split())
t = input()
if s == t:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1))

Fixed submission:
s = input().split()
a, b = map(int, input().split())
t = input()
if s[0] == t:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1))
Buggy python submission (verdict: Runtime Error):
s = input()
for i in len(s):
  print(x,end="")


Fixed submission:
s = input()
print("x" * len(s))

Buggy python submission (verdict: Runtime Error):
s = input()
for i in list(s):
  print(x,end="")

Fixed submission:
s = input()
print("x" * len(s))

Buggy python submission (verdict: Runtime Error):
s = input()
print(x * len(s))

Fixed submission:
s = input()
print("x" * len(s))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = []
for i in p:
  a.append((i+1)/2)
ans = 0
for f in range(n - k + 1):
  ans = max([ans, sum(a[f:f+k])])
print(ans)  

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0] * n 
asum = 0
for i in range(n):
  a[i] = (p[i]+1)/2 + asum
  asum = a[i]
ans = a[k-1]
for f in range(1, n-k+1):
  ans = max([ans, a[f+k-1] - a[f-1]])
print(ans)
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = [int(input()) for i in range(n)]
if sum(a) >= h:
  print("Yes")
else:
  print("No")

Fixed submission:
h, n = map(int, input().split())
a = list(map(int, input().split()))
if h <= sum(a):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a = sorted(input().split())
print(a[0] * a[1]

Fixed submission:
a = sorted(input().split())
print(a[0] * int(a[1]))
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b  

Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)

Buggy python submission (verdict: Runtime Error):
from math import gcd

a = list(map(int, input().split()))
print((a[0] * a[1]) // math.gcd(a[0], a[1]))


Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)

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

a = list(map(int, input().split()))
print((a[0] * a[1]) // math.gcd(a[0], a[1]))


Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)

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

a = list(map(int, input().split()))
print((a[0] * a[1]) // math.gcd(a[0], a[1]))


Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)

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

a = list(map(int, input().split()))
print((a[0] * a[1]) // math.gcd(a[0], a[1]))


Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)

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

a = list(map(int, input().split()))
print((a[0] * a[1]) // math.gcd(a[0], a[1]))

Fixed submission:
a = list(map(int, input().split()))
b = a[0]
while b % a[1] != 0:
  b += a[0]
print(b)
Buggy python submission (verdict: Runtime Error):
s = input()
s1 = s[:s//2]
s2 = s[-1 * (s//2):]
ans = 0
for i in range(s//2):
  if s1[i] != s2[i]:
    ans += 1
print(ans)    


Fixed submission:
n = input()
s = len(n)
s1 = n[:s//2]
s2 = n[-1 * (s//2):]
s2 = s2[::-1]
ans = 0
for i in range(s//2):
  if s1[i] != s2[i]:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
s1 = s[:s//2]
s2 = s[-(s//2):]
ans = 0
for i in range(s//2):
  if s1[i] != s2[i]:
    ans += 1
print(ans)    

Fixed submission:
n = input()
s = len(n)
s1 = n[:s//2]
s2 = n[-1 * (s//2):]
s2 = s2[::-1]
ans = 0
for i in range(s//2):
  if s1[i] != s2[i]:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
x = 10 ** 10
for i in range(1, n):
    x = min(x, abs(sum(a[:i])-sum(a[i:])))
print(x)

Fixed submission:
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
l = list(accumulate(a))
x = 10 ** 10
for i in range(n-1):
    x = min(x, abs(l[i]*2-l[-1]))
print(x)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)

Fixed submission:
import math

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
  print(a.index(i) + 1,end=" ")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
  ans[a[i]-1] = i+1
for j in range(n):
  print(ans[j],end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
for i in b:
  print(a.index(i) + 1,end=" ")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
  ans[a[i]-1] = i+1
for j in range(n):
  print(ans[j],end=" ")
Buggy python submission (verdict: Runtime Error):
l = ["Sunny", "Cluody", "Rainy", "Sunny"]
s = input()
print(l[l.index(s)+1])

Fixed submission:
s = input()
wether = ["Sunny", "Cloudy", "Rainy", "Sunny"]
print(wether[wether.index(s) + 1])
Buggy python submission (verdict: Runtime Error):
import sys

s = input()
for i in len(s):
  if i % 2 == 0:
    if s[i] == "R":
      print("No")
      sys.exit()
  else:
    if s[i] == "L":
      print("No")
      sys.exit()
print("Yes")

Fixed submission:
import sys

s = input()
for i in range(len(s)):
  if i % 2 == 1:
    if s[i] == "R":
      print("No")
      sys.exit()
  else:
    if s[i] == "L":
      print("No")
      sys.exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    a[a.index(max(a))] = max(a)//2
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i*-1 for i in a]
heapq.heapify(a)
for i in range(m):
    x = ((-1) * heapq.heappop(a)) //2
    heapq.heappush(a, -x)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
  a[a.index(max(a))] //= 2
print(sum(a))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i*-1 for i in a]
heapq.heapify(a)
for i in range(m):
    x = ((-1) * heapq.heappop(a)) //2
    heapq.heappush(a, -x)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
  a[a.index(max(a))] //= 2
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i*-1 for i in a]
heapq.heapify(a)
for i in range(m):
    x = ((-1) * heapq.heappop(a)) //2
    heapq.heappush(a, -x)
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n):
  ans += i
print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

num = int(input())
a = [int(input()) for i in range(num)]
b = heapq.nlargest(2, a)
c = [b[0] for i in range(num)]
if b[0] == b[1]:
  for j in c:
    print(j)
else:
  for f in range(num):
    if f == a.index(b[0]):
      print(b[1])
    else:
      print(b[0])



Fixed submission:
from heapq import nlargest

n = int(input())
a = [int(input()) for i in range(n)]
b = nlargest(2, a)
ma = max(a)
for j in a:
  if j == ma:
    print(b[1])
  else:
    print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

num = int(input())
a = [int(input()) for i in range(num)]
b = heapq.nlargest(2, a)
c = [b[0] for i in range(num)]
if b[0] == b[1]:
  for j in c:
    print(j)
else:
  for f in range(num):
    if f == a.index(b[0]):
      print(b[1])
    else:
      print(b[0])



Fixed submission:
from heapq import nlargest

n = int(input())
a = [int(input()) for i in range(n)]
b = nlargest(2, a)
ma = max(a)
for j in a:
  if j == ma:
    print(b[1])
  else:
    print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

num = int(input())
a = [int(input()) for i in range(num)]
for f in a:
  if max(a) == f:
    print(heapq.nlargest(2, a)[1])
  else:
    print(max(a))


Fixed submission:
from heapq import nlargest

n = int(input())
a = [int(input()) for i in range(n)]
b = nlargest(2, a)
ma = max(a)
for j in a:
  if j == ma:
    print(b[1])
  else:
    print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
a = [int(input()) for i in range(num)]
b = sorted(a, reverse=True)
for f in a:
  if max(a) == f:
    print(b[1])
  else:
    print(b[0])

Fixed submission:
from heapq import nlargest

n = int(input())
a = [int(input()) for i in range(n)]
b = nlargest(2, a)
ma = max(a)
for j in a:
  if j == ma:
    print(b[1])
  else:
    print(ma)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 1 == 0:
      cnt += 1
print(cnt)

Fixed submission:
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 1 == 0:
      cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l.sort()
print(l[n//2] - l[n//2  +1])

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
print(abs(l[n//2-1] - l[n//2]))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
ans = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    ans += 1
print(ans)    

Fixed submission:
from math import gcd

a, b, c, d = map(int, input().split())
n = c * d // gcd(c,d)
x = (b // c) - ((a-1) // c)
y = (b // d) - ((a-1) // d)
z = (b // n) - ((a-1) // n)
print(b-a+1-(x+y-z))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  L[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  l[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
if m > n // 2:
  print(0)
else:
  dp = [0] * (n+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2, n+1):
    if i not in a:
      dp[i] = dp[i-1] + dp[i-2]
  print(dp[-1]%(10 ** 9 + 7))

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
l = [1] * (n+1)
for j in a:
  l[j] = 0
x = 10 ** 9 + 7
if m > n // 2:
  print(0)
else:
  dp = [0] * (n+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2, n+1):
    if l[i]:
      dp[i] = (dp[i-1] + dp[i-2]) % x
  print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
dp = [0] * (n+1)
dp[0] = 1
if 1 not in a:
  dp[1] = 1
for i in range(2, n+1):
  if i in a:
    continue
  dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%(10 ** 9 + 7))

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
l = [1] * (n+1)
for j in a:
  l[j] = 0
x = 10 ** 9 + 7
if m > n // 2:
  print(0)
else:
  dp = [0] * (n+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2, n+1):
    if l[i]:
      dp[i] = (dp[i-1] + dp[i-2]) % x
  print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
dp = [0] * (n+1)
dp[0] = 1
if 1 not in a:
  dp[1] = 1
for i in range(2, n+1):
  if i in a:
    continue
  dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%(10 ** 9 + 7))

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
l = [1] * (n+1)
for j in a:
  l[j] = 0
x = 10 ** 9 + 7
if m > n // 2:
  print(0)
else:
  dp = [0] * (n+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2, n+1):
    if l[i]:
      dp[i] = (dp[i-1] + dp[i-2]) % x
  print(dp[-1])
Buggy python submission (verdict: Runtime Error):
a, b = int(input))
if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)

Fixed submission:
a, b = map(int, input().split())
if a >= 13:
  print(b)
elif a <= 5:
  print(0)
else:
  print(b//2)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
ans = 0
for i in range(1, n+1):
  if max(l) <= i <= min(r):
    ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
lm = max(l)
rm = min(r)
ans = 0
for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
ans = 0
for i in range(1, n+1):
  b = True
  for j in range(m):
    if i < lr[j][0] or lr[j][1] < i:
      b = False
  if b:
    ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
lm = max(l)
rm = min(r)
ans = 0
for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
  k = 0
  m = 0
  for j in range(n):
    if (i >> j) & 1:
      k += v[j]
      m += c[j]
  ans = max(ans, k - m)
print(ans)


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
  k = 0
  m = 0
  for j in range(n):
    if (i >> j) & 1:
      k += v[j]
      c += c[j]
  ans = max(ans, k - m)
print(ans)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
l = []
for i in range(n):
    if i < n-1:
        if s[i] == "A" and s[i+1] == "C":
            l.append("a")
        else:
            l.append(s[i])
    else:
        l.append(s[i])
ans = 0
for i in range(q):
    print(l[lr[i][0]-1:lr[i][1]-1].count("a"))

Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
    print(t[lr[i][1]-1] - t[lr[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
for i in lr:
  print(s[i[0]-1:i[1]].count("AC"))
  

Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
    print(t[lr[i][1]-1] - t[lr[i][0]-1])
Buggy python submission (verdict: Runtime Error):
from math import gcd
import sympy


a, b, k = map(int, input().split())
x = gcd(a, b)
l = sympy.divisors(x)
print(l[-k])

Fixed submission:
from math import gcd

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
a, b, k = map(int, input().split())
x = gcd(a, b)
l = make_divisors(x)
print(l[-k])
Buggy python submission (verdict: Runtime Error):
s = input()
if s[5] = "1":
  print("TBD")
elif int(s[6]) >= 5:
  print("TBD")
else:
  print("Heisei")

Fixed submission:
s = input()
if s[5] == "1":
  print("TBD")
elif int(s[6]) >= 5:
  print("TBD")
else:
  print("Heisei")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i:i+k][-1] - h[i:i+k][0])
print(ans)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i+k-1] - h[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i:i+k][-1] - a[i:i+k][0])
print(ans)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i+k-1] - h[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, (max(h[i:i+k])-min(h[i:i+k])))
print(ans)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i+k-1] - h[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, (max(a[i:i+k])-min(a[i:i+k])))
print(ans)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n-k+1):
  ans = min(ans, h[i+k-1] - h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-x*6/1000)))
print(l.index(min(l))+1)


Fixed submission:
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-h[i]*6/1000)))
print(l.index(min(l))+1)