Harryxun/stf_run huggingface dataset:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm_base(x,y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

n,m = LI()
a = LI()

lcm = lcm_list(a)
print((m//(lcm//2))-(m//lcm))

### FIXED CODE ###

import fractions
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm_base(x,y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

n,m = LI()
a = [int(i)//2 for i in LI()]

def num_of_2(x):
    c = 0
    while x%2==0:
        c+=1
        x//=2
    return c

a0 = num_of_2(a[0])
if any([num_of_2(i) != a0 for i in a]):
    print(0)
else:
    def lcm(x,y):
        return x//fractions.gcd(x,y)*y

    c = 1
    for i in a:
        c = lcm(c,i)
        if c>=inf:
            break
    
    ans = m//c
    print((ans+1)//2)
import networkx as nx

G = nx.Graph()

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

G.add_nodes_from(range(1, N + 1))
for _ in range(M):
    x, y, z = map(int, input().split())
    G.add_edge(y, z)

cnt = 0
for c in  nx.connected_components(G):
        cnt += 1
print(cnt)


### FIXED CODE ###

import queue
import sys
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
XYZ = []
for _ in range(M):
    XYZ.append(tuple(map(int, input().split())))

G=[[] for _ in range(N+1)]
for el in XYZ:
    G[el[0]].append(el[1])
    G[el[1]].append(el[0])
#print(G)

seen=[False]*(N+1)
todo=queue.Queue()
def bfs(n):
    seen[n]=True
    for nxt in G[n]:
        if seen[nxt]==False:
            bfs(nxt)


cnt=0
for check in range(1, N+1):
    if seen[check]==False:
        cnt+=1
        bfs(check)
print(cnt)
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

for i in range(len(ans)):
    print(ans[i])


### FIXED CODE ###

H,W = map(int, input().split())
A = [input() for _ in range(H)]
ind_H = []
ind_W = []
for h,a in enumerate(A):
    if '#' in a:
        ind_H.append(h)
        for w,s in enumerate(a):
            if s == '#':
                ind_W.append(w)
for h in ind_H:
    ans = ''
    for w in range(W):
        if w in ind_W:
            ans += A[h][w]
    print(ans)
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
    c -= b
    if c>0:
        a -=d
        if a<=0:
        print("no")
    else:
        print("Yes")
    


### FIXED CODE ###

try:
  a, b, c, d = map(int, input().split())
  while a > 0 and c > 0:
      c -= b
      if c>0:
          a -=d
          if a<=0:
          	print("No")
      else:
          print("Yes")
    
except:
  pass
def main():
    import sys
    import math
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    r = int(input())
    print(2*r*math.pi)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    A = sum([int(x) for x in input().strip().split()])
    if N - A < 0:
        print(-1)
    else:
        print(N - A)

if __name__ == '__main__':
    main()
N=int(input())
F=[ [[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
P= [[0 for _ in range(10)] for _ in range(N)]
total= [[0 for _ in range(5)] for _ in range(2)]

for i in range(N):
  tmp=list( map(int,input().split()) )
  for j in range(5):
    for k in range(2):
      F[i][j][k]=tmp[j+k]
for i in range(N):
  P[i]=list(map(int,input().split()))

for i in range(N):
  tmp=0
  for j in range(5):
    for k in range(2):
      tmp += 

### FIXED CODE ###

from itertools import product

N=int(input())
F=[ [[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
P= [[0] for _ in range(N)]
total= [[0 for _ in range(5)] for _ in range(2)]

for i in range(N):
  tmp=list( map(int,input().split()) )
  for j in range(5):
    for k in range(2):
      F[i][j][k]=tmp[2*j+k]
for i in range(N):
  P[i]=list(map(int,input().split()))
  
maxi=float("-inf")
combi=product([1,0],repeat=10)

for kumi in combi:
  mini=float("-inf")
  if sum(kumi)==0:
    pass
  else:      
    tmp=0
    for i in range(N):
      summ=0
      for k,open in enumerate(kumi):
        m,n = k//2, k%2
        summ += open * F[i][m][n]
      tmp += P[i][summ]
  maxi=max(maxi,tmp)
      
print(maxi)
K=input()
X=input()
if int(K)*500>=int(X):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

K,X=input().split()
if int(K)*500>=int(X):
    print('Yes')
else:
    print('No')
N = int(input())
p = list(map(int, input().split()))

i = 0
ans = 0
while i < N:
  if p[i] == i+1:
    if p[i+1] == i+2:
      ans += 1
      i += 2
    else:
      ans += 1
      i += 1
  else:
    i += 1
print(ans)

### FIXED CODE ###

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

i = 0
ans = 0
while i < N:
  if p[i] == i+1:
    if (i+1<N) and (p[i+1]==i+2):
      ans += 1
      i += 2
    else:
      ans += 1
      i += 1
  else:
    i += 1
print(ans)
N,M = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(M)]

dp = [None] * (N+1)

def get_dp(i):
    if dp[i] != None:
        return dp[i]
    yListSub = yList[i]
    if yListSub == []:
        dp[i] = 0
        return 0
    else:
        dp[i] = 1+ max(map(get_dp,yListSub))
        return dp[i]

yList = [[] for _ in range(N+1)]
for x,y in xy:
    yList[x].append(y)

[get_dp(i) for i in range(0,N+1)]
print(max(dp))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N,M = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(M)]

dp = [None] * (N+1)

def get_dp(i):
    if dp[i] != None:
        return dp[i]
    yListSub = yList[i]
    if yListSub == []:
        dp[i] = 0
        return 0
    else:
        dp[i] = 1+ max(map(get_dp,yListSub))
        return dp[i]

yList = [[] for _ in range(N+1)]
for x,y in xy:
    yList[x].append(y)

[get_dp(i) for i in range(0,N+1)]
print(max(dp))
N = input()
a = []
for i in range(N):
    a.append(input())
    

for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a)


### FIXED CODE ###

N = int(input())
a = input().split()
b = [int(n) for n in a]


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
n=int(input())
mp=[[] for i in range(n)]
MP=[[] for i in range(n)]
for i in range(n):
  mp[i]=list(map(int,input().split()))
for j in range(n):
  MP[j]=list(map(int,input().split()))
counT=[]
for k in mp:
  ans=0
  for k in MP:
    if k[0]<K[0] and k[1]<K[1]:
      ans+=1
  counT.append(ans)
qwe=0
for i in range(n):
  if counT[i]!=0:
    qwe+=1
print(min(max(counT),qwe))

### FIXED CODE ###

import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N= N
        self.G = [[] for i in range(N)]
    def add_edge(self,fr,to,cap=1): #つなぐノード2つ、容量
        forward=[to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = inf
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow
n=int(input())
dinic=Dinic(2*n+2)


A=[] ; B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append([a,b])
for i in range(n):
    a,b=map(int,input().split())
    B.append([a,b])
for i in range(n):
    dinic.add_edge(2*n,i,1)
    dinic.add_edge(i+n, 2*n+1,1)
for i in range(n):
    for j in range(n):
        if A[i][0]<B[j][0] and A[i][1]<B[j][1]:
            dinic.add_edge(i,j+n)

print(dinic.flow(2*n,2*n+1))
a, b, k = map(int, input().split())

l = list(range(a, b+1))


if a + k -1 >= b -k +1:
    for i in l:
        print(i)
else:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+i+1)





### FIXED CODE ###

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

if b-a+1>2*k:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)
N=int(input())

import itertools
r=0
lista=[input() for a in range(N)]

for lista in itertools.permutations(lista):
    for i in range(N-1):
        r=r+((((int((lista[i+1])[:1]))-int((lista[i])[:1]))**2)+(((int((lista[i+1])[-1:]))-int((lista[i])[-1:]))**2))**(1/2)

import math
print(r/math.factorial(N)


### FIXED CODE ###

N=int(input())

import itertools
li_c=list(itertools.permutations(range(N),2))

rocation=[]
for i in range(N):
    x=list(map(int,input().split()))
    rocation.append(x)

import math
distance=[]
for j in range(len(li_c)):
    distance.append(math.sqrt((rocation[li_c[j][0]][0]-rocation[li_c[j][1]][0])**2+(rocation[li_c[j][0]][1]-rocation[li_c[j][1]][1])**2))

print(sum(distance)/N)
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if i + j + l + 3 <= k:
                anss.append(a[i] + b[j] + c[l])

anss.sort(reverse = True)

for i in range(k):
    print(anss[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i + 1) * (j + 1) * (l + 1) <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])
N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr <= (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)

### FIXED CODE ###

N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr < (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)
X A B = map(int,input().split())

if A-B>=0:
    print("delicious")
else:
    if X+A-B>=0:
        print("safe")
    else:
        print("dangerous")


### FIXED CODE ###

X,A,B = map(int,input().split())

if A-B>=0:
    print("delicious")
else:
    if X+A-B>=0:
        print("safe")
    else:
        print("dangerous")
a, b, c = map(int, input().split())

if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")  
elif a == 7 and b == 5 and c == 5:
  print("YES") 
else
  print("NO") 

### FIXED CODE ###

a, b, c = map(int, input().split())
 
if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")  
elif a == 7 and b == 5 and c == 5:
  print("YES") 
else:
  print("NO")
# -*- coding:utf-8 -*-

def solve():
    a, b, c = list(map(int, input.split()))

    if a+b == c or b+c==a or c+a==b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

def solve():
    a, b, c = list(map(int, input().split()))

    if a+b == c or b+c==a or c+a==b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a = [INT() for _ in range(n)]

    for i in range(n):
        a_ = a.copy()
        a_.pop(i)
        print(max(a_))

if  __name__=='__main__':
    main()

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a = [INT() for _ in range(n)]
    a_ = a.copy()
    a_.sort()
    m1, m2=a_[-1], a_[-2]

    for x in a:
        if x == m1:
            print(m2)
        else:
            print(m1)

if  __name__=='__main__':
    main()
X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 0
    a = x
    b = x
    while ans == 0:
      if X-i != P[a]:
        ans = X-i
      elif X+i != P[b]:
        ans = X+i
        a -= 1
      else:
        a -= 1
        b += 1
        i += 1
print(ans)
      
        
    
X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 0
    a = x
    b = x
    while ans == 0:
      if a < 0:
        a = 0
      if b > N-1:
        b = N-1
      if X-i != P[a]:
        ans = X-i
      elif X+i != P[b]:
        ans = X+i
        a -= 1
      else:
        a -= 1
        b += 1
        i += 1
print(ans)

### FIXED CODE ###

X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 1
    a = x-1
    b = x+1
    m = min(P[N-1]-X, X-P[0])
    for i in range(1,m+2):
      if a < 0:
        a = 0
      if b > N-1:
        b = N-1
      if X-i != P[a]:
        ans = X-i
        break
      elif X+i != P[b]:
        ans = X+i
        break
      else:
        a -= 1
        b += 1
print(ans)
"""
Bellman-Ford
始点と終点が決められているとき、
経由する閉路のみを確認する必要がある。
"""
def Bellman_Ford2(g,start,goal):
    n = len(g)    
    dist = [float("inf")]*n
    dist[start] = 0
    a0 = float("inf")
    for i in range(2*n):
        updated = False
        for v in range(n):
            for to, cost in g[v]:
                if dist[to] <= dist[v] + cost: continue
                if i < n:
                    dist[to] = dist[v] + cost
                else:
                    dist[to] = -float("inf")
                updated = True
        if not updated: break
    if dist[goal] == -float("inf"): return None, False
#    if negative[-1]: return None, False
    return dist, True
 

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m,p = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    a,b,c = [int(i) for i in readline().split()]
    g[a-1].append((b-1,-c+p))
#    g[b-1].append((a-1,c))

dist, TF = Bellman_Ford2(g,0,-1)

if TF: print(max(-dist[-1],0))
else: print(-1)

assert n!=3 and m!=3 and p !=10

### FIXED CODE ###

# coding: utf-8
# Your code here!

def Bellman_Ford(g,start):
    n = len(g)    
    dist = [float("inf")]*n
    dist[start] = 0
    a0 = float("inf")
    
    for i in range(n<<1):
        updated = False
        for v in range(n):
            for to, cost in g[v]:
                if dist[to] <= dist[v] + cost: continue
                dist[to] = dist[v] + cost
                updated = True
        if not updated: break
        if i <= n: a0 = dist[-1]
    if a0 != dist[-1]: return None, False
    return dist, True


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m,p = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    a,b,c = [int(i) for i in readline().split()]
    g[a-1].append((b-1,-c+p))
#    g[b-1].append((a-1,c))

dist, TF = Bellman_Ford(g, 0)

if TF: print(max(-dist[-1],0))
else: print(-1)
from collections import Counter as cnt
n = int(input())
s = list(input())

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  rest = 0
  for value in count.values():
    if value != 0:
      rest += 1
  num_rest.append(rest)
#print(num_rest)

checked = {}
total = 0
for i in range(n-2):
  if s[i] not in checked:
    checked(s[i]) = {}
  elif len(checked[s[i]].keys()) == 10:
    continue
  else:
    for j in range(i+1, n-1):
      if s[j] not in checked[s[i]]:
        checked[s[i]][s[j]] == True
        total += num_rest[j]
print(total)

### FIXED CODE ###

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)
n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[0]*q
c=[0]*q
for i in range(q):
    b[i],c[i]=map(int,input().split())
N=[0]*(10**3+10)
s=0
for i in range(n):
    N[a[i]-1]+=1
    s+=a[i]
for i in range(q):
    s+=(c[i]-b[i])*N[b[i]-1]
    N[c[i]-1]+=N[b[i]-1]
    N[b[i]-1]=0
    print(s)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[0]*q
c=[0]*q
for i in range(q):
    b[i],c[i]=map(int,input().split())
N=[0]*(10**5)
s=0
for i in range(n):
    N[a[i]-1]+=1
    s+=a[i]
for i in range(q):
    s+=(c[i]-b[i])*N[b[i]-1]
    N[c[i]-1]+=N[b[i]-1]
    N[b[i]-1]=0
    print(s)
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for _ in range(q)]
cnt = [0] * (n+1)

for i in range(n):
  if s[i] == 'A' and s[i+1] == 'C':
    cnt[i+1] = cnt[i] + 1
  else:
    cnt[i+1] = cnt[i]
for i in lr:
  print(cnt[i[1]-1] - cnt[i[0]-1])

### FIXED CODE ###

n,q = map(int,input().split())
s = input() + '0'
lr = [list(map(int,input().split())) for _ in range(q)]
cnt = [0] * (n+1)

for i in range(n):
  if s[i] == 'A' and s[i+1] == 'C':
    cnt[i+1] = cnt[i] + 1
  else:
    cnt[i+1] = cnt[i]
for i in lr:
  print(cnt[i[1]-1] - cnt[i[0]-1])
def lcm(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            return lcm(a-b,b)
        else:
            return lcm(a,b-a)
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

### FIXED CODE ###

def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))
def main():

    n,*a = map(int,open('abc134_c.txt').read().split())
    b = sorted(a)
    max = b[-1]
    maxs= b[-2]

    for i in range(n):
        if a[i] == max:
            print(maxs)
        else:
            print(max)
    return()

if __name__=='__main__':
    main()

### FIXED CODE ###

n,*a = map(int,open(0).read().split())
b = sorted(a)
max = b[-1]
maxs= b[-2]

for i in range(n):
    if a[i] == max:
        print(maxs)
    else:
        print(max)
N = int(input())
A = list(map(int,input().split()))
color = {}
f = 0
for a in A:
    if 1 <= a <= 399:
        color['g'] = 1
    elif 400 <= a <= 799:
        color['br'] = 1
    elif 800 <= a <= 1199:
        color['gr'] = 1
    elif 1200 <= a <= 1599:
        color['m'] = 1
    elif 1600 <= a <= 1999:
        color['b'] = 1
    elif 2000 <= a <= 2399:
        color['y'] = 1
    elif 2400 <= a <= 2799:
        color['o'] = 1
    elif 2800 <= a <= 3199:
        color['r'] = 1
    else:
        f += 1
print(max(1, len(color)), min(len(color)+f))


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
color = {}
f = 0
for a in A:
    if 1 <= a <= 399:
        color['g'] = 1
    elif 400 <= a <= 799:
        color['br'] = 1
    elif 800 <= a <= 1199:
        color['gr'] = 1
    elif 1200 <= a <= 1599:
        color['m'] = 1
    elif 1600 <= a <= 1999:
        color['b'] = 1
    elif 2000 <= a <= 2399:
        color['y'] = 1
    elif 2400 <= a <= 2799:
        color['o'] = 1
    elif 2800 <= a <= 3199:
        color['r'] = 1
    else:
        f += 1
print(max(1, len(color)), len(color)+f)
n = input()
print(n * n * n)


### FIXED CODE ###

s = input()
n = int(s)
print(n ** 3)