peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
n, *CSF = list(map(int, sys.stdin.buffer.read().split()))
C = CSF[::3]
S = CSF[1::3]
F = CSF[2::3]


def solve(x):
    cur = 0
    for i in range(x, n - 1):
        y = cur % F[i]
        if S[i] > cur:
            cur = S[i] + C[i]
        elif y == 0:
            cur += C[i]
        else:
            cur += (F[i] - y) + C[i]
    return cur


for i in range(n - 1):
    print(solve(i))
print(0)
# Judge status: Accepted
# B

n, d = map(int, input().split())
xy_l = [[int(x) for x in input().split()] for y in range(n)]

d2 = d ** 2
ans = 0
for i in range(n):
    if d2 >= (xy_l[i][0]**2 + xy_l[i][1]**2):
        ans += 1
        
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
    print ("0")
else:
    print (min(a*b,b*c,c*a))
# Judge status: Accepted
from collections import deque
import sys
input=sys.stdin.readline
s=deque([input().rstrip()])
q=int(input())
rev=0
for _ in range(q):
	qw=input().split()
	if qw[0]=="1":
		rev+=1
	else:
		f=qw[1]
		c=qw[2]
		if f=="1":
			if rev%2==0:
				s.appendleft(c)
			else:
				s.append(c)
		else:
			if rev%2==0:
				s.append(c)
			else:
				s.appendleft(c)
ans=""
for x in s:
	ans+=x
if rev%2==0:
	print(ans)
else:
	print(ans[::-1])
# Judge status: Accepted
L, R = map(int, input().split())

if R - L >= 2019:
    ans = 0
else:
    l, r = L % 2019, R % 2019
    ans = 2018 ** 2
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            x = (i*j) % 2019
            ans = min(ans, x)

print(ans)
# Judge status: Accepted
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    n = int(input())
    s = set()
    for i in range(n):
        t = input()
        s.add(t)
    print(len(s))
    return

if __name__ == "__main__":
    main()
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 16:49:00 2020

@author: matsui
"""



N,K=map(int,input().split())
h=[int(num) for num in input().split()]

dp=[0]*N
dp[1]=abs(h[0]-h[1])
   
def cost(h,N,K,dp):
    for i in range(2,N):
        dp[i]=min([abs(h[i]-h[j])+dp[j] for j in range(max(0, i-K), i)])
    return dp[-1]
    
print(cost(h,N,K,dp))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

ans=float('inf')
for a in A:
    aa=list(reversed(format(a,'b')))
    ai=aa.index('1')
    if ans>ai:
        ans=ai

print(ans)
# Judge status: Accepted
import sys

def solve():
    input = sys.stdin.readline
    A, B, C = map(int, input().split())
    print("Yes" if A <= C <= B else "No")
   
    
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
o=input()
e=input()
lo, le=len(o), len(e)
s=''
for i in range(le):
  s=s+o[i]+e[i]
if lo>le:
  s+=o[-1]
print(s)
# Judge status: Accepted
def solve(s):

  res=0

  for i in range(len(s)):
    if s[i]=="R":
      res+=1

    elif s[i]=="S" and res>0:
      return res
  return res
  
s=input()
print(solve(s))
# Judge status: Accepted
n,k=map(int,input().split())
f=set()
for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for i in a:
    f.add(i)
print(n-len(f))
# Judge status: Wrong Answer
x,a,b = map(int,input().split())

if (a+b) <= x:
    print('delicious')
elif (b-a) <= x:
    print('safe')
else:
    print('dangerous')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print('Yes' if 2*a+b*2-c>=0 else 'No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
answer = 0

for i in range(N-1):
    if A[i+1]==A[i]+1:
        answer += C[A[i]-1]

print(answer+sum(B))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>8 or b>8:
  print(":(")
else:
  print("Yey!")
# Judge status: Wrong Answer
n,m=map(int,input().split())
ans=n+(m-2*n)//4 if m-2*n>=0 else n
print(ans)
# Judge status: Accepted
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

x = ni()
tmp = 0
for i in range(1,10**9):
    tmp+=i
    if tmp>=x:
        break
print(i)
# Judge status: Accepted
S = input()

N = len(S)
ans = [0] * (N+1)

for i in range(N):
    if S[i] == '<':
        ans[i+1] = ans[i] + 1

for i in range(N-1, -1, -1):
    if S[i] == '>' and ans[i] <= ans[i+1]:
        ans[i] = ans[i+1]+1
print(sum(ans))
# Judge status: Wrong Answer
n,k = map(int,input().split())

count = 0

for i in range(n):
    a,b = map(int,input().split())
    count +=b
    if count >=k:
        print(a)
        break
    else:
        pass
# Judge status: Accepted
n,h=map(int,input().split())
a,b=[0]*n,[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
p=max(a)
b.sort(reverse=True)
ans=0
for i in range(n):
    if b[i]>=p:
        ans+=1
        h-=b[i]
        if h<=0:
            print(ans)
            exit()
x=(-h//p)*(-1)
ans+=x
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
ans,nokori=0,0
c=sorted(c.items(),reverse=True)
for k,v in c:
  cnt=min((v+nokori)//2,n)
  n-=cnt
  ans+=int(k)*cnt
  nokori=(v+nokori)%2
print(ans)
# Judge status: Accepted
N = int(input())
List = list(map(int,input().split()))
Q = int(input())

arr = [0 for i in range(10**5+1)]
S = 0

for i in range(N):
  a = List[i]
  arr[a] += 1
  S += int(a)
  
for i in range(Q):
  a,b = map(int,input().split())
  aa = arr[a]
  arr[b] += aa
  arr[a] = 0
  S += int ( (b-a) * aa )
  print(int(S))
# Judge status: Wrong Answer
n=int(input())
s=[]
for i in range(n):
    tmp=input().split()
    tmp[1]=100-int(tmp[1])
    s.append(tmp+[str(i+1)])
print(s)
s=sorted(s)
print(s)

for i in range(n):
    print(s[i][-1])
# Judge status: Accepted
import math
N = int(input())

ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        tmp = math.gcd(i, j)
        for k in range(1, N+1):
            ans += math.gcd(tmp, k)

print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
x1=int(a//0.08)+1
x2=int((a+1)//0.08)

y1=int(b//0.1)+1
y2=int((b+1)//0.1)

xx=[i for i in range(x1,x2)]
for z in xx:
    if z>=y1 and z<=y2:
        print(z)
        exit()
    
print(-1)
# Judge status: Wrong Answer
K = int(input())
X = 1

while K != 0:
  
  if X <= 9:
    K -= 1
    X += 1
    continue
  
  for i in range(len(str(X))-1):
    if int(str(X)[i+1]) - 1 <= int(str(X)[i]) <= int(str(X)[i+1]) + 1:
      K -= 1
      X += 1
    else:
      X += 1

print(X)
# Judge status: Wrong Answer
a, b, c = input().split(' ')

int(a)
int(b)
int(c)

if c >= a and c <= b:
    print ('Yes')
else:
    print ('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
pnt = 0
cnt = -2
for i in a:
  if i == cnt+1:
    pnt += c[cnt-1]
  pnt += b[i-1]
  cnt = i
print(pnt)
# Judge status: Accepted
n = int(input())
ans = 0
for x in range(1, n + 1, 2):
    d = 0
    for i in range(1, x + 1, 2):
        if x % i == 0:
            d += 1
    if d == 8:
        ans += 1
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)
th = s / (4*M)
cnt = 0

for a in A:
    if a > th:
        cnt += 1

if cnt < M:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N = int(input())
c1 = 0
c2 = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        c1 += 1
    else:
        c1 = 0
    if c1 == 3:
        c2 += 1
if c2 > 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
left, right = [0,], []
a, b = 0, 0

for i in range(len(s)):
    a = a+1 if s[i] == '<' else 0
    left.append(a)
    b = b+1 if s[-1*i] == '>' else 0
    right.append(b)

right.append(0)
right.reverse()
ans = sum(max(x, y) for x, y in zip(left, right))
print(ans)
# Judge status: Accepted
s = input()
n = len(s)

def dfs(i, f, sum_):
    if i == n-1:
        if sum_ == 7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1, f+'+'+s[i+1], sum_+int(s[i+1]))
        dfs(i+1, f+'-'+s[i+1], sum_-int(s[i+1]))
        
print(dfs(0, s[0], int(s[0])))
# Judge status: Wrong Answer
N=int(input())
if N%2==0:
  print((N/2)**2)
else:
  print((N//2)*(N//2+1))
# Judge status: Accepted
A, B, N = map(int, input().split())
ans = 0
x = min(B-1, N)
print((A*x)//B-A*(x//B))
# Judge status: Wrong Answer
import re
S=input().replace("?", ".")
T=input()
ans=""
moji = len(T)
for i in range(len(S)-len(T)+1):
  m = re.search(S[i:moji+i], T)
  if m is not None:
    ans = S[0:i] + T + S[i+moji-1:-1]
    ans = ans.replace(".", "a")

if ans:
  print(ans)
else:
  print("UNRESTORABLE")
# Judge status: Wrong Answer
def gcd(a,b):
	a,b=max(a,b),min(a,b)
	return a if b==0 else gcd(b,a%b)
def GCD(t):
	if len(t)==0:
		return 0
	l=t[0]
	r=t[-1]
	for i in range(1,len(t)//2):
		l=gcd(l,t[i])
		r=gcd(r,t[-i-1])
	return gcd(l,r)
n=int(input())
a=list(map(int,input().split()))
m=1
for i in range(n):
	t=a[:i]+a[i+1:]
	m=max(GCD(t),m)
print(m)
# Judge status: Accepted
s=input()

if s<="2019/04/30":
  print("Heisei")
else:
  print("TBD")
# Judge status: Accepted
H,A = map(int,input().split())
 
i = 1
while (A*i < H):
    i = i+1

print(i)
# Judge status: Accepted
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]
r=[]
for i in ab:
  x1,y1=i[0],i[1]
  temp=[]
  for j in cd:
    x2,y2=j[0],j[1]
    temp.append(abs(x1-x2)+abs(y1-y2))
  r.append(temp.index(min(temp))+1)
print(*r,sep='\n')
# Judge status: Accepted
D=input()
D=int(D)

if D==25:
  print("Christmas")
if D==24:
  print("Christmas Eve")
if D==23:
  print("Christmas Eve Eve")
if D==22:
  print("Christmas Eve Eve Eve")
# Judge status: Accepted
a,b=map(int,input().split())
print((a+b)%24)
# Judge status: Accepted
S = input()

N=len(S)
flag=1

for i in range(N):
  if i%2==0 and S[i]=='L':
    flag=0
  elif i%2==1 and S[i]=='R':
    flag=0

print('Yes' if flag==1 else 'No')
# Judge status: Wrong Answer
N, C, K = map(int, input().split())
T = [0] * N
for i in range(N):
  T[i] = int(input())
T = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  elif len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  else:
    waiting.append(t)
else:
  ans += 1
print(ans)
# Judge status: Wrong Answer
A,N=map(int, input().split())
print(N*10^A)
# Judge status: Wrong Answer
n, r = map(int, input().split())

if n >= 10:
  print(r)
else:
  print(r - 100 * (10-n))
# Judge status: Accepted
import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, x = na()
if 500 * k >= x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())
print(0 if b+c <=a else b+c-a)
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
while n > 1:
    n -= m - 1
    ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
lb = 0
rw = sum([s == "." for s in S])
ans = rw

for s in S:
  if s == ".":
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw+lb)
print(ans)
# Judge status: Wrong Answer
X, N = map(int, input().split())

if N > 0:
    p = set(map(int, input().split()))
else:
    print(X)
    exit()

if X not in p:
    print(X)
    exit()

for i in range(1,50):
    if X-i not in p:
        print(X-i)
        exit()
    elif X+i not in p:
        print(X+i)
        exit()

print(X)
# Judge status: Accepted
a,b,k=map(int,input().split())
x=[]
y=[]
if b-a<k:
    k=b-a+1
for i in range(a,a+k):
    x.append(i)
for i in range(b-k+1,b+1):
    x.append(i)
x=list(set(x))
x.sort()
for i in range(len(x)):
    print(x[i])
# Judge status: Wrong Answer
l=list(map(int,input().split()))
k=int(input())
print(max(l)*2*k+sum(l)-max(l))
# Judge status: Accepted
n=int(input())
print(((n-1)//111+1)*111)
# Judge status: Accepted
s = list(input())
q = int(input())
judge = 1
front = []
back = []
for i in range(q):
  a = list(map(str,input().split()))
  if int(a[0]) == 1:
    judge *= -1
  else:   
    if (int(a[1]) == 1 and judge == 1) or (int(a[1]) == 2 and judge == -1):
      front.append(a[2])
    else:
      back.append(a[2])
ans = front[::-1] + s + back
if judge == -1:
  ans.reverse()
print(*ans, sep='')
# Judge status: Accepted
X,K,D=map(int,input().split())

N=abs(X)//D
if N>=K:
    ans=abs(X)-D*K
    print(ans)
else:
    M=K-N
    if M%2==0:
        ans=abs(X)-D*N
    else:
        ans=D*(N+1)-abs(X)
    print(ans)
# Judge status: Accepted
a = int(input())
if a < 1000:
  print('ABC')
else:
  print('ABD')
# Judge status: Accepted
a,b,c = map(int, input().split())
if (b - a) == (c - b):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
def main():
    a, b, k = map(int, input().split())
    count = 0
    for i in range(max(a, b), 0, -1):
        if a % i == 0 and b % i == 0:
            count += 1
        if count == k:
            print(i)
            return


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
S = list(input())
ans = 0+S.count("E")
now = S[0]
e = ans
w = 0
for i in range(1,N):
    if now == "W":
        w += 1
    now = S[i]
    if now == "E":
        e -= 1
    if w+e < ans:
        ans = w+e
print(ans)
# Judge status: Accepted
N = int(input())
a = [0]
a.extend(list(map(int, input().split())))
b = [0 for _ in range(N+1)]

for i in reversed(range(1, N+1)):
    total = 0
    for j in range(i+i, N+1, i):
        total ^= b[j]
    b[i] = total ^ a[i]

ans_n = 0
ans_l = []
for i in range(N+1):
    if b[i]:
        ans_n += 1
        ans_l.append(str(i))

print(ans_n)
print(' '.join(ans_l))
# Judge status: Wrong Answer
from math import sqrt
x = int(input())
cnt = 0
l = []
for i in range(1, x + 1):
    for j in range(1, int(sqrt(i)) +1):
        for k in range(2, max(2, j) + 1):
            if j ** k == i:
                l.append(i)
print(max(l))
# Judge status: Accepted
s, w = map(int, input().split())

if s <= w:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
def f(x):
  return sum([(i-1)//x for i in a])<=k

def main():
  l,r=0,10**9
  while r-l>1:
    m=(l+r)//2
    if f(m): r=m;
    else: l=m;
  print(r)

if __name__=='__main__':
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  main()
# Judge status: Wrong Answer
a,b = map(int,input().split())
num = a * b
mod = num % 2

if mod == 0:
  print("Even")
else:
  print("0dd")
# Judge status: Accepted
s = input()

i = 0
ans = 0
while i < len(s)-1:
    # print(i, s[i], s[i+1], ans)
    if s[i] != s[i+1]:
        i += 1
        ans += 1
    else:
        if i == len(s)-2:
            i += 3
            ans += 1
        else:
            i += 3
            ans += 2
if i == len(s)-1:
    ans += 1
print(ans)
# Judge status: Accepted
def check(X):
    for i in range(len(X)):
        if X[i] % 2 != 0:
            return False
        X[i] /= 2
    return True

N = int(input())
A = list(map(int, input().split()))
ans = 0
while check(A):
    ans += 1
print(ans)
# Judge status: Accepted
import itertools
N = int(input())
xy_list = [list(map(int, input().split())) for _ in range(N)]

ans = 0
num = 0
for xy in itertools.permutations(xy_list):
    ans_pre = 0
    for i in range(N-1):
        ans_pre += ((xy[i][0]-xy[i+1][0])**2 + (xy[i][1]-xy[i+1][1])**2)**(0.5)
    num += 1
    ans += ans_pre
print(ans/num)
# Judge status: Wrong Answer
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    if N%(A+B)<=A:
        print(A*N//(A+B)+N%(A+B))
    else:
        print(A*N//(A+B)+A)
    
    
    
if __name__=="__main__":
    main()
# Judge status: Accepted
x = int(input())

if x >= 2000:
    print(1)
    exit()
    
for i in range(1, 20):
    if (100 * i <= x) and (x <= 105 * i):
        print(1)
        exit()
print(0)
# Judge status: Accepted
N, M = map(int, input().split())
print(N + (M - 2*N)//4 if N < M//2 else M // 2)
# Judge status: Accepted
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()

ok = True
if int(s[0:4]) > 2019:
    ok = False

if int(s[0:4]) == 2019 and int(s[5:7] + s[8:]) > 430:
    ok = False

if ok:
    print('Heisei')
else:
    print('TBD')
# Judge status: Accepted
s = input()
ans = 753

for i in range(len(s)-2):
    if abs(753-int(s[i:i+3])) < ans:
        ans = abs(753-int(s[i:i+3]))

print (ans)
# Judge status: Accepted
MM = input().split()
N = int(MM[0])
L = int(MM[1])
list1 = []
for i in range(N):
  a = input()
  list1.append(a)
list1.sort()
for i in list1:
  print(i,end='')
# Judge status: Accepted
A = list(map(int,input().split()))
A.sort()

print(A[2]*10 + A[0] + A[1])
# Judge status: Wrong Answer
A = int(input())
B = int(input())
L = A + B
print(5 - L)
# Judge status: Accepted
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")
# Judge status: Accepted
def main():
    N = int(input())
    S = input()
    
    ans = 0
    for i in range(1, N):
        X = set(S[:i])
        Y = set(S[i:])
        ans = max(ans, len(X & Y))
    print(ans)
main()
# Judge status: Accepted
n = int(input())
ten = 1
eight = 1
nine = 1
for i in range(n):
    ten *= 10
    ten = ten%(10**9 + 7)
    eight *= 8
    eight = eight%(10**9 + 7)
    nine *= 9
    nine = nine%(10**9 + 7)
print((ten+eight-(2*nine))%(10**9 + 7))
# Judge status: Accepted
a,b,c,k=map(int, input().split())
print(k if a>=k else a if a+b>k>a else 2*a+b-k)
# Judge status: Accepted
import sys
s = [int(n) for n in list(input())]

for i in range(3):
    if s[i] == s[i+1]:
        print('Bad')
        sys.exit(0)
print('Good')
# Judge status: Wrong Answer
s=list(input())
t=[int(a) for a in s]
n=int(len(t))
ans=0
b=0
list1=[]
s=1000
for i in range(n-2):
    u=[t[i],t[i+1],t[i+2]]
    v="".join(map(str, u))
    w=int(v)-753
    list1.append(w)
u=int(len(list1))
for i in range(u-1):
    if abs(list1[i])-abs(s)<0:
        s=list1[i]
    else :
        pass
print(abs(s))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0

for i in range(n):
    if a[i] < b[i]:
        cnt += (b[i] - a[i]) // 2
    else:
        cnt -= (a[i] - b[i])

print("Yes" if cnt >= 0 else "No")
# Judge status: Accepted
C = [list(map(int, input().split())) for _ in range(3)]

# a1=0と仮定すると、b1=C[0][0], b2=C[0][1], b3=C[0][2]
# a2=C[1][0]-b1=C[1][1]-b2=C[1][2]-b3
# a3=C[2][0]-b1=C[2][1]-b2=C[2][2]-b3

b1, b2, b3 = C[0][0], C[0][1], C[0][2]
if (C[1][0]-b1 == C[1][1]-b2 == C[1][2]-b3) and (C[2][0]-b1 == C[2][1]-b2 == C[2][2]-b3):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort()

n = 0
for i in range(N):
  if n + ab[i][1] < K:
    n += ab[i][1]
  else:
    print(ab[i][0])
    break
# Judge status: Accepted
a,b,t=map(int,input().split())
print(t//a*b)
# Judge status: Accepted
n=int(input())
v=sorted(list(map(int,input().split())))
s=v[0]
for i in range(1,n):
  s=(s+v[i])/2
print(s)
# Judge status: Wrong Answer
N = int(input())
S = input()

sp = N - 1
ans = 0
for i in range(1,(sp+1)//2+1):
    cnt = 0
    zenhan = list(set(S[:i]))
    kouhan = list(set(S[i:]))
    for j in zenhan:
        if kouhan.count(j) == 1:
            cnt += 1
    else:
        ans = max(ans,cnt)
print(ans)
# Judge status: Wrong Answer
l,r,d=map(int,input().split())
ans=0
for i in range(l,r+1):
    if i%d: ans+=1
print(ans)
# Judge status: Accepted
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
da = deque(sorted(a))
dans = deque()
dans.append(da.popleft())
for _ in range(1,n):
  if len(dans) == 0:
    dans.append(da.popleft())
  else:
    dlast = dans.pop()
    daleft = da.popleft()
    if dlast != daleft:
      dans.append(dlast)
      dans.append(daleft)
print(len(dans))
# Judge status: Accepted
#abc156 c
n=int(input())
x=list(map(int,input().split()))

s=min(x)
b=max(x)

ans=100100100

for i in range(s,b+1):
    hp=0
    for j in x:
        hp+=(i-j)**2
    if hp<ans:
        ans=hp
print(ans)
# Judge status: Accepted
k = int(input())
a,b = map(int, input().split())
if b//k * k >= a:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
print("Yes" if int(input())%500<=int(input()) else "No")
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())
print(max(min(C, D)-max(A, B), 0))
# Judge status: Accepted
import sys, math

if(__name__ == "__main__"):
    N, K = map(int, input().strip().split() )
    AList = list( map(int, input().strip().split() ) )

    
    """
    i = K+1 , K+2 ,..., N
    score[i] = i * i-1 * ...* (i-K+1)
    score[i]/score[i-1] = i / (i-K)
    """
    for i in range(K, N):
        if(AList[i] > AList[i-K]):
            print("Yes")
        else:
            print("No")
# Judge status: Accepted
A,B,C=list(map(int,input().split()))
print(min(B//A,C))
# Judge status: Accepted
s=input()
a=[chr(i) for i in range(ord("a"),ord("z")+1) if chr(i) not in s]
print("None" if len(a)==0 else a[0])
# Judge status: Accepted
N, M = map(int, input().split())
V = [[] for _ in range(N)]
ans = [0] * M

for i in range(M):
    p, y = map(int, input().split())
    V[p-1].append((y, i))

for i, v in enumerate(V, start=1):
    v.sort()
    for k, (y, j) in enumerate(v, start=1):
        ans[j] = format(str(i), "0>6") + format(str(k), "0>6")

for a in ans:
    print(a)
# Judge status: Accepted
n, k = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
h.sort()
# answer = min(h[k - 1] - h[0], h[-1] - h[-k])
# print(answer)
answer = float('inf')
for i in range(n - k + 1):
    cost = h[k - 1 + i] - h[i]
    # print(h[i:k+i])
    if answer > cost:
        answer = cost

print(answer)
# Judge status: Accepted
from collections import Counter

n = int(input())
S = input()
counts = Counter(S)
mod = int(1e9) + 7
ans = 1
for count in counts.values():
    ans *= (count + 1)
    ans %= mod
ans -= 1
print(ans)
# Judge status: Accepted
s = input()
print("2018"+s[4:])
# Judge status: Accepted
import math
n,h = map(int ,raw_input().split())
ais = [map(int, raw_input().split()) for _ in range(n)]
ais.sort(key = lambda x: (-x[1],x[0]))
cumul = 0
r = +float('inf')
m = max(ais)[0]
for i in range(-1,len(ais)):
	if i >= 0:
		cumul += ais[i][1]

	if cumul >= h:
		r = min(r, (i+1))
		break
	else:
		r = min(r, i+1 + math.ceil(abs(h - cumul) /  float(m)))
print int(r)
# Judge status: Wrong Answer
n = int(input())
l = []

for i in range(n):
    a, b = map(int, input().split())
    a %= b
    l.append([a, b])

ans = 0

for i in range(1, n)[::-1]:
    ans += (l[i][1] - l[i][0])  
    l[i-1][0] += ans
    l[i-1][0] %= l[i-1][1]

ans += (l[0][1] - l[0][0])

print(ans)
# Judge status: Accepted
c = input()

if c in "aiueo":
    print("vowel")
else :
    print("consonant")
# Judge status: Accepted
import numpy as np
import math

n,k = str(input()).split()
if int(n) == 0:
    print(1)
else:
    ans = np.log(int(n))/np.log(int(k))
    print(int(ans)+1)
# Judge status: Accepted
n, m = sorted(map(int, input().split()))
print(1 if n==m==1 else m-2 if n==1 else (n-2)*(m-2))
# Judge status: Accepted
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()

score = 0
back = 0

for fst in range(K):
  index = fst
  while True:
    ch = T[index]
    if ch != back:
      back = ch
      if ch == "r":
        score += P
      elif ch == "p":
        score += S
      else:
        score += R
    else:
        back = 0
    
    index += K
    if index >= N:
      break
  back = 0
  
print(score)
# 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 and x+y+z == s:
            ans += 1
print(ans)