Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
import heapq
push = heapq.heappush
pop = heapq.heappop
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
 
H,W = map(int,readline().split())
sh,sw = map(int,readline().split())
gh,gw = map(int,readline().split())
sh,sw = sh-1,sw-1
gh,gw = gh-1,gw-1
maze = []
for _ in range(H):
    maze.append(readline().rstrip().decode())
visited = [[10**6]*W for _ in range(H)] #必要な最小ワープ回数
hp = []
push(hp,(0,sh,sw))
visited[sh][sw] = 0
while hp:
    rp,h,w = pop(hp)
    if h == gh and w == gw:
        print(rp)
        exit()
    for i in range(5):
        for j in range(5):
            if i == 2 and j == 2:
                continue
            if 0 <= h+i-2 < H and 0 <= w+j-2 < W:
                if maze[h+i-2][w+j-2] == ".":
                    if abs(i-2)+abs(j-2) <= 1:
                            if visited[h+i-2][w+j-2] > rp:
                                push(hp,(rp,h+i-2,w+j-2))
                                visited[h+i-2][w+j-2] = rp
                    else:
                        if visited[h+i-2][w+j-2] > rp+1:
                            push(hp,(rp+1,h+i-2,w+j-2))
                            visited[h+i-2][w+j-2] = rp+1
print(-1)


### FIXED CODE ###

import sys
import heapq
push = heapq.heappush
pop = heapq.heappop
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
 
H,W = map(int,readline().split())
sh,sw = map(int,readline().split())
gh,gw = map(int,readline().split())
sh,sw = sh-1,sw-1
gh,gw = gh-1,gw-1
maze = []
for _ in range(H):
    maze.append(readline().rstrip().decode())
visited = [[10**6]*W for _ in range(H)] #必要な最小ワープ回数
hp = []
push(hp,(0,sh,sw))
visited[sh][sw] = 0
while hp:
    rp,h,w = pop(hp)
    if visited[h][w] < rp:
        continue
    if h == gh and w == gw:
        print(rp)
        exit()
    for i in range(5):
        for j in range(5):
            if i == 2 and j == 2:
                continue
            if 0 <= h+i-2 < H and 0 <= w+j-2 < W:
                if maze[h+i-2][w+j-2] == ".":
                    if abs(i-2)+abs(j-2) <= 1:
                            if visited[h+i-2][w+j-2] > rp:
                                push(hp,(rp,h+i-2,w+j-2))
                                visited[h+i-2][w+j-2] = rp
                    else:
                        if visited[h+i-2][w+j-2] > rp+1:
                            push(hp,(rp+1,h+i-2,w+j-2))
                            visited[h+i-2][w+j-2] = rp+1
print(-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
n,*a=map(int,open(0).read().split())
dp=[[0]*(n+1) for _ in range(n+1)]
def dfs(l,r):
	if l+r==n:return 0
	if dp[l][r]:return dp[l][r]
	dp[l][r]=max(a[l]-dfs(l+1,r),a[n-1-r]-dfs(l,r+1))
	return dp[l][r]
print(dfs(0,0))

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
dp=[[0]*(n+1) for _ in range(n+1)]
for l in range(n)[::-1]:
	for r in range(n)[::-1]:
		if l+r<=n-1:
			dp[l][r]=max(a[l]-dp[l+1][r],a[n-1-r]-dp[l][r+1])
print(dp[0][0])
### BUGGY CODE ###

num=int(input())
list0=[]
sum=0
for i in range(num):
  date=input()
  list0.append(date)
  j=0
  a=0
  if len(list0)-2>=0:
    for j in range(len(list0)-1):
        if list0[j]==date:
            a+=1
  if a==0:
    sum+=1
print(sum)
  

### FIXED CODE ###

num=int(input())
list0=[]
for i in range(num):
  date=input()
  list0.append(date)
list0=set(list0)
print(len(list0))
### BUGGY CODE ###

N, P = map(int, input().split())
s = list(input())
s = [int(i) for i in s]
S = []
ans = 0
for i in range(len(s)+1):
    for j in range(1, len(s)+1-i):
        A = 0
        for k in range(len(s[i:i+j])):
            A += s[i+k]*10**(j-k-1)
            
        if A%P==0:
            ans +=1
print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
mod = [0]*P
if P==2 or P==5:
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
    print(ans)
else:
    un1 = 0
    un = 0
    for i in range(N-1, -1, -1):
        #a =int(S[i])*10**un + un1
        a =int(S[i])*pow(10,un,P)+(un1)%P
        un += 1
        un1 = a
        mod[a%P]+=1
    ans += mod[0]  
    for i in range(P):
        ans += mod[i]*(mod[i]-1)/2
    print(int(ans))
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
ans=0
INF=-10**9
k=0
while max(a)>=0:
  de=[]
  f=a[k]
  de.append(k)
  if f<0:
    k+=1
    continue
  for i in range(k+1,n):
    if f<a[i]:
      de.append(i)
      f=a[i]
  for i in de:
    a[i]=INF
  ans+=1
  k+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=[int(input()) for _ in range(n)][::-1]
lis=[a[0]]
for i in a[1:]:
  if i>=lis[-1]:
    lis.append(i)
  else:
    lis[bisect.bisect_right(lis,i)]=i
print(len(lis))
### BUGGY CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[int(n[i]) for i in range(len(n))]
# for i in range(len(n)):
#     lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()

dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
# dp=[[float('inf')]*2 for i in range(keta+1)]
dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))
### BUGGY CODE ###

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
ans = 0
for n in range(N):
    ans = max(ans, sum(V[n:n+K]))
print(ans)

### FIXED CODE ###

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)
### BUGGY CODE ###

X, K, D = map(int, input().split())
X = abs(X)
while X >= D and K > 0  :
  X -= D
  K -= 1
if K % 2 == 0:
  print(X)
else:
  print(abs(X - D))

### FIXED CODE ###

X, K, D = map(int, input().split())
X = abs(X)
if X >= K * D:
  print(X - K * D)
elif X == D:
  if K % 2 == 0:
    print(X)
  else:
    print(abs(X - D)) 
else:
  K -=  X // D
  X = X % D
  if K % 2 == 0:
    print(X)
  else:
    print(abs(X - D))
### BUGGY CODE ###

while True:
    try:
        N, Q = map(int, input().split())
        verts = [None] * N
        qs = [0] * N
        results = [0] * N
        for i in range(N - 1):
            a, b = map(int, input().split())
            a -= 1
            b -= 1
            if verts[a] is None:
                verts[a] = list()
            if verts[b] is None:
                verts[b] = list()
            verts[a].append(b)
            verts[b].append(a)
        for i in range(Q):
            q, x = map(int, input().split())
            q -= 1
            qs[q] += x
        rests = [(0, None)]
        while rests:
            x, parent = rests.pop()
            if parent is not None:
                results[x] += results[parent]
            results[x] += qs[x]
            if verts[x] is not None:
                rests.extend((i, x) for i in filter(lambda j: j != parent, verts[x]))
        print(" ".join(map(str, results)))
    except EOFError:
        break

### FIXED CODE ###

while True:
    try:
        N, Q = map(int, input().split())
        verts = [None] * N
        qs = [0] * N
        results = [0] * N
        for i in range(N - 1):
            a, b = map(int, input().split())
            a -= 1
            b -= 1
            if verts[a] is None:
                verts[a] = list()
            if verts[b] is None:
                verts[b] = list()
            verts[a].append(b)
            verts[b].append(a)
        for i in range(Q):
            q, x = map(int, input().split())
            q -= 1
            qs[q] += x
        rests = [(0, None)]
        while rests:
            x, parent = rests.pop()
            if parent is not None:
                results[x] += results[parent]
            results[x] += qs[x]
            for i in verts[x]:
                if i != parent:
                    rests.append((i, x))
        print(" ".join(map(str, results)))
    except EOFError:
        break
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
for i in range(0,n,2): print(a.pop(n-i-1),end=" ")
print(*a)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
if n%2:
    print(*l[::-2], end=' ')
    print(*l[1::2])
else:
    print(*l[::-2], end=' ')
    print(*l[0::2])
### BUGGY CODE ###

n, m = map(int, input().split())
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if is_prime(m):
    print(1)
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break

### FIXED CODE ###

n, m = map(int, input().split())
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if is_prime(m):
    print(1)
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break
### BUGGY CODE ###

# coding: utf-8
from itertools import count

def merge(A, left, mid, right, counter):
  n1, n2 = mid - left, right - mid
  L, R = [None]*(n1+1), [None]*(n2+1)
  for i in range(n1):
    L[i] = A[left + i]
  for i in range(n2):
    R[i] = A[mid + i]
  L[n1], R[n2] = float("inf"), float("inf")
  i, j = 0, 0
  for k in range(left, right):
    next(counter)
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right, counter):
  if left+1 < right:
    mid = (left + right)//2;
    mergeSort(A, left, mid, counter)
    mergeSort(A, mid, right, counter)
    merge(A, left, mid, right, counter)

N = int(input())
A = [int(i) for i in input().split()]
counter = count(0)
mergeSort(A, 0, len(A), counter)
print(*A)
print(next(counter))

### FIXED CODE ###

def merge(A, left, mid, right):
  global counter
  n1, n2 = mid - left, right - mid
  L, R = list(A[left:left+n1]+[float("inf")]), list(A[mid:mid+n2]+[float("inf")])
  i = j = 0
  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1
  counter += right - left
def mergeSort(A, left, right):
  if left+1 < right:
    mid = (left + right)//2;
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

N = int(input())
A = [int(i) for i in input().split()]
counter = 0
mergeSort(A, 0, len(A))
print(*A)
print(counter)
### BUGGY CODE ###

n = int(input())
i = n
while 1:
  if i%n == 0 and i%2 ==0:
    print(i)
    break
  i += 1

### FIXED CODE ###

n = int(input())
if n%2 == 0:
  print(n)
else:
  print(n*2)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

# 木構造をリストで表現する
graph = [[] for _ in range(N+1)]

for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

# 各操作で与えられる値を、各頂点ごとに集計しておく
value = [0] * (N+1)
for p, x in PX:
    value[p] += x


def dfs(v, parent, point):
    # 現在いる頂点vの親までの値をpointとする
    value[v] += point
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])


dfs(1, 0, 0)

res = ' '.join(map(str, value[1:]))
print(res)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
 
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
 
dfs(1,0,0)
 
answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [0]*(N+1)
res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    if k < N//2:
        dp[k] = A[k]-sum([x for i,x in enumerate(dp[k+1:]) if i%k==0])%2
    else:
        dp[k] = A[k]
    res += dp[k]

print(res)
print(' '.join([str(i) for i,x in enumerate(dp) if x==1]))

### FIXED CODE ###

N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    tmp = 0
    for j in range(k,N+1,k):
       	tmp += res[j]
    res[k] = A[k] ^ tmp%2
    sum_res += res[k]
 
print(sum_res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))
### BUGGY CODE ###

k, s = map(int, input().split())
res = 0
for a in range(k + 1):
  for b in range(k + 1):
    for c in range(k + 1):
      if a + b + c == s:
        res += 1
        
print(res)

### FIXED CODE ###

k, s = map(int, input().split())
res = 0
for a in range(k + 1):
  for b in range(k + 1):
    z = s - a - b
    if z >= 0 and z <= k:
        res += 1
        
print(res)
### BUGGY CODE ###

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

# 小さい順にソートする
#def sort(h):
#    if len(h) <= 1:
#        return h
#    base = h[-1]
#    low_temp = [];
#    high_temp = [];
#    base_count = 1
#    for i in range(len(h)-1):
#        if h[i] < base:
#            low_temp.append(h[i])
#        elif h[i] > base:
#            high_temp.append(h[i])
#        else:
#            base_count += 1
#    low = sort(low_temp)
#    high = sort(high_temp)
#    return low + [base]*base_count + high

h.sort()
hantei = 10**10
for i in range(N-K+1):
    temp = h[i:i+K]
    temp_dif = max(temp) - min(temp)
    if temp_dif < hantei:
        hantei = temp_dif

print(hantei)


### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
### BUGGY CODE ###

N = int(input())
ans = 0
l = [0] * (10 ** 7 + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        l[j] += 1

for i in range(1, N + 1):
    ans += i * l[i]
print(ans)


### FIXED CODE ###

N = int(input())
ans = 0
l = [0] * (10 ** 7 + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        l[j] += 1

for i in range(1, N + 1):
    ans += i * l[i]
print(ans)
### BUGGY CODE ###

import heapq
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    ls = [0 for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[P[i]-1] = 1
        if sum(ls[0:P[i]])==1:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    ls = [0 for _ in range(N)]
    ans = 0
    mins = 10**10
    for i in range(N):
        mins = min(mins,P[i])
        if mins==P[i]:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

for i in range(n):
    a2 = a[i:] + a[:i]
    b = a2[1:n:2]
    c = a2[2:n-1:2]
    ans += str(a2[0]+a2[n-1]+sum(c)-sum(b))
    if i != n-1:
        ans += ' '

print(ans)


### FIXED CODE ###

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

ans = [sum(a[0:2*n:2])-sum(a[1:2*n:2])]
ans2 = ''

for i in range(n-1):
    ans.append(2*a[i]-ans[i])

for i in range(n):
    ans2 += str(ans[i])
    if i != n-1:
        ans2 += ' '

print(ans2)
### BUGGY CODE ###

import collections

N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
c = collections.Counter(A)

if K - Q > 0:
    for _ in range(N):
        print('Yes')
else:
    l = []
    for i,v in dict(c).items():
        if v > (Q-K):
            l.append(i-1)
    for j in range(N):
        if j in l:
            print('Yes')
        else:
            print('No')

### FIXED CODE ###

import collections

N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
c = collections.Counter(A)

if (K - Q) > 0:
    for _ in range(N):
        print('Yes')
else:
    l = ['No'] * N
    for i,v in dict(c).items():
        if v >(Q - K):
            l[i-1] = 'Yes'
    for j in l:
        print(j)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

from collections import Counter

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=sum(LIST)
BASE=[]
BASESUM=0

MAX=LIST[-1]

for k in range(1,N+1):
    if k>LEN:
        print(0)
    else:
        BASE.append(LIST[-k])
        #print(BASE)

        BASESUM+=LIST[-k]

        REST=SUM-BASESUM
        REST0=REST

        MIN=LIST[-k]
        #MAX=LIST[-1]

        if LIST[-1]*k-BASESUM<=REST:
            print(SUM//k)
            continue

        while MIN!=MAX:
            mid=(MIN+MAX+1)//2
            REST=REST0

            for b in BASE[::-1]:
                if b<mid:
                    REST-=mid-b
                if REST<0 or b>=mid:
                    break

            #print(MAX,MIN,mid,REST)

            if REST>=0:
                MIN=mid
            else:
                MAX=mid-1

        print(MIN)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)
### BUGGY CODE ###

import sys
from collections import deque
N, M = map(int, input().split())
Edge = [[] for _ in range(N+1)]
comp = set()
mod = 10**9+7
for _ in range(M):
    p, q, c = map(int, input().split())
    Edge[p].append(mod*q+c)
    Edge[q].append(mod*p+c)
    comp.add(c)
dist = {mod: 0}
Q = deque()
Q.append(mod)
visited = set()
while Q:
    vn, cp = divmod(Q.pop(), mod)
    if mod*vn+cp in visited:
        continue
    if vn == N:
        break
    visited.add(mod*vn+cp)
    for t in Edge[vn]:
        vf, cf = divmod(t, mod)
        if mod*vf+cp in visited:
            continue
        if cp == cf:
            dist[mod*vf+cf] = dist.get(mod*vn+cp, 10**9)
            Q.append(mod*vf+cf)
        else:
            dist[mod*vf+cf] = min(dist.get(mod*vf+cf, 10**9), 1 + dist.get(mod*vn+cp, 10**9))
            Q.appendleft(mod*vf+cf)
L = [dist.get(N*mod+c, 10**9) for c in comp]
if not L or min(L) == 10**9:
    print(-1)
else:
    print(min(L))


### FIXED CODE ###

import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
inf = 10**9+7
def dijkstra(N, s, Edge):    
    dist = [inf] * N
    dist[s] = 0
    Q = [(0, s)]
    while Q:
        dn, vn = hpp(Q)
        if dn > dist[vn]:
            continue
        for df, vf in Edge[vn]:
            if dn + df < dist[vf]:
                dist[vf] = dn + df
                hp(Q, (dn + df,vf))
    return dist

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C


N, M = map(int, readline().split())

Edge = []
VS = set(range(N))
geta = 20
Edge = [tuple(map(int, readline().split())) for _ in range(M)]
for a, b, c in Edge:
    a -= 1
    b -= 1
    VS |= {(c<<geta) | a, (c<<geta) | b}
   
_, Cv = compress(list(VS))

Vnum = len(Cv)

nEdge = [[] for _ in range(Vnum)]

for a, b, c in Edge:
    a -= 1
    b -= 1
    ca = Cv[(c<<geta) | a]
    cb = Cv[(c<<geta) | b]
    nEdge[ca].append((0, cb))
    nEdge[cb].append((0, ca))
    nEdge[a].append((1, ca))
    nEdge[ca].append((0, a))
    nEdge[b].append((1, cb))
    nEdge[cb].append((0, b))

dist = dijkstra(Vnum, 0, nEdge)
if dist[N-1] >= inf:
    dist[N-1] = -1
print(dist[N-1])
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
point = 1
for i in range(k):
  point = point*a[i]
#print(point)
t = 0
for j in range(k, n):
  point0 = point
  point = point*a[j]/a[t]
  t+=1
  if point > point0:
    print("Yes")
  else:
    print("No")

    

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
#point = 1
t = 0
"""for i in range(t, n):
  point = point*a[i]"""
  
#print(point)
#t = 0
for j in range(k, n):
  #point0 = point
  #point = point*a[j]/a[t]
  if a[j] > a[t]:
    print("Yes")
  else:
    print("No")
  t+=1
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
for i in range(1,n + 1):
    print(a.count(i))
    

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in a:
    b[i - 1] += 1

for j in b:
    print(j)
### BUGGY CODE ###


import numpy as np
N, K = map(int, input().split())
dst = np.array(list(map(int, input().split())),dtype=int)

# N = 200000
# K = 10**18
# dst = np.array(list(range(2, N+1))+[1], dtype=int)

log = np.full(N, -1, dtype=int)
log[0] = 1
current = 1
for i in range(1, K+1):
    current = dst[current-1]
    if np.count_nonzero(log == current) != 0:
        loop_start_ind = np.where(log == current)[0][0]
        loop_len = i-loop_start_ind
        current = log[loop_start_ind+(K-i) % loop_len]
        break
    else:
        log[i] = current
print(current)

### FIXED CODE ###

N, K = map(int, input().split())
dst = list(map(int, input().split()))
log = [1]
log_set=set(log)
current = 1
for i in range(1, K+1):
    current = dst[current-1]
    if current in log_set:
        loop_start_ind = log.index(current)
        loop_len = i-loop_start_ind
        current = log[loop_start_ind+(K-i) % loop_len]
        break
    else:
        log.append(current)
        log_set.add(current)
print(current)
### BUGGY CODE ###

if __name__ == "__main__":
  N = int(input())
  A = [int(x) for x in input().split()]
  Q = int(input())
  for i in range(Q):
    B, C = [int(x) for x in input().split()]
    A = [x if x!=B else C for x in A]
    print(sum(A))

### FIXED CODE ###

import numpy as np
M = 100002

if __name__ == "__main__":
  N = int(input())
  A = [int(x) for x in input().split()]
  Q = int(input())
  Num = np.zeros((M))
  Sum = sum(A)
  for i in range(N):
    Num[A[i]] += 1
  for i in range(Q):
    B, C = [int(x) for x in input().split()]
    if(Num[B] == 0):
      print(int(Sum))
    else:
      Sum = Sum + (C - B)*Num[B]
      Num[C] += Num[B]
      Num[B] = 0
      print(int(Sum))
### BUGGY CODE ###

n, x = map(int, input().split())
a = [int(x) for x in input().split()]
b = [None] * n
for i, c in enumerate(a):
    b[i] = [None] * n
    b[i][0] = a[i]
    for j in range(1, n): b[i][j] = min(b[i][j - 1], a[(i - j) % n])
d = None
for i in range(n):
    c = i * x
    for j in range(n): c += b[j][i]
    if d is None or c < d: d = c
print(d)


### FIXED CODE ###

n, x = map(int, input().split())
a = [int(x) for x in input().split()]
b = [None] * n
for i, c in enumerate(a):
    b[i] = [None] * n
    b[i][0] = a[i]
    for j in range(1, n): b[i][j] = min(b[i][j - 1], a[(i - j) % n])
d = None
for i in range(n):
    c = i * x
    for j in range(n): c += b[j][i]
    if d is None or c < d: d = c
print(d)
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    lis = []
    for i in range(n):
        k = input()
        if k in lis :
            pass
        else:
            lis.append(k)
    print(len(lis))

### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    print(len(set(input().rstrip('\n') for _ in range(n))))