Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
for i in a:
  ans = 0
  for k,v in count.items():
    if k == i: v -= 1
    ans += v*(v-1)//2
  print(ans)

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

nums = [0]*(n+1)
for i in a:
  nums[i] += 1
  
t = 0
for j in nums:
  t += j*(j-1)//2

for k in a:
  print(t+1-nums[k])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
for i in a:
  ans = 0
  for j in count.items():
    
    if i == j[0]:
      ans += (j[1]-1)*(j[1]-2)//2
    else:
      ans += j[1]*(j[1]-1)//2
  print(ans)


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

nums = [0]*(n+1)
for i in a:
  nums[i] += 1
  
t = 0
for j in nums:
  t += j*(j-1)//2

for k in a:
  print(t+1-nums[k])

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

nums = list(set(a))
for _ in range(n):
  ans = 0
  t = a.pop(0)
  for j in nums:
    s = a.count(j)
    ans += s*(s-1)//2
  print(ans)
  a.append(t)

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

nums = [0]*(n+1)
for i in a:
  nums[i] += 1
  
t = 0
for j in nums:
  t += j*(j-1)//2

for k in a:
  print(t+1-nums[k])

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

p = {}
t = sorted(list(set(a)))
s = [0]*len(t)
for i in range(len(t)):
  l = a.count(t[i])
  p[t[i]] = l
#print(p)
for i in a:
  s = 0
  x = p[i]
  p[i] -= 1
  for j in t:
    for k in range(p[j]):
      s += k
  print(s)
  p[i] = x
    

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

nums = [0]*(n+1)
for i in a:
  nums[i] += 1
  
t = 0
for j in nums:
  t += j*(j-1)//2

for k in a:
  print(t+1-nums[k])

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

p = a
t = sorted(list(set(a)))
for i in range(n):
  x = p[i]
  p[i] = 0
  s = 0
  for j in t:
    m = p.count(j)
    for k in range(m):
      s += k
  print(s)
  p[i] = x

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

nums = [0]*(n+1)
for i in a:
  nums[i] += 1
  
t = 0
for j in nums:
  t += j*(j-1)//2

for k in a:
  print(t+1-nums[k])
Buggy python submission (verdict: Runtime Error):
s = input()

n = s.count("hi")
print("Yes" if n*2 == len(n) else "No")

Fixed submission:
s = input()

n = s.count("hi")
print("Yes" if n*2 == len(s) else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int, input().split())

s = 0
t = 0
while t < n:
  for i in range(a):
    s += 1
    t += 1
    if t == n:
      break
  for j in range(b):
    t += 1
    if t == n:
      break
print(s)

Fixed submission:
n,a,b = map(int, input().split())
x = n // (a+b)
ans = a * x + min(a, n - (a+b) * x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

t = 0
for _ in range(q):
  query = list(input().split())
  query[0] = int(query[0])
  if query[0] == 1: t = 1 - (t)
  else:
    if t == 0:
      if int(query[1]) == 1: s = query[2]+s
      else: s += query[2]
    else:
      if int(query[1]) == 1: s += query[2]
      else: s = query[2]+s
if t == 0: print(s)
else: print(s[::-1])

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())

rev = 0
for i in range(q):
  tfc = list(input().split())
  if tfc[0] == "1":
    rev = abs(rev-1)
  else:
    t,f,c = tfc
    if rev:
      if f == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
        if f == "1":
          s.appendleft(c)
        else:
          s.append(c)
if rev:
  t = []
  for i in range(len(s)):
    t.append(s.pop())
  print("".join(t))
else:
  print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
  qq = list(map(str, input().split()))
  if qq[0] == "1":
    s = s[::-1]
  else:
    if qq[1] == "1":
      s = qq[2] + s
    else:
      s = s + qq[2]
print(s)

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())

rev = 0
for i in range(q):
  tfc = list(input().split())
  if tfc[0] == "1":
    rev = abs(rev-1)
  else:
    t,f,c = tfc
    if rev:
      if f == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
        if f == "1":
          s.appendleft(c)
        else:
          s.append(c)
if rev:
  t = []
  for i in range(len(s)):
    t.append(s.pop())
  print("".join(t))
else:
  print("".join(s))
Buggy python submission (verdict: Runtime Error):
import sys
n,m = map(int, input().split())

p = [0]*n
q = [False]*n
for i in range(m):
  s,c = map(int, input().split())
  if s == 1 and c == 0 and n != 1:
    #continue
  if s > n:
    print(-1)
    sys.exit()
    
  if q[s-1] == False:
    p[s-1] = c
    q[s-1] = True
  elif p[s-1] > c:
    p[s-1] = c

t = ''
for i in p:
  t += str(i)
  
t = int(t)
if len(str(t)) == n:
  print(t)
else:
  print(-1)

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

t = [-1]*n
for _ in range(m):
  s,c = map(int, input().split())
  s -= 1
  if t[s] != -1 and t[s] != c:
    print(-1)
    exit()
  t[s] = c
  
if n != 1:
  if t[0] == 0:
    print(-1)
    exit()
    
  if t[0] == -1:
    t[0] = 1
    
  for i in range(1, n):
    if t[i] == -1:
      t[i] = 0
else:
  if t[0] == -1:
    t[0] = 0
    
print(''.join(map(str, t)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
  s.append(input())

t = list(set(s))

p = []
for j in t:
  p.append([s.count(j), j])

a = []
b = 0
q = 0
for k in sorted(p, reverse = True):
  if k[0] >= b:
    a.append(k[1])
    b = k[0]
  else:
    break

for l in sorted(a):
  print(l)
  

Fixed submission:
N = int(input())

d = {}
for _ in range(N):
  S = input()
  if S in d:
    d[S] += 1
  else:
    d[S] = 1

m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
  print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
  s.append(input())

t = list(set(s))

p = []
for j in t:
  p.append([s.count(j), j])

a = []
b = 0
q = 0
for k in sorted(p, reverse = True):
  if k[0] >= b:
    a.append(k[1])
    q +=1
    b = k[0]

for l in sorted(a):
  print(l)
  

Fixed submission:
N = int(input())

d = {}
for _ in range(N):
  S = input()
  if S in d:
    d[S] += 1
  else:
    d[S] = 1

m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
  print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n):
  if i == 0:
    count+=1
  elif p[i - 1] => p[i]:
    count+=1
print(count)

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

result = 0
m = P[0]
for i in range(N):
    if P[i] <= m:
        result += 1
        m = P[i]
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
n,m = map(int, input().split())

res = []
for i in range(m):
  res.append(input().split())

que = []
for a1,a2 in res:
  if a2 == 'AC':
    que.append(a1)
  
num = set(que)

ac = 0
wa = 0
c = ''
for b in num:
  for c1,c2 in res:
    if c1 == b and c2 == 'AC':
      #print(b,c1,c2)
      ac += 1
      break
    elif c1 == b and c2 =='WA':
      #print(b,c1,c2)
      wa += 1

print(ac,wa)

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

# 3桁の番号を作るにあたり、文字列から抽出して作るのではなく、000〜999までの組み合わせが存在するかを確認する。
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1) # aの取得位置の次から検索を行う
    for k in range(10):
      c = s.find(str(k), b+1)　# bの取得位置の次から検索を行う
      if a == -1 or b == -1 or c == -1: continue
      else: ans += 1
print(ans)

Fixed submission:
n = int(input())
s = input()

# 3桁の番号を作るにあたり、文字列から抽出して作るのではなく、000〜999までの組み合わせが存在するかを確認する。
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1) # aの取得位置の次から検索を行う
    for k in range(10):
      c = s.find(str(k), b+1) # bの取得位置の次から検索を行う
      if a == -1 or b == -1 or c == -1: continue
      else: ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

l = []
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      t = s[i]+s[j]+s[k]
      if t not in l: l.append(t)
print(len(l))

Fixed submission:
n = int(input())
s = input()

# 3桁の番号を作るにあたり、文字列から抽出して作るのではなく、000〜999までの組み合わせが存在するかを確認する。
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1) # aの取得位置の次から検索を行う
    for k in range(10):
      c = s.find(str(k), b+1) # bの取得位置の次から検索を行う
      if a == -1 or b == -1 or c == -1: continue
      else: ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
  for j in range(n):
    if i == j: continue
    ans += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
    t += 1
print(ans/n)

Fixed submission:
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
  x1,y1 = map(int, input().split())
  x[i] = x1
  y[i] = y1

a = 0
b = 0
for i in range(n):
  t = list(range(n))
  t.remove(i)
  for j in t:
    a += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
    b += 1
    
print(a*(n-1)/b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

p = [True]*n
for i in range(n-1):
  for j in range(i+1, n):
    if s[i] == s[j]:
      p[j] = False
    elif s[i] != s[j]:
      break
print(p.count(True))

Fixed submission:
n = int(input())
s = input()

p = ''
count = 0
for i in range(n):
  if p != s[i]:
    count += 1
    p = s[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))

ans = 0
for i in range(n-1):
  s = h[i]
  t = 0
  for j in range(i+1,n):
    if s >= h[j]:
      t += 1
      s = h[j]
    else:
      ans = max(ans, t)
      break
    ans = max(ans, t)
print(ans)

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

x = 0
y = 0
z = 0
for i in h:
  if x < i:
    x = i
    y = 0
    continue
    
  y += 1
  x = i
  if z < y:
    z = y
print(z)
Buggy python submission (verdict: Runtime Error):
n = int(input())

nums = list(range(1,n+1))
print(sum(nums)-n)

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())

nums = list(range(1,n+1))
print(sum(nums[:-1]))

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

ans = 0
d = []
for i in s:
  if i not in d:
    t = s.count(i)
    ans += t*(t-1)//2
    d.append(i)
print(ans)

Fixed submission:
import collections

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

c = collections.Counter(s)

ans = 0
for i in set(s):
  x = c[i]
  ans += x * (x -1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

ans = 0
for i in list(set(s)):
  t = s.count(i)
  ans += t*(t-1)//2
print(ans)

Fixed submission:
import collections

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

c = collections.Counter(s)

ans = 0
for i in set(s):
  x = c[i]
  ans += x * (x -1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
  t = a.pop(i)
  print(max(a))
  a.insert(i,t)

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

x = sorted(set(a), reverse = True)
t = [0]*2
if len(x) > 1:
  t[0],t[1] = x[0],x[1]
else:
  t[0],t[1] = x[0],x[0]
  
max = t[0]
count= a.count(max)
for i in range(n):
  if a[i] == max:
    if count > 1:
      print(max)
    else:
      print(t[1])
  else:
    print(max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

x = sorted(set(a), reverse = True)
t = [0]*2
if len(x) > 1:
  t[0],t[1] = x[0],x[1]
else:
  t[0],t[1] = x[0],x[0]
  
max = t[0]  
for i in range(n):
  if a[i] == max:
    if a.count(max) > 1:
      print(max)
    else:
      print(t[1])
  else:
    print(max)
  

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

x = sorted(set(a), reverse = True)
t = [0]*2
if len(x) > 1:
  t[0],t[1] = x[0],x[1]
else:
  t[0],t[1] = x[0],x[0]
  
max = t[0]
count= a.count(max)
for i in range(n):
  if a[i] == max:
    if count > 1:
      print(max)
    else:
      print(t[1])
  else:
    print(max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

for i in range(n):
  t = a[i]
  a[i] = 0
  print(max(a))
  a[i] = t

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

x = sorted(set(a), reverse = True)
t = [0]*2
if len(x) > 1:
  t[0],t[1] = x[0],x[1]
else:
  t[0],t[1] = x[0],x[0]
  
max = t[0]
count= a.count(max)
for i in range(n):
  if a[i] == max:
    if count > 1:
      print(max)
    else:
      print(t[1])
  else:
    print(max)
Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = list(map(int, input().split()))

s = 0
d = 0
for i in range(n):
  d += l[i]
  s += 1
  if d >= x:
    break
print(s)

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

if a <= x: print(10)
else: print(0)
Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = list(map(int, input().split()))

ans = 1
t = 0
for i in range(x):
  t += l[i]
  if t <= x:
    ans += 1

print(ans)

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

s = 1
d = 0
for i in l:
  d += i
  if d <= x:
    s += 1
print(s)

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

ans = 1
t = 0
for i in range(x):
  t += l[i]
  if t <= x:
    ans += 1
  else:
    break
print(ans)

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

s = 1
d = 0
for i in l:
  d += i
  if d <= x:
    s += 1
print(s)

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

s = 0
d = 0
for i in range(n):
  d += l[i]
  s += 1
  if t > x:
    break
print(s)

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

s = 1
d = 0
for i in l:
  d += i
  if d <= x:
    s += 1
print(s)

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

s = 0
t = 0
for i in range(n+1):
  t += l[i]
  s += 1
  if t >= x:
    break
print(s)

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

s = 1
d = 0
for i in l:
  d += i
  if d <= x:
    s += 1
print(s)

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

s = 0
t = 0
for i in range(n+1):
  t += l[i]
  s += 1
  if t > x:
    break
print(s)

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

s = 1
d = 0
for i in l:
  d += i
  if d <= x:
    s += 1
print(s)
Buggy python submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

if w%x == 0 and h%y == 0:
  print(w*h/2, 1)
else:
  print(w*h/2, 0)

Fixed submission:
w,h,x,y = map(int, input().split())

t = w * h / 2

if x == w/2 and y == h/2:
  print(t, 1)
else:
  print(t, 0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))

s1, s2 = 0, sum(w)
ans = sum(w)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans, abs(s1, - s2))
print(ans)

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

s1, s2 = 0, sum(w)
ans = sum(w)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans, abs(s1 - s2))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

nums = list(range(1,n+1))
ans = 0
for i in nums:
  for j in lr:
    if i < j[0] or i > j[1]:
      break
  else:
    ans += 1
print(ans)

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r

x = min(b)
y = max(a)
if x >= y:
  print(x-y+1)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r
  
s = 0
for i in range(a[m-1], b[m-1]+1):
  t = 0
  for j in range(m):
    if a[j] <= i and i <= b[j]:
      t += 1
    else:
      break
  if t == m:
    s += 1
print(s)

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r

x = min(b)
y = max(a)
if x >= y:
  print(x-y+1)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

p = []
for i in range(m):
  l,r = map(int, input().split())
  p.append([l,r])
  
s = 0
for i in range(1, n+1):
  t = 0
  for l,r in p:
    if l <= i and i <= r:
      t += 1
    else:
      break
  if t == m:
    s += 1
print(s)

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r

x = min(b)
y = max(a)
if x >= y:
  print(x-y+1)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

p = []
for i in range(m):
  l,r = map(int, input().split())
  p.append([l,r])
  
  
s = 0
for i in range(1, n+1):
  t = 0
  for l,r in p:
    if l <= i and i <= r:
      t += 1
  if t == m:
    s += 1
print(s)

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r

x = min(b)
y = max(a)
if x >= y:
  print(x-y+1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int, input().split())

ans = 0
for i in range(n//r+1):
  for j in range(n//g+1):
    if n - (r*i + g*j) >= 0 and (n - (r*i + g*j)) % b == 0: ans += 1
print(ans)

Fixed submission:
from math import ceil
r,g,b,n = map(int, input().split())

ans = 0
for i in range(ceil(n/r)+1):
  for j in range(ceil(n/g)+1):
    if n - (r*i + g*j) >= 0 and (n - (r*i + g*j)) % b == 0: ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
r,g,b,n = map(int, input().split())

ans = 0
for i in range(ceil(n/r)+1):
  for j in range(ceil(n/g)+1):
    if n - (r*i + g*j) >= 0 and (n - (r*i + g*j)) % b == 0: ans += 1
print(ans)

Fixed submission:
from math import ceil
r,g,b,n = map(int, input().split())

ans = 0
for i in range(ceil(n/r)+1):
  for j in range(ceil(n/g)+1):
    if n - (r*i + g*j) >= 0 and (n - (r*i + g*j)) % b == 0: ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int ,input().split())
s = input()

for _ in range(q):
  ans = 0
  l,r = map(int, input().split())
  for i in range(l,r):
    if s[i-1] == "A" and s[i] == "C": ans += 1
  print(ans)
      
  

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

nums = [0]*n
for i in range(n):
  if s[i] == "C":
    if s[i-1] == "A": nums[i] += 1
  if i != n-1: nums[i+1] = nums[i]

for _ in range(q):
  l,r = map(lambda x: int(x)-1, input().split())
  print(nums[r]-nums[l])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()

for _ in range(q):
  l,r = map(int, input().split())
  l -= 1
  print(s[l:r].count("AC"))

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

nums = [0]*n
for i in range(n):
  if s[i] == "C":
    if s[i-1] == "A": nums[i] += 1
  if i != n-1: nums[i+1] = nums[i]

for _ in range(q):
  l,r = map(lambda x: int(x)-1, input().split())
  print(nums[r]-nums[l])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])

l = [0]*(n-1)
for i in range(n-1): l[i] = h[i+1]-h[i]

s = 0
t = float("inf")
for i in range(n-k+1):
  p = sum(l[i:i+k-1])
  if p < t:
    t = p
    s = i
    
print(h[s+k-1] - h[s])

Fixed submission:
n,k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])

ans = 0
t = float("inf")
for i in range(n-k+1):
  if abs(h[i+k-1] - h[i]) < t:
    t = abs(h[i+k-1] - h[i])
    ans = i

print(h[ans+k-1] - h[ans])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

l = [[] for _ in range(n)]
city = []
for i in range(m):
  p,y = map(int, input().split())
  city.append([p,y])
  l[p-1].append(y)

for i in l: i.sort()
for i in city:
  ans = ""
  ans += "0"*(6-len(str(i[0])))+str(i[0])
  t = str(l[i[0]-1].index(i[1])+1)
  ans += "0"*(6-len(t))+t
  print(ans)

Fixed submission:
from bisect import bisect_left
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(bisect_left(l[p],y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(l[p].index(y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)

Fixed submission:
from bisect import bisect_left
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(bisect_left(l[p],y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(l[p].index(y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)

Fixed submission:
from bisect import bisect_left
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(bisect_left(l[p],y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)