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

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

order = []
for j in range(1, n+1):
    for c, k in enumerate(a, start=1):
        if j == k:
            order.append(c)
            break

result = str(order).strip("[]").replace(",", "")
print(result)

### FIXED CODE ###

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

s = [0] * n
for i, m in enumerate(a, start=1):
    s[m - 1] = i

b = " ".join(list(map(str, s)))
print(b)
### BUGGY CODE ###

import bisect

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

# index list
lst = [0] * (N + 1)
for i in range(N):
    lst[P[i]] = i

finished = [-1, -1, lst[N], N, N] # index set
#print(finished)
ans = 0
for i in range(N - 1, 0, -1):
    idx = lst[i]
    idx2 = bisect.bisect_left(finished, idx)
    finished = finished[:idx2] + [idx] + finished[idx2:]
    #print(finished)
    x = finished[idx2 - 1]
    y = finished[idx2 + 1]
    z = finished[idx2 + 2]
    w = finished[idx2 - 2]
    #print('When P_i = {}, w={}, x={}, y={}, z={}'.format(i,w,x,y,z))

    C = (x - w) * (y - idx) + (idx - x) * (z - y)
    ans += i * C
    #print('ans = {}'.format(ans))

print(ans)

### FIXED CODE ###

N = int(input())
P = [None] + [int(x) for x in input().split()]
id_list = [None] * (N+1)
for i,x in enumerate(P[1:],1):
    id_list[x] = i

# 左隣にあるインデックスを取得できるようにしておく
# Binary Iindex Treeを使うことで、区間[L,R]内での和をとれば[L,R]内のデータ件数を数えられる
class BIT:
    def __init__(self, n):
        # 要素数を与えてインスタンス化
        self.size = n
        self.tree = [0] * (n + 1) # index must be 1-origin

    def add(self, i, x=1):
        # add x(>= 1) to a_i
        while i <= self.size:
            self.tree[i] += x
            i += i&(-i) # i&(-i) = BITでのi番目の区間の長さ

    def sum(self, i):
        # sum of a_1, a_2, ... , a_i
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & (-i) # i&(-i) = BITでのi番目の区間の長さ
        return s

    def search(self, x):
        # 二分探索。a_1 + a_2 + ... + a_i >= xなる最小のインデックスi(>= 1)を返す
        i = 0
        s = 0
        step = 1<<(N.bit_length()-1) # the largest 2^k (= step) <= N
        while step:
            if i+step <= N and s + self.tree[i+step] < x:
                i += step
                s += self.tree[i]
            step >>= 1
        return i+1


def main():
    bit = BIT(N)
    ans = 0
    for x in range(N,0,-1):
        idx = id_list[x]
        L = bit.sum(idx) # 左にある既に書き込んだ数の個数
        bit.add(idx)
        R = N-x-L # 右にある既に書き込んだ数の個数
        ll = bit.search(L-1) if L >= 2 else 0
        l = bit.search(L) if L >= 1 else 0
        r = bit.search(L+2) if R >= 1 else N+1
        rr = bit.search(L+3) if R >= 2 else N+1
        coef = 0
        if l != 0:
            # [b,c]を含むようにする。(a,b) と(c,d)が自由
            coef += (l - ll) * (r - idx)
        if r != 0:
            # [c,d]を含むようにする。
            coef += (rr - r) * (idx - l)
        ans += x * coef
    print(ans)

main()
### BUGGY CODE ###

n = int(input())
set0=set([0])
set1 =set()
from collections import deque
ls = deque([])
for _ in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))

ans = [-1] * n
ans[0] = 0
while ls:
    u, v, w = ls.popleft()
    if w == 0: # same
        if u in set0 or v in set0:
            #set0 |= set([u, v])
            set0.add(u)
            set0.add(v)
            ans[u]=0
            ans[v]=0
        elif u in set1 or v in set1:
            #set1 |= set([u, v])
            set1.add(u)
            set1.add(v)
            ans[u] = 1
            ans[v] = 1
        else:
            ls.append((u, v, w))
    else:#different
        if u in set0:
            set1.add(v)
            ans[v] =1
        elif v in set0:
            set1.add(u)
            ans[u] =1
        elif v in set1:
            set0.add(u)
            ans[u] =0
        elif u in set1:
            set0.add(v)
            ans[v] =0
        else:
            ls.append((u, v, w))

for i in ans:
    print(i)

### FIXED CODE ###

n = int(input())
explored = set()
next = [[]for _ in range(n)]

from collections import deque
ls = []
for i in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))
    next[u-1].append((v-1, w%2))
    next[v-1].append((u-1, w%2))

ans = [-1] * n

exploring = deque()
next_que = deque([0])
ans[0]=0
explored.add(0)
while next_que:
    i = next_que.popleft()
    exploring.extend(next[i])
    while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a)


for i in ans:
    print(i)
### BUGGY CODE ###

# coding:utf-8
# Doubly Linked List


def main():

    n = int(input())
    dll = []
    for _ in range(n):
        operation = input()[::]
        if operation[0] == 'i':
            dll.insert(0, operation[7:])
        
        elif operation[6] == ' ':
            try:
                dll.remove(operation[7:])
            except:
                pass

        else:
            if operation[6] == 'F':
                dll.pop(0)
            else:
                dll.pop()

    print(' '.join(dll))

if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding:utf-8
# Doubly Linked List

from collections import deque

def main():

    n = int(input())
    dll = deque()

    for _ in range(n):
        operation = input().split(' ')
        if operation[0] in ["insert", "delete"]:
            key = operation[1]
            if operation[0] == "insert":
                dll.appendleft(key)
            else:
                try:
                    dll.remove(key)
                except:
                    pass

        else:
            if operation[0][6] == 'F':
                dll.popleft()

            else:
                dll.pop()

    print(' '.join(dll))

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

from collections import deque

def bfs(idx,k):
  q = deque()
  visited[idx] = True
  q.append(idx)
  color = 0
  while q:
    r = q.pop()
    for n in set(graph[r].keys()):
      if not visited[n]:
        if color not in graph[r].values():
          graph[r][n] = color
          graph[n][r] = color
          color = (color+1)%k
        else:
          color = (color+1)%k
          graph[r][n] = color
          graph[n][r] = color
          color = (color+1)%k
        visited[n] = True
        q.append(n)

        
N = int(input())
graph = {}
visited = [False]*(N+1)
for i in range(N+1):
  graph[i] = {}
ab = []
for i in range(N-1):
  a,b = map(int,input().split())
  ab.append((a,b))
  graph[a][b] = -1
  graph[b][a] = -1
  
k = 0
for i in range(1,N+1):
  k = max(k,len(graph[i]))

bfs(1,k)
print(k)
for i in range(N-1):
  a,b = ab[i]
  print(graph[a][b]+1)

  


  


### FIXED CODE ###

from collections import deque

def bfs(idx,k,colored):
  q = deque()
  visited[idx] = True
  q.append(idx)
  while q:
    r = q.pop()
    color = 0
    for n in graph[r].keys():
      if not visited[n]:
        if color == colored[r]: color+=1
        colored[n] = color
        graph[r][n] = color
        graph[n][r] = color
        color += 1

        visited[n] = True
        q.append(n)

        
N = int(input())
graph = {}
colored = [-1]*(N+1)
visited = [False]*(N+1)
for i in range(N+1):
  graph[i] = {}
ab = []
for i in range(N-1):
  a,b = map(int,input().split())
  ab.append((a,b))
  graph[a][b] = -1
  graph[b][a] = -1
  
k = max([len(graph[i]) for i in range(1,N+1)])

bfs(1,k,colored)
print(k)
for a,b in ab:
  print(graph[a][b]+1)
### BUGGY CODE ###

N = int(input())

divList = []

n = N

while n != 1:
    div = 1
    for i in range(2, n+1):
        if n % i == 0:
            div = i
            break
    divList.append(div)
    n = int(n / div)
    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))


### FIXED CODE ###

N = int(input())


def countDigits(n):
    return len(str(n))


ans = countDigits(N)
A = 1
while A * A <= N:
    if(N % A != 0):
        A += 1
        continue
    B = N // A

    cur = max(countDigits(A), countDigits(B))
    if (ans > cur):
        ans = cur
    A += 1
print(ans)
### BUGGY CODE ###


N=int(input())
S=list(input())
bango=[]
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            s=[S[i],S[j],S[k]]
            n=''.join(s)
            if n not in bango:
                ans+=1
            bango.append(n)
print(ans)

### FIXED CODE ###


N=int(input())
S=list(input())
numlist=range(1000)
ans=0

for i in numlist:
    num=str(i)
    if len(num)==1:
        num="00"+num
    if len(num)==2:
        num="0"+num
    if num[0] in S[:N-1]:
        num1=S.index(num[0])
        if num[1] in S[num1+1:N-1]:
            S2=S[num1+1:N-1]
            num2=S2.index(num[1])+num1+1
            if num[2] in S[num2+1:]:
                ans+=1
print(ans)
### BUGGY CODE ###

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

    A.sort()

    ans = 0
    modlist = list()
    ignor = list()
    for i in range(N):
        flag = True
        for j, m in enumerate(modlist):
            if A[i] in ignor:
                flag = False
                break
            if m == A[i]:
                ignor.append(A[i])
                ans -= 1
                flag = False
                break

            if A[i] % m == 0:
                flag = False
                break
        if flag:
            modlist.append(A[i])
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import sqrt
from collections import Counter


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

    ans = 0
    p = [0] * (10**6 + 1)
    c = Counter(A)

    for a in c.keys():
        tmp = a * 2
        while tmp <= 10**6:
            p[tmp] = 1
            tmp += a

    for a in A:
        if p[a] == 0 and c[a] == 1:
            ans += 1

    print(ans)


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

S = input().strip()
T = input().strip()

import bisect

dp = {}
dp[-1] = []

for c in S:
  ndp = {}
  for k, v in dp.items():
    j = T.find(c, k+1)
    if k not in ndp or (len(v) > len(ndp[k])):
      ndp[k] = v[:]
    if j != -1:
      if j not in ndp or (len(v) + 1 > len(ndp[j])):
        ndp[j] = v[:] + [c]
  dp = ndp

ans = ''
for s in list(map(lambda x: ''.join(x), dp.values())):
  if len(s) > len(ans):
    ans = s
print(ans)


### FIXED CODE ###

S = input().strip()
T = input().strip()


dp = [[0] * (len(T)+1) for _ in range(len(S)+1)]

for i, s in enumerate(S):
  for j, t in enumerate(T):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i][j-1], dp[i-1][j])
ans = []
s = (len(S)-1, len(T)-1)
while True:
  x, y = s
  if x < 0 or y < 0:
    break
  if S[x] == T[y]:
    ans.append(S[x])
    s = (x-1, y-1)
  else:
    if dp[x-1][y] > dp[x][y-1]:
      s = (x-1, y)
    else:
      s = (x, y-1)

    
print(''.join(reversed(ans)))
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left
from heapq import heappush,heappop
from collections import deque,defaultdict
from sys import stdin,stdout


def main():
  ## input
  N,Q = map(int, stdin.readline().rstrip().split())
  STX = deque()
  for i in range(N):
    s,t,x = map(int, stdin.readline().rstrip().split())
    STX.append([x,s-x,t-x])
  Dn = [int(stdin.readline().rstrip()) for _ in range(Q)]+[10**10]

  ans = defaultdict(lambda:-1)
  for x,s,t in sorted(list(STX)):
    l = bisect_left(Dn,s)
    while Dn[l] < t:
      ans[Dn[l]] = x
      Dn.pop(l)
  for d in Dn[:-1]:
    ans[d] = -1

  return ans


if __name__ == "__main__":
  ans = main()
  for d in sorted(list(ans.keys())):
    print(ans[d])
    

### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

n=int(input())
L=[int(i) for i in input().split()]
L.sort(reverse=True)

def binary(a,b,mid):
  if  L[mid]+L[j]>L[i]:
    return True
  else:
    return False

ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    l=j
    r=n
    while r-l>1:
      mid=(r+l)//2
      if binary(i,j,mid):
        l=mid
      else:
        r=mid
    ans+=l-j
print(ans)
        

### FIXED CODE ###

from bisect import bisect_right
n=int(input())
L=[int(i) for i in input().split()]
L.sort()


ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    c=L[i]+L[j]-1
    ans+=bisect_right(L,c)-j-1
    
print(ans)
### BUGGY CODE ###

# ABC 127 c
n, m = [int(el) for el in input().split(' ')]
for i in range(m):
    l, r = [int(el) for el in input().split(' ')]
    if i == 0:
        cards = set(range(l, r + 1))
    else:
        newcards = set(range(l, r + 1))
        cards = cards.intersection(newcards)
print(len(cards))


### FIXED CODE ###

# ABC 127 c
n, m = [int(el) for el in input().split(' ')]
max_l = 0
min_r = n
for i in range(m):
    l, r = [int(el) for el in input().split(' ')]
    max_l = max(max_l, l)
    min_r = min(min_r, r)

print(max(min_r - max_l + 1, 0))
### BUGGY CODE ###

import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())
# import heapq
# import bisect
# import math
import itertools
from collections import Counter
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    l = [0, 1]
    ans = 0
    mod = 998244353
    for comb in itertools.product(l, repeat=N):
        if np.dot(comb, A) == S:
            ans += 2 **(N - sum(comb))
            ans %= mod
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())



def input():
    return sys.stdin.readline().rstrip()


def main():
    mod =998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    dp =[[0]*(S+1) for _ in range(N+1)]
    dp[0][0]=1
    for i in range(0,N):
        for j in range(S+1):
            if A[i]>j:
                dp[i+1][j] =dp[i][j]*2
                dp[i+1][j] %= mod
            else:
                dp[i+1][j] = dp[i][j]*2 + dp[i][j-A[i]]
                dp[i+1][j] %= mod
    print(dp[N][S])
    pass



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

n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
m = float("inf") * (-1)
for i in range(n-1):
    for j in range(i+1,n):
        if m < (x[j] - x[i]):
            m = x[j] - x[i]
print(m)



### FIXED CODE ###

n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
mx = float("inf") * (-1)
mn = x[0]
for i in range(1,n):
    if mx < (x[i] - mn):
        mx = x[i] - mn
    if mn > x[i]:
        mn = x[i]
print(mx)
### BUGGY CODE ###

import sys
from collections import deque
def main():
    n = int(input())
    q = deque(map(int, sys.stdin.readline().split()))
    cnt=1
    while q:
        print(q.count(cnt))
        cnt +=1
        q.popleft()
    print(0)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n+1])
### BUGGY CODE ###

n = int(input())
s = [['n' for i in range(10)] for j in range(n)]
for i in range(n):
    s[i]=list(input())
    s[i].sort()
j=0
ans=0
for i in range(n):
    j=n-1
    while j>i:
        if s[i]==s[j]:
            ans = ans + 1
        j=j-1

print(ans)


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
s.sort()
ans = 0
t = 0
for i in range(1,n):
    if s[i-1]==s[i]:
        t += 1
        if i==n-1:
            ans += t*(t+1)/2
    else:
        if t>0:
            ans += t*(t+1)/2
            t = 0

print(int(ans))
### BUGGY CODE ###

x,y=map(int,input().split())
if(x==y):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1


### FIXED CODE ###

x,y=map(int,input().split())
if(x%y==0):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1
### BUGGY CODE ###

n=int(input())
lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
diflist=[]
for i in range(n):
    for j in range(n):
        if i!=j:
            add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
            diflist.append(add)
        else:
            continue
            
length=0
for some in diflist:
    cnt=0
    for i in range(n):
        for j in range(n):
            if i!=j:
                check=[lists[i][0]-lists[j][0],lists[i][1]-lists[j][1]]
                if check==[some[0],some[1]]:
                    cnt+=1
            else:
                continue

    length=max(length,cnt)
print(n-length)

### FIXED CODE ###

n=int(input())
lists=[]
if n>=2:
    for i in range(n):
        a,b=map(int,input().split())
        lists.append([a,b])
    diflist=[]
    for i in range(n):
        for j in range(n):
            if i!=j:
                add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
                diflist.append(add)
            else:
                continue
    import collections
    dic=collections.Counter(diflist)
    value=dic.values()
    a=max(value)
    print(n-a)
else:
    print(1)
### BUGGY CODE ###

d = []
e = 0
n = int(input())
for i in range(n):
    a = input()
    if a not in d:
        d.append(a)
        e += 1
print(e)

### FIXED CODE ###

d = set()
n = int(input())
for i in range(n):
   d.add(input())
print(len(d))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000000)
def mod_combination(n, k, mod):
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-mod_combination(n, a, mod)-mod_combination(n, b, mod))%mod)

### FIXED CODE ###

def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  
    denomi = 1  

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod

n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-binomial_coefficients(n, a)-binomial_coefficients(n, b))%mod)
### BUGGY CODE ###

s = input()
s_len = int(len(s))
count = 0
n = int(s_len*(s_len+1)/4)
for _ in range(n):
  num = s.count('BW')
  s = s.replace('BW','WB')
  count += num
print(count)

### FIXED CODE ###

S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)
### BUGGY CODE ###

N = int(input())

v = list(map(int,input().split()))
v_odd = []
v_eve = []
v_odd_set = []
v_eve_set = []
v_odd_count = []
v_eve_count = []
v_o_max = 0
v_e_max = 0

v_odd = v[::2]
v_eve = v[1::2]

v_odd_set = list(set(v_odd))
v_eve_set = list(set(v_eve))

for c in v_odd_set:
    a = v_odd.count(c)
    v_odd_count.append(a)
    if a == max(v_odd_count):
        v_o_max = c
    else:
        continue

for c in v_eve_set:
    a = v_eve.count(c)
    v_eve_count.append(a)
    if a == max(v_eve_count):
        v_e_max = c
    else:
        continue

v_odd_count.sort()
v_eve_count.sort()

if len(v_odd_count) != 1 or len(v_eve_count) != 1:
    if v_o_max == v_e_max:
        if v_odd_count[-1] >= v_eve_count[-2]:
            print(N - v_eve_count[-1] - v_eve_count[-2])
        else:
            print(N - v_odd_count[-1] - v_eve_count[-2])
    else:
        print(N - v_eve_count[-1] - v_odd_count[-1])
else:
    if v_o_max == v_e_max:
        print(int(N/2))
    else:
        print(0)

### FIXED CODE ###

import collections
c = collections.Counter

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

v_odd = v[::2]
v_eve = v[1::2]

c1 = c(v_odd).most_common(2)
c2 = c(v_eve).most_common(2)

if len(c1) == 1 and len(c2) == 1:
    if c1[0][0] != c2[0][0]:
        ans = 0
    else:
        ans = int(N/2)
else:
    if c1[0] != c2[0]:
        ans = N - c1[0][1] - c2[0][1]
    else:
        if c1[1][1] >= c2[1][1]:
            ans = N - c1[1][1] - c2[0][1]
        else:
            ans = N - c1[0][1] - c2[1][1]

print(ans)
### BUGGY CODE ###

N = int(input())
L = sorted(list(map(int, input().split())))
cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        left = j
        right = N
        v = L[i] + L[j]
        while right - left > 1:
            mid = (left + right) // 2
            if L[mid] < v:
                left = mid
            else:
                right = mid
        cnt += left - j
print(cnt)


### FIXED CODE ###

import bisect
N = int(input())
L = sorted(list(map(int, input().split())))
cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        v = bisect.bisect_left(L, a + b)
        cnt += v - j - 1
print(cnt)
### BUGGY CODE ###

N = int(input())
A,B = [],[]
for _ in range(N-1):
    array = list(map(int,input().split()))
    A.append(array[0])
    B.append(array[1])
from collections import defaultdict as ddict
children = ddict(list)
for a,b in zip(A,B):
    children[a].append(b)
ans = ddict(int)
col = 0
for child in sorted(children.keys()):
    used = set({0,ans[child]})
    for j in sorted(children[child]):
        temp = min(set(range(max(used)+2))-used)
        ans[j] = temp
        col = max(col,temp)
        used.add(temp)
print(col)
for b in B:
    print(ans[b])

### FIXED CODE ###

N = int(input())
AB = [[]]*(N-1)
for i in range(N-1):
    AB[i] = list(map(int,input().split()))
from collections import defaultdict as ddict
from collections import deque
tree = ddict(list)
B = [0]*(N-1)
for i,ab in enumerate(AB):
    tree[ab[0]].append(ab[1])
    B[i] = ab[1]
# 各エッジの色を格納する変数の初期化
# C[0]は使わない
C = [0]*N
# 幅優先探索用のcue
Q = deque([1])
while Q:
    q = Q.popleft()
    c = 0
    for w in tree[q]:
        # 色をインクリメントした際に親の色とかぶったら更に1を加算する
        # 他は単純なインクリメント
        c += 1 + int(C[q-1] == c+1)
        # エッジの色を格納
        C[w-1] = c
        # 子供をcueに追加
        Q.append(w)
print(max(C))
for b in B:
    print(C[b-1])
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
ans=[]
for i in range(q):
    l,r=map(int,input().split())
    ans.append(s[l-1:r].count('AC'))
for i in range(len(ans)):
    print(ans[i])

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])