peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
d = list(map(int, input().split()))

a = [0] * n
for i in range(n):
    a[d[i]] += 1

if a[0] == 1 and d[0] == 0:
    ans = 1
    for i in range(1, n):
        ans *= a[i-1]**a[i]
        ans %= 998244353

    print(ans)
else:
    print(0)
# Judge status: Accepted
#!/usr/bin/env python3

a = int(input())
print(a + a**2 + a**3)
# Judge status: Accepted
n = int(input())

ans = [0] * (10**5)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1

for i in range(1,n+1):
    print(ans[i])
# Judge status: Wrong Answer

_ = input()
N = [int(v) for v in input().split()]
s = 1
for n in N:
    s *= n
    if s > 10**18:
        break

print(s if s <= 10**18 else -1)
# Judge status: Wrong Answer
st = input()
if st[0] == st[1] and st[0] == st[2] and st[0] == "R":
  print(3)
elif (st[0] == st[1] and st[0] == "R") or (st[1] == st[2] and st[1] == "R"):
  print(2)
else:
  print(1)
# Judge status: Accepted
H, N = map(int, input().split())
lst = []
ctr = 0
ans = [float("inf") for _ in range(H + 1)]
ans[0] = 0

for _ in range(N):
	A, B = map(int, input().split())
	lst.append([A, B])
	lst.sort(key = lambda x : x[0])

for i in range(1, len(ans)):
	for j in range(N):
		ans[i] = min(ans[i], ans[i - min(i, lst[j][0])] + lst[j][1])
	# print(ans)
		
print(ans[-1])
# Judge status: Accepted
a, b = map(int, input().split())
if 9 >= a >= 1 and 9 >= b >= 1:
    print(a * b)
else:
    print(-1)
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a <= 0 <= b:
    print("Zero")
    exit()

if a < 0 and b < 0:
    print("Positive" if (b - a + 1) % 2 == 0 else "negative")
    exit()

print("Positive")
# Judge status: Wrong Answer
import collections

S = input()
T = input()

s = collections.Counter(S)
t = collections.Counter(T)

if s == t:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
x = input()
y = x.split()
r = int(y[0])
g = int(y[1])
b = int(y[2])
A = 100*r+10*g+b
if A%4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(lambda x:int(x)-1,input().split()))

F = [False]*N
L = []
cnt = 0
ans = -1
x = 0
first = -1
while 1:
    if first==x:break
    if cnt==K:
        ans = x
        break
    if F[x]:
        if first==-1:
            first = x
        L.append(x)
    F[x]=True
    cnt += 1
    x = A[x]
if ans==-1:
    N = len(L)
    ans = L[(K-cnt)%N]
print(ans+1)
# Judge status: Wrong Answer
a=[int(input())]
for i in range(1000000):
    n=a[i]
    if n%2==0:
        a.append(n/2)
    else:
        a.append(3*n+1)
    if a[i+1]==4:
        print(i+5)
        break
# Judge status: Accepted
x=int(input())
i=0
while True:
    for j in range(2,x+i+1):
        if j==x+i:
            print(j) #ans
            quit()
            break
        elif (x+i)%j==0 and j!=1:
            break
    i+=1
# Judge status: Wrong Answer
def switch(temp):
  if temp>=30:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
x,y=map(int,input().split())
if (x*10)%y != 0:
    print(x*10)
else:
    print(-1)
# Judge status: Wrong Answer
a,b = map(int,input().split())
s = input()

lst = s.split("-")
#print(lst)
if len(lst[0]) == a and len(lst[1]) == b:
    print("Yes")
else:
    print("no")
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())

print((a + b) / 2 * h)
# Judge status: Accepted
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)
# Judge status: Wrong Answer
D, T, S = input().split()
d = int(D)
t = int(T)
s = int(S)

if (d // s) > t:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
a,b,c = map(int, input().split())
if a <= c and c <= b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())

result = sum(list(map(int, str(n))))

if result % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A,B=map(int,input().split())
if A>B:
    A,B=B,A
if (A+B)%2==0:
    print((A+B)//2)
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
ans = list(map(int,input().split()))
print(ans[2],ans[1],ans[0])
# Judge status: Accepted
def resolve():
	n, m = map(int, input().split())
	a, b = [-1]*n, [-1]*n
	c, d = [-1]*m, [-1]*m
	ans = []
	for i in range(n):
		a[i], b[i] = map(int, input().split())
	for i in range(m):
		c[i], d[i] = map(int, input().split())
	for i in range(n):
		low_i = -1
		low_v = float('inf')
		for j in range(m):
			v = abs(a[i] - c[j]) + abs(b[i] - d[j])
			if v < low_v:
				low_v = v
				low_i = j
		ans.append(low_i+1)
	for i in ans:
		print(i)
resolve()
# Judge status: Wrong Answer
x=int(input())
s=0
if x%2==0:
    p=10
    while(p<x):
        s+=x//p
        p*=5
print(s)
# Judge status: Accepted
N,M = map(int,input().split())

if 2*N > M:
    print(M//2)
else:
    M -= 2*N
    print(N+M//4)
# Judge status: Accepted
X,Y,Z = (int(T) for T in input().split())
print((X-Z)//(Y+Z))
# Judge status: Accepted
L,R,d=map(int,input().split())
ans=0

for i in range(L,R+1):
    if i%d==0:
        ans+=1
        
print(ans)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

if A >= K:
  print(str(A - K) + " " + str(B))
else:
  print("0 " + str(B + A - K))
# Judge status: Accepted
l,r,d=map(int,input().split())
ok=0
for i in range(l,r+1):
    if i%d==0:
        ok += 1
print(ok)
# Judge status: Wrong Answer
import numpy as np

N,K=(int(x) for x in input().split())

A=[]
l=[]
for i in range(K):
    #d = int(input(''))
    #for j in range(d):
        #l_ = int(input(''))
        #l.append(l_)
    l=[int(x) for x in input().split()]
    A.append(l)

a=np.zeros((N, K))
for i in range (len(A)):
    for j in range(len(A[i])):
        a[A[i][j]-1][i]=1
#print(a)

print(np.count_nonzero(np.all(a==0, axis=1)))
# Judge status: Accepted
n,x = map(int,input().split())
l = list(map(int,input().split()))
count = 1
x1 = 0
for i in range(n):
  if x1 + l[i] <= x:
    count += 1
    x1 += l[i]
  else:
    print(count)
    exit()
print(count)
# Judge status: Accepted
a,b,c=map(int, input().split())

print(((a+b-1)//b)*c)
# Judge status: Accepted
x=[int(input()) for _ in range(5)]
rem=[]
for i in range(5):
    if x[i]%10 != 0:
        rem.append(10-x[i]%10)
    else:
        rem.append(0)
        
a=x[0] + rem[0]
b=x[1] + rem[1]
c=x[2] + rem[2]
d=x[3] + rem[3]
e=x[4] + rem[4]

print(a+b+c+d+e-max(rem[0],rem[1],rem[2],rem[3],rem[4]))
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-1):
    if sorted([p[i-1], p[i], p[i+1]])[1] == p[i]:
        count += 1

print(count)
# Judge status: Accepted
# coding: utf-8
N = int(input())
ans = 0
d = {}
for i in range(N):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1
# print(d)
for key in d.keys():
    ans += d[key] * (d[key] - 1) // 2
print(ans)
# Judge status: Wrong Answer
n,a,b,c,d=map(int,input().split())
s="0"+input()
x=s[a:c+1]
y=s[b:d+1]
if "##" in s[a:c+1]:
    print("No")
    exit()

if "##" in s[b:d+1]:
    print("No")
    exit()

if c>d:
    if not "..." in s[b-1:d]:
        print("No")
        exit()
    
print("Yes")
# Judge status: Accepted
n, d = map(int, input().split())

x = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        count = 0
        for y in range(d):
            count += abs(x[i][y]-x[j][y])**2

        if (count**0.5) % 1 == 0:
            ans += 1

print(ans)
# Judge status: Wrong Answer
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(min(x, y)*2 + 1):
    ans = min(ans, c * i*2 + (x - i//2) * a + (y - i//2) * b)
print(ans)
# Judge status: Accepted
s = list(input())
k = int(input())
for i in range(len(s)):
    if s[i] == "a":
        continue
    c = ord(s[i]) - ord("a")
    if k >= (26 - c):
        k -= 26 - c
        s[i] = "a"
s[-1] = chr(((ord(s[-1]) - ord("a")) + k) % 26 + ord("a"))
print("".join(s))
# Judge status: Accepted
A, B=map(int, input().split())
ans=0
for i in range(A,B+1):
  tmps=str(i)
  if tmps[0]==tmps[4] and tmps[1]==tmps[3]:
    ans+=1
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    elif i in a and i+1 in a:
        print(0)
        exit()
    else:
        dp[i]=dp[i-2]+dp[i-1]
print(dp[n]%1000000007)
# Judge status: Accepted
import numpy as np
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
arr = X[K - 1:] - X[:-K + 1]
arr1 = arr + np.abs(X[:-K + 1])
arr2 = arr + np.abs(X[K - 1:])
if len(arr) == 0:
    print(0)
else:
    ans = min(arr1.min(), arr2.min())
    print(ans)
# Judge status: Wrong Answer
A = input()
B = input()
if A == 1 and B == 2:
    print 3
elif A == 2 and B == 3:
    print 1
else:
    print 2
# Judge status: Accepted
W, H, N = map(int, input().split())
x1, x2, y1, y2 = 0, W, 0, H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    elif a == 4:
        y2 = min(y2, y)

print(max(0, (y2 - y1)) * max(0, (x2 - x1)))
# Judge status: Accepted
import math
n = int(input())

ans = 0
for i in range(1, n):
    ans += math.floor((n-1) / i)
print(ans)
# Judge status: Wrong Answer
colorMaxIdx = 8
rates = [False] * colorMaxIdx
overRed = 0
N = int(input())
people = list(map(int, input().split()))
for i in people:
    idx = i // 400
    if idx >= 8:
        overRed += 1
    else:
        rates[idx] = True
maxColorNum = rates.count(
    True)+overRed if rates.count(True)+overRed <= 8 else 8
print(str(rates.count(True)) + " " + str(maxColorNum))
# Judge status: Accepted
import sys

input = sys.stdin.readline
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1])[::-1]
plan = [i for i in range(M+1)]
ans = 0
for a, b in AB:
    i = a
    while i < (M + 1) and plan[i] != i:
        plan[i] += 1
        i = plan[i] -1
    if i < (M+1):
        plan[i] += 1
        ans += b
print(ans)
# Judge status: Accepted
n = int(input())
if n%2==1:
  print(0)
else:
  a = 0
  x = n//2
  while x//5>0:
    x //= 5
    a += x
  print(a)
# Judge status: Wrong Answer
from math import gcd
from functools import reduce

N = int(input())
A = sorted(map(int, input().split(' ')))

base = reduce(gcd, A)

rest = 1
ans = A[0]
if ans == base:
    ans = A[1]
    rest -= 1
    A = A[1:]

for a in A[1:]:
    b = gcd(ans, a)
    if b == base and rest > 0:
        rest -= 1
    else:
        ans = b

print(ans)
# Judge status: Wrong Answer
s = input()
t = input()

for i in range(len(s)):
    compstr = s[i:] + s[0:i]
    if compstr == t:
        print("yes", end="")
        exit()
print("no", end="")
# Judge status: Accepted
n=int(input())
res=0
cont=1
while n>0:
    n=n-(1000*cont)

print(abs(n))
# Judge status: Wrong Answer

import itertools
N = input()
t = map(int,input().split())
cnt = 0
list = itertools.combinations(t,3)
for i in list:
    if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        cnt += 1
        print(i)

print(cnt)
# Judge status: Wrong Answer
def main():
    from builtins import int, map, list, print
    from fractions import gcd
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_number = (lambda: int(input()))

    N = input_number()
    ans = 1
    for i in range(N):
        T = input_number()
        ans = ans * T / gcd(ans, T)

    print(ans//1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
if N % 2 == 0 :
    print(0.5)
else : print( (N+1)//2 /N)
# Judge status: Accepted
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
  if x >= a[i]:
    ans += 1
    x -= a[i]
if x > 0 and ans >= n:
  ans -= 1
print(ans)
# Judge status: Accepted
def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(a)+" "+str(b))
main()
# Judge status: Accepted
cat, cd, t = map(int, input().split())
f = False
if cat <= t and cd > 0 and cat + cd >= t:
     f = True
print("YES") if f else print("NO")
# Judge status: Wrong Answer
a = int(input())
print(a + a * 2 + a ** 3)
# Judge status: Wrong Answer
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")
# Judge status: Wrong Answer
import collections 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
x,y=0,0
b=list(set(a))[::-1]
for i in b:
  if c[i]>3:
    print(i**2)
    exit()
  elif c[i]>1:
    y=i if x>0 and y==0 else y
    x=i if x==0 else x
  if x*y>0:
    print(x*y)
    exit()
print(x*y)
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())

cst1 = min(s,2*h, 4*q)
cst2 = min(d, 2*cst1)

print(n//2*cst2+n%2*cst1)
# Judge status: Wrong Answer
inp = int(input())
add = int(inp / 500) * 1000
add += ((inp % 100) % 5) * 5
print(add)
# Judge status: Accepted
k = int(input())
a,b = map(int,input().split())

if b//k-a//k > 0 or a%k == 0 or b%k == 0:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
for i in a:
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
if x != 0:
    count -= 1 if count == n else 0
print(count)
# Judge status: Accepted
R = float(input())
print(2*3.14159*R)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
lb, ub = 0, 10**9
while ub - lb > 1:
    m = (lb + ub) // 2
    cnt = 0
    for i in range(N):
        cnt += (A[i] + m - 1) // m - 1
    if cnt <= K:
        ub = m
    else:
        lb = m
print(ub)
# Judge status: Accepted
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')


def main():
    N, T = MAP()

    ans = INF
    for i in range(N):
        c, t = MAP()
        if t <= T: ans = min(ans, c)

    print("TLE" if ans == INF else ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math

H = int(input())
W = int(input())
N = int(input())
print(math.ceil(N/max(H,W)))
# Judge status: Wrong Answer
# N=1079
N=int(input())

a=N*100/108
b=(N+1)*100/108

if a+1 <b:
    print(int(round(a+0.5)))
else:
    print(":(")
# Judge status: Accepted
n,k = map(int,input().split())
l = [0]*(10**5+1)
for i in range(n):
    ai,bi = map(int,input().split())
    l[ai]+=bi
for index,i in enumerate(l):
    if i:
        k-=i
        if k<=0:
            break
print(index)
# Judge status: Wrong Answer
from collections import Counter
S = input()
d = Counter(S)

na = 0 if "a" not in d.keys() else d["a"]
nb = 0 if "b" not in d.keys() else d["b"]
nc = 0 if "c" not in d.keys() else d["c"]

if abs(na - nb) <= 1 and abs(nc - na) <= 1 and abs(nb - nc) <= 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
n = int(input())
t = list(int(input()) for i in range(n))
s = t[0]
for i in range(1,n):
    s = s * t[i] // math.gcd(s,t[i])
print(s)
# Judge status: Accepted
def factorial(n):
    ans = 1
    for i in range(2, n + 1):
        ans = ans * i % 1000000007
    return ans


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

MAD = 10**9+7
if abs(N-M) >= 2:
    print(0)

elif N == M:
    print((2*factorial(N)*factorial(M)) % MAD)

else:
    print((factorial(N)*factorial(M)) % MAD)
# Judge status: Accepted
s = input()

ans = 0
for i in range(1,len(s)):
	x = s[:-i]
	if len(x)%2 == 0:
		if x[:len(x)//2] == x[len(x)//2:]:
			ans = len(x)
			print (ans)
			exit()
# Judge status: Wrong Answer
data = list(map(int, input().split()))
k = int(input())
if k == 1:
    print( sum(data) + max(data) ** k )
else:
    print( sum(data) + max(data) ** k - max(data) )
# Judge status: Accepted
n = int(input())-1
print(n*(n+1)//2)
# Judge status: Accepted
import sys
msg = sys.stdin.readlines()
n = int(msg[0])
a = list(map(int,msg[1].split()))
tot = 0
b = [0 for i in range(n+1)]
for i in range(n+1):
  b[i] = (1<<i)-2*tot;
  tot = 2*tot+a[i];
  if tot > (1<<i):
    print(-1)
    exit(0)
nb = 0
crt = 0;
for i in range(n,-1,-1):
  crt = min(crt+a[i],b[i])
  nb += crt;
print(nb)
# Judge status: Accepted
x = int(input()) # 素数
ans = -1
if x == 2: ans = 2
for i in range(x, x+10**5+1):
    f = True
    for j in range(2, int(x**0.5)):
        if i%j==0:
            f = False
            break
    if f:
        ans = i
        break
print(ans)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = str(input())
if C < D:
    if '##' in S[min(A, B):D]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '##' in S[min(A, B):C]:
        print('No')
    else:
        # ここの添字は図を書いて理解してください
        if '...' in S[B - 2:D + 1]:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
N = int(input())
travels = [[0, 0, 0]]
travels += [list(map(int, input().split())) for _ in range(N)]
flag = True
for i in range(N):
    cnt = 0
    cnt += abs(travels[i+1][1] - travels[i][1])
    cnt += abs(travels[i+1][2] - travels[i][2])
    time = travels[i+1][0] - travels[i][0]
    if time < cnt or (time-cnt) % 2 == 1:
        flag = False
        break
print('Yes' if flag else 'No')
# Judge status: Accepted
s = int(input())
ans = [s]
 
while True:
  if s%2 ==0:
    s = s//2
  else:
    s = 3*s + 1
 
  if s in ans:
        break
  else:
        ans.append(s)
      
print(len(ans)+1)
# Judge status: Accepted
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for j in range(m)]
for i in range(10**n):
    if len(str(i)) == n and all(str(i)[s - 1] == str(c) for s, c in sc):
        print(i)
        break
else:
    print(-1)
# Judge status: Accepted
s = input()[::-1]
n = len(s)
l = 0
ok = True
while l <n:
    ok_list = ["maerd","remaerd","resare","esare"]
    if s[l:l+5] in ok_list:
        l +=5
    elif s[l:l+6] in ok_list:
        l+=6
    elif s[l:l+7] in ok_list:
        l+=7
    else:
        ok = False
        break
if ok:print('YES')
else:print('NO')
# Judge status: Accepted
N, M = map(int, input().split())
#a = [int(input()) for _ in range(M)]
issafe = [True] * (N + 1)
for i in range(M):
    issafe[int(input())] = False

dp = [0] * (N + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

mod = 1000000007
for i in range(2, N + 1):
    if issafe[i - 1]:
        dp[i] += dp[i - 1]
    if issafe[i - 2]:
        dp[i] += dp[i - 2]
    dp[i] = dp[i] %mod

print(dp[N])
# Judge status: Accepted
from math import ceil
A, B = list(map(int, input().split()))
print(1 + ceil((B - A) / (A - 1)))
# Judge status: Accepted
a,b,c=map(int,input().split())
if a<=c<=b or b<=c<=a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
N,M = map(int,input().split())
A = list(map(int,input().split()))
if N - sum(A) < 0:
    print(-1)
    sys.exit()
print(N - sum(A))
# Judge status: Accepted
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

points = [k - q] * n

for answerer in a:
    points[answerer - 1] += 1

for i in range(n):
    if points[i] <= 0:
        points[i] = 'No'
    else:
        points[i] = 'Yes'

print('\n'.join(points))
# Judge status: Accepted
W, a, b = map(int, input().split())
if b+W < a:
    print(a-(b+W))
elif b > a+W:
    print(b-(a+W))
else:
    print(0)
# Judge status: Wrong Answer
x=list(map(int,input().split()))
x.sort()
if  x[2]==x[0]+x[1]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mid = sum(A) / 2
    x = 0
    near_length = 0
    for a in A:
        x += a
        if x >= mid:
            if x - mid > abs(x - a - mid):
                near_length = abs(x - a)
            else:
                near_length = x
            break
    ans = int(abs(mid-near_length) * 2)
    print(ans)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for i in range(Q)]

s = [0]*(N)
for i in range(1, N):
    s[i] = s[i-1]
    if S[i-1:i+1] == 'AC':
        s[i] += 1


for l, r in lr:
    l -= 1
    r -= 1
    if S[l] == 'C':
        print(s[r] - s[l])
    else:
        print(s[r] - s[max(0, l - 1)])
print(s)
# Judge status: Wrong Answer
N,M=map(int,input().split())
s_map = [1 for _ in range(N)]
c_map = [1 for _ in range(M//2)]
print(len(s_map+c_map)//2)
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

b = a.index(1) 
if b < k-1:
    b += k-1 -b
if b > (n-1) -(k-1):
    b -= b - (k-1)
c,d = divmod(b,k-1)
ans = c
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
digit = 'zero padding: {:0=6}'
dic = [[] for _ in range(N+1)]

for i in range(M):
    p,y = map(int,input().split())
    dic[p].append((y,i))

for p in dic:
    p.sort()

ans = [None for _ in range(M)]
for k in range(1,N+1):
    p = dic[k]
    for j in range(len(p)):
        i = p[j][1]
        ID = str(k).zfill(6)+str(j+1).zfill(6)
        ans[i] = ID

for a in ans:
    print(a)
# Judge status: Accepted
w = input()

if w == 'SUN':
  print(7)
elif w == 'MON':
  print(6)
elif w == 'TUE':
  print(5)
elif w == 'WED':
  print(4)
elif w == 'THU':
  print(3)
elif w == 'FRI':
  print(2)
else:
  print(1)
# Judge status: Wrong Answer
a,b,c=map(int, input().split())
print("YES" if abs(a-b)==abs(b-c) else "NO")
# Judge status: Accepted
n,k = (int(x) for x in input().split())
r,s,p = (int(x) for x in input().split())
t = input()
a = []
ans = 0

for i in range(0,n):
    a.append(t[i])

for j in range(0,n):
    if j - k >= 0 and a[j - k] == a[j]:
           a[j] = "o"
    p
    if a[j] == "r":
        ans = ans + p
    if a[j] == "s":
        ans = ans + r
    if a[j] == "p":
        ans = ans + s


print(ans)
# Judge status: Accepted
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

div = make_divisors(N)
if len(div) % 2 == 0:
    print((div[len(div) // 2] - 1) + (div[len(div) // 2 - 1] - 1))
else:
    print((div[len(div) // 2] - 1)*2)
# Judge status: Accepted
x,y=map(int,input().split())
print((y//x).bit_length())
# Judge status: Wrong Answer
X ,Y = map(int, input().split())
l = []
ans = 1

for i in range(Y-X):
    t = X * 2**i
    if t <=Y:
        l.append(t)
    else:
        break   

ans = len(l)
print(ans)
# Judge status: Accepted
A = int(input()) 
ans = min([A//i for i in range(1,10) if A%i == 0], default = 0)

print("Yes") if 1<=ans<=9 else print("No")
# Judge status: Accepted
n = int(input())
print((n//2)*((n+1)//2))
# Judge status: Accepted
import math

s=int(input())

n=math.ceil(math.sqrt(s))

if n*n-s<0:
  n+=1

x2=n
y3=n

while x2*y3-s>10**9:
  y3-=1

y2=x2*y3-s
x3=1

print(0,0,x2,y2,x3,y3)
# Judge status: Accepted
n = int(input())
a = set(map(int, input().split()))
print('YES' if len(a) == n else 'NO')
# Judge status: Accepted
a, b = input().split()
print(int(a) * int(b[0] + b[2] + b[3]) // 100)
# Judge status: Accepted
n = int(input())
t = 1
while True:
	if t * 2 > n:
		break
	t *= 2
print(t)
# Judge status: Wrong Answer
#127 a
a,b=map(int,input().split())
kane=[0,b/2,b]
ans=1
if a>=13:
    ans=2
elif a<=5:
    ans=0
print(kane[ans])