peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n ,k = map(int ,input().split())
hai = list(map(lambda x:(int(x)+1)/2 ,input().split()))
hait= hai[:k]
ans = tmp = sum(hait)
for i in range(k,n):
  tmp = tmp - hai[i-k] + hai[i]
  if ans < tmp:
    ans = tmp
print(ans)
# Judge status: Accepted
x, y, z = map(int, input().split())

a = x
x = y
y = a

a = x
x = z
z = a

print(x, y, z)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

ans = float('inf')
for i in range(0, 2 * max(x, y)+1, 2):
    total = a * (x - (i // 2)) + b *(y - (i // 2)) + c * i
    ans = min(ans, total)
print(ans)
# Judge status: Accepted
a = list(map(int,input().split()))
count = 1

for i in a:
    if i == 0:
        print(count)
        break
    count+=1
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1,N+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)
# Judge status: Accepted
n = int(input())

l = len(str(n))
if n < 10:
    ans = n
else:
    ans1 = 9 * (l-1) + int(str(n)[0]) - 1
    ans2 = sum([int(x) for x in list(str(n))])
    ans = max(ans1, ans2)
print(ans)
# Judge status: Accepted
K,N = map(int,input().split())
A = list(map(int,input().split()))

dist_max = 0
for i in range(N-1):
    dist_max = max(dist_max,A[i+1]-A[i])
dist_max = max(dist_max,K-A[N-1]+A[0])

print(K-dist_max)
# Judge status: Wrong Answer
list = (input().split())

A=set(list)

print(A)
# Judge status: Accepted
a, b = map(int, input().split())
if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')
# Judge status: Accepted
k = int(input())
a, b = [int(i) for i in input().split()]

i = k
while(i < a):
    #print(i)
    i += k
#print(i)
if i <= b:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
n = int(input())
ans = 1
mod = 10**9+7
for i in range(1,n+1):
    ans *= i
    ans %= mod

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

if N <= K:
    print(0)
else:
    H.sort(reverse=True)
    del H[:K]
    print(sum(H))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    d = [a, b, c]
    d.sort()
    print(a * b)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Fri May 29 21:29:28 2020

@author: naoki
"""
import fractions

N = int(input()) # 時計の個数
T = [int(input()) for i in range(N)] # 時計の針が一周する時間
T.sort() # 小さい順番にソートする
lcm = T[0] 

for i in range(1,N):
    lcm = lcm*T[i]// fractions.gcd(lcm,T[i])
print(lcm)
# Judge status: Accepted
A, B = map(int, input().split())
print(A*B) if (A<=9) & (B<=9) else print(-1)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
c=input()
h,i,j=c[:(a-2)],c[a-2],c[a-1:]
if i=="A":
  i="a"
if i=="B":
  i="b"
if i=="C":
  i="c"
print(h+i+j)
# Judge status: Accepted
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())

for i in range(N):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dt < dist:
        print("No")
        exit(0)

    if dist % 2 != dt % 2:
        print("No")
        exit(0)

print("Yes")
# Judge status: Wrong Answer
N=int(input())

min_x=[]
max_x=[]
for _ in range(N):
    A,B=map(int,input().split())
    min_x.append(A)
    max_x.append(B)

if N%2==0:
    center=N//2
    min_tmp=(min_x[center]+min_x[center-1])
    max_tmp=(max_x[center]+max_x[center-1])
    print(max_tmp-min_tmp+1)
else:
    center=N//2
    print(max_x[center]-min_x[center]+1)
# Judge status: Wrong Answer
n = int(input().strip())
a = [int(input().strip()) for _ in range(n)]
a.sort()
ans = 0
for i in range(len(a) - 1):
    if a[i + 1] == a[i]:
        ans += 1
print(ans)
# Judge status: Accepted
N=int(input())
A=[0]
for i in range(1,N+1):
    A.append(int(input()))

ans=0
i=1
while i<=N:
    # print(i)
    # print(A[1:])
    if A[i]>=2:
        ans+=A[i]//2
        A[i]%=2
    # print(A[1:])
    if i<N and A[i]==1 and A[i+1]>=1:
        ans+=1
        A[i]-=1
        A[i+1]-=1
    # print(A[1:])
    # print(ans)
    i+=1

print(ans)
# Judge status: Wrong Answer
l = list(map(int,input().split()))
a=l[0]
b=l[1]
c=l[2]
d=b//c
if(b==1):
    print(a*c)
else:
    x=abs(a-b)
    if(x>c):
        print(c+c)
    else:
        print(c+x)
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
x = a
y = c
max = x * y
if b <= 0:
  print(max)
else:
  for x in range(a,b + 1):
    for y in range(c,d + 1):
      if x * y > max:
        max = x * y
  print(max)
# Judge status: Wrong Answer
N = int(input())

if N >= 1:
    print('ABC')
elif N <= 999:
    print('ABC')
if N >= 1000:
    print('ABD')
elif N <= 1998:
    print('ABD')
# Judge status: Wrong Answer
import sys
li  =   lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw  =   lambda : sys.stdin.readline().strip().split()
ni  =   lambda : int(sys.stdin.readline().strip())
nsi =   lambda : sys.stdin.readline().strip()

from collections import defaultdict as df
import math
s=input()
sum=0
for i in s:
    sum+=int(i)

if(sum%9==0):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
# -*- coding: utf-8 -*-
x,y = map(int, input().split())
cnt = 0
b = 1
while x*b<=y:
    cnt += 1
    b *= 2

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

if N%2==0 and all(a==b for a,b in zip(S,S[N//2:])):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    ans += (1 if 0 <= s-i-j <= k else 0)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
if N%2==1:
    #print(A[0])
    #print(A[1:N//2])
    #print(A[N//2])
    print(A[0] + sum(A[1:N//2])*2 + A[N//2])
else:
    print(A[0] + sum(A[1:N//2])*2)
# Judge status: Wrong Answer
import math

n = int(input())

_sum = int(n / 2) * (n + 1)

print(_sum - n)
# Judge status: Wrong Answer
X,Y=map(int,input().split())
s=(2*X-Y)/3
t=(2*Y-X)/3
mod=(10**9)+7
if s!=int(s) or t!=int(t):
  print(0)
  exit()
s=int(s)
t=int(t)
up=1
d=1
for i in range(s+t,max(s,t),-1):#a!/b!c!(a=b+c)がやりたい
  up=(up*i)%mod
for i in range(1,min(s,t)+1):
  d=(d*i)%mod
d=pow(d,mod-2,mod)
print((up*d)%mod)
# Judge status: Accepted
# 配るDP

n = int(input())


max_n = 110000
dp = [n] * max_n

# 初期化
dp[0] = 0

for i in range(n):
    pow6, pow9 = 1, 1
    while i + pow6 <= n:
        dp[i + pow6] = min(dp[i + pow6], dp[i] + 1)
        pow6 *= 6
    while i + pow9 <= n:
        dp[i + pow9] = min(dp[i + pow9], dp[i] + 1)
        pow9 *= 9
print(dp[n])
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
N, M, X = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 10
for i in range(2 ** N):
    p = [0] * M
    sum = 0
    for j in range(N):
        if ((i >> j) & 1):
            sum += li[j][0]
            for k in range(M):
                p[k] += li[j][k + 1]
        if all(x >= X for x in p):
            ans = min(sum, ans)

print(ans if ans != 10 ** 10 else -1)
# Judge status: Accepted
d={}
for i in range(int(input())):
  s=input()
  d[s]=d.get(s,0)+1
print(len(d))
# Judge status: Wrong Answer
def main():
    N,A,B=map(int,input().split())
    count=(N//(A+B))
    if (A+B)*10**100 <= N:
        print(A*10**100)
        return 0
    ans=count*A
    if A>=N-(A+B)*count:
        ans+=(N-(A+B)*count)
        print(ans)
    else:
        print(ans)
main()
# Judge status: Accepted
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
u,v,w=0,0,0
for t,x,y in txy:
  p=t-u
  q=abs(v-x)+abs(w-y)
  if p<q or p%2!=q%2:
    print("No")
    break
else:
  print("Yes")
# Judge status: Wrong Answer
def f(n):
  ret=0
  while n%2==0:
    ret+=1
    n/=2
  return ret
n=int(input())
ans=0
max_=0
for a in range(1,n+1):
  if f(a)>max_:
    max_=f(a)
    ans=a
print(ans)
# Judge status: Accepted
#Common Raccoon vs Monster
H, N = map(int,input().split())
A = list(map(int,input().split()))

if sum(A) >= H:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m,x = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
ans = 10**18
for i in range(2**n):
  uds = [0]*m
  cost = 0
  for j in range(n):
    if i&1<<j:
      for k in range(m):
        uds[k] += ls[j][k+1]
      cost += ls[j][0]
  if min(uds) >= x:
    ans = min(ans,cost)
if ans == 10**18:
  print(-1)
else:
  print(ans)
# Judge status: Accepted
n=int(input());print(sum(sorted(map(int,input().split()))[n::2]))
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
ans = set()
for i in range(k):
    if b>a+i: ans.add(a+i)
for i in range(k-1,-1,-1):
    if a<b-i: ans.add(b-i)
ans = sorted(ans)
for i in ans:
    print(i)
# Judge status: Accepted
import sys
input = sys.stdin.readline

R = int(input())
print(R * 6.28318530717958623200)
# Judge status: Wrong Answer
s = list(map(int, input().split()))
print(s.count(1))
# Judge status: Accepted
def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 0

    for i in range(1, N - 1):
        tmp = [P[i - 1], P[i], P[i + 1]]
        tmp.sort()

        if tmp[1] == P[i]:
            ans += 1

    print(ans)


resolve()
# Judge status: Accepted
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


l, r, d = zz()
ans = 0
for i in range(l, r+1):
    if(i % d == 0):
        ans += 1
print(ans)
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    if a < c < b or b < c < a:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a=int(input())
b=[]
c=""
for i in range(a):
    b.append(str(input()))
for j in range(a-1):
    if b[j][-1]==b[j+1][0]:
        if len(set(b))==a:
            c="Yes"
        else:
            c="No"
            
    else:
        c="No"
print(c)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
n = len(s)
for i in range(n):
    tmp = [s[-1]] + s[:n-1]
    s = tmp[::]
    if s == t:
        print('Yes')
        break
else:
    print('No')
# Judge status: Accepted
#coding: utf-8

N, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

ret = 0
for i in range(N-1):
    if A[i] + A[i+1] > X:
        tmp = A[i] + A[i+1] - X
        ret += tmp
        A[i+1] -= min(A[i+1], tmp)


print(ret)
# Judge status: Wrong Answer
n=int(input())
l=[]
for i in range(n):
    s=input()
    s=sorted(s)
    s="".join(s)
    l.append(s)

l.sort()
cnt=0
tmp=0

for i in range(1,len(l)):
    if l[i]==l[i-1]:
        tmp += 1
    else:
        cnt += tmp+1*(tmp)//2
        tmp=0
cnt += tmp+1*(tmp)//2
print(cnt)
# Judge status: Accepted
X = int(input())

count = 0
num = 100
while num < X:
    num = int(num * 1.01)
    count += 1
print(count)
# Judge status: Accepted
def resolve():
    x = int(input())
    ans = 0
    money = 100
    while money < x:
        money *= 1.01
        money = int(money)
        ans += 1
    print(ans)
resolve()
# Judge status: Wrong Answer
n,k=tuple(map(int,input().split()))
print(n,k)
s=list(input())
s[k-1]=s[k-1].lower()
print("".join(s))
# Judge status: Accepted
N = int(input())

g = [[0] * (10) for _ in range(10)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

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

if k >= a + b:
    print(0, 0)
    
elif a <= k < a + b:
    print(0, a + b - k)
    
else:
    print(a - k, b)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(N):
    dic[input().rstrip('\n')] += 1
for k, v in dic.items():
    print(k, 'x', v)
# Judge status: Wrong Answer
from fractions import gcd
from math import ceil
a,b,c,d = map(int, input().split())

nums = b-a+1
t1 = ceil(b/c - a/c)
t2 = ceil(b/d - a/d)

lcm = (c*d)//gcd(c,d)
t3 = b//lcm - a//lcm
print(nums-t1-t2+t3)
# Judge status: Wrong Answer
a = input().split()
s = int(a[0])
w = int(a[1])

if w <= s:
    print('safe')
else:
    print('unsafe')
# Judge status: Wrong Answer
a, b = map(int, input().split())

if 1 < a and a < 10000 and 1 < b and b < 10000:
    if (a * b) % 2 == 1:
        print('Odd')
    if (a * b) % 2 == 0:
        print('Even')
# Judge status: Accepted
from operator import itemgetter
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[list(map(int,input().split())) for _ in range(m)]
B.sort(key=itemgetter(1),reverse=True)
C=[]
for b,c in B:
  C+=[c]*b
  if len(C)>=n:break
print(sum(sorted(A+C)[-n:]))
# Judge status: Wrong Answer
A=int(input())
B=int(input())
L=[1,2,3]
L.remove(A)
L.remove(B)
print(L)
# Judge status: Wrong Answer

D = int(input())

print("christmas"+" Eve"*(25-D))
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if ((500*a)+(100*b)+(50*c))==X:
                count+=1
print(count)
# Judge status: Accepted
x, y = map(int, input().split())
if abs(y) > abs(x):
    if (x >= 0 and y > 0):
        print(abs(y - x))
    elif x * y <= 0:
        print(abs(y) - abs(x) + 1)
    else:
        print(abs(y) - abs(x) + 2)
else:
    if x > 0 and y > 0:
        print(x - y + 2)
    elif x * y < 0 or (y == 0 and x > 0):
        print(abs(x) - abs(y) + 1)
    else:
        print(abs(x - y))
# Judge status: Accepted

X = int(input())

if X % 1.08 == 0:
    print(int(X//1.08))
else:
    if int((int(X//1.08)+1) * 1.08) == X:
        print(int(X//1.08+1))
    else:
        print(":(")
# Judge status: Wrong Answer
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
print(sum(L_list))
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<=abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()
# Judge status: Wrong Answer
N=input()
if N=="RRR":
  print(3)
elif N=="SRR" or N=="RSR" or N=="RRS":
  print(2)
elif N=="SSR" or N=="SRS" or N=="RSS":
  print(1)
else:
  print(0)
# Judge status: Accepted
n,r = map(int,input().split())
ans = 0
if n>10:
  ans = r
else:
  ans = r+100*(10-n)
print(ans)
# Judge status: Wrong Answer
A, B, C = map(int,input().split())

if A == B == C == 1:
    print(0)

elif A == B == C:
    print(-1)
    exit()

LA = []
LB = []
LC = []
LA.append(A)
LB.append(B)
LC.append(C)
i = 0
cnt = 0

while LA[i] % 2 == 0 and LB[i] % 2 == 0 and LC[i] % 2 == 0:
    LA.append((LB[i]+LC[i])/2)
    LB.append((LC[i]+LA[i])/2)
    LC.append((LA[i]+LB[i])/2)
    i += 1
    cnt += 1

print(cnt)
# Judge status: Accepted
# ABC 081: A – Placing Marbles
n = input()
print(n.count('1'))
# Judge status: Accepted
N = int(input())
count = 0
for i in range(1,N+1):
  if i<10 or 100<=i<1000 or 10000<=i<100000:
    count += 1
    
print(count)
# Judge status: Wrong Answer
N,M,K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.append(10**9+7)
B.append(10**9+7)
ans = 0

while True:
    if A[0] > B[0]:
        K = K- B[0]
        B = B[1:]
        ans +=1
    else:
        K = K-A[0]
        A = A[1:]
        ans +=1
    if K <0:
        break
print(ans-1)
# Judge status: Accepted
n = int(input())
a = input().split()
s = set()

dup = False
for i in a:
    if i in s:
        dup = True
    else:
        s.add(i)

if dup:
    print("NO")
else:
    print("YES")
# Judge status: Wrong Answer
N=map(int,input().split())
S=list(map(str,input().split()))

AC=S.count('AC')
WA=S.count('WA')
TLE=S.count('TLE')
RE=S.count('RE')

print("AC × ", end='') 
print(AC)
print("WA × ", end='') 
print(WA)
print("TLE × ", end='') 
print(TLE)
print("RE × ", end='') 
print(RE)
# Judge status: Wrong Answer
import sys
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a+1, c-1):
    if s[i-1]==s[i]=='#':
        print('No')
        sys.exit()
for i in range(b+1, d-1):
    if s[i-1]==s[i]=='#':
        print('No')
        sys.exit()
if c<d:
    print('Yes')
else:
    for i in range(b-1, d-1):
        if s[i-1]==s[i]==s[i+1]=='.':
            print('Yes')
            sys.exit()
    print('No')
# Judge status: Wrong Answer
a, b = map(int,input().split())

if a < b:
  print(a)
else:
  if b%a == 0:
    print(a)
  else:
    print(b%a)
# Judge status: Wrong Answer
import math

l=list(map(int, input().split(' ')))
a=l[0]
b=l[1]
h=l[2]
m=l[3]
hours = (h+m/60)/12
minutes = m/60
theta = 2*math.pi*(hours-minutes)
ans = a**2+b**2+2*a*b*math.cos(theta)
print(ans**0.5)
# Judge status: Accepted
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(cnt) == 1:
    if len(s) == 1:
        print('YES')
    else:
        print('NO')
    # print('YES')
    exit()
if len(cnt) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
    exit()

if cnt[0][1] > cnt[-1][1] + 1:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
from itertools import groupby as gb
l=[(a,len(list(b))) for a,b in gb(list(input()))]
ans=0
now=0
if l[0][0]=="T":
    ans+=l[0][1]
    now+=1
pres=0
for (k,x),(k1,y) in zip(l[now::2],l[now+1::2]):
    #print(ans,pres)
    if x+pres>=y:pres=(x+pres-y)
    else:
        ans+=y-x-pres
        pres=0
print(ans+pres+(0 if l[-1][0]=="T" else l[-1][1]))
# Judge status: Wrong Answer
n, k = map(int, input().split())
ss = set()

for i in range(1, k*2+1):
  if i%2==1:
    pass
  else:
    for s_i in map(int, input().split()):
      ss.add(s_i)
print(len([s for s in range(1, n+1) if s not in ss]))
# Judge status: Accepted
N = int(input())
S = []
for _ in range(N): S.append(input())

print('AC x', S.count('AC'))
print('WA x', S.count('WA'))
print('TLE x', S.count('TLE'))
print('RE x', S.count('RE'))
# Judge status: Accepted
D = int(input())
ans = " ".join(["Christmas"] + ["Eve"] * (25 - D))
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
four = 0
two = 0
one = 0 
for e in A:
    if e%4 == 0:
        four += 1
    elif e %2 == 0:
        two += 1
    else:
        one += 1

if two == 0:
    if one <= four + 1:
        print('Yes')
    else:
        print('No')
else:
    if one <= four:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
from collections import Counter
import sys

N, K = map(int, input().split())
A = list(input().split())
ball = [int(A[i]) for i in range(N)]
kinds = len(set(ball))
Cou = list(Counter(ball).most_common())
dele = [int(Cou[i][1]) for i in range(len(Cou) - kinds + K, len(Cou))]
print(sum(dele))
# Judge status: Wrong Answer
import math

K = int(input())

sum = 0
for a in range(1, K+1) :
    for b in range(1 , K+1) :
        tmp = math.gcd(a, b)
        for c in range(1 , K+1) :
            sum = sum + math.gcd(a, tmp)

print(sum)
# Judge status: Wrong Answer
n = int(input())
d = list(map(int, input().split()))

l = [0]*(max(d)+1)
for i in d:
    l[i] += 1

if l[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(1, len(l)):
    ans *= l[i-1]**l[i]

print(ans%998244353*min(l))
# Judge status: Accepted
from itertools import accumulate
N, M = map(int, input().split())

# left = 1
# right = N
#
# for i in range(M):
#     a,b = map(int, input().split())
#     left = max(left,a)
#     right = min(right, b)
#
# print(max(0,right-left+1))

imos = [0] * (N + 2)
for i in range(M):
    l, r = map(int, input().split())
    imos[l] += 1
    imos[r + 1] -= 1

imos = list(accumulate(imos))

ans = 0
for im in imos:
    ans += (im == M)

print(ans)
# Judge status: Accepted
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = [0] * 2
for k, v in a.items():
    b.extend([k] * (v // 2))
else:
    b.sort()
    print(b[-1] * b[-2])
# Judge status: Accepted
s=input()
ss=list(s)
if ss[len(ss)-1] == "s":
    print(s+"es")
else:
    print(s+"s")
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
magic = [list(map(int, input().split())) for _ in range(M)]
magic = sorted(magic, key=lambda x: -x[1])

hold = []
now = 0
for k, v in magic:
    hold.extend([v]*k)
    now += k
    if now >= N:
        break
A.extend(hold)
A.sort(reverse=True)
print(sum(A[:N]))
# Judge status: Wrong Answer
n, m=map(int, input().split())
a = [-1]*n
ans = 0
for i in range(m):
  s, c = map(int, input().split())
  if a[s-1]!=c and a[s-1]!=-1:
    ans = -1
    break
  elif n>1 and s==1 and c==0:
    ans = -1
    break
  else:
    a[s-1]=c
if ans == 0:
  if a[0]==-1:
    a[0]=1
  for i in range(n):
    if a[n-1-i] != -1:
      ans += a[n-1-i]*10**i
print(ans)
# Judge status: Wrong Answer
X = str(input())

# 文字列を4つのintに分裂
# 二分検索でヒットしたらタス、そうでなければ引く、listに履歴を残しておく

for i in range(2**3):
  ans = int(X[0])
  list = []
  for j in range(3):
    if (i>>j & 1) == 1:
      ans += int(X[j+1])
      list.append("+")
    else:
      ans -= int(X[j+1])
      list.append("-")
  if ans == 7:
    break

ans = X[0]
for i in range(3):
  ans += list[i]
  ans += X[i+1]
print(ans)
# Judge status: Accepted
def e_count_median():
    N = int(input())
    Min, Max = [], []
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        Min.append(a)
        Max.append(b)
    Min.sort()
    Max.sort()

    mid = N // 2
    median_min, median_max = ((Min[mid], Max[mid]) if N % 2 == 1
                              else (Min[mid] + Min[mid - 1], Max[mid] + Max[mid - 1]))
    return median_max - median_min + 1

print(e_count_median())
# Judge status: Wrong Answer
A1, A2 = map(int, input().split())
B = list(map(int,input().split()))	

B.sort()
num = 0

for i in range(A2):
  num = B[i]

print(num)
# Judge status: Wrong Answer
N, X, T = map(int,input().split())
int((N/X)*T)
# Judge status: Wrong Answer
X = int(input())
x = 1
while ((x-1)**2)*9 < X:
  x += 1
for i in range(x):
  for j in range(-x, i):
    if i**5-j**5 == X:
      a = [i,j]
      print(*a)
# Judge status: Accepted
s=input()
n=len(s)
if n%2==1:
  print('No')
else:
  fail=0
  for i in range(n):
    if (s[i]!='h' and i%2==0) or (s[i]!='i' and i%2==1):
      fail=1
  if fail==0:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
s=list(range(n))
s.sort(key=lambda i: l[i])
newl=""
for i in range(n):
    newl+=str(s[i]+1) + ""
print(*newl)
# Judge status: Wrong Answer
s=list(input())
n=len(s)
ans=[]
for i in range(n-1):
  for j in range(i+1,n+1):
    part=set(s[i:j])
    flag=True
    for p in part:
      if p not in list('ATGC'):
        flag=False
        break
    if flag==True:
      ans.append(len(s[i:j]))
#print(ans)
if ans:
  print(max(ans))
else:
  print(0)
# Judge status: Accepted
import math
A,B = map(int,input().split())

ans = ""
for i in range(1,1251):
  a = math.floor(i * 0.08)
  b = math.floor(i * 0.1)
  if a == A and b == B:
    ans = i
    break
    
print(ans if ans != "" else -1)
# Judge status: Wrong Answer
a, b, n = map(int, input().split())
ans = 0
for i in range(n, max(0, n-b), -1):
    ans = max(ans, int(a * i / b) - (a * int(i / b)))
print(ans)
# Judge status: Wrong Answer
def add_1(n):
    return n + 1

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

for n_chg in range(k):
    n_light = [0] * n
    for i in range(n):
        print(n_light)
        print('i: {}, a[i]:{}\n'.format(i,a[i]))
        for j in range(max(i-a[i],0), min(i+a[i],n-1) + 1):
            n_light[j] += 1
            # n_light[max(i-a[i],0):min(i+a[i],n-1)] += 1
    a = n_light
    print('-------------\n')

print(a)