peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))

B=[0]*(n+1)
C,cnt=[],0
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(i,n+1,i)])
    if sum_list%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)

print(cnt)
print(*C[::-1])
# Judge status: Wrong Answer
i = list(map(int, input().split()))
N = i[0]
K = i[1]
 
for i in range(1000000):
    if i == 0:
        min = abs(N-K)
    min = abs(min-K)
    if (min-K) < 0:
        break
if min > 5:
    print('0')
else:
    print(min)
# Judge status: Wrong Answer
N, A, B, C, D = map(int, input().split())
N-=1
A-=1
B-=1
C-=1
D-=1
S = input()

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
#C
N, K = map(int, input().split())
ans = N

if N <= abs(N-K):
    pass
else:
    for i in range(N+1):
        try:
            if ((N-i) / K).is_integer():
                ans = i
                break
            elif ((N+i) / K).is_integer():
                ans = i
                break
        except:
            break

print(ans)
# Judge status: Accepted
x, a, b = map(int,input().split())
if abs(a - x) < abs(b - x):
    print('A')
else:
    print('B')
# Judge status: Wrong Answer
N,M = map(int, input().split())
S = [list(map(int,input().split())) for _ in range(N)]
C = [list(map(int,input().split())) for _ in range(M)]

for a,b in S:
    distance = 10**10
    ans = 0
    for c,d in C:
        #print(abs(a - c) + abs(b - d))
        if abs(a - c) + abs(b - d) < distance:
            distance = abs(a - c) + abs(b - d)
            ans += 1
    print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
for i in range(n):
  if i==0:
    dp[i]=0
  elif i==1:
    dp[i]=abs(h[1]-h[0])
  else:
    for j in range(1,min(i,k)+1):
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])
# Judge status: Accepted
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
a=(t.count("r"))*p+(t.count("s"))*r+(t.count("p"))*s
for i in range(n-k):
    if t[i]==t[i+k]:
        if t[i]=="r":
            a-=p
        elif t[i]=="s":
            a-=r
        elif t[i]=="p":
            a-=s
        t[i+k]=i
print(a)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
l=sorted([a,b,c])
int(str(l[2])+str(l[1]))+l[0]
# Judge status: Wrong Answer
n = int(input())
a_list = list(map(int,input().split()))
dp = [[0] * 2 for _ in range(n-1)]
dp[0][0] = a_list[0] + a_list[1]
dp[0][1] = -1*(a_list[0] + a_list[1])

for i in range(1,n-1):
    dp[i][0] = max(dp[i-1][0] + a_list[i+1] , dp[i-1][1] + a_list[i+1])
    dp[i][1] = max(dp[i-1][0] - a_list[i+1] -2*a_list[i-1], dp[i-1][1] - a_list[i+1]+2*a_list[i-1])
    
print(max(dp[n-2][0] ,dp[n-2][1]))
# Judge status: Accepted
import math
A,B=map(int,input().split())

print(int(math.ceil((B-1)/(A-1))))
# Judge status: Wrong Answer
import math
a,b,h,m=map(int,input().split())
h=h*30+(m/60)*30
m=m*6
diff=abs(h-m)*((math.pi)/180)
if(diff>180):
    diff=diff-180
ans=a*a+b*b-2*a*b*abs(math.cos(diff))
print(math.sqrt(ans))
# Judge status: Accepted
from sys import stdin

def main():
    times = int(stdin.readline())
    results = []
    for x in range(times):
        results.append(stdin.readline())
    
    print(len(set(results)))


main()
# Judge status: Accepted
Q,H,S,D = map(int, input().split())
N = int(input())
if N >=2:
    if N%2 == 0:
        ans = N//2*min([8*Q,4*H,2*S,D])
    else:
        ans = (N-1)//2*min([8*Q,4*H,2*S,D]) + min([4*Q,2*H,S])
else:
    ans = min([4*Q,2*H,S])
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = 0
if a == b == c and a != 1:
  ans = -1
else:
  while a % 2 == b % 2 == c % 2 == 0:
    x = a // 2
    y = b // 2
    z = c // 2
    if x % 2 == y % 2 == z % 2:
      a = y + z
      b = z + x
      c = z + x
      ans += 1
    else:
      ans += 1
      break
print(ans)
# Judge status: Accepted
N, C, K = map(int, input().split())
T = [0 for _ in range(N)]
for __ in range(N):
    T[__] = int(input())
 
T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K
 
for ix in range(N):
 
    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1
 
    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 1
 
print(bus_count)
# Judge status: Accepted
s = input()

ans = min(s.count("0"), s.count("1"))*2
print(ans)
# Judge status: Accepted
import math
from decimal import Decimal
a,b,c = [int(x) for x in input().split()]

if (Decimal(a).sqrt() + Decimal(b).sqrt()) < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
ans = 1000000

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

print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
l=[[1,1],[2,11],[3,111],[4,1111],[5,11111],[6,111111],[7,1111111],[8,11111111],[9,111111111]]

c=0
d=0

for i in range(9):
    if l[i][0]==a:
        c=b*l[i][1]
    if l[i][0]==b:
        d=a*l[i][1]
print(min(c,d))
# Judge status: Wrong Answer
n,k = map(int,input().split())
d = input().split()
for i in range(n,10000):
    for j in range(k):
        for l in range(len(str(n))):
            if str(n)[l] == str(d)[j]:
                break
        else:
            continue
        break
    else:
        print(i)
        break
    n += 1
# Judge status: Accepted
n = int(input())
B = list(map(int,input().split()))
A = [0]*n
A[0] = B[0]
for i in range(1,n-1):
    if B[i-1] >= B[i]:
        A[i] = B[i]
    else:
        A[i] = B[i-1]
else:
    A[n-1] = B[n-2]
print(sum(A))
# Judge status: Accepted
import math

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

print(math.ceil( (a + b) / 2))
# Judge status: Accepted
A,B=map(int,input().split())
if max(A,B) <=8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
S = input()
Month = []
for i in range(1,13):
    if i < 10:
        Month.append("0" + str(i))
    else:
        Month.append(str(i))
YYMMpt = 0
MMYYpt = 0
if S[0:2] in Month:
    MMYYpt += 1
if S[2:4] in Month:
    YYMMpt += 1
if YYMMpt == 0 and MMYYpt == 0:
    print("NA")
elif YYMMpt == 0 and MMYYpt == 1:
    print("MMYY")
elif YYMMpt == 1 and MMYYpt == 0:
    print("YYMM")
else:
    print("AMBIGUOUS")
# Judge status: Accepted
s = list(input())
s.sort()
t = list(input())
t.sort()
t.reverse()
print('Yes' if s < t else 'No')
# Judge status: Accepted
n, a, b = map(int, input().split())
rest = n % (a + b)
block = (n // (a + b)) * a
if a <= rest:
    print(block + a)
else:
    print(block + rest)
# Judge status: Wrong Answer
import sys
n=int(input())
if n<=81:
  for i in range(1,10):
    if n%i!=0:
      print('No')
      sys.exit()
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

L = [A[0]]
for i in range(1, N):
  if A[i] != A[i - 1]:
    L.append(A[i])

N = len(L)

if N == 1:
  print(1)
  exit()

f = L[1] > L[0]
ans = 1

i = 2
while i < N:
  if (L[i] > L[i - 1]) != f:
    ans += 1
    if i == N - 1:
      break
    i += 1
    f = L[i] > L[i - 1]

  i += 1
 
print(ans)
# Judge status: Accepted
import sys
A,B,C,D = map(int,input().split())
if A < 0 or B < 0 or B <= A or A > 100 or B > 100:
    sys.exit()
if C < 0 or D < 0 or D <= C or C > 100 or D > 100:
    sys.exit()

count = 0
for I in range(A,B):
    for J in range(C,D):
        if I == J:
            count += 1
print(count)
# Judge status: Wrong Answer
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0]
a_i = getInput()
a_i.sort(reverse=True)
lst = [a_i[i] for i in range(len(a_i)-1) if i >= N and i < 2*N]

print(sum(lst))
# Judge status: Accepted
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353



N = int(input())

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

A = sorted(A, reverse=True)

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

print(ans)
# Judge status: Accepted
W,H,x,y = map(int,input().split())

if x == W/2 and y == H/2:
  res = 1
else:
  res = 0
  
print(W*H/2,res)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
from collections import deque
ans = deque([a[0]])
odd = True
for i in range(1,n):
    if odd:
        ans.appendleft(a[i])
        odd = False
    else:
        ans.append(a[i])
        odd = True
ans = list(ans)
for i in range(n):
    print(ans[i],end = ' ')
# Judge status: Accepted
n = int(input())
h_list = [int(x) for x in input().split()]

ans = "Yes"
h_pre = h_list[0]
for h in h_list:
    if h > h_pre:
        h -= 1
    elif h < h_pre:
        ans = "No"
        break
    h_pre = h
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
ans=""
for i in range(len(s)):
    tmp=ord(s[i])+n
    if tmp>90:
        tmp-=26
    ans+=chr(tmp)
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
if((N-1)%(K-1) == 0):
  print((N-1)//(K-1))
else:
  print((N-1)//(K-1) + 1)
# Judge status: Accepted
input();ans,a=1,[*map(int,input().split())]
if 0 in a:
  print(0)
else:
  for i in a:
    ans*=i
    if ans>10**18:
      print(-1);break
  else:
    print(ans)
# Judge status: Accepted
e = input()
set_e = set(e)
is_beautiful = 'Yes'
for i in set_e:
    if e.count(i)%2 == 1:
        is_beautiful = 'No'
        break
    else:
        pass
print(is_beautiful)
# Judge status: Wrong Answer
a=input()
if a[1::2] in ['R','U','D'] and a[2::2] in ['L','U','D']:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#!python3

iim = lambda: map(int, input().rstrip().split())

def NKS(N, K, S):
    M5 = 10**5
    M9 = 10**9

    for i in range(K):
        yield S

    tmp = S + 1 if S < M9 else 1
    for i in range(N-K):
        yield tmp

def resolve():
    N, K, S = iim()

    it = NKS(N, K, S)
    for i in range(N-1):
        print(next(it), end=" ")
    print(next(it))

if __name__ == "__main__":
    resolve()
# Judge status: Accepted
W, A, B = [int(i) for i in input().split()]

if B <= A <= B+W or B <= A+W <= B+W or A <= B <= A+W or A <= B+W <= A+W:
  print(0)
elif W + A <= B:
  print(B - (W + A))
else:
  print(A - (B + W))
# Judge status: Accepted
num = int(input())
input_num = input()
num_list = [int(i) for i in input_num.split(" ")]
num_list.sort()
min = num_list[0]
max = num_list[num-1]
if min== max:
    print(0)
    exit()
min_sum = 100**3
for i in range(min,max):
    temp_sum = 0
    for j in range(0,num):
        temp_sum += (num_list[j] - i)**2
    if min_sum>temp_sum:
        min_sum = temp_sum
print(min_sum)
# Judge status: Wrong Answer
x = int(input())

for i in range(0,10000):
    ix = i*(i+1)/2
    if x <= ix :
        print(i)
        exit()
# Judge status: Wrong Answer
c = input()

if "c" == "a" or "c" == "e" or "c" == "i" or "c" == "o" or "c" == "u":
    print("vowel")
else:
    print("consonant")
# Judge status: Wrong Answer
n = int(input())
w = list(map(int, input().split()))
x = 0
for i in range(n):
    x += w[i]
y = w[0]
for j in range(n - 1):
    if abs(2 * y - x) >= abs(2 * (y + w[j + 1]) - x):
        y += w[j + 1]
print(abs(2 * y - x))
# Judge status: Wrong Answer
n,m = map(int,input().split())
print((n-2)*(m-2))
# Judge status: Wrong Answer
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def calc_bango(lst):
  ban = 0
  for i in range(N):
    ban += lst[i]*math.factorial(N-i-1)  
  return(ban)

a = calc_bango(P)
b = calc_bango(Q)
print(abs(a-b))
# Judge status: Accepted
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a=a[0]
p = 0
a=a-1

b.sort()
for i in range(a):
	p=(b[i]+b[i+1])/2
	b[i+1]=p

print(b[a])
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
fees=0
if(k>n):
	for i in range(0,n):
		fees+=x
elif(k<n):
	diff=n-k
	for j in range(0,k):
		fees+=x
	for k in range(0,diff):
		fees+=y
		
print(fees)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
ans = [a*c, a*d, b*c, b*d]
print(max(ans))
# Judge status: Accepted
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 100000000000
for i in range(N-K+1):
  le = l[i]
  ri = l[i+K-1]
  ans = min(ans,abs(le)+abs(ri-le),abs(ri)+abs(ri-le))
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
lis=list(map(int,input().split()))
li=[lis[i+1]-lis[i] for i in range(m-1)]
li.append(n-lis[-1]+lis[0])
print(sum(li)-max(li))
# 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,A*C))
# Judge status: Accepted
a, b = map(int, input().split())
if b < 0:
    if (b - a) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
elif a <= 0:
    print("Zero")
else:
    print("Positive")
# Judge status: Wrong Answer
l = input()
 
if l[0]==l[2] and l[1]==l[3]:
  print('Yes')
elif l[0]==l[3] and l[1]==l[2]:
  print('Yes')
elif l[0]==l[1] and l[2]==l[3]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a, b = map(int, input().split())
n = b-a-1
num = 0
for i in range(1,n+1):
    num += i

print(num-a)
# Judge status: Accepted
N = int(input())

count = 0
div = 10

if N % 2 == 0:
    for i in range(1, 26):
        count += N // div
        div *= 5

print(count)
# Judge status: Wrong Answer
# coding: utf-8
n = int(input())

list_a = map(int, input().split())

q = int(input())

for i in range(q):
    b, c = map(int, input().split())
    list_a = list(map(lambda a: c if a==b else a, list_a))

print(sum(list_a))
# Judge status: Accepted
s,w=map(int,input().split())
if w>=s:
    print("unsafe")
    exit()
print("safe")
# Judge status: Accepted
a = input()
b = []
for z in a:
  b.append(z)
if b[2]==b[3]:
  if b[4]==b[5]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())

answer = int((a + b) * h / 2)
print(answer)
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()

C=[0]*(N)
c=0
for i in range(len(S)-1):
  if S[i:i+2]=="AC": c += 1
  C[i] = c

#print(C)

for q in range(Q):
  l, r = map(int, input().split())
  l, r = l-1, r-1

  ans = C[r-1] - C[l-1]
  print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
P=list(map(int,input().split()))

P.sort()
print(sum(P[0:3]))
# Judge status: Accepted
h, n = map(int, input().split())

dp = [float('inf')] * (h+1)

for _ in range(n):
    damage, mp = map(int, input().split())
    for i in range(h+1):
        if i <= damage:
            dp[i] = min(dp[i], mp)
        else:
            dp[i] = min(dp[i], dp[i-damage] + mp)
print(dp[h])
# Judge status: Wrong Answer
n=list(map(int,input().strip().split()))
m=list(map(int,input().strip().split()))
for i in range(n[1],n[0]):
    if(m[i]>m[i-1]):
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
n = input()
n_list = [int(i) for i in n]
ans = 0
if len(n) == 1:
    print(n)
else:
    if sum(n_list[1:]) == (len(n)-1)*9:
        ans = sum(n_list)
    else:
        ans = n_list[0]-1 + (len(n_list)-1)*9
print(ans)
# Judge status: Accepted
n = int(input())

ans = 1
for i in range(n):
    ans *= i + 1
    ans %= 10**9 + 7
print(ans)
# Judge status: Wrong Answer
x,y = map(int,input().split())
if(x*500<y):
  print("NO")
else:
  print("YES")
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())

x = I()-1
print(x//11*2+1+(x%11)//6)
# Judge status: Accepted
n = int(input())
if n % 2 == 0: print(0.5)
else: print(((n - 1) // 2 + 1) / n)
# Judge status: Wrong Answer
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if a+b+c+d==7:
  print("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
# Judge status: Wrong Answer
N = int(input())
S = list(input())
a = 0
if N == 1:
    print("No")
else:
    for i in range(len(S)//2):
        if S[i] != S[i+(len(S)//2)]:
            a = a+1
    if a == 0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n,l = map(int,input().split())
t = n*l-n+(1+n)*n//2
a = l+n-1
if 0 < l:
  print(t-l)
elif a < 0:
  print(t-a)
else:
  print(t)
# Judge status: Accepted
A=list(map(int,input().split()))
K=int(input())
A.sort(reverse=True)
ans=sum(A)
for i in range(K):
  ans+=A[0]
  A[0]*=2
print(ans)
# Judge status: Accepted
import numpy as np
n, m = map(int, input().split())

X = [input() for _ in range(n)]
np_x = np.zeros((n, n), dtype=int)
for i in range(n):
  for j in range(n):
    np_x[i, j] = X[i][j] == '.'
Y = [input() for _ in range(m)]
np_y = np.zeros((m, m), dtype=int)
for i in range(m):
  for j in range(m):
    np_y[i, j] = Y[i][j] == '.'

for i in range(n-m+1):
  for j in range(n-m+1):
    if np.all(np_x[i:i+m, j:j+m] == np_y):
      print('Yes')
      exit()
else:
  print('No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
s=input().strip()
print("2017"+s[4:])
# Judge status: Wrong Answer
T = input()
for i in range(0, len(T)):
    if T[0] == "P":
        first = "P"
        second = "D"
    else:
        first = "D"
        second = "P"

for i in range(0, len(T)):
    if T[i] == "?":
        if i % 2 == 0:
            T = T.replace("?", first)
        else:
            T = T.replace("?", second)
print(T)
# Judge status: Accepted
import copy
from collections import deque

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
d = deque()
c = 0
count = 2
ans = 0

for k in range(N-1):
    ans += A[ (k+1) // 2]
print(ans)
# Judge status: Wrong Answer
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
d=[x+y for x,y in xy]
d.sort()
ans=d[-1]-d[0]
maxy=max([y for x,y in xy])
dr=[x+(maxy-y) for x,y in xy]
ans=max(ans,dr[-1]-dr[0])
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = a + b + c
if ans > 21:
    print('bust')
else:
    print('win')
# Judge status: Wrong Answer
n=int(input())
s=input()


if(n%2==1):
  print('No')
  exit()

else:  
   
    
    if s[0:n//2]==s[(n//2)+1:n]:
     	print('Yes')
    else:
      print("No")
# Judge status: Accepted
import sys

n, k = map(int, input().split())
ara = [0]
ara += list( map(int, input().split()) )

now = 1
vis = []
taken = [0]*(n+1)

while taken[now] == 0:
	vis.append(now)
	taken[now] = 1
	now = ara[now]

cycleLen = len(vis) - vis.index(now)

if k < vis.index(now):
	print(vis[k])
	sys.exit()

k -= vis.index(now)

k %= cycleLen

print(vis[k + vis.index(now) ])
# Judge status: Accepted
a,b = map(int,input().split())

if 0 < a <= b:
    print("Positive")
elif a <= b < 0:
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")
else:
    print("Zero")
# Judge status: Wrong Answer
import numpy as np
W, N = map(int,input().split())
items = [[int(x) for x in reversed(input().split())] for _ in range(N)]
INF = 10 ** 4
dp = [[INF for i in range(W+1)] for j in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
for i in range(1,N+1): #1<= i <= N
        for j in range(1, W+1): # 1 <= j <= W
            dp[i][j] = min(dp[i-1][j], dp[i-1][max(j - items[i-1][1],0)] + items[i-1][0], dp[i][max(j - items[i-1][1],0)] + items[i-1][0])
print(dp[N][W])
# Judge status: Accepted
N,M=map(int,input().split())
if N==1:
    if M==1:
        print(1)
    else:
        print(M-2)
elif M==1:
    print(N-2)
else:
    print(N*M+4-2*N-2*M)
# Judge status: Accepted
s=input()
n=len(s)
for i in range(1,n):
  if (n-i)%2==0:
    m=(n-i)//2
    if s[:m]==s[m:n-i]:
      print(n-i)
      exit()
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1],reverse=True)
d=[]
i=0
while i<m and len(d)<n:
  d+=[bc[i][1]]*bc[i][0]
  i+=1
d=d[:n]
s=sum(a)
ans=s
for x in range(min(n,len(d))):
  s+=d[x]-a[x]
  ans=max(ans,s)
print(ans)
# Judge status: Accepted
N = int(input())
a = 0
for i in range(N,1000):
  if i == 111 or i == 222 or i == 333 or i ==444 or i ==555 or i == 666 or i ==777 or i ==888 or i == 999:
    a = i
    break
print(a)
# Judge status: Accepted
S = input()
masterNum = 753

minNum = 1000
for i in range(len(S)-2):
    digit = int(S[i:i+3])
    diff = abs(digit - masterNum)
    if diff < minNum:
        minNum = diff

print(minNum)
# Judge status: Accepted
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')
# Judge status: Accepted
inputs = input().split()
n = int(inputs[0])
k = int(inputs[1])
cnt = 1
while n >= k:
  n = n // k
  cnt += 1
print(cnt)
# Judge status: Accepted
def prb2():
    a,b,c,d = map(int,input().split())
    t = (a+b)
    ak = (c+d)
    print('Yes' if t>ak else "No")

def prb3():
    n = int(input())
    d = set()
    for i in range(n):
        s = input()
        d.add(s)
    print(len(d))



#prb1()
#prb2()
prb3()
# Judge status: Accepted
import math

n = int(input())

sum = 0
memo = {'1,1':1}
for i in range(1, n+1):
  for j in range(1, n+1):
      if str(i)+','+str(j) in memo:
        ret = memo[str(i)+','+str(j)]
      elif str(j)+','+str(i) in memo:
        ret = memo[str(j)+','+str(i)]
      else:
        ret = math.gcd(i, j)
        memo[str(i)+','+str(j)] = ret
        memo[str(j)+','+str(i)] = ret

for i in memo.values():
  for j in range(1, n+1):
    sum += math.gcd(i, j)

print(sum)
# Judge status: Accepted
a, b = map(int, input().split())
nb = b - a
lb = nb*(nb + 1)//2
print(lb - b)
# Judge status: Accepted
S = list(input())
a=0
b=0
for i in S[::2]:
    if i=="1":
        a+=1
for k in S[1::2]:
    if k=="0":
        a+=1

for i in S[::2]:
    if i=="0":
        b+=1
for k in S[1::2]:
    if k=="1":
        b+=1
print(min(a,b))
# Judge status: Accepted
n=int(input())
t=n%1000
if t==0:
  print(0)
else:
  print(1000-t)
# Judge status: Accepted
a=input()
b=list(a)
c=b[0:3]
d="".join(c)
print(d)
# Judge status: Accepted
A, B, M = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

ans = min(al) + min(bl)
for _ in range(M):
    a, b, m = list(map(int, input().split()))
    ans = min(ans, al[a-1]+bl[b-1]-m)
print(ans)
# Judge status: Accepted
s= input()
if s.endswith('s'):
  print(s+'es')
else:
  print(s+'s')
# Judge status: Accepted
A, B, C, K = map(int, input().split())

count = 0

if K >= A:
    count += A
    K -= A
else:
    count = K
    K = 0

if K != 0:
    if K>=B:
        K -= B
    else:
        K= 0
if K != 0:
    count -= K

print(count)
# Judge status: Wrong Answer
O = input()
E = input()

ans = ""
for o, e in zip(O, E):
    ans += o + e

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

ans = []
c = 1
# RL圧縮
for i in range(1,n):
    if S[i-1] == S[i]:
        c += 1
    else:
        ans.append(c)
        c = 1
ans.append(c)
# ansの個数は1個毎に減っていく
if len(ans) // 2  <= k:
    print(n-1)
else:
    d = len(ans) - 2*k
    print(n-d)
# Judge status: Accepted
def solve():
    n,k = map(int,input().split())
    d = set(map(int,input().split()))
    for i in range(n,100000):
        s = map(int,str(i))
        flag = True
        for j in s:
            if j in d:
                flag = False
        if flag:
            print(i)
            return

if __name__ == "__main__":
    solve()
# Judge status: Accepted
n = int(input())
ans = 0
f1, f2, f3 = 0, 0, 0
for i in range(n):
    f3 = f2
    f2 = f1
    d1, d2 = map(int, input().split())
    f1 = d1 == d2
    if f1 == f2 == f3 == 1:
        ans = 1
print('Yes' if ans else 'No')
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if k <= a+b:
    print(min(a, k))
else:
    print(a-(k-a-b))