peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import math
a, b, h, m = map(int, input().split())
# 角度を求める
H = 30 * h + (m/2)
M = 6 * m
theta = abs(H-M)
if theta == 0 or theta == 360:
  print(abs(a-b))
  exit()
if theta > 180:
  theta = theta - 180
#print(a, b, H, M, theta, math.sin(theta), math.cos(theta), math.tan(theta), math.sin(math.radians(theta)), math.cos(math.radians(theta)), math.tan(math.radians(theta)))
l = a * a + b * b - 2 *a*b* math.cos(math.radians(theta))
print(math.sqrt(round(l,9)))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
sum_a = sum(a)
ans = 0

for i in a:
    sum_a -= i
    ans += i * sum_a
    ans %= 10**9 + 7
    
print(ans)
# Judge status: Accepted
ans=''
s=input()
for i in s:
    if i=='B':
        ans=ans[:-1]
    else :
        ans+=i
print(ans)
# Judge status: Accepted
N, K = list(map(int,input().split()))
r, s, p = list(map(int,input().split()))
T = input()

ans = 0

def sc(st):
    if st == "p":  return s
    elif st == "r":  return p
    return r

for i in range(K):
    pre = T[i]
    cnt = i
    ans += sc(T[i])
    while(1):
        cnt += K
        if cnt >= N: break 
        if T[cnt] == pre:  pre = "#"
        else:  
            ans += sc(T[cnt])
            pre = T[cnt]
print(ans)
# Judge status: Wrong Answer
n ,x, y = map(int, input().split())

sub_degree = [0]*n
for i in range(1,n):
    for j in range(i+1, n+1):
        a = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))+1
        sub_degree[a]+=1

for i in range(n-1):
    print(sub_degree[i])
# Judge status: Accepted
l = list(map(int,input().split()))
s = l[0]%l[1]
if abs(s-l[1])<s:
    print(abs(s-l[1]))
else:
    print(s)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
remain = A[0]
power = 0
ans = 0
for i in range(n):
    if remain < B[i]:
        power = B[i] - remain
        ans += remain
        if A[i + 1] > power:
            ans += power
            remain = A[i + 1] - power
        else:
            ans += A[i + 1]
            remain = 0
    else:
        power = 0
        ans += B[i]
        remain = A[i + 1]
print(ans)
# Judge status: Accepted
x, n = map(int, input().split())
s = list(map(int, input().split()))

for i in range(n//2 +2):
    if x-i not in s:
        print(x-i)
        exit(0)
    if x+i not in s:
        print(x+i)
        exit(0)
# Judge status: Accepted
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    W = input()

    c = collections.Counter(W)
    for key in c.keys():
        if c[key] % 2 != 0:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
num = [x for x in input()]
ans = 0
if num[0] == num[1]:
  ans = ans + 1
if num[0] == num[2]:
  ans = ans + 1
if num[1] == num[2]:
  ans = ans + 1

if ans == 1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())

cnt = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0
else:
    print("No")
# Judge status: Wrong Answer
a=input()
import string
list1=list(string.ascii_lowercase)
if a in list1 == 'true':
  print('a')
else:
  print('A')
# Judge status: Wrong Answer
X, Y = map(int, input().split())
print(X+Y/2)
# Judge status: Wrong Answer
n = int(input())

# 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...
# 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, ...

# 開始位置を用意
A = [0] * (n + 1)
A[1] = 1
for i in range(1, n):
    A[i + 1] = A[i] + i

from bisect import bisect_left
idx = bisect_left(A, n)

for i in range(1, idx):
    if i == idx - 1 - (n - A[idx - 1] + 1): continue
    print(i)
# Judge status: Wrong Answer
s=input()
for bit in range(1<<3):
  ans=int(s[0])
  f=s[0]
  for i in range(3):
    if bit & (1<<i):
      ans+=int(s[i+1])
      f+="+s[i+1]"
    else:
      ans-=int(s[i+1])
      f+="-s[i+1]"
  if ans==7:
    print(f+"=7")
    exit()
# Judge status: Wrong Answer
S = list(input())
if list(set(S)) == ["A","B","C"]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys

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

if 0 in a:
    print(0)
    sys.exit()

hg = 10 ** 18
ans = 1
for i in a:
    ans *= i
    if ans > hg:
        print(-1)
        sys.exit()

print(ans)
# Judge status: Wrong Answer
A,B = map(int,input().split())
print(B//A if B%A==0 else (B//A)+1)
# Judge status: Wrong Answer
O = input()
E = input()
P = ''
for i in range(min(len(O),len(E))) :
    P = P + O[i]
    P = P + E[i]
print(P)
# Judge status: Accepted
vowel = ("a", "i", "u", "e", "o")

input_str = input()

if input_str in vowel:
  print("vowel")
else:
  print("consonant")
# Judge status: Accepted
N = int(input())
chk = [0] * (10 ** 4 + 2)
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            a = i**2 + j**2 + k**2 + i*j + j*k + i*k
            if a > 10001:
                break
            chk[a] += 1
for i in range(N):
    print(chk[i+1])
# Judge status: Accepted
import sys
input = sys.stdin.readline

n=int(input())
L=list(map(int,input().split()))
MIN = 1<<30
ans = 0
for i in L:
    MIN = min(MIN,i)
    if i<=MIN:
        ans+=1
print(ans)
# Judge status: Accepted
N=int(input())
s=list(map(int,input().split()))
s_max=max(s)
s_min=min(s)
A=[]
for i in range(s_min,s_max+1):
  b=0
  for j in s:
    b+=(j-i)**2
  A.append(b)
print(min(A))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

summ = 0
ans = 0
for i in range(1, n):
    summ += a[-i]
    ans += a[-(i + 1)] * summ
    ans %= MOD

print(ans % MOD)
# Judge status: Wrong Answer
N=int(input())
*P,=map(int, input().split())
ans=0
for i in range(N-1):
    if P[i]==i+1:
        P[i],P[i+1]=P[i+1],P[i]
        ans+=1
print(ans)
# Judge status: Wrong Answer
s = list(input())
if set(s) == 3:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s,w = map(int,input().split())
print("safe") if s>=w else print("unsafe")
# Judge status: Wrong Answer
import math
x = int(input())
if x == 6:
  x -= 1  
print(math.ceil(x/5.5))
# Judge status: Accepted
s = input()

for i in range(len(s)):
    if s[i]=='A':
        left = i
        break
for i in range(len(s)):
    if s[-i-1]=='Z':
        right = len(s)-i
        break
print(right-left)
# 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())

f = True
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:
        f = False
    if dist%2 != dt%2:
        f = False

print('Yes' if f else 'No')
# Judge status: Accepted
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
ans=1
c=l[0][0]+l[0][1]
for i in range(1,n):
    if c>=l[i][0]+l[i][1]:
        c=l[i][0]+l[i][1]
    elif c<=l[i][0]-l[i][1]:
        c=l[i][0]+l[i][1]
        ans+=1
print(ans)
# Judge status: Wrong Answer
S = input()
flg = False
if len(S) < 2:
  print('No')
else:
  for i in range(len(S)-1):
    if S[i:i+2] == 'hi':
      print('Yes')
      flg = True
      break
  if not flg:
    print('No')
# Judge status: Wrong Answer
import sys
import math

def permutations_count(n, r):
  ret = 0
  for i in range(r):
    ret += (n-i)
  return ret
  
N = int(input())
#print(N)
if N == 1:
  print(1)
  sys.exit()
elif N == 2:
  print(2)
  sys.exit()

r = N - 2

ret = permutations_count(N, r) + 2
print(ret)
# Judge status: Wrong Answer
n = int(input())

if n//2 == 0:
    print((n//2)/n)
else:
    print((n//2+1)/n)
# Judge status: Wrong Answer
from itertools import permutations
import math

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

np = int(''.join(P))
nq = int(''.join(Q))

lst = []
lstn = ['1', '2', '3', '4', '5', '6', '7', '8']

for i in permutations(lstn[:N]):
    lst.append(int(''.join(i)))
lst.sort()

for i in range(1, math.factorial(N)):
    if lst[i] == np: np = i
    if lst[i] == nq: nq = i

print(abs(np - nq))
# Judge status: Accepted
N = int(input())
min = 100000000000000
for i in range(1, N):
  A = str(i)
  B = str(N - i)
  ref = 0
  for a in A:
    ref += int(a)
  for b in B:
    ref += int(b)
  if ref < min:
    min = ref
print(min)
# Judge status: Accepted
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n, l = map(int, input().split())
s = [input().strip() for _ in range(n)]
s.sort()
print(''.join(s))
# Judge status: Accepted
from collections import deque

S = input()
Q = int(input())

ANS = deque(S)

rev = 0

for _ in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        rev = rev ^ 1
    else:
        f, c = int(query[1]), query[2]
        if (f - 1) ^ rev:
            ANS.append(c)
        else:
            ANS.appendleft(c)

if rev:
    ANS.reverse()

print(''.join(ANS))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(60):
  X=1<<i
  n=len([1 for a in A if a&X])
  ans+=X*n*(N-n)%mod
  ans%=mod
print(ans)
# Judge status: Wrong Answer
# Hello World program in Python
from collections import Counter as cn

d = int (input())
l = []
for k in range(d):
  d = input()
  p = cn(d)
  l.append(p)

oi = l[0]

for g in range(len(l)):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
st = []
res = [0] * N
for _ in range(N):
  a, b = map(int, input().split())
  st.append((a, b))
cp = []
for _ in range(M):
  a, b = map(int, input().split())
  cp.append((a, b))
for i in range(N):
  a, b = st[i]
  for j in range(M):
    c, d = cp[j]
    x, y = cp[res[i]]
    if abs(c - a) + abs(d - b) < abs(x - a) + abs(y - b):
      res[i] = j
  res[i] += 1
for r in res: print(r)
# Judge status: Accepted
import fractions

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

gcd = 0

for x in range(N):
    gcd = fractions.gcd(abs(a[x] - X), gcd)
print(gcd)
# Judge status: Wrong Answer
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
point = []
u = []
for i in range(n):
    a,b = mp()
    point.append((a,b))
    u.append(a+b)
print(max(u)-min(u))
# Judge status: Accepted
N = int(input())
print(int(N**0.5)**2)
# Judge status: Accepted
L, R = map(int, input().split())

import sys
minimum = sys.maxsize
for i in range(L, min(L + 2019, R)):
  for j in range(i+1, min(i + 1 + 2019, R+1)):
    minimum = min(minimum, i * j % 2019)
print(minimum)
# Judge status: Accepted
N = int(input())
S = []
L = []
for i in range(N):
  s = str(input())
  S.append(s)
M = int(input())
for i in range(M):
  l = str(input())
  L.append(l)
Ans = 0
for i in range(N):
  a = S[i]
  A = S.count(a)-L.count(a)  
  if A > Ans:
    Ans = A
print(Ans)
# Judge status: Wrong Answer
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
g1 = a[0]
g2 = a[0] // 2
for i in range(n):
    g1 = lcm(g1, a[i])
    if g1 > m:
        break
for i in range(n):
    g2 = lcm(g2, a[i] // 2)
    if g2 > m:
        break
print(m // g2 - m // g1)
# Judge status: Accepted
a,b,c=sorted(list(map(int,input().split())),reverse=True)
print(10*a+b+c)
# Judge status: Wrong Answer
d, n = map(int, input().split())
count = 0
i = 1
if d==0:
    print(5)
    exit()
while True:
    if i%100*d==0 and i//(100**d) < 100**d:
        count += 1
    if count == n:
        print(i)
        break
    i += 1
# Judge status: Accepted
abc = list(map(int, input().split()))
abc.sort()

bc = abc[2] - abc[1]
ab = abc[1] - abc[0]

print(bc + ab//2 if ab%2==0 else bc + ab//2 + 2)
# Judge status: Wrong Answer
s = input()
even, odd = [], []
for i in range(len(s)):
    if i%2:
        odd.append(s[i])
    else:
        even.append(s[i])
e = list(set(odd))
o = list(set(even))
print('o: ',o,'e: ',e)
if('L' in o or 'R' in e):
    print('No')
else:
    print('Yes')
# Judge status: Accepted
n, k = map(int, input().split())

ans = 0

for i in range(1, n+1):
    m = i
    cnt = 0
    for j in range(1, 101):
        if m >= k:
            break
        else:
            m = m * 2
            cnt += 1
    ans += (1 / n) * (0.5**cnt)

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

h_i = input().split()
h_i = [int(N) for N in h_i]
h_i.sort()
if N < K:
    print("0")
else :
    newh_i = h_i[0:N-K]
    print(sum(newh_i))
# Judge status: Accepted
from sys import stdin
input = stdin.readline

s = int(input())
mod = 1000000007
cnt = 0

a = [[1] for _ in range(2001)]
a[0].append(0)

for x in range(1, 2001):
    for y in range(1, x):
        a[x].append(a[x - 1][y - 1] + a[x - 1][y])
    a[x].append(1)

for x in range(1, 2001):
    s -= 3

    if s < 0:
        break

    cnt += a[s + x - 1][s]
    cnt %= mod

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

left = 0 
right = N
while left < N and S[left] == '.':
    left += 1
while right > 0 and S[right - 1] == '#':
    right -= 1

cb = 0
cw = 0
for c in S[left:right]:
    if c == '#':
        cb += 1
    else:
        cw += 1
print(min(cb, cw))
# Judge status: Accepted
x = int(input())
print((x // 500)*1000 + ((x%500)//5)*5)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
if rule1 and rule2:
  ans = True

text = "Yes" if ans else "No"
print(text)
# Judge status: Accepted
s = input()

vowel_list = ['a', 'i', 'u', 'e', 'o']

if s in vowel_list:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
a,b,c,d = input()

for i in range(2**3):
    op = ["+","+","+"]
    for j in range(3):
        if ((i>>j)&1) == 1:
            op[j] = "-"
    ans = eval(a + op[0] + b + op[1] + c + op[2] +d)
    if ans == 7 :
        print("{}{}{}{}{}{}{}={}".format(a,op[0],b,op[1],c,op[2],d,ans))
        break
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))

A.append(0)

for j in range(min(50,K)):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n*m-2*(n+m-2) if n > 1 and m > 1 else n*m-2)
# Judge status: Accepted
# AGC 017: A – Biscuits
N, P = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]

isAllEven = True

for k in A:
    if k % 2 == 1:
        isAllEven = False
        break

if isAllEven:
    if P == 0:
        print(2 ** N)
    else:
        print(0)
else:
    print(2 ** (N -1))
# Judge status: Accepted
a,b = map(int, input().split())

if (a+b)%2==0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
print(a*(a-1)//2)
# Judge status: Wrong Answer
import math
K = int(input())
res = sum([math.gcd(math.gcd(a, 1), c) for a in range(1,K+1) for b in range(1,K+1) for c in range(1,K+1)])
print(res)
# Judge status: Wrong Answer
s = input()

ans = 0
for l in range (len(s)-1):
  for r in range(l+1, len(s)+1):
    cnt = 0
    for str in s[l:r+1]:
      if str not in ['A','C','G','T']:
        cnt = 0 
        break
      else:
        cnt += 1
    ans = max(ans, cnt)
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
a,b=b,a
a,c=c,a
print(a,b,c)
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = 0
ans += (n//(a + b)) * a
m = n%(a + b)
if m >= a:
    ans += a
else:
    ans += m
print(ans)
# Judge status: Accepted
def LI():
    return list(map(int, input().split()))


N, M = LI()
x = M//N
for i in range(x, 0, -1):
    if M % i != 0:
        continue
    ans = i
    break
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())

area = (a+b)*h/2

print('{:.0f}'.format(area))
# Judge status: Accepted
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
  if a[0][i] in b and a[1][i] in b and a[2][i] in b:
    print('Yes')
    exit()
  if a[i][0] in b and a[i][1] in b and a[i][2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    exit()
print('No')
# Judge status: Wrong Answer
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    print(ans)
    
elif x[0] < x[1]:
    ans = np.repeat(x[0],x[1])
    print(ans)
    
else:
    print(np.repeat(x[0],x[1]))
# Judge status: Accepted
S = input()
T = input()
flag=1
for i in range(len(S)):
    if S==T:
        flag=0
        print("Yes")
        break
    S = S[-1]+S[:-1]
    # print(S)
    
if flag==1:
    print("No")
# Judge status: Wrong Answer
arr=raw_input()
ans="No"
for i in range(len(arr)):
  if arr[i]==9:
    ans = "Yes"
  else:
    print ans
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=[0]*M;p=-1

for i in range(M):
  a,b=map(int,input().split())
  A[i]=a,b
A.sort(reverse=True,key=lambda x: x[1])
#print(A)
#print("Yes" if A[0][1]==N else "No")

if A[0][1]!=N:
  print("IMPOSSIBLE")
else:
  for i in range(1,M):
    if A[i][0]==1 and A[i][1]==A[0][0]:
      p=2
      #print(1,A[i][0],A[i][1],A[0][0],p)

  if p==2:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**7)
L = []
def lunlun(x, cnt, c):
  if cnt == 10:
    L.append(int(x))
    return
  e = int(x[-1])
  if c:
    for i in range(max(e-1, 0), min(e+2, 10)):
      lunlun(x+str(i), cnt+1, 1)
  else:
    lunlun(x+"0", cnt+1, 0)
    for i in range(1, 10):
      lunlun(x+str(i), cnt+1, 1)
lunlun("0", 1, 0)
for i in range(1, 10):
  lunlun(str(i), 1, 1)
L.sort()

k = int(input())
ans = L[k]
print(ans)
# Judge status: Wrong Answer
X, Y = map(int,input().split())

if (X+Y)%3 != 0:
    print(0)
    exit()

n = int((2*Y-X)/3)
m = int((2*X-Y)/3)

mod = 10**9+7


def comb(n, r, mod):
    x=y=1
    for i in range(r):
        x *= n; y *= r
        x %= mod; y %= mod
        n -= 1; r -= 1
    return x * pow(y, mod - 2, mod) % mod

print(comb(n+m, n, mod))
# Judge status: Accepted
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
c = 0
ans = 0

for i in range(N):
    if c + a[i] <= x:
        c += a[i]
        ans += 1
    else:
        print(ans)
        exit()

if c == x:
    print(N)
else:
    print(N-1)
# Judge status: Accepted
inf = 10 ** 15
mod = 10 ** 9 + 7

n = int(input())
tmp = 0
flag = False
while tmp <= n:
    if (n-tmp) % 7 == 0:
        flag = True
    tmp+=4
if flag:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

r = p[:x] + q[:y] + r
r.sort(reverse=True)
r = r[:x+y]

print(sum(r))
# Judge status: Accepted
n=int(input())
s=[]
ans=0
for i in range(n):
    x=int(input())
    ans+=x
    if x%10!=0:s.append(x)
s=sorted(s)
if ans%10==0:
    if len(s)>=1:
        print(ans-s[0])
    else:
        print(0)
else:
    print(ans)
# Judge status: Wrong Answer
N = int(input())
A = []
B = []
for i in range(N):
    a,b = list(map(int,input().split()))
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2==1:
    print(B[(N-1)//2] - A[(N-1)//2]+1)
else:
    b1 = B[(N-2)//2]
    b2 = B[N//2]
    a1 = A[(N-2)//2]
    a2 = A[N//2]
    print(a2 + b2 - (a1 + b1) + 1)
# Judge status: Accepted
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 0
on_bus = 1
arr_time = t[0]
waiting_time = 0
for i in range(1,n):
    on_bus += 1
    waiting_time = t[i] - arr_time
    if on_bus > c or waiting_time >k:
        on_bus = 1
        arr_time = t[i]
        waiting_time = 0
        cnt += 1
print(cnt+1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
ans=0
for i in range(n):
    ans^=a[i]
for i in range(n):
    b[i]=ans^a[i]
print(*b)
# Judge status: Wrong Answer
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

P=N-K


if N-K>=0:
  print(K*X+(N-K)*Y)
else:
  print(K*X)
# Judge status: Accepted
# -*- coding: utf-8 -*-
# map(int, input().split())
mod = pow(10,9)+7
S = int(input())
if S <= 2:
    print(0)
    exit(0)

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

max_len = int(S/3)

ans = 0
for l in range(1,max_len+1):
    s = S-(l*3)
    ans = (ans+cmb(s+l-1,s))%mod

print(ans)
# Judge status: Accepted
def main():
    d = int(input())

    if d == 25:
        print("Christmas")
    elif d == 24:
        print("Christmas Eve")
    elif d == 23:
        print("Christmas Eve Eve")
    elif d == 22:
        print("Christmas Eve Eve Eve")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b, c, d, e, k = [int(input()) for i in range(6)]

print("Yay!" if (e - a < k) else ":(")
# Judge status: Accepted
X = str(input())
if X in "753":
  print("YES")
else:
  print("NO")
# Judge status: Accepted
S = input()
T = input()
s = len(S)
t = len(T)
A = []

for i in range(s-t+1):
  if all(S[i+j]==T[j] or S[i+j]=="?" for j in range(t)):
    A.append(S[:i]+T+S[i+t:])

A = [a.replace("?","a") for a in A]

if len(A)==0:
  print("UNRESTORABLE")
else:
  print(min(A))
# Judge status: Accepted
from collections import Counter

N = int(input())
al = list(map(int,input().split()))
C = Counter(al)

ans = 0
for i in C.keys():
    if i in C:
        if C[i] == i:
            continue
        elif C[i] > i:
            ans += C[i] - i
        else:
            ans += C[i]
print(ans)
# Judge status: Accepted
N = int(input())
L = sorted(list(map(int, input().split())))

import bisect

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += bisect.bisect_left(L, L[i]+L[j]) - (j+1)

print(ans)
# Judge status: Accepted
from fractions import gcd
import math

def lcm(l):
  x = l[0]
  for i in range(1, len(l)):
    x = (x * l[i]) // gcd(x, l[i])
  return x  

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N
cnt = [0]*N

for i in range(N):
  a = A[i]
  B[i] = a//2
  while a % 2 == 0:
    a /= 2
    cnt[i] += 1

cnt = set(cnt)
if len(cnt) != 1:
  print(0)
  exit()

x = lcm(B)
ans = 0

a = M//x
if a % 2:
  a += 1
print(a//2)
# Judge status: Wrong Answer
print(1)
print(2)
print(3)
print(4)
print(5)
print(6)
print(7)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
dic = {}
for i in range(n):
    dic.setdefault(a[i],0)
    dic[a[i]] += 1
ans = []
for item in dic.items():
    if item[1]>=2:
        ans.append(item[0])
if len(ans)<=1:
    print(0)
else:
    ans.sort()
    if dic[ans[-1]]>=4:
        print(ans[-1]**2)
    else:
        print(ans[-1]*ans[-2])
# Judge status: Accepted
from collections import deque
ls = deque()
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        ls.appendleft(a[i])
    else:
        ls.append(a[i])
if n%2 == 0:
    print(*reversed(ls))
else:
    print(*ls)