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

import sys
input = sys.stdin.readline
Max = 2000
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())

h,w = m()

aa = [[] for i in range(h)]
aaa = []
ma = 0
for i in range(h):
    k = list(input())
    for j in range(w):
        if k[j] == "#":
            aa[i].append(0)
            aaa.append([i,j])
        else:
            aa[i].append(Max)
kk = []
while True:
    if len(aaa) == 0:
        break
    for i in range(len(aaa)):
        c,v = aaa.pop(0)
        if not c == 0:
            if aa[c-1][v] > aa[c][v]+1:
                aa[c-1][v] = aa[c][v]+1
                kk.append([c-1,v])
                ma = max(ma,aa[c-1][v])
        if not c == h-1:
            if aa[c+1][v] > aa[c][v]+1:
                aa[c+1][v] = aa[c][v]+1
                kk.append([c+1,v])
                ma = max(ma,aa[c+1][v])
        if not v == 0:
            if aa[c][v-1] > aa[c][v]+1:
                aa[c][v-1] = aa[c][v]+1
                kk.append([c,v-1])
                ma = max(ma,aa[c][v-1])
        if not v == w-1:
            if aa[c][v+1] > aa[c][v]+1:
                aa[c][v+1] = aa[c][v]+1
                kk.append([c,v+1])
                ma = max(ma,aa[c][v+1])
    aaa = kk
    kk = []
print(ma)
        


### FIXED CODE ###

import sys
input = sys.stdin.readline
Max = 2000
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())

h,w = m()

aa = [[] for i in range(h)]
aaa = []
ma = 0
for i in range(h):
    k = list(input())
    for j in range(w):
        if k[j] == "#":
            aa[i].append(0)
            aaa.append([i,j])
        else:
            aa[i].append(Max)
kk = []
while True:
    if len(aaa) == 0:
        break
    for i in range(len(aaa)):
        c,v = aaa[i]
        if not c == 0:
            if aa[c-1][v] > aa[c][v]+1:
                aa[c-1][v] = aa[c][v]+1
                kk.append([c-1,v])
                ma = max(ma,aa[c-1][v])
        if not c == h-1:
            if aa[c+1][v] > aa[c][v]+1:
                aa[c+1][v] = aa[c][v]+1
                kk.append([c+1,v])
                ma = max(ma,aa[c+1][v])
        if not v == 0:
            if aa[c][v-1] > aa[c][v]+1:
                aa[c][v-1] = aa[c][v]+1
                kk.append([c,v-1])
                ma = max(ma,aa[c][v-1])
        if not v == w-1:
            if aa[c][v+1] > aa[c][v]+1:
                aa[c][v+1] = aa[c][v]+1
                kk.append([c,v+1])
                ma = max(ma,aa[c][v+1])
    aaa = kk
    kk = []
print(ma)
### BUGGY CODE ###

n,m = map(int, input().split())
height = list(map(int, input().split()))

roads = []
for i in range(m):
    x,y = map(int, input().split())
    roads.append([x-1,y-1])

bestcount = 0

for i in range(n):
    best = 1 # 良い展望台なら1
    for j in range(m):
        if (roads[j][0] == i):
            a = roads[j][0]
            b = roads[j][1]
            if (height[a] <= height[b]):
                best = 0
                break
        if (roads[j][1] == i):
            a = roads[j][1]
            b = roads[j][0]
            if (height[a] <= height[b]):
                best = 0
                break
    if(best == 1):
        bestcount += 1

print(str(bestcount))

### FIXED CODE ###

n,m = map(int, input().split())
height = list(map(int, input().split()))

roads = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    roads[x-1].append(y-1)
    roads[y-1].append(x-1)

bestcount = 0

for i in range(n):
    best = 1 # 良い展望台なら1
    for j in roads[i]:
        if (height[j] >= height[i]):
            best = 0
            break
    if(best == 1):
        bestcount += 1

print(str(bestcount))
### BUGGY CODE ###

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

cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e and s in cnt and cnt[s] <= 1:
    break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)

### FIXED CODE ###

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

cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e:
    if s in cnt:
      if cnt[s] <= 1:
        break
    else:
      break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
count_e = [0] * N
count_w = [0] * N
for i in range(N):
    if S[i] == "E":
        count_e[i] = 1
    else:
        count_w[i] = 1
ans = float('inf')
for i in range(N):
    ans = min(ans, sum(count_w[:i]) + sum(count_e[i:]))
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
count_e = [0] * N
count_w = [0] * N
for i in range(N-1):
    if S[i] == "W":
        count_w[i+1] = count_w[i] + 1
    else:
        count_w[i+1] = count_w[i]

    if S[N-i-1] == "E":
        count_e[i+1] = count_e[i] + 1
    else:
        count_e[i+1] = count_e[i]

count_e = count_e[::-1]
ans = float('inf')
for i in range(N):
    ans = min(ans, count_w[i] + count_e[i])
print(ans)
### BUGGY CODE ###

# D - Equals

import numpy as np
import sys, bisect
from collections import deque

N, M = map(int, sys.stdin.buffer.readline().split())
p = np.array(list(map(int, sys.stdin.buffer.readline().split()))) - 1
xy = np.array(sys.stdin.buffer.read().split(), np.int64) - 1

x = xy[::2]
y = xy[1::2]

neighbor = [[] for _ in range(N)]
for idx in range(M):
    neighbor[x[idx]].append(y[idx])
    neighbor[y[idx]].append(x[idx])
    
can_swap = []
visited = [-1]*N

for start in range(N):
    if visited[start] == -1:
        tmp = [start] # startから到達可能なpointのリスト
        visited[start] = 1
        d = deque([start])
        while d:
            current_point = d.pop()
            visited[current_point] = 1
            for next_point in neighbor[current_point]:
                if visited[next_point] == -1:
                    d.append(next_point)
                    tmp.append(next_point)
        can_swap.append(tmp)                

ans = 0
for idx_group in can_swap:
    tmp_p = [p[idx] for idx in idx_group]
    ans += len(set(tmp_p) & set(idx_group))

print(ans)

### FIXED CODE ###

# D - Equals

from collections import deque

N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

neighbor = [[] for _ in range(N)]
for idx in range(M):
    neighbor[xy[idx][0]-1].append(xy[idx][1]-1)
    neighbor[xy[idx][1]-1].append(xy[idx][0]-1)
    
can_swap = []
visited = [-1]*N

for start in range(N):
    if visited[start] == -1:
        tmp = [start] # startから到達可能なpointのリスト
        d = deque([start])
        while d:
            current_point = d.pop()
            visited[current_point] = 1
            for next_point in neighbor[current_point]:
                if visited[next_point] == -1:
                    d.append(next_point)
                    tmp.append(next_point)
        can_swap.append(tmp)                

ans = 0
for idx_group in can_swap:
    tmp_p = [p[idx]-1 for idx in idx_group]
    ans += len(set(tmp_p) & set(idx_group))

print(ans)
### BUGGY CODE ###

import itertools
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i,j in itertools.combinations(a,2):
    cnt += i*j
print(cnt % (10**9 + 7))

### FIXED CODE ###

import itertools
n = int(input())
a = list(map(int,input().split()))
ruisekiwa = [0] * n
cnt = 0
ruisekiwa[0] = a[0]
for i in range(1,n):
    ruisekiwa[i] = ruisekiwa[i-1] + a[i]
for i in range(n):
    cnt += a[i] * (ruisekiwa[-1] - ruisekiwa[i])
print(cnt % (10**9 + 7))
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    ans = 0
    list = []
    for i in a:
        if len(list) > 0:
            ans+=max(list)
            list.remove(max(list))
            list.append(i)
            list.append(i)
        else:
            list.append(i)


    print(ans)



### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    ans = 0
    count = 0
    for i in a:
        if ans ==0:
            ans+=i
            count+=1
        else:
            if count == n-2:
                ans+=i
                break
            elif count == n-3:
                ans+=i*2
                break
            else:
                ans+=i*2
                count+=2

    if n ==2:
        ans= max(a)

    print(ans)
### BUGGY CODE ###

n, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - a[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i][0]] + a[i][1])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])

### FIXED CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])
### BUGGY CODE ###

n = int(input())
print(0,flush=True)

prev = input()
if prev=='Vacant': exit()

now=[]

def isok(ans, odd_diff):
    print(ans,flush=True)
    now = input()

    if now == 'Vacant': exit()

    if (now==prev and odd_diff)or(now!=prev and not odd_diff):
        return True
    else:
        return False

ok = n-1 #ok以前にVacantが存在
ng = 0 #ng以前にVacantは存在しない

while ok - ng > 1:
    m = (ok+ng)//2
    odd_diff = ((m-ng)%2==1)
    if isok(m, odd_diff):
        prev=now
        ok = m
    else:
        prev=now
        ng = m

print(ok)


### FIXED CODE ###

n = int(input())
print(0,flush=True)

prev = input()
if prev=='Vacant': exit()
zero = prev
now=[]

def isok(ans, odd_diff):
    print(ans,flush=True)
    now = input()

    if now == 'Vacant': exit()

    if (now==zero and odd_diff)or(now!=zero and not odd_diff):
        return True
    else:
        return False

ok = n-1 #ok以前にVacantが存在
ng = 0 #ng以前にVacantは存在しない

while ok - ng > 1:
    m = (ok+ng)//2
    odd_diff = (m%2==1)
    if isok(m, odd_diff):
        ok = m
    else:
        ng = m

print(ok,flush=True)
exit()
### BUGGY CODE ###

N = int(input())
prime_number = []


def f_func(X):
    x = X
    ans = [0] * (x - 1)

    pn = 0
    n = 1
    while n <= x:
        if pn < len(prime_number):
            n = prime_number[pn]
        else:
            n += 1

        j = 1
        while True:
            mod = x % n
            if mod != 0:
                break
            x = x // n
            j += 1
        ans[n - 2] = j - 1
        pn += 1


    result = 1
    for i in ans:
        result = result * (i + 1)
    if sum(ans) == 1:
        prime_number.append(X)
    return result

ans = 1
for i in range(2, N + 1):
    ans += i * f_func(i)
print(ans)

### FIXED CODE ###

N = int(input())


def f(x):
    result = N // x
    return result

ans = 0
for x in range(1, N + 1):
    Y = f(x)
    ans += x * Y * (Y + 1) / 2
print(int(ans))
### BUGGY CODE ###

n,k = map(int,input().split())
res_graph = [[1,i] for i in range(2,n+1)]
res = (n-1)*(n-2)//2

if(k > (n-2)*(n-1)//2):
    print(-1)
    exit()

tmp = 1
tmp_edge = 2
while 1:
    chek = [0]*(n-tmp_edge)
    for i in range(tmp_edge-1,len(chek)+1):
        res_graph.append([tmp_edge, i+tmp_edge])
        res -=1
        if(res==k):
            break
    tmp_edge+=1
    if res==k:
        break
print(len(res_graph))
for i,j in res_graph:
    print(i,j)


### FIXED CODE ###

n,k = map(int,input().split())
res_graph = [[1,i] for i in range(2,n+1)]
res = (n-1)*(n-2)//2

if(k > (n-2)*(n-1)//2):
    print(-1)
    exit()

tmp_edge = 2
while res!=k:
    tmp = 1
    for i in range(n-tmp_edge):
        res_graph.append([tmp_edge,tmp+tmp_edge])
        res-=1
        tmp+=1
        if res==k:
            break
    tmp_edge+=1

print(len(res_graph))
for i,j in res_graph:
    print(i,j)
### BUGGY CODE ###

n = int(input())
p = [(int(x), i) for i, x in enumerate(input().split())]
p.sort(reverse=True)

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: return
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

bit = BinaryIndexedTree(n)
ans = 0

for x, i in p:
    i += 1
    bit.add(i, 1)
    idx = bit.sum(i)
    l1, l2 = bit.lower_bound(idx-1), bit.lower_bound(idx-2)
    r1, r2 = bit.lower_bound(idx+1), bit.lower_bound(idx+2)
    ans += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * x

print(ans)


### FIXED CODE ###

n = int(input())
p = [(int(x), i) for i, x in enumerate(input().split())]
p.sort(reverse=True)

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: return
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

bit = BinaryIndexedTree(n)
ans = 0

for x, i in p:
    i += 1
    bit.add(i, 1)
    idx = bit.sum(i)
    l1, l2 = bit.lower_bound(idx-1), bit.lower_bound(idx-2)
    r1, r2 = bit.lower_bound(idx+1), bit.lower_bound(idx+2)
    ans += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * x

print(ans)
### BUGGY CODE ###

n = int(input())

a = list(map(int,input().split()))
flag = 0
count = 0

if 1 in a:
    pass
else:
    print(-1)
    exit()
    
for i in range(1,n+1):
    if i in a:
        indx = a.index(i)
        count += indx
        a = a[indx+1:]
        # print(count)
        # print(a)
    else:
        count += len(a)
        break

print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
count = 0

if 1 in a:
    pass
else:
    print(-1)
    exit()

no = 1
for i in range(len(a)):
    if a[i]==no:
        no += 1
    else:
        count += 1

print(count)
### BUGGY CODE ###

N, M, Q = map(int, raw_input().split())
L = []
R = []
for i in range(M):
	_l, _r = map(int, raw_input().split())
	L.append(_l)
	R.append(_r)

p = []
q = []
for i in range(Q):
	_p, _q = map(int, raw_input().split())
	p.append(_p)
	q.append(_q)


start_end_mat = [[0] * (N + 1) for i in range(N + 1)]

for i in range(M):
	start = L[i]
	end = R[i]
	for j in range(start, -1, -1):
		for k in range(end, N + 1):
			start_end_mat[j][k] += 1


for i in range(Q):
	start = p[i]
	end = q[i]
	print(start_end_mat[start][end])



### FIXED CODE ###

N, M, Q = map(int, raw_input().split())
L = []
R = []
for i in range(M):
	_l, _r = map(int, raw_input().split())
	L.append(_l)
	R.append(_r)

p = []
q = []
for i in range(Q):
	_p, _q = map(int, raw_input().split())
	p.append(_p)
	q.append(_q)


start_end_mat = [[0] * (N + 1) for i in range(N + 1)]

for i in range(M):
	start_end_mat[L[i]][R[i]] += 1

for i in range(1, N + 1):
	for j in range(1, N + 1):
		start_end_mat[i][j] += start_end_mat[i-1][j]
		start_end_mat[i][j] += start_end_mat[i][j-1]
		start_end_mat[i][j] -= start_end_mat[i-1][j-1]

for i in range(Q):
	res = start_end_mat[N][q[i]]
	res -= start_end_mat[p[i] - 1][q[i]]
	print(res)
### BUGGY CODE ###

import numpy as np
S = input().replace('LR', 'L,R').replace('RL', 'R,L').split(',')
ans = []
for i in range(len(S)//2):
    r = len(S[2*i])
    l = len(S[2*i+1])
    
    if (r+l) % 2 == 0:
        nums = [(r+l)//2] * 2
    else:
        diff = r - l
        if diff>0 and r%2==0 or diff<0 and l%2==1:
            nums = [(r+l-1)//2, (r+l-1)//2+1]
        else:
            nums = [(r+l-1)//2+1, (r+l-1)//2]
                
    li = [0]*(r-1) + nums + [0]*(l-1)
    ans.append(li)    
    
print(*sum(ans, []))

### FIXED CODE ###

import numpy as np
S = input()
n = len(S)
rl_li = []
for i in range(n-1):
    if S[i]+S[i+1]=='RL':
        rl_li.append(i) 

ans = [0] * n
rl_idx = 0
for i in range(n):
    rl = rl_li[rl_idx]
    distance = abs(i - rl)
    
    if distance % 2 == 0:
        ans[rl] += 1
    else:
        ans[rl+1] += 1
    
    if i == n-1:
        break
        
    if S[i] == 'L' and S[i+1] == 'R':
        rl_idx += 1

print(*ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

S = [0 for _ in range(N+1)]

s = 0
for i in range(N):
    s += A[i]
    S[i+1] = s

ans = 0
for j in range(N+1):
    for i in range(j):
        if (S[j]-S[i]) % M == 0:
            ans += 1

print(ans)


### FIXED CODE ###

from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

d = defaultdict(int)

s = 0
for i in range(N):
    d[s % M] += 1
    s += A[i]
d[s % M] += 1


ans = 0
for v in d.values():
    ans += v*(v-1)//2
print(ans)
### BUGGY CODE ###

H,W = map(int,input().split())
S = []
for i in range(H):
    s = input()
    S.append([x for x in s])
 
S_t = list(map(list, zip(*S)))
 
S_h = [[] for i in range(H)]
S_w = [[] for i in range(W)]
S_hh = [[0]*(W+1) for i in range(H)]
S_ww = [[0]*(H+1) for i in range(W)]
 
for x in range(W):
    for y in range(H):
        if S[y][x] == '#':
            S_h[y].append(x)
            S_w[x].append(y)
            S_hh[y][x] = 1
            S_ww[x][y] = 1
        S_hh[y][x] += S_hh[y][x-1]
        S_ww[x][y] += S_ww[x][y-1]
 
ans = 0
for x in range(W):
    for y in range(H):
        if S[y][x] == '.':
            c = 1
            if len(S_w[x]) == 0:
                c += H-1
            else:
                i = S_ww[x][y]
                if i == 0:
                    c += S_w[x][0]-1
                elif i == len(S_w[x]):
                    c += H-S_w[x][-1]-2
                else:
                    c += S_w[x][i]-S_w[x][i-1]-2
            if len(S_h[y]) == 0:
                c += W-1
            else:
                i = S_hh[y][x]
                if i == 0:
                    c += S_h[y][0]-1
                elif i == len(S_h[y]):
                    c += W-S_h[y][-1]-2
                else:
                    c += S_h[y][i]-S_h[y][i-1]-2
            ans = max(ans,c)
 
print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
S = [input() for i in range(H)]

S_h1 = [[0]*(W+1) for i in range(H)]
S_w1 = [[0]*(H+1) for i in range(W)]
S_h2 = [[0]*(W+1) for i in range(H)]
S_w2 = [[0]*(H+1) for i in range(W)]

for x in range(W):
    for y in range(H):
        if S[y][x] == '#':
            S_h1[y][x] = 0
            S_w1[x][y] = 0
        else:
            S_h1[y][x] += S_h1[y][x-1]+1
            S_w1[x][y] += S_w1[x][y-1]+1

for x in range(W-1,-1,-1):
    for y in range(H-1,-1,-1):
        if S[y][x] == '#':
            S_h2[y][x] = 0
            S_w2[x][y] = 0
        else:
            S_h2[y][x] += S_h2[y][x+1]+1
            S_w2[x][y] += S_w2[x][y+1]+1

ans = 0
for x in range(W):
    for y in range(H):
        if S[y][x] == '.':
            ans = max(ans,S_h1[y][x]+S_h2[y][x]+S_w1[x][y]+S_w2[x][y]-3)
 
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

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

log = []

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if x in log:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        iter += 1
        return func(x, iter)

print(func(1, 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

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

log = []
check = [False]*N

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if check[x-1]:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        check[x-1] = True
        iter += 1
        return func(x, iter)

print(func(1, 0))
### BUGGY CODE ###

n=int(input())
lst=[]
for i in range(n):
 lst.extend(input().split())
list_uniq=[]
ans=0
for j in lst:
 if list_uniq.count(j)==0:
    list_uniq.append(j)
    ans+=1
 else:
    pass
print(ans)

### FIXED CODE ###

n=int(input())
lst={}
for i in range(n):
  lst[input()]=1
print(len(lst))
### BUGGY CODE ###

N,W = map(int, input().split())
dp = [0] * (W + 1)

for i in range(N):
    w, v = map(int, input().split())

    for j in range(W, w - 1, -1 ):
        dp[j] = max(dp[j] , dp[j - w] + v)

print(dp[W])


### FIXED CODE ###

def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())
### BUGGY CODE ###

a,b,k=(int(i)for i in input().split())
while 0<k:
    if 0<a:a=a-1
    elif 0<b:b=b-1
    k=k-1
print(a,b)


### FIXED CODE ###

a, b, k = map(int, input().split())
print(0,max(0,b+a-k)) if a<=k else print(a-k,b)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(input())
dic = {}
for i in set(s):
  if s.count(i) not in dic.keys():
    dic[s.count(i)] = [i]
  else:
    dic[s.count(i)].append(i)
a = max(list(dic.keys()))
dic[a] = sorted(dic[a])
for i in dic[a]:
  print(i)

### FIXED CODE ###

n = int(input())
s = {}
for i in range(n):
  x = input()
  if x not in s.keys():
    s[x] = 1
  else:
    s[x] += 1
x = max(list(s.values()))
keys = sorted([k for k, v in s.items() if v == x])
for i in keys:
  print(i)