peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = []
b = []
for _ in range(n):
  A, B = map(int, input().split())
  a.append(A)
  b.append(B)
x = 0
for i in range(1, n+1):
  a[-i] += x
  if a[-i]%b[-i] != 0: x += b[-i] - a[-i]%b[-i]
print(x)
# Judge status: Accepted
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

P.sort()

# print(P)

ans = sum(P[:K])
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
temp=(n*2+m)//4
print(min(temp,m//2))
# Judge status: Accepted
from collections import Counter

N = int(input())
S = input()

d = Counter(S)

m = 10 ** 9 + 7
# print(d)
ans = 1
for k, v in d.items():
    ans = ans * (v + 1) % m
print((ans - 1) % m)
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(sum([i if (i%3 != 0 and i%5 != 0) else 0 for i in range(1,N+1)]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B = [int(i) for i in input().split()]
print(A+B//2)
# Judge status: Accepted
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    k,s = map(int,input().split())
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i-j<=k and s-i-j>=0:
                ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()
# Judge status: Accepted
col=list(map(str,input().split()))
num=list(map(int,input().split()))
U=str(input())
if U == col[0]:
  num[0] = num[0]-1
elif U == col[1]:
  num[1] = num[1]-1
[print(num[i],end=" ") for i in range(2)]
# Judge status: Wrong Answer
n = int(input())

s = 0
for i in range(n):
    if not (i % 3 == 0 or i % 5 == 0):
        s += i
        
print(s)
# Judge status: Wrong Answer
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    x = int(readline().rstrip())
    li = [400, 600, 800, 1000, 1200, 1400, 1600, 1800]
    for i in range(8):
        if li[i] > x:
            print(9 - i)
            break


if __name__ == '__main__':
    main()
# Judge status: Accepted
h, m, H, M, K = map(int, input().split())

print(H*60 +M - ( h*60 +m  + K ))
# Judge status: Accepted
N, M = map(int, input().split())
D = [0]*N
for _ in range(M):
  a, b = map(int, input().split())
  D[a-1] += 1
  D[b-1] += 1

for d in D:
  print(d)
# Judge status: Accepted
s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))
# Judge status: Accepted
from math import sqrt
n=int(input())
nn=int(sqrt(n))
print(nn*nn)
# Judge status: Accepted
n = int(input())
nums = list(map(int, input().split()))
ans = []

for _ in range(n):
  ans.append(-1)

for i in range(1, n + 1)[::-1]:
  C = i*2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ans2 = []
for i in range(n):
  if ans[i] == 1:
    ans2.append(i+1)

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)
# Judge status: Wrong Answer
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
def lcm_(x, y):
    return x * y // gcd(x, y)
a = reduce(lcm_, map(lambda x: x//2, A))
print(M//a - M//(2*a))
# Judge status: Wrong Answer
import math
x = int(input())
money = 100
cnt = 0

while money < x:
    money = int(money*1.01)
    cnt += 1
    

print(cnt)
# Judge status: Wrong Answer
n,m = list(map(int,input().split()))
output = n*(n-1)/2+m*(m-1)/2
print(output)
# Judge status: Accepted
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()
# Judge status: Accepted
import sys

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

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0] * (N + 1)

    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2,N):
        dp[i] = min(dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i))
    print(dp[N-1])

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
X, N = list(map(int, input().split()))
p = set(map(int, input().split()))

dist = 0

if N == 0:
    print(X)
    dist_max = -1
else:
    dist_max = max(abs(max(p) - X), abs(min(p) - X))

while dist <= dist_max:

    if (X - dist in p) and (X + dist in p):
        dist += 1
        continue

    if not (X - dist in p):
        print(X - dist)
        break
    elif not (X + dist in p):
        print(X + dist)
        break
# Judge status: Wrong Answer
a=int(input())
b=[int(input()) for i in range(a)]
b.sort()
ans=0

while ans==0 and len(b)!=0:
	if sum(b)%10==0:
		del b[0]
	else:
		ans=sum(b)

print(ans)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
maxDown = 0
count = 0
for x in range(N-1):
    if H[x] >= H[x + 1]:
        count += 1
    else:
        count = 0
    if maxDown < count:
        maxDown = count
print(maxDown)
# Judge status: Wrong Answer
def swapper(X,Y,Z):
      X=int(X)
      Y=int(Y)
      Z=int(Z)
      b=X
      X=Z
      Z=b
      return X, Y, Z
# Judge status: Accepted
x=int(input())
if x==0:
    print(1)
elif x==1:
    print(0)
# Judge status: Accepted
S = list(input())

if ((S[0] == S[1] and S[2] == S[3] and S[1] != S[2]) or
    (S[0] == S[2] and S[1] == S[3] and S[1] != S[2]) or
    (S[0] == S[3] and S[1] == S[2] and S[0] != S[1])):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import collections
from collections import defaultdict
import math
import numpy as np
import re
import itertools
import bisect

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

l = 6*m
s = 0.5*m+30*h

kakudo = min(abs(l-s),360-abs(l-s))
print(math.sqrt(a*a+b*b-2*b*a*math.cos(math.radians(kakudo))))
# Judge status: Accepted
import numpy as np
from collections import Counter
input()
rates = np.array(input().split(), dtype=np.int64) // 400
over3199 = (rates >= 8).sum()
colors = len(Counter(rates[rates < 8]).keys())
print(max(1, colors), colors + over3199)
# Judge status: Wrong Answer
import numpy as np
n,m = map(int, input().split())
arr = np.zeros(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] = 1
ans = int(arr.sum())
print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())
if a >= n%500:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
K,S = map(int,input().split())
cnt = 0
for i in range(K+1):
  for j in range(K+1):
    if S-(i+j) <= K:
      cnt += 1

print(cnt)
# Judge status: Accepted
n,a,b=map(int,input().split())

if (n==1 and a!=b) or a>b:
  print(0)
  exit()
  
print((b-a)*(n-2)+1)
# Judge status: Accepted
import heapq

N = int(input())
h = [4, 7]
heapq.heapify(h)

while True:
    n = heapq.heappop(h)

    if n > N:
        print('No')
        break

    if n == N:
        print('Yes')
        break

    heapq.heappush(h, n + 4)
    heapq.heappush(h, n + 7)
# Judge status: Wrong Answer
a,b,c,d,e,k=[int(input())for _ in range(6)]
if e-a >= k:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
N, M = map(int, input().split())

S = set(i for i in range(1, M + 1))
for i in range(N):
    K, *A = map(int, input().split())
    S &= set(A)
print(len(S))
# Judge status: Accepted
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b=MI()
if a%b==0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if a<=0 and 0<=b:
    print('Zero')
elif 0<a and 0<b:
    print('Posiive')
else:
    ans = b-1+1
    if ans%2==0:
        print('Positive')
    else:
        print('Negative')
# Judge status: Wrong Answer
x = int(input())

#def prime number discriminator
def prime_or_not(a):
  b = 0
  for i in range(a):
    if a % (i + 1)== 0:
      b += 1
    else:
      pass
    if b >= 1:
      return 1
    else:
      return 0

ans = 0

while ans <1:
  ans += prime_or_not(x)
  x += 1
print(x - 1)
# Judge status: Accepted
n = int(input())

ans = n*(n-1)//2
print(ans)
# Judge status: Wrong Answer
S = input()
if S[0] == 'R':
  if S[1] == 'R':
    if S[2] == 'R':
      print("3")
    else:
      print("2")
  else:
    print("1")
else:
  print("0")
# Judge status: Accepted
from fractions import gcd
n, m = map(int, input().split())
a = [int(i)//2 for i in input().split()]


def lcm(x, y):
    return x*y//gcd(x, y)


l = 1
for i in a:
    l = lcm(l, i)
for i in a:
    if l//i % 2 == 0:
        print(0)
        exit()
print((m//l+1)//2)
# Judge status: Accepted
n=input()
x,y=n.split()
for c in range(int(x)+1):
  cnt=0
  t=int(x)-c
  asi=2*c+4*t
  if asi==int(y):
    print("Yes")
    cnt=1
    break
if cnt==0:
  print("No")
# Judge status: Wrong Answer
import math

x = float(input())
print(x * x * math.pi)
# Judge status: Accepted
n,m, k = map(int, input().split())

bo = False
for  i in range(0,n+1):
    for j in range(0,m+1):
        if i*(m-j) + j*(n-i) == k:
            bo = True

if bo :
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,M=map(int,input().split())

dp=[True]*(N+2)
S=list(int(input()) for _ in range(M))
for i in S:
    dp[i]=False
num=[0]*(N+2)
MOD=1000000007
num.insert(0,1)
for i in range(0,N):
    if dp[i]:
        num[i+1]+=num[i]
        num[i+1]%=MOD
        num[i+2]+=num[i]
        num[i+2]%=MOD
print(num[N])
# Judge status: Accepted
h1,m1,h2,m2,k=map(int,input().split())
ans2=h2*60+m2
ans1=h1*60+m1
print(ans2-ans1-k)
# Judge status: Accepted
s = input()
ans = 0

def check(sub):
    check_s = set(list("ACGT"))
    for c in sub:
        if not c in check_s:
            return 0
    return len(sub)    
    
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        ans = max(ans, check(s[i:j]))

print(ans)
# Judge status: Wrong Answer
import numpy as np
k = int(input())

if k % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
elif k  == 101:
  print(4)
else:
  print(k-1)
# Judge status: Accepted
a = int(input())

ans = a + a*a + a*a*a
print(ans)
# Judge status: Accepted
d,t,s = map(int,input().split())

if d / (s*t) <= 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys
N = int(input())
S = str(input())
if N <= 0 or N >= 100:
    sys.exit()
x = 0
max = 0
for I in S:
    if I == "I":
        x += 1
        if max < x:
            max = x
        continue
    if I == "D":
        x -=1
        continue
print(max)
# Judge status: Accepted
k,x = [int(x) for x in input().split()]

k = k * 500 

if k >= x:
  print("Yes")
else:
	print("No")
# Judge status: Accepted
import heapq
n,k=map(int,input().split())

q=[]
for _ in range(n):
    a,b=map(int,input().split())
    heapq.heappush(q,(a,b))

while k>0:
    a,b=heapq.heappop(q)
    k-=b

print(a)
# Judge status: Accepted
def resolve():
    ans=1
    x,y=map(int,input().split())
    while True:
        x*=2
        if x>y:
            print(ans)
            break
        ans+=1
resolve()
# Judge status: Accepted
N=list(input())
if "9" in N:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = list(map(int, input().split()))
k = int(input())
s.sort(reverse=True)
print(s[0]*(2**k)+s[1]+s[2])
# Judge status: Accepted
X,N = map(int,input().split())
P = set(map(int,input().split()))

diff = 0
while True:
    if X - diff not in P:
        print(X - diff)
        break
    elif X + diff not in P:
        print(X + diff)
        break
    else:
        diff += 1
# Judge status: Accepted
a, b, c = map(int, input().split())
num = (100 * a) + (10 * b) + c
print('YES' if (num % 4) == 0 else 'NO')
# Judge status: Wrong Answer
a , b = map(int,input().split())
 
x =  a * b 
 
if x % 2 == 0:
    print("Even")
else:
    print("odd")
# Judge status: Accepted
N = int(input())

count = 0
ans = "No"
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count == 3:
            ans = "Yes"
    else:
        count = 0
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
print('YNeos'[sum(B)-sum(A)<sum(max(0,(b-a+1)//2)for a,b in zip(A,B))::2])
# Judge status: Wrong Answer
A, B =map(int,input().split())
answer = 0
if A >=13:
	answer = B
elif A > 6:
		answer = B/2
print(int(answer))
# Judge status: Accepted
from heapq import heappush,heappop
n,k=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in a:
  heappush(q,-i)
for _ in range(k):
  i=heappop(q)
  i=-i//2
  heappush(q,-i)
print(-sum(q))
# Judge status: Wrong Answer
n = int(input())
s = [i for i in input()]

max = 0

for i in range(1, n-1):
    a = set(s[:i])
    b = set(s[i:])

    print(a & b)
    
    if max < len(a & b):
        max = len(a & b)
print(max)
# Judge status: Accepted
S = [input() for _ in range(3)]
D = {'a':0, 'b':1, 'c':2}
N = [0]*3
p = 0
while N[p]<len(S[p]):
    p_new = D[S[p][N[p]]]
    N[p]+=1
    p = p_new

print('ABC'[p])
# Judge status: Accepted
a, b = map(int, input().split())
print('Yes' if (int(str(a) + str(b)) ** 0.5).is_integer() else 'No')
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding: utf-8 -*-
k = int(input())
a, b = map(int, input().split())
flag = 0
for i in range(a, b + 1):
    if i % k == 0:
        flag = 1
        break

if flag == 1:
    print("OK")
else:
    print("NG")
# Judge status: Accepted
S = list(input())
count = 0
for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        count += 1
print(count)
# Judge status: Wrong Answer
l = int(input())

m = 0
for i in range(l):
    for j in range(l-i):
        t = i * j * (l-i-j)
        if m < t:
            m = t
print(m)
# Judge status: Accepted
N,A,B = map(int,input().split())
a = min(A,B)
b = max(A,B)
d = b - a

#差が偶数の時：d/2
#差が奇数の時：どちらかの端で一回稼ぐ

if d%2 == 0:
  print(d//2)
else:
  r = min(a,N-b+1)
  r += (b-a-1)//2
  print(r)
# Judge status: Accepted
from math import floor
A,B = map(int,input().split(" "))
s = 10*B
t = 10*(B+1)
ans = 2**60
for tmp in range(s,t):
    if floor(tmp*0.08) == A:
        ans = tmp
        break
s = 125*A
t = 125*(A+1)
for tmp in range(s,t):
    if floor(tmp/10) == B:
        ans = min(ans,tmp)
        break
if ans == 2**60:
    ans = -1
print(ans)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline().rstrip()

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

for i in range(N):
    if S[i:i+2] == 'AC':
        li[i+1] = li[i] + 1
    else:
        li[i+1] = li[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-1])
# Judge status: Accepted
a,b=map(int,input().split())
h=sum([i for i in range(1,b-a+1)])
print(h-b)
# Judge status: Wrong Answer
s = input()
n = len(s)//2

cnt = 0
for i in range(n):
  if (s[i] != s[n - 1 - i]):
    cnt+=1

print(cnt)
# Judge status: Accepted
N,K=map(int,input().split())
p = list(map(int,input().split()))

ruisekiwa=[0]

for i in range(N):
    ruisekiwa.append(ruisekiwa[i]+(1+p[i])/2)

max_value=0
for i in range(N-K+1):
    tmp=ruisekiwa[i+K]- ruisekiwa[i]
    if(max_value < tmp):
        max_value=tmp
print(max_value)
# Judge status: Accepted
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)
# Judge status: Accepted
S = input()

T = input()

count = 0

for i in range(len(S)):
    if S[i] != T[i]:
        count += 1

print(count)
# Judge status: Wrong Answer
n = int(input())
a = 1000
while a < n:
    a += 1000
print(a-n)
# Judge status: Accepted
x,y=map(int,input().split())
a=-1
p=10**9+7
for i in range(x//2+1):
  if i+2*(x-2*i)==y:
    a=i
    break
if a==-1:
  print(0)
  exit()
elif a==0:
  print(1)
  exit()
else:
  gyaku=[0,1]
  for i in range(2,a+1):
    gyaku.append(((p//i)*-gyaku[p%i])%p)
  com=[1]
  for i in range(1,a+1):
    com.append(com[-1]*gyaku[i]*(x-a+1-i)%p)
print(com[-1])
# Judge status: Wrong Answer
s = int(input())

print(0, 0, 1, 1, s, 0)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
  if a[i]/a[i-k]>1:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
s=0
i=1
while 1:
	if n<5**i:
		break
	s+=(n+5)//((5**i)*2)
	i+=1
print(0 if n%2 else s)
# Judge status: Wrong Answer
a = input()
b = input()
c = input()
countlist = [0, 0, 0]
list = ["a", "b", "c"]
turn = 0
value = ""
for x in range(len(a) + len(b) + len(c)):
    if countlist[0] == len(a) or countlist[1] == len(b) or countlist[2] == len(c): break
    if turn == 0: value = a[countlist[turn]]
    elif turn == 1: value = b[countlist[turn]]
    elif turn == 2: value = c[countlist[turn]]
        
    turn = list.index(value)
    countlist[turn] += 1

if countlist[0] == len(a): print("A")
elif countlist[1] == len(b): print("B")
elif countlist[2] == len(c): print("C")
# Judge status: Wrong Answer
x,y = map(int, input().split())
if y%x == 0: print(-1)
else: print(x)
# Judge status: Wrong Answer
n, k = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))

MAX = 10**5

dp = [MAX] * (n)
dp[0] = 0

for i in range(0, n):
    for j in range(i, i + k + 1):
        if j < n:
            dp[j] = min( dp[j], dp[i] + ( abs( arr[j] - arr[i] ) ) )


print(dp[-1])
# Judge status: Wrong Answer
import heapq

N = int(input())
A = list(map(int, input().split()))
res = "YES"
heapq.heapify(A)
for i in range(len(A)):
    if i == 0:
        continue
    if A[i] == A[i-1]:
        res = "NO"
        break
    else:
        continue
print(res)
# Judge status: Accepted
N, K = map(int, input().split())
a = list(map(int, input().split()))

max_a = 10**9
min_a = 0
while True:
    k = K
    res = (max_a+min_a)//2
    for i in range(N):
        if a[i] <= res:
            continue
        k -= (a[i]//res)
    if k >= 0:
        max_a = res
    else:
        min_a = res
    if max_a - min_a == 1:
        break
print(max_a)
# Judge status: Accepted
S = input()

l = len(S)

l = (l-2)//2
while l > 0:
    if S[0:l] == S[l:2*l]:
        print(2*l)
        break
    l = l-1
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
q, h, s, d = map(int,input().split())
n = int(input())

tmp = [4 * q, 2 * h, s, d / 2]
tmp.sort()
if tmp[0] == d / 2:
    if tmp[1] == s:
        ans = d * (n // 2) + s
    if tmp[1] == 2 * h:
        ans = d * (n // 2) + 2 * h
    if tmp[1] == 4 * q:
        ans = d * (n // 2) + 4 * q
if tmp[0] == s:
    ans = s * n
if tmp[0] == 2 * h:
    ans = h * n * 2
if tmp[0] == 4 * q:
    ans = q * n * 4
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))

if n < sum(a):
    print(-1)
else:
    print(n - sum(a))
# Judge status: Accepted
m=int(input())

for j in range(m,1000000):
    #print(j)
    pf={}
    for i in range(2,int(j**0.5)+1):
        while j%i==0:
            pf[i]=pf.get(i,0)+1
            j//=i
    if j>1:pf[j]=1
    #print(pf)
    if sum(pf.values())==1:
        print(j)
        exit()
# Judge status: Wrong Answer
baisu=set([])

i=1
while 1:
    temp=2019*i
    if "0" not in str(temp):
        baisu.add(str(temp))
    
    if temp>20000000:
        break
    i+=1

n=input()
cnt=0
for i in baisu:
    if i in n:
        cnt+=1

print(cnt)
# Judge status: Accepted
n = int(input())
s = [input() for i in range(n)]

s_set = set(s)

print(len(s_set))
# Judge status: Wrong Answer
import numpy as np
N, W = map(int, input().split())

dp = np.zeros(W + 1, int)

for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    print(dp)

print(dp[-1])
# Judge status: Wrong Answer
import numpy as np

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

Ls = np.array(Ls)
cut = np.array([1]*N)
ans = Ls / cut

for k in range(K):
    idx = np.argmax(ans)
    cut[idx] += 1
    ans = Ls / cut
print(int(np.round(max(ans))))
# Judge status: Wrong Answer
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()
rate = [0]*9


for i in a:
  rate[min(i//400,8)]+=1
base = 8-rate[:-1].count(0)
ma = min(8,base+rate[-1])
print(max(base,1),ma)
# Judge status: Accepted
s=input()
for i in range(200):
    s=s[0:len(s)-1]
    if len(s)%2==1:
        continue
    if s[0:len(s)//2]*2==s:
        print(len(s))
        exit()
# Judge status: Accepted
#Beginner 048 A
S = str(input())
print("A"+S[8]+"C")
# Judge status: Accepted
n=int(input())
a,b=[0]*n,[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
a.sort()
b.sort()
if n&1:
    print(b[n//2]-a[n//2]+1)
else:
    print(1+(b[n//2]+b[(n-1)//2])-(a[n//2]+a[(n-1)//2]))
# Judge status: Accepted
def main():
    n = int(input())
    
    z = []
    w = []

    for _ in range(n):
        x,y = tuple(map(int,input().split()))
        z.append(x+y)
        w.append(x-y)

    print(max(max(z)-min(z),max(w)-min(w)))

if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys

input = sys.stdin.readline


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

    if (B - A) % 2 == 0:
        ans = (B - A) // 2
    else:
        a = (A - 1) + 1 + ((B - ((A - 1) + 1)) - 1) // 2
        b = (N - B) + 1 + (N - (A + ((N - B) + 1))) // 2
        ans = min(a, b)

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
num=0
dist=abs(a-(t-h[0]*0.006))
for i in range(1,n):
    if dist>abs(a-(t-h[i]*0.006)):
        num=i
print(num+1)
# Judge status: Accepted
n, k = map(int, input().split())
d = set(map(int, input().split()))
d ^= {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}

while True:
    if d >= set(map(int, list(str(n)))):
        print(n)
        break
    n += 1
# Judge status: Accepted
a,b = [int(x) for x in input().split()]

dif = b - a
org = sum([x for x in range(1,dif)])
print(org-a)
# Judge status: Accepted
S = input()
T = input()
for i in range(len(T)):
    S = S[-1] + S[0:-1]
    if S == T:
        print("Yes")
        break
else:
    print("No")
# Judge status: Wrong Answer
import heapq
n = raw_input()
heap = [x*(-1) for x in map(float, raw_input().split(' '))]
heapq.heapify(heap)
while(len(heap)>1):
	u,v = heapq.heappop(heap), heapq.heappop(heap)
	u*=-1
	v*=-1
	w = 0.5*(u+v)
	heapq.heappush(heap, -w)


print -heap[0]
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    W, H, x, y = list(map(float, sys.stdin.buffer.readline().split()))
    ret = (W * H) / 2
    p = x == W//2 and y == H//2
    print(ret, 1 if p else 0)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import  deque
n=int(input())
a=list(map(int,input().split()))
cnt=0
judge=[]
for i in range(n-1):
    if a[i]<a[i+1]:
        flag=0
    elif a[i]>a[i+1]:
        flag=1
    elif a[i]==a[i+1]:
        continue
    if judge==[]:
        judge.append(flag)
    else:
        ff=judge.pop()
        if flag==ff:
            judge.append(flag)
        else:
            cnt+=1

print(cnt+1)
# Judge status: Accepted
from collections import defaultdict

dd = defaultdict(int)

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

for i in range(1,N):
    dd[i+1-A[i]] += 1
ans = 0
for i in range(N-1):
    ans += dd[A[i]+i+1]
    dd[i+1-A[i]] -= 1

print(ans)