peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,m = map(int,input().split())
a = []
for i in range(m):
    a.extend(list(map(int,input().split())))
for i in range(1,n+1):
    print(a.count(i))
# Judge status: Accepted
n,m,x,y=map(int,input().split())
listx=list(map(int,input().split()))
listy=list(map(int,input().split()))
if max(listx)>=y:
    print("War")
elif min(listy)<=x:
    print("War")
elif max(listx)>=min(listy):
    print("War")
else:
    print("No War")
# Judge status: Accepted
a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>5:
    print(b//2)
else:
    print(0)
# Judge status: Wrong Answer
import math

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

if a*c<=b:
  print(c)
else:
  print(math.floor(b/3))
# Judge status: Wrong Answer
def main():
    n, m = list(map(int, input().split()))
    mod = 1000000007
    def factorial(num, mod):
        ans = 1
        if num <= 1: return ans
        for i in range(2, n + 1):
            ans = (ans * i) % mod
        return ans

    if abs(n - m) >= 2:
        print(0)
    elif abs(n - m) == 1:
        print(factorial(n, mod) * factorial(m, mod) % mod)
    else:
        print(2 * factorial(n, mod) * factorial(m, mod) % mod)




if __name__ == '__main__':
    main()
# Judge status: Accepted
#!/usr/bin/env python3
from heapq import *

a = [*range(1, 10)]
heapify(a)
i = 0
k = int(input())
c = 0
while True:
    t = str(heappop(a))
    i += 1
    if i == k:
        break
    if t[-1] != "0":
        heappush(a, int(t + str(int(t[-1]) - 1)))
    heappush(a, int(t + t[-1]))
    if t[-1] != "9":
        heappush(a, int(t + str(int(t[-1]) + 1)))
print(t)
# Judge status: Wrong Answer
from math import log
x, y = map(int, input().split())
print(int(log(y // x, 2)) + 1)
# Judge status: Accepted
X,Y=list(map(int,input().split()))

ymin=2*X
ymax=4*X

if Y%2==0:
    if ymin<=Y<=ymax:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Wrong Answer
n,k,q = list(map(int, input().strip().split()))
point=[k-q]*n
a=[0]*q
for i in range(q):
    a[i]=int(input())
for i in range(n):
    point[i]+=a.count(i+1)
for i in range(n):
    if point[i]>0:
        print("yes")
    else:
        print("No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

num=[0]*(max(a)+1)
for i in a:
  num[i-1]+=1
#print(num)
mx=0
for i in range(1,max(a)):
  #print(num[i-1:i+2])
  m=sum(num[i-1:i+2])
  if m>mx:
    mx=m

print(mx)
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d, N = map(int, read().split())

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)
# Judge status: Wrong Answer
A,V = list(map(int,input().split()))
B,W = list(map(int,input().split()))
T = int(input())

sub = B - A
speed = V - W
if sub > T*speed:
  print("No")
else:
  print("YES")
# Judge status: Accepted
X, Y = map(int, input().split())

A = [X]
while True:
    if A[-1] * 2 <= Y:
        A.append(A[-1] * 2)
    else:
        break

print(len(A))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

yosan = 1000
kabu = 1000//a[0]
syozi = 1000%a[0]
ans = 1000
tmp = 0
for i in range(1,n) :
    if a[i-1] < a[i] and kabu != 0:
        syozi += (kabu*a[i])
        kabu = 0
    elif a[i-1] > a[i] and syozi > a[i]:
        tmp = syozi//a[i]
        kabu += tmp
        syozi -= tmp*a[i]
    ans = max(syozi, ans)

print(ans)
# Judge status: Accepted
import math as mt
a,b,h,m=map(int, input().split())
print(mt.sqrt(a**2+b**2-2*a*b*mt.cos(2*mt.pi*(1/12*(h+m/60)-m/60))))
# Judge status: Accepted
x,y,z = map(int,input().split())

ans = int(x/(y+z))
if x%(y+z) < z:
    ans -= 1
print(ans)
# Judge status: Accepted
print('Yes' if len(set(input()))==3 else 'No')
# Judge status: Wrong Answer
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
guess=["0"]*N
for i in sc:
  guess[i[0]-1]=i[1] 
if guess[0]=="0":
  print("-1")
else:
  for i in guess:
    print(i,end="")
# Judge status: Accepted
#入るp学期と、外されるp-k学期の比較
n,k=map(int,input().split())
ls=list(map(int,input().split()))
for i in range(n-k):
  if ls[i]<ls[i+k]:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
S=[]
a=0
b=0
for i in range(N):
  A=int(input())
  S.append(A)
  for j in range(i):
    if S[j]==A:
      a=a+1
      break
  if a==0:
    b=b+1
  else:
    b=b-1
    a=0
  
print(b)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)
# Judge status: Wrong Answer
A, B, K = [int(i) for i in input().split()]

numbers = set() 
for i in range(A, A+K):
    if i <= B:
        numbers.add(i)
    
for j in range(B-K, B):
    if j >= A:
        numbers.add(j+1)
    
for n in numbers:
    print(n)
# Judge status: Accepted
n=int(input())
a=int(input())

if a>=n%500:
    print("Yes")
else:
    print("No")
# Judge status: Accepted


#import sys
#import os
#import re
#import datetime

N = int(input())
#print(input().split())
a = list(map(int, input().split()))
#print(a)
countA = {}
for v in a:
	for i in (-1,0,1):
		#print("i = {}".format(i))
		if(v - i in countA):
			countA[v - i] = countA[v - i] + 1
		else:
			countA[v - i] = 1
print(max(countA.values()))

#town = {}
#for _ in range(N):
#	S, P = input().split()
#	town[S] = int(P)
#
#sum2 = sum(town.values()) / 2
#for S, P in town.items():
#	if P > sum2:
#		print(S)
#		break
#else:
#	print('atcoder')
# Judge status: Wrong Answer
N, K = map(int,input().split())
S = input()

A = 0
B = 0

for i in range(N-1):
    if S[i] == "R" and S[i+1] == "L":
        A += 1

if S[0] == "L":
    B += 1
if S[N-1] == "R":
    B += 1

ans = A * 2 + B

while(K > 0):
    if A > 0:
        ans -= 2
        A -= 1
    elif B > 0:
        ans -= 1
        B -= 1
    else:
        break
    K -= 1

print(N - ans)
# Judge status: Wrong Answer
n = int(input())
A = input()
a = A.count('W')
b = A.count('R')
c = A[:n//2]
d = c.count('W')
print(min(a,b,d))
# Judge status: Wrong Answer
def times(X):
    if 1< X < 179:
        K = 360/X
        print(K)
        return K
    else:
        print("please input an integer.")

times(90)
times(1)
# Judge status: Accepted
# D - Chat in a Circle

N = int(input())
A = list(int(a) for a in input().split())

A.sort(reverse=True)

n = N-1
ans = A[0]
n -= 1
i = 1
while n > 0:
    if n == 1:
        ans += A[i]
        n -= 1
    else:
        ans += A[i] * 2
        n -= 2
    i += 1
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    s = list(input())
    cnt = 0  # 幸福の人の数
    for i in range(n-1):
        if s[i] == s[i+1]:
            cnt += 1
    # 1回の操作で最大２人まで幸福にできるが，必ず一人は幸福にならない
    print(min(n-1, cnt + 2 * k))


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

print(2*int(input())*math.pi)
# Judge status: Accepted
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n >= (p ** e) and n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n >= p and n % p == 0:
      n //= p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)
# Judge status: Accepted
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x: x[1])

time = 0
for i in range(N):
    time += AB[i][0]
    if time > AB[i][1]:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
b0 = B[0]
b1 = B[1]
for i in range(N):
    a = A[i]
    if a!=b0:
        print(b0)
    else:
        print(b1)
# Judge status: Wrong Answer
N = int(input())
p = list(map(int,input().split()))
num = list(range(1,N+1))
ans = 0
for i in range(N):
    if p[i] != num[i]:
        ans += 1
if ans == 2 or 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
D.sort()

print(D[int(N/2)] - D[int(N/2)-1])
# Judge status: Accepted
s = input()
k = int(input())

if k == 1 or len(s) == 1:
    ans = list(s)[0]
else:
    ans = None
    for i, j in enumerate(list(s)):
        if i < k-1:
            if j != '1':
                ans = j
                break
        elif i == k-1:
            ans = j           
            break
        else:
            continue
print(ans)
# Judge status: Accepted
N = int(input())
A = []
A = list(map(int,input().split()))

count = []
for i in range(len(A)+1):
    count.append(0)
for i in range(len(A)):
    count[A[i]-1] += 1

for i in count:
    print(i)
# Judge status: Wrong Answer
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
cnt=0
if a[0]>x:
    cnt += a[0] - x
    a[0]=x 
for i in range(N-1):
    cnt += a[i] + a[i+1] - x
    a[i+1]=x-a[i]
print(cnt)
# Judge status: Accepted
X=input()

if X in "357":
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
A,B = map(int,input().split())

alist = {1}
blist = {1}

for i in range(2,10**6+7):
    while A%i == 0:
        A = A//i
        alist.add(i)

for j in range(2,10**6+7):
    while B%j == 0:
        B = B//j
        blist.add(j) 

#print(alist,blist)

print(len(alist&blist))
# Judge status: Accepted
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())

ans = 0
for i in range(1,n+1):
    ans += (i+i*(n//i))*(n//i)//2
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=[0]*9
for i in a:
    x[min(i//400,8)]+=1
ans=0
for i in range(8):
    if x[i]>0:
        ans+=1
mini=max(1,ans)
maxe=ans+x[8]
print(mini,maxe)
# Judge status: Wrong Answer

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

if a <= 2*b:
    print(0)
else:
    print(a - 2*b)
# Judge status: Accepted
from itertools import product
n, m, x = map(int, input().split())
books = [[int(j) for j in input().split()] for i in range(n)]
min_cost = float('inf')
for bit in product([0, 1], repeat=n):
    cost = 0
    skill = [0] * m
    for i, b in enumerate(bit):
        if b == 1:
            cost += books[i][0]
            for j in range(m):
                skill[j] += books[i][j + 1]
    if x <= min(i for i in skill):
        min_cost = min(min_cost, cost)
print(min_cost if min_cost != float('inf') else -1)
# Judge status: Accepted
x = input().split()
H = int(x[0])
N = int(x[1])
A = input().split()
A = [int(l) for l in A]
T = "No"
for i in range(N):
    H = H - A[i]
    if H <= 0:
        T = "Yes"
        break
print(T)
# Judge status: Accepted
player = {}

player['a'] = list(input())
player['b'] = list(input())
player['c'] = list(input())
flag = 1
next_player = player['a'][0]
player['a'].pop(0)
while flag:
    if player[next_player]:
        before_player = next_player
        next_player = player[next_player][0]
        player[before_player].pop(0)
    else:
        print(next_player.upper())
        break
# Judge status: Accepted
a,b,k = map(int,input().split())
for i in range(a, min(a+k, b+1)):
  print(i)
for i in range(max(a+k, b-k+1), b+1):
  print(i)
# Judge status: Accepted
def actual(A, B, K):
    min_a = A
    max_a = min(A + (K - 1), B)

    min_b = max(B - (K - 1), max_a + 1)
    max_b = B

    left = list(range(min_a, max_a + 1))
    right = list(range(min_b, max_b + 1))

    return '\n'.join(map(str, sorted(set(left + right))))

  
A, B, K = map(int, input().split())
print(actual(A, B, K))
# Judge status: Wrong Answer
a = int(input())
s = input()
print("red" if a < 3200 else "s")
# Judge status: Wrong Answer
from scipy.special import comb
a, b = map(int, input().split())
 
def coun(x, y):
  a = comb(x, y, exact=True)
  return a
 
if(a+1== b):
  print(1)
else:
  count = 0
  for i in range(a-b+2):
    count += coun(a+1,i+b)
  print(count)
# Judge status: Accepted
k = int(input())
print(k//2 * (-(-k//2)))
# Judge status: Accepted
n = int(input())
cnt = 0
for i in range(1,n+1):
    if i*(1+i)//2 >= n:
        cnt = i
        break
for i in range(cnt, 0, -1):
    if i <= n:
        print(i)
        n -= i
# Judge status: Wrong Answer
m=list(map(int,input().split()))
a=m[0]
b=m[1]

high=0
low=0
if a==b:
    high=a
    low=b
elif a>b:
    high=a
else:
    low=b

temp=a+b
temp2=high+(high-1)

if temp>temp2:
    print(temp)
else:
    print(temp2)
# Judge status: Accepted
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
my_sum = np.sum(np.abs(A))
if np.count_nonzero(A < 0) % 2 == 0:
    print(my_sum)
else:
    print(my_sum - 2 * np.min(np.abs(A)))
# Judge status: Accepted
def main():
    N, K = map(int, input().split(" "))
    H = list(map(int, input().split(" ")))
    H.sort(reverse=True)
    print(sum(H[K:]))


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b = map(int, input().split())
grA = [1,3,5,7,8,10,12]
grB = [4,6,9,11]
grC = [2]
if (a in grA and b in grA) or (a in grB and b in grB):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
K = int(input())
ans = 1
tmp = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    for i in range(1,K):
        tmp += (10 ** i) * 7
        ans += 1
        if tmp % K == 0:
            print(ans)
            break
        else:
            continue
# Judge status: Accepted
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse = True)
temp = 1/(4*m)*(sum(a))
res = list(filter(lambda x:x<temp, a[:m]))
if len(res) == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
ans = 10**12
for i in range(1,int(n**0.5) + 1):
    if n % i == 0:
        ans = min(ans,i+(n//i)-2)
print(ans)
# Judge status: Wrong Answer
H, A = (int(x) for x in input().split())

if H%A==0:
  print(H/A)
else:
  print(int(H/A)+1)
# Judge status: Wrong Answer
N=int(input())
A=list(input().split())
L=[]
for a in A:
  L.append(int(a))
L.sort(reverse=True)
count=0
for i in range(N):
  for j in range(1,N):
    for k in range(2,N):
      if i<j and j<k:
        a=L[i]
        b=L[j]
        c=L[k]
        cos=((b**2)+(c**2)-(a**2))/(2*b*c)
        if -1<=cos<=1:
          count+=1
print(count)
# Judge status: Accepted
n = int(input())
print(n//2 + n%2)
# Judge status: Accepted
import bisect
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        idx = bisect.bisect_left(l, l[i]+l[j])
        ans += max(0, idx - 1 - j)        
#print(l)
#while i+2 < n:
#    if l[i] < l[i+1] + l[i+2]:
#        ans+=1
#        i+=3
#    else: i+=1
print(ans)
# Judge status: Wrong Answer
N = int(input())
s = input()

ans = 0
for n in range(N):
  if s[n]=="I":
    ans += 1
  else:
    ans -= 1
print(ans)
# Judge status: Wrong Answer
A,B = map(int,input().split())

if A >= 10 and B >= 10:
    print(-1)
else:
    print(A*B)
# Judge status: Accepted
K, S = map(int,input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        Z = S-X-Y
        if 0 <= Z <= K:
            ans += 1
print(ans)
# Judge status: Wrong Answer
n, h = map(int,input().split())
throw = []
attack = 0
for _ in range(n):
    a, b = map(int,input().split())
    throw.append(b)
    attack = max(attack, a)
throw.sort(reverse=True)

ans = 0
for t in throw:
    if t > attack:
        ans += 1
        h -= t
    else:
        break

ans += -(-h//attack)

print(ans)
# Judge status: Accepted
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

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

    num = 1
    cnt = 0
    while B > num:
        num -= 1
        num += A
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
N=int(input())
x=math.ceil(N/1.08)
X=math.floor((N+1)/1.08)
if math.floor(x) < math.floor(X):
  print(x)
else:
  print(":(")
# Judge status: Accepted
s=list(input())
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        p=i+1
        pnum=int(s[i])
        break
    p=101

if k<p:
    print(1)
else:
    print(pnum)
# Judge status: Accepted
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)
# Judge status: Accepted
n, m = map(int, input().split())
num = [1] * n
red = [False] * n
red[0] = True
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    if red[x]:
        red[y] = True
    num[x] -= 1
    num[y] += 1
    if num[x] == 0:
        red[x] = False
ans = 0
for r in red:
    ans += r
print(ans)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
num=a-b
if k%2==1:
    print((-1)*num)
else:
    print(num)
# Judge status: Accepted
N,M = map(int,input().split())
if 2*N >= M:
    ans = M//2
else:
    ans = N
    M = M - 2*N
    ans += M//4
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
H = list(map(int, input().split()))
links = [list(map(int, input().split())) for _ in range(M)]
survivors = [True for _ in range(N)]

for a, b in links:
  if H[a-1] <= H[b-1]:
    survivors[a-1] = False
  if H[b-1] <= H[a-1]:
    survivors[b-1] = False

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

digits = 0
tmp = N
while tmp != 0:
    tmp = tmp // 10
    digits += 1

if digits == 1:
    print(N)
if digits == 2:
    print(9)
if digits == 3:
    print(N-90)
if digits == 4:
    print(N-(90+(N-999)))
if digits == 5:
    print(N-90-9000)
if digits == 6:
    print(N-90-9000-1)
# Judge status: Accepted
N = int(input())

for i in range(1, 10)[::-1]:
    if N%i==0:
        break

print("Yes" if 1<=i<=9 and 1<=N//i<=9 else "No")
# Judge status: Accepted
import sys
from operator import itemgetter

n = int(input())
robots = []
for line in sys.stdin:
    X, L = map(int, line.split())
    l, r = X - L, X + L
    robots.append((l, r))
robots.sort(key=itemgetter(1))

curr = -(10 ** 10)
ans = 0
for l, r in robots:
    if curr > l:
        continue
    ans += 1
    curr = r
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
#ans = False
for dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
            for j in range(M):
                if A[i+dx][j+dy] != B[i][j]:
                    flg = False
        if flg:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
from collections import Counter

s = Counter(input())
t = Counter(input())

sv = sorted(s.values())
tv = sorted(t.values())

if sv == tv:
    print("Yes")
    exit()

print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

li=[]
for i in a:
  li+=[i-1,i,i+1]

from collections import Counter
c=Counter(li)
print(c.most_common()[0][1])
# Judge status: Accepted
N = int(input())
INF = 10 ** 9
dp =  [INF] * (N + 1)
dp[0] = 0
for i in range(N):
    dp_i = dp[i]
    x = 1
    while N >= i + x:
        if dp[i+x] > dp_i + 1:
            dp[i+x] = dp_i + 1
        x *= 6
    x = 1
    while N >= i + x:
        if dp[i+x] > dp_i + 1:
            dp[i+x] = dp_i + 1
        x *= 9
print(dp[N])
# Judge status: Accepted
n = int(input())
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
count = 0
for i in range(n):
  count += min(la[i],lb[i])
  if la[i]<lb[i]:
    if la[i+1] >= lb[i]-la[i]:
      count+=(lb[i]-la[i])
      la[i+1]-=(lb[i]-la[i])
    else:
      count+=la[i+1]
      la[i+1]=0
print(count)
# Judge status: Accepted
# ABC135

N = int(input())
P = list(map(int, input().split()))
sorted_P = sorted(P)
cnt = 0
for i in range(len(P)):
    if P[i] != sorted_P[i]:
        cnt += 1

    if cnt > 2:
        print("NO")
        exit()
print("YES")
# Judge status: Accepted
def main():
    s = input()
    rem = [0] * 2019  # the count of the each remainder: 0 ~ 2018
    rem[0] = 1  # why? can't understand.

    temp = 0
    digit = 1
    for c in s[::-1]:
        # No time to pow.
        temp += int(c) * digit
        rem[temp % 2019] += 1
        digit *= 10
        digit %= 2019

    return sum(c * (c - 1) // 2 for c in rem)


if __name__ == '__main__':
    print(main())
# Judge status: Accepted
import sys
import math
input = sys.stdin.readline
n=int(input())
print(math.ceil(n/2))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:


    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)
# Judge status: Accepted
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    a=int(readline())
    ss=readline().rstrip()
    if a<3200:
        ss="red"
    print(ss)
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
# Judge status: Wrong Answer
N,D=map(int,input().split())
print(N//(D*2+1)+1)
# Judge status: Accepted
print("YES" if (int(input().replace(" ", "")) % 4) == 0 else "NO")
# Judge status: Wrong Answer
S = input()
if set(S) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from math import floor
a, b, n = [int(x) for x in input().split()]
x = min(b - 1, n)
answer = floor(a * x / b) - a * floor(x / b)
print(answer)
# Judge status: Accepted
right = input()
Q = int(input())
flag = 1
left = ""
for i in range(Q):
  q = input()
  if q == "1":
    flag = 1-flag
    continue
  m,f,c = q.split(" ")
  f = int(f)
  left += c*(1-flag)*(f-1)
  right += c*flag*(f-1)
  left += c*flag*(2-f)
  right += c*(1-flag)*(2-f)
if flag == 1:
  print(left[::-1]+right)
else:
  print(right[::-1]+left)
# Judge status: Accepted
import math

a=input()
b=input()

if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
A = list(map(int,input().split()))
A = sorted(A)
cnt = 0

if A[1]-A[0]>=2:
  cnt += (A[1]-A[0])//2
  A[0]+= cnt*2

#print(A)

while(True):
  cnt+=1
  A = sorted(A)
  A[0]+=1
  A[1]+=1

  if A[0]==A[1]==A[2]:
    break

print(cnt)
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

	if N==1 and A!=B:
		res = 0
	elif A>B:
		res = 0
	else:
		#res = ((N-1)*B+A)-((N-1)*A+B)+1
		res = (N-2)*(B-A) + 1
	
	print(res)
	
main()
# Judge status: Accepted
N, X, T = map(int, input().split())

if(N % X == 0):
    ans = T * int(N/X)
else:
    ans = T * (int(N/X) + 1)

print(ans)
# Judge status: Accepted
x = int(input())
n = -(-x//11)
print(2*n-1 if 0<x%11<7 else 2*n)
# Judge status: Accepted
n, m, x = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(n)]
ans = 193934993409409
for mask in range(2 ** n):
    C = [0] * m
    cst = 0
    for i in range(n):
        if (mask >> i) & 1:
            cst += X[i][0]
            for j in range(1, m + 1):
                C[j - 1] += X[i][j]
    if min(C) >= x:
        ans = min(ans, cst)
if ans < 91912922191:
    print(ans)
else:
    print(-1)