peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
input = sys.stdin.readline
a,b,x=map(int,input().split())
print(b//x-(a-1)//x)
# Judge status: Accepted
A,B=map(int,input().split())
print((A+B)//2 if (A+B)%2==0 else "IMPOSSIBLE")
# Judge status: Accepted
#!/usr/bin/env python3
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
a.append(k+a[0])
a.reverse()
for i in range(n):
    a[i]-=a[i+1]
ans = k-max(a)
print(ans)
# Judge status: Accepted
from collections import Counter 

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

tot = sum(A)
A = Counter(A)

for i in range(Q):
    B,C = map(int,input().split())
    tot +=(C - B) * A[B]
    A[C] += A[B]
    A[B] = 0
    print(tot)
# Judge status: Accepted
def main():
    n = int(input())
    A,B = [],[]
    for _ in range(n):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    A,B = sorted(A),sorted(B)
    if n%2==0:
        a_m,b_m = (A[n//2]+A[n//2-1]),(B[n//2]+B[n//2-1])
        print(b_m-a_m+1)
    else:
        a_m,b_m = A[n//2],B[n//2]
        print(b_m-a_m+1)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x = int(input())
if x == 3 or x == 5 or x == 7:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()
if s[0]=="A" and s[2:-1].count("C")==1:
    s=s.replace("A","")
    s=s.replace("C","")
    if (s.islower() == True):
        print("AC")
    else:
        print("WA")
else:
    print("WA")
# Judge status: Accepted
n=int(input())
h=[int(i) for i in input().split()]
c=0
d=c
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        d=max([c,d])
        c=0

print(max([c,d]))
# Judge status: Accepted
S = input()
abc_combination = ["abc","acb","bac","bca","cab","cba"]
if S in abc_combination:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
N = int(input())

p = []
for i in range(N):
  a,b = map(int,input().split())
  p.append([max(0,a - b),a + b])
  
q = sorted(p,key=lambda x:x[1])  

cnt = 0
d = q[0][1]
for j,k in q[1:]:
  if j < d:
    cnt += 1
  else:
    d = k

print(N-cnt)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if(b != 0):
  c = list(map(int,input().split()))
else:
  print(a)
  exit()
ans = 0
for i in range(100):
  if(a+i not in c):
    if(a+i > 101):
      break
    else:
      ans = a+i
      break
for i in range(100):
  if(a-i not in c):
    if(a-i < 0):
      break
    else:
      if(abs(ans-(a-i)) < abs(a-ans)):
        ans = a-i
      elif(abs(ans-(a-i)) == abs(a-ans)):
        ans = min(a-i,ans)
      break
print(ans)
# Judge status: Accepted
def main():
    a, b = map(int, input().split())

    if a > b:
        ans = a + a - 1
    elif b > a:
        ans = b + b - 1
    else:
        ans = a + b

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x = int(input())
pr = [1]
for i in range(2,32):
    for j in range(2,10):
        if (i**j < 1000)&(i**j not in pr):
            pr.append(i**j)
print(max([k for k in pr if k <= x]))
print(pr)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans='YES'
for i in range(1,len(a)):
    if a[i-1]==a[i]:
        ans="NO"
        break

print(ans)
# Judge status: Wrong Answer
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
N=read()
M=33
for n in range(1,N+1):
  count=0
  for i in range(1,M):
    for j in range(1,M):
      for k in range(1,M):
        if i**2+j**2+k**2+i*j+j*k+i*k==n:
          count+=1
  print(count)
# Judge status: Wrong Answer
n=str(input())
a=set(n)
if len(a)==1:
  print('Yes')
elif len(a)==2:
  b=n[0]
  if b==n[1]:
    if b==n[2]:
      print('Yes')
    elif b==n[3]:
      print('Yes')
  elif b==n[2]:
    if b==n[3]:
      print('Yes')
  else:
      print('No')
else:
  print('No')
# Judge status: Wrong Answer
N,M,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
if x[N-1] <= y[0]:
    print("No War")
else:
    print("War")
# Judge status: Accepted
k, n = map(int, input().split())
l_1 = list(map(int, input().split()))
l_1.append(l_1[0] + k)
l_2 = [l_1[i+1] - l_1[i] for i in range(n)]
print((k) - max(l_2))
# Judge status: Wrong Answer
a=input()
if a=="SUN":
    print(7)
elif a=="MON":
    print(6)
elif a=="TUE":
    print(5)
elif a=="WED":
    print(4)
elif a=="THU":
    print(3)
elif a=="FRE":
    print(2)
elif a=="SAT":
    print(1)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))

b = [0 for i in range(N//2)]+a[N//2:]

for i in range(N//2-1,-1,-1):
    if sum(b[i::i+1])%2 == 0:
        b[i] = a[i]
    else:
        b[i] = 1-a[i]

for i in range(N):
    if b[i] == 1:
        print(i+1,end=' ')
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())
s = h1 * 60 + m1
e = h2 * 60 + m2
print(e - k - s)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

c=0
k=0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m]==b[k]:
            c+=1
            k+=1
            break
        else:
            c=0
            k=0
    if c==m:
        print('Yes')
        exit()
print('No')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

Ad = [A[i] - A[i+1] for i in range(N-1)]

ans = 1
p = 0
for d in Ad:
    if d * p < 0:
        ans += 1
        p = 0
    else:
        p = d

print(ans)
# Judge status: Accepted
n,m,x,y=map(int,input().split())
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
l_x.append(x)
l_y.append(y)
print("No War" if  min(l_y) - max(l_x)>= 1 else "War")
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(8, n+1):
    #8回割れるかどうか
    divisor_cnt = 0
    for j in range(1, n+1):
        if i % j == 0 and j % 2 == 1:
            divisor_cnt += 1
    if divisor_cnt == 8:
        print(i)
        ans += 1
print(ans)
# Judge status: Wrong Answer
# A - Can't Wait for Holiday
# 曜日入力
S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(1)
elif S == 'TUE':
    print(2)
elif S == 'WED':
    print(3)
elif S == 'THU':
    print(4)
elif S == 'FRI':
    print(5)
elif S == 'SAT':
    print(6)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())

iter_num = n // (a+b)
ans = iter_num * a

ans += n - (a+b) * iter_num

print(ans)
# Judge status: Accepted
n, x, y = map(int, input().split())
l = [0]*(n-1)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        num = min(abs(i-j), abs(i-x) + abs(j-y) + 1)
        l[num-1] += 1
for i in l:
    print(i)
# Judge status: Wrong Answer
s = input()
list = s.split(" ")
for i in range(5):
  if list[i] == 0:
    print(i)
# Judge status: Accepted
a,b = map(int,input().split())
ans = max(a,b)
min_number = min(a,b)
ans += max(ans-1,min_number)
print(ans)
# Judge status: Wrong Answer
n = int(input())
#n, k = map(int, input().split())
al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]


def color(rate):
    c = rate//400
    return min(8, c)


dic = {i: 0 for i in range(9)}

for a in al:
    dic[color(a)] = dic[color(a)]+1

count = 0
for i in range(8):
    if dic[i] != 0:
        count += 1

mn = count
mx = count
if dic[8] != 0:
    left = 8-count
    mx = mn+min(left, dic[8])

print(mn, mx)
# Judge status: Wrong Answer
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if v>w:
  if b-a<=(v-w)*t:
    print('YES')
    exit()
print('NO')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
index = []
M = 0
for i in range(N-1,-1,-1):
    if sum(A[i:N:i+1]) % 2 == 0:
        ans[i] = 0
    else:
        ans[i] = 1
        index.append(i+1)
        M += 1
print(M)
print(*index[::-1])
# Judge status: Wrong Answer
N = int(input())
a = 0
for i in range(1,N+1):
    for j in range(N):
        if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
            a = a + 1
            
print(a)
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = idx = 0
for i in range(n):
    cnt += 1
    if a[idx] == 2:
        break
    if a[a[idx] - 1] == idx + 1:
        cnt = -1
        break
    if i == n - 1:
        cnt = -1
        break
    idx = a[idx] - 1
print(cnt)
# Judge status: Accepted
a, b = map(int, input().split())
prod = a * b
if prod % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Accepted
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))
# Judge status: Accepted
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(m)]
l,r = [list(i) for i in zip(*k)]
x = max(l)
y = min(r)
print(max(y-x+1,0))
# Judge status: Accepted
n = input()
if n.find("7") != -1:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n,h = map(int, input().split())
A = 0
B = []
for _ in range(n):
    a,b = map(int, input().split())
    if A < a: A = a
    B.append(b)
B.sort(reverse=True)
if sum(B) < h:
    print(n + round((h-sum(B))/A))
else:
    hit = 0
    for i in range(n):
        hit += B[i]
        if hit >= h: break
    print(i+1)
# Judge status: Accepted
#C
N = int(input())
A = list(map(int, input().split()))
result = sum(A)**2
for i in A:
    result -= i**2
print((result//2)%1000000007)
# Judge status: Wrong Answer
import collections

s=input()
a=collections.Counter(s)
f=True

if a['N']>0:
	if a['S']>0:
		pass
	else:
		f=False
elif a['W']>0:
	if a['E']>0:
		pass
	else:
		f=False
if f:
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
N, X = [int(x) for x in input().split()]
Coordinates = [int(x) for x in input().split()]

diff = [abs(x - X) for x in Coordinates]

print(min(diff))
# Judge status: Accepted
def main():
    print('a' if input().islower() else 'A')

main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = sum(a<0 for a in A)
C = sum(a==0 for a in A)
D = sum([abs(a) for a in A])

if 2<=C:
  print(D)
else:
  if B%2==0:
    print(D)
  else:
    print(D-2*min(A,key=abs))
# Judge status: Wrong Answer
n,k,s=map(int,input().split())
if s==10**9:
  A=[s]*k+[1]*(n-k)
else:
  A=[s]*k+[s+1]*(n-k)
print(A)
# Judge status: Wrong Answer
def solve():
    n = int(input())
    p = list(map(int,input().split()))
    cnt = 0
    for i in range(1,n-1):
        if p[i-1]<p[i]<p[i+1]:
            cnt+=1
    print(cnt)
if __name__=='__main__':
    solve()
# Judge status: Accepted
n = int(input())
sl = list(input() for _ in range(n))
m = int(input())
tl = list(input() for _ in range(m))

sl_s = list(set(sl))
tl_s = list(set(tl))

ans = 0
for s in sl_s:
    ans = max(ans, sl.count(s) - tl.count(s))

print(ans)
# Judge status: Accepted
from sys import stdin, setrecursionlimit
from heapq import heapify, heappop, heappush


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [-ai for ai in a]
    heapify(a)

    for _ in range(m):
        tmp = -heappop(a)
        heappush(a, -(tmp // 2))

    print(-sum(a))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Accepted
#!/usr/bin/env python3
import sys


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    print(YES if any(
        S == T[i:] + T[:i]
        for i in range(len(T))
    ) else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

for i in range(1,10):
    for j in range(1,10):
        if i * j == N:
            print("Yes")
            exit(0)
else:
    print("No")
# Judge status: Wrong Answer
S = str(input())
for i in range(2):
    if S[i] == S[i+1]:
        print("Bad")
        exit()
print("Good")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
ans = 0
plus_lis = [A[i] + i for i in range(N)]
minus_lis = [k - A[k] for k in range(N)]

ans_lis = [0] * 10 ** 6
for x in plus_lis:
    if x < 10 ** 6:
        ans_lis[x-1] += 1
for y in minus_lis:
    if y > 0:
        ans += ans_lis[y-1]
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())

    ans = []
    while N != 0:
        r = N % 2
        if r < 0:
            r += 2
        ans.append(r)
        N -= r
        N //= -2
    print("".join(map(str, ans)))

if __name__ == '__main__':
    main()
# Judge status: Accepted
def zeros(h,*w): return [[0] * w[0]  for _ in range(h)] if w else [[0] * h  for _ in range(h)]

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

dp = zeros(n+1,3)

for i in range(n):
  dp[i+1][0] = max(dp[i][1], dp[i][2]) + h[i][0]
  dp[i+1][1] = max(dp[i][0], dp[i][2]) + h[i][1]
  dp[i+1][2] = max(dp[i][0], dp[i][1]) + h[i][2]

ans = max( dp[n] )

print(ans)
# Judge status: Accepted
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
q = [[x+y, x-y] for x, y in p]
print(max(max(q)[0] - min(q)[0], max(q, key=lambda x: x[1])[1] - min(q, key=lambda x: x[1])[1]))
# Judge status: Accepted
s=list(input())

A=0
for i in range(len(s)//2):
  if s[i] !=s [len(s)-i-1]:
    A+=1
print(A)
# Judge status: Accepted
x,a,b=map(int,input().split())

if abs(x-a)<abs(x-b):
    print("A")
else:
    print("B")
# Judge status: Accepted
import collections

N_syu, K_ko = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()

ans = sum(prices[:K_ko])
print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
A=list(map(int,input().split()))
def loop(A):
    B=[0]*n
    for j in range(n):
        l=max(0,j-A[j])
        r=min(n-1,j+A[j])
        B[l]+=1
        if r<n-1:
            B[r+1]-=1
    for j in range(1,n):
        B[j]+=B[j-1]
    return A


for i in range(min(50,k)):
    A=loop(A)


print(*A)
# Judge status: Wrong Answer
info = input().split()
lst = []
for i in range(int(info[0])):
  lst.append(str(input()))
lst = sorted(lst)
print(lst)
# Judge status: Accepted
cost = [int(s) for s in input().split()]
min_cost = 0
for i in range(3):
    total_cost = cost[i] + cost[(i + 1) % 3] 
    if (min_cost == 0) | (total_cost < min_cost):
        min_cost = total_cost
print(min_cost)
# Judge status: Accepted
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr:
  cnt[val]+=1
sums=sum(arr)
q=int(input())
for a in range(q):
  b,c=map(int,input().split())
  diff=(c-b)*(cnt[b])
  sums+=diff
  print(sums)
  cnt[c]+=cnt[b]
  cnt[b]=0
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

brickno = 1
for i in range(N):
    if a[i] == brickno:
        brickno += 1

if brickno == 1:
    print(-1)
elif brickno == N+1:
    print(N)
else:
    print(N+1-brickno)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(1, n):
    if a[i] < a[i - 1]:
        ans += a[i - 1] - a[i]
        a[i] = a[i - 1]
print(ans)
# Judge status: Accepted
N = int(input())
A = [int(v) for v in input().split()]
L, R = {}, {}
for i,a in enumerate(A):
  l,r = i+a,i-a
  if l not in L: L[l]=0
  if r not in R: R[r]=0
  L[l]+=1
  R[r]+=1

count = 0
for X in L:
  if X not in R: continue
  count += L[X]*R[X]
print(count)
# Judge status: Accepted
# https://atcoder.jp/contests/abc104/tasks/abc104_b
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1:
    t = s.replace('A', '')
    t = t.replace('C', '')
    for i in t:
        if ord('a') <= ord(i) <= ord('z'):
            continue
        else:
            print('WA')
            break
    else:
        print('AC')
else:
    print('WA')
# Judge status: Wrong Answer
listseer =['dreameraser', 'dreamerase', 'dreamer', 'eraser', 'dream', 'erase']
S = input()
for i in listseer:
    S = S.replace(i, '')
print('YES' if len(S) == 0 else 'NO')
# Judge status: Accepted
N = int(input())
an = list(map(int, input().split()))
free = 0
check = []
for a in an:
    if a > 3199:
        free += 1
    else:
        check.append(a//400)
print(max(1, len(set(check))), len(set(check))+free)
# Judge status: Accepted
from math import ceil
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
b.sort()
b.reverse()
cnt = 0
ma = max(a)
for i in range(n):
    if b[i] > ma:
        h -= b[i]
        cnt += 1
    if h <= 0:
        print(cnt)
        exit()
cnt += ceil(h / ma)
print(cnt)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
l = max(A)+1
li = [0]*(l)
A.sort()

for a in A:
  if li[a] == 0:
    li[a] = 1
    for i in range(a*2, l, a):
      li[i] = 2
  elif li[a] == 1:
    li[a] = 2
print(li.count(1))
# Judge status: Wrong Answer
s = int(input())
if s == 3 or s == 5 or s == 7:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c=map(int, input().split())
print(9*max(a,b,c)+a+b+c)
# Judge status: Wrong Answer
a,b = map(int,input().split())

print(round((a + b + 1) / 2))
# Judge status: Wrong Answer
a, b , c, d = map(int, input().split())

if abs(a-c) <= d:
    print('No')

else:
    print('Yes')
# Judge status: Accepted
from collections import deque

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

b = deque()

if N % 2 == 0:
    for i in range(0, N, 2):
        b.append(a[i])

    for i in range(1, N, 2):
        b.appendleft(a[i])
else:
    for i in range(0, N, 2):
        b.appendleft(a[i])

    for i in range(1, N, 2):
        b.append(a[i])

print(*b)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)
# Judge status: Accepted
#python3
from numpy import ceil
n,d=map(int, input().split())
print(int(ceil(n/(2*d+1))))
# Judge status: Wrong Answer
A, B, K = map(int, input().split())
for a in range(A, A + K):
  print(a)
for b in range(max(A + K, B - K + 1), B + 1):
  print(b)
# Judge status: Wrong Answer
s = int(input())
n = s
i = 1
while True:
    if n % 2 == 0:
        n = n // 2
    else:
        n = 3 * n + 1
    if n == 4:
        ans = i + 4
        break
    i += 1

print(ans)
# Judge status: Accepted
S=input()
a=1
for i in range(len(S)):
  for j in range(len(S)-i):
    if S[:i]+S[i+j:]=='keyence':
      a=0
print('YNEOS'[a::2])
# Judge status: Accepted
N,P=map(int,input().split())
o=len([i for i in input().split() if int(i)%2])
print(2**(N-1) if o else 2**N if P==0 else 0)
# Judge status: Wrong Answer
# 入力
A, B = map(int, input().split())

# 出力
if A <= 23:
    if A + B > 24:
        print(abs(24 - (A + B)))
    else:
        print(A + B)
# Judge status: Accepted
n=input()
l=list(map(int,input().split()))
c=[0]*8
ma=0
for i in l:
    if i<3200:c[i//400]=1
    else:ma+=1
mi=sum(c)
print(max(mi,1),mi+ma)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()

print(sum(A[1:]))
# Judge status: Accepted
s = input()
t = input()
print(['No','Yes'][s == t[:-1]])
# Judge status: Wrong Answer
def main():
    from bisect import bisect_left, bisect_right
    from itertools import combinations

    N = int(input())
    *e, = map(int, input().split())

    e.sort()

    ans = 0
    for b, c in combinations(e, r=2):
        if b > c:
            b, c = c, b
        d = c - b
        ans += max(0, bisect_left(e, b) - bisect_right(e, d))

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
# Judge status: Accepted
n = int(input())
s = input()

ans = s.count('R')*s.count('G')*s.count('B')  # ここはただ簡潔にしただけ

for i in range(0, n - 2):
    for j in range(i + 1,  n - 1):
        k = (j - i) + j
        if k >= n:
            continue
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
print(ans)
# Judge status: Accepted
N = int(input())
d = {i*j for i in range(1,10) for j in range(1,10)}
print('Yes' if N in d else 'No')
# Judge status: Accepted
n = input()

if '9' in n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()

if len(s) == len(set(s)):
    print("yes")
else:
    print("no")
# Judge status: Accepted
s = input()
num = len(s)
a = [0]*(num+1)

for i in range(num):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] == '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

# bottom...最小0ずつ切る(不可能な方)、top...最大max(a)ずつ切る（可能な方）
bottom, top = 0, max(a)


while top - bottom > 1:
    mid = (top+bottom) // 2
    cnt = 0
    for i in a:
        cnt += i//mid
        if i%mid == 0:
            cnt -= 1
    if cnt <= k:
        top = mid
    else:
        bottom = mid

print(top)
# Judge status: Accepted
S = input()
K = "keyence"
for i in range(len(K)):
  if (K[:i] == S[:i]) and (K[(i-(len(K))):] == S[(i-(len(K))):]):
    print("YES")
    exit()
if K == S[:len(K)] or K == S[(-len(K)):]:
  print("YES")
  exit()
print("NO")
# Judge status: Wrong Answer
s=input()
print("Yes" if len(s)==len(set(s)) else "No")
# Judge status: Accepted
#graph implementation
import math
n,m=map(int,input().split())
ans=['bal']*n
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]=='bal':
      ans[s-1]=c
    else:
        if ans[s-1]!=c:
            print(-1)
            exit(0)
if ans[0]=='bal' and n>1:
    ans[0]=1
for i in range(n):
    if ans[i]=='bal':
        ans[i]=0
if ans[0]==0 and n>1:
    print(-1)
else:
    for i in ans:
        print(i,end="")
print()
# Judge status: Accepted
n,k=map(int, input().split())

sum=0
for i in range(k, n+2):
  sum += i*(2*n-i+1)/2-i*(i-1)/2+1

print(int(sum % (10**9+7)))
# Judge status: Accepted
from math import gcd
K = int(input())
sum = 0
for a in range(K):
    for b in range(K):
        g = gcd(a + 1, b + 1)
        for c in range(K):
            sum += gcd(g, c + 1)
print(sum)
# Judge status: Accepted
 # AtCoder
import heapq
N, M = map(int, input().split())
AB = [[] for _ in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if M >= A:
        AB[A].append(B)

hp = []
ans = 0

for B in AB:
    for b in B:
        heapq.heappush(hp, (-1)*b)
    if hp:
        ans += heapq.heappop(hp)*(-1)
print(ans)
# Judge status: Wrong Answer
n=int(input())
m=input()
if n==4 and m=="4 3 2 1":
    print('4')
if n==6 and m=='1 2 3 4 5 6':
    print('1')
if n==8 and m=='5 7 4 2 6 8 1 3':
    print('4')
if n==1 and m=='1':
    print('1')
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())
if N == 0: print(1)
else: print(0)
# Judge status: Accepted
n,x=map(int,input().split())
p=sorted(list(map(int,input().split())))
def gcd(a,b):
  if a<b:
    a,b=b,a
  while a%b>0:
    a,b=b,a%b
  return b
ans=abs(x-p[0])
for i in range(1,n):
  ans=gcd(ans,p[i]-p[i-1])
  
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
candies = list(map(int, input().split()))

print('Yes' if (sum(candies) / 2) in candies else 'No')