Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def print_list(n, s, list_q):
    tmp = 0
    count = 0
    list_q[1] = n - list_q[1]
    for i in range(list_q[0] - 1):
        s = s[1:]
    for i in range(list_q[1]):
        s = s[:-1]
    s = s.split("AC")
    print(len(s) - 1)


n, q = map(int, input().split())
s = input()
for i in range(q):
    print_list(n, s, list(map(int, input().split())))


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = list(input())[:-1]
list_Sum = [0]*(N+1)
for i in range(1, N):
    list_Sum[i+1] = list_Sum[i]
    if S[i-1] == "A" and S[i] == "C":
        list_Sum[i+1] += 1
for i in range(Q):
    l, r = map(int,input().split())
    print(list_Sum[r]-list_Sum[l])
### BUGGY CODE ###

N, K = map(int, input().split())
As = sorted(map(int, input().split()))

def check(t):
    "if the number of the pairs (i, j) that satisfies Ai * Aj <= t is < K, return True"
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            #index = bisect_right(As, t//A, lo = i+1) - (i+1)
            l = i
            r = N
            while r - l > 1:
                mid = (l + r) // 2
                if As[mid] <= t//A:
                    l = mid
                else:
                    r = mid
            index = r - (i+1)
        elif A < 0:
            #index = N - bisect_left(As, -((-t)//A), lo = i+1)
            l = i
            r = N
            while r - l > 1:
                mid = (l + r) // 2
                if As[mid] < -((-t)//A):
                    l = mid
                else:
                    r = mid
            index = N - r
        else:
            if t < 0:
                index = 0
            else:
                index = N - i - 1
        count += index
    return (count < K)
        

l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while r - l > 1:
    mid = (l + r) // 2
    if check(mid):
        l = mid
    else:
        r = mid

print(r)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

b = []
for i, a in enumerate(A):
	if not i % 2:
		b.append(a)
	else:
		b.insert(0, a)

if not len(A) % 2:
	print(*b)
else:
	print(*b[::-1])


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
"""
b = []
for i, a in enumerate(A):
	if not i % 2:
		b.append(a)
	else:	
		b.insert(0, a)

if not len(A) % 2:
	print(*b)
else:
	print(*b[::-1])
"""
print(*(A[::-2] + A[len(A) % 2::2]))
### BUGGY CODE ###

n = int(input())

for i in range(1, n + 1):
    ans = 0
    limit = int(i ** 0.5) + 1
    for x in range(1, limit):
        for y in range(x, limit):
            for z in range(y, limit):
                if (x + y + z) ** 2 == i + x * y + y * z + z * x:
                    if len(set([x, y, z])) == 1:
                        ans += 1
                    elif len(set([x, y, z])) == 2:
                        ans += 3
                    else:
                        ans += 6
    print(ans)


### FIXED CODE ###

n = int(input())

ans = [0] * (10 ** 4 + 1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x * x + y * y + z * z + x * y + y * z + z * x
            if s <= 10 ** 4:
                ans[s] += 1

for i in range(1, n + 1):
    print(ans[i])
### BUGGY CODE ###

import bisect

N = int(input())
Ali = [int(input()) for _ in range(N)]
n = N
c = 0

while n > 0:
  dp = [Ali[0]]
  Ali2 = []
  for i in range(1,n):
    a = Ali[i]
    if a > dp[-1]:
      dp.append(a)
    else:
      b = bisect.bisect_left(dp, a)
      Ali2.append(dp[b])
      dp[b] = a
  Ali = Ali2[::1]
  n = len(Ali)
  c += 1
    
print(c)

### FIXED CODE ###

from bisect import bisect
import heapq

N = int(input())
A = [int(input()) for _ in range(N)]
q = []
A.reverse()

for i in range(N):
  ii = bisect(q,A[i])
  if ii == len(q):
    heapq.heappush(q,A[i])
  else:
    q[ii] = A[i]
    
print(len(q))
### BUGGY CODE ###

import collections
N = int(input())
S = [input() for i in range(N)]

#重複チェック
dup = [x for x in set(S) if S.count(x) > 1]
l = len(dup)

if not dup:
    ans = sorted(S)
    for i in ans:
        print(i)
else:
    c = collections.Counter(S)
    value,count = zip(*c.most_common(l))

    if len(set(count)) == 1:
        s = sorted(value)
        for i in s:
            print(i)
    else:
        for i in value:
            print(i)
            exit()

### FIXED CODE ###

import collections
N = int(input())
S = [input() for i in range(N)]

c = collections.Counter(S)
value,count = zip(*c.most_common())

s = sorted(value)
ans = []
if len(set(count)) == 1 :
    for i in s:
        print(i)
else: 
    for i in range(len(value)):
        ans.append(value[i])
        if count[i] > count[i+1]:
            [print(i) for i in sorted(ans)]
            exit()
### BUGGY CODE ###

# D - Binomial Coefficients

import sys
readline = sys.stdin.readline

n = int(readline())
A = list(int(a) for a in readline().split())
A.sort(reverse=True)

def comb(n, r):
    num = 1
    den = 1
    r = min(r, n-r)
    for i in range(r):
        num = (num * (n-i))
        den = (den * (i+1))
    return num // den

tmp = 0
ans = (0, 0)
for i in range(1, n):
    c = comb(A[0], A[i])
    if tmp < c:
        tmp = c
        ans = (A[0], A[i])

print(' '.join(map(str, ans)))    

### FIXED CODE ###

# D - Binomial Coefficients

import sys
readline = sys.stdin.readline

n = int(readline())
A = list(int(a) for a in readline().split())
A.sort(reverse=True)

N = A[0]
R = 0
tmpR = 0
for i in range(1, n):
    tmp = min(A[i], N-A[i])
    if tmpR < tmp:
        tmpR = tmp
        R = A[i]       

print(N, R)
### BUGGY CODE ###

def solve():
    from operator import itemgetter

    turns = tuple(map(int, input().split()))[1]
    cardsList = sorted(list(map(int, input().split())))

    turnsList = [tuple(map(int, input().split())) for _ in range(turns)]
    for chances, num in sorted(turnsList, key=itemgetter(1), reverse=True):
        for i in range(chances):
            if num > cardsList[i]:
                cardsList[i] = num
            elif i == 0:
                return print(sum(cardsList))
            else:
                break
        cardsList.sort()
    print(sum(cardsList))
solve()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter

def solve():
    cardsNum, turnsNum = tuple(map(int, input().split()))
    cards = sorted([int(x) for x in input().split()])
    turns = sorted([tuple(int(x) for x in input().split()) for _ in range(turnsNum)], key=itemgetter(1), reverse=True)
    
    largeCount = 0
    largeCards = [0,] * cardsNum
    for chances, num in turns:
        for _ in range(chances):
            if (largeCount < cardsNum):
                largeCards[largeCount] = num
                largeCount += 1
            else:
                break
        if (largeCount >= cardsNum):
            break 
    
    for i in range(cardsNum):
        if (largeCards[i] > cards[i]):
            cards[i] = largeCards[i]
        else:
            break
    print(sum(cards))
solve()
### BUGGY CODE ###

def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def Ind(b,n):
    count=0
    while n%b==0:
        count+=1
        n//=b
    return count

N=int(input())
X=input()
x=0
for i in range(N):
    x=2*x+int(X[i])

a=Ind(2,N)
n=N//(2**a)
d=divisors(n)
data={i*2**(a+1):0 for i in d}
mod=998244353

for i in d:
    Q=((2**(i*2**a)+1)*(x+1))//(2**N+1)
    Q%=mod
    data[i*2**(a+1)]+=Q
    data[i*2**(a+1)]%=mod


for i in d:
    for j in d:
        if i>j and i%j==0:
            data[i*2**(a+1)]-=data[j*2**(a+1)]
            data[i*2**(a+1)]%=mod


ans=0
for i in data:
    ans+=data[i]*i
    ans%=mod
print(ans)

### FIXED CODE ###

def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def Ind(b,n):
    count=0
    while n%b==0:
        count+=1
        n//=b
    return count

N=int(input())
X=input()
x=0
for i in range(N):
    x=2*x+int(X[i])

a=Ind(2,N)
n=N//(2**a)
d=divisors(n)
data={i*2**(a+1):0 for i in d}
mod=998244353

for i in d:
    Q=((2**(i*2**a)+1)*(x+1))//(2**N+1)
    Q%=mod
    data[i*2**(a+1)]+=Q
    data[i*2**(a+1)]%=mod


for i in d:
    for j in d:
        if i>j and i%j==0:
            data[i*2**(a+1)]-=data[j*2**(a+1)]
            data[i*2**(a+1)]%=mod


ans=0
for i in data:
    ans+=data[i]*i
    ans%=mod
print(ans)
### BUGGY CODE ###

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

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
    c = 0
    s = input()
    f = ''
    b = ''
    for _ in range(int(input())):
        q = input().split()
        if q[0] == '1':
            c += 1
        else:
            if (q[1] == '1' and c%2 == 0) or (q[1]=='2' and c%2==1):
                f = q[2] + f
            else:
                b += q[2]
    if c % 2 == 0:
        print(f+s+b)
    else:
        print(b[::-1]+s[::-1]+f[::-1])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
s=input()


count= n*(n-1)*(n-2)/6

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if k-j==j-i:
                count-=1
            else:
                if s[i]==s[j] or s[j]==s[k] or s[i]==s[k]:
                    count-=1
print(int(count))

### FIXED CODE ###

def reduce(arr,n):
    count=len(arr)*(len(arr)-1)*(n-len(arr))/2+len(arr)*(len(arr)-1)*(len(arr)-2)/6
    return count

n=int(input())
s=input()

r,g,b=[],[],[]

for i,j in enumerate(s):
    if j=='R':
        r.append(i)
    elif j=='G':
        g.append(i)
    else:
        b.append(i)

count= n*(n-1)*(n-2)/6
count-=reduce(r,n)
count-=reduce(g,n)
count-=reduce(b,n)

for i in range(n):
    for j in range(i+1,n):
        if j+(j-i)<n:
            if s[i]!=s[j] and s[j]!=s[j+(j-i)] and s[i]!=s[j+(j-i)]:
                count-=1
print(int(count))
### BUGGY CODE ###

def main():
  n, m = map(int, input().split())
  data = [[int(e) for e in input().split()] for _ in range(n)]
  d1 = {}
  for i in range(n):
    a, b = data[i]
    if a not in d1:
      d1[a] = []
    d1[a].append(b)
  result = 0
  d2 = {}
  for i in range(1, m + 1):
    if i in d1:
      for j in d1[i]:
        if j not in d2:
          d2[j] = 0
        d2[j] += 1
    else:
      if len(d2) == 0:
        continue
    maxb = max(d2.keys())
    result += maxb
    if d2[maxb] == 1:
      del d2[maxb]
    else:
      d2[maxb] -= 1
  print(result)
main()


### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())

end=[[] for i in range(N+2)]

for i in [0]*M:
    l,r,a=map(int,input().split())
    end[r+1].append((l,a))

#Starry Sky tree
seg_el=1<<18#Segment treeの台の要素数

SEG=[0]*(2*seg_el-1)#Segment tree.色々考えると0で初期化してOKそう
ADD=[0]*(2*seg_el-1)#加算用Segment tree,SEG[k]+ADD[k]がkにおける本当の最大値

def updates(a,b,x,k,l,r):#区間[a,b)にxを加算
    
    if a==l and r==b:
        ADD[k]+=x#そのノードのADD値を更新
        return

    if a>=(r+l)//2:
        updates(a,b,x,k*2+2,(l+r)//2,r)#左側の子のみを見る
    elif b<=(r+l)//2:
        updates(a,b,x,k*2+1,l,(l+r)//2)#右側の子のみを見る
    else:
        updates(a,(l+r)//2,x,k*2+1,l,(l+r)//2)#それ以外のときは,SEG[k*2+1]とSEG[k*2+2]で場合分け
        updates((l+r)//2,b,x,k*2+2,(l+r)//2,r)

    SEG[k]=max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2])

def update_solo(n,x,seg_el):#A[n]=xに更新（反映）
    i=n+seg_el-1
    SEG[i]=x
    i=(i-1)//2
    
    while i>=0:
        SEG[i]=max(SEG[i*2+1]+ADD[i*2+1],SEG[i*2+2]+ADD[i*2+2])
        i=(i-1)//2

for i in range(1,N+2):

    for b,x in end[i]:
        updates(b,i,x,0,0,seg_el)#点数がもらえる区間から出たときにその分を加算

    update_solo(i,SEG[0],seg_el)#[0,i)の最大値はSEG[0](=SEG[0]+ADD[0])と一致するはず

print(SEG[0])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())

end=[[] for i in range(N+2)]

for i in [0]*M:
    l,r,a=map(int,input().split())
    end[r+1].append((l,a))

#Starry Sky tree
seg_el=1<<18#Segment treeの台の要素数

SEG=[0]*(2*seg_el-1)#Segment tree.色々考えると0で初期化してOKそう
ADD=[0]*(2*seg_el-1)#加算用Segment tree,SEG[k]+ADD[k]がkにおける本当の最大値
seg_el_list=[524286, 262142, 131070, 65534, 32766, 16382, 8190, 4094, 2046, 1022, 510, 254, 126, 62, 30, 14, 6, 2, 0]

def update(k):#SEGのkより上のノードを更新（反映）
    while k>=0:
        k=(k-1)//2
        if SEG[k]==max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2]):
            break
        SEG[k]=max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2])

def to_seg(a):#aが終点となる区間をSegment treeの座標へ変換  
    b=(a&(-a)).bit_length()
    return seg_el_list[b]+a//(1<<(b-1))

def add(a,b,x):#区間(a,b]にxを加算
    #print(a,b,x)
    while b!=0:
        ADD[to_seg(b)]+=x
        update(to_seg(b))
        b-=(b&(-b))

    while a!=0:
        ADD[to_seg(a)]+=-x
        update(to_seg(a))
        a-=(a&(-a))
    
for i in range(N+2):
    for b,k in end[i]:
        add(b,i,k)#点数がもらえる区間から出たときにその分を加算

    SEG[i+seg_el-1]=SEG[0]
    update(i+seg_el-1)

print(SEG[0])
### BUGGY CODE ###

import math
n=int(input())
r=int(math.sqrt(n))
z=0
ans=0
for N in range(1,n+1):
    ans=0
    z=0
    for x in range(1,r):
        if x**2+x+x>=N:
            break
        for y in range(1,r):
            if x**2+y**2+x*y+x+y>=N:
                break
            #if (x+y)**2+4*N-4*(x**2+y**2)-4*x*y>=0:
            z=((-x-y)+math.sqrt((x+y)**2+4*N-4*(x**2+y**2)-4*x*y))/2
                #print(x,y,z)
            if z>=1 and z%1==0:
                ans+=1
                    #print(x,y,z)
    print(ans)


### FIXED CODE ###

n=int(input())
z=0
N=[0]*10000
ans=0
ko=0
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ko=x**2+y**2+z**2+x*y+y*z+z*x
            if ko<=n:
                N[ko-1]+=1
            else:
                break
for i in range(n):
    print(N[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math


dice0 = list(map(int, input().split()))
dice1 = list(map(int, input().split()))

def dice_roll(dice, c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]
    return dice

# up???????????????
num = 0
while dice0[0] != dice1[0]:
    if num % 2 == 0:
        dice0 = dice_roll(dice0, 'E')
    else:
        dice0 = dice_roll(dice0, 'N')
    num += 1

# front???????????????
while dice0[1] != dice1[1]:
    dice0 = dice_roll(dice0, 'R')

if dice0[2] == dice1[2] and dice0[3] == dice1[3] and dice0[4] == dice1[4] and dice0[5] == dice1[5]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math


dice0 = list(map(int, input().split()))
dice1 = list(map(int, input().split()))

def dice_roll(dice, c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]
    return dice


def check():
    global dice0
    global dice1

    # up???????????????
    num = 0
    while dice0[0] != dice1[0]:
        if num % 2 == 0:
            dice0 = dice_roll(dice0, 'E')
        else:
            dice0 = dice_roll(dice0, 'N')
        num += 1
        if num > 10:
            return False

    # front???????????????
    num = 0
    while dice0[1] != dice1[1]:
        dice0 = dice_roll(dice0, 'R')
        num += 1
        if num > 10:
            return False

    if dice0[2] == dice1[2] and dice0[3] == dice1[3] and dice0[4] == dice1[4] and dice0[5] == dice1[5]:
        return True
    else:
        return False

result = check()
if result:
    print('Yes')
else:
    # ????????????
    dice0 = dice_roll(dice0, 'N')
    result = check()
    if result:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n = int(input())
s = str(input())

check = dict()
def get_pattern2(i, j):
    a = s[i]
    b = s[j]
    total = 0
    check_str = ""
    if a == "R" or b == "R":
        check_str += "R"
    if a == "G" or b == "G":
        check_str += "G"
    if a == "B" or b == "B":
        check_str += "B"

    center = j - i
    if n < j + 1 + center:
        center = 0

    for k in range(j+1+center, n):
        if check_str+str(k) in check:
            total += check[check_str+str(k)]
            break
        if a != s[k] and b != s[k]:
            total += 1
    check[check_str+str(j+1+center)] = total

    for k in range(j+1, j+center):
        if a != s[k] and b != s[k]:
            total += 1
    return total

def get_pattern(i):
    a = s[i]
    total = 0
    for j in range(i+1, n):
        if a != s[j]:
            total += get_pattern2(i, j)
    return total

total = 0
for i in range(n-1, -1, -1):
    total += get_pattern(i)
print(total)


### FIXED CODE ###

n = int(input())
s = str(input())

check = dict()
def get_pattern2(i, j):
    a = s[i]
    b = s[j]
    total = 0
    check_str = ""
    if a == "R" or b == "R":
        check_str += "R"
    if a == "G" or b == "G":
        check_str += "G"
    if a == "B" or b == "B":
        check_str += "B"

    for k in range(j+1, n):
        if check_str+str(k) in check:
            total += check[check_str+str(k)]
            break
        if a != s[k] and b != s[k]:
            total += 1
    check[check_str+str(j+1)] = total
    return total

def get_pattern(i):
    a = s[i]
    total = 0
    for j in range(i+1, n):
        if a+str(j) in check:
            total += check[a+str(j)]
            break
        if a != s[j]:
            total += get_pattern2(i, j)
    check[a+str(i+1)] = total

    # k-j = i-jなものをぬく
    for j in range(i+1, n):
        k = j + j - i
        if k >= n:
            break
        if a != s[k] and s[j] != s[k] and a != s[j]:
            total -= 1
    return total

total = 0
for i in range(n-1, -1, -1):
    total += get_pattern(i)
print(total)
### BUGGY CODE ###

import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0
 
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)
### BUGGY CODE ###

n,x,y = [int(x) for x in input().split()]

for k in range(1, n):
    ans = 0
    for i in range(1,n):
        for j in range(i+1, n+1):
            if min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x)) == k:
                ans += 1
    print(ans)

### FIXED CODE ###

n,x,y = [int(x) for x in input().split()]
d = {x: 0 for x in range(1, n)}
for i in range(1,n):
    for j in range(i+1, n+1):
        d[min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1
for v in d.values():
    print(v)
### BUGGY CODE ###

import sys
import copy
import math
import itertools
import numpy as np
N = int(input())
A = [int(input()) for c in range(N)]

for i in range(N):
    max = 0
    for j in range(N):
        if j!=i:
            if max<A[j]:
                max = A[j]
    print(max)

### FIXED CODE ###

import sys
import copy
import math
import itertools
import numpy as np
N = int(input())
A = [int(input()) for c in range(N)]
B = sorted(copy.deepcopy(A),reverse=True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])
### BUGGY CODE ###

import math

a,b = map(int,input().split())


ans = 1
sosuu = [2]
A = min(a,b)+1
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)
        if a%L==0 and b%L==0:
            ans += 1

if a%2==0 and b%2==0:
    ans += 1
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())

if min(a,b) == 1:
    print(1)
    exit()

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

A = factorization(a)
B = factorization(b)
ans = len(set(A) & set(B))
print(ans+1)
### BUGGY CODE ###

import sys
a,b,m = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
ans = sys.maxsize
summoney = 0
for i in range(m):
  x,y,c = map(int,input().split())
  summoney = al[x-1] + bl[y-1] - c
  ans = min(ans,summoney)
for i in range(a):
  for j in range(b):
    summoney = al[i] + bl[j]
    ans = min(ans,summoney)
print(ans)

### FIXED CODE ###

a,b,m = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
yasuiyo = min(al) + min(bl)
ans = []
for i in range(m):
  x,y,c = map(int,input().split())
  ans.append(al[x-1] + bl[y-1] - c)

print(min(min(ans),yasuiyo))
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
L = []
R = []
B = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

for a, b in zip(L,R):
    A = S[a-1:b]
    B.append(A.count("AC"))

for b in B:
    print(b)

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])