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

n = int(input())
s = [input() for i in range(n)]

s_unique   = []
s_cnt      = [0]*n
unique_num = 0
for i in range(n):
  # 新しい文字列の場合は配列に加える
  if (not(s[i] in s_unique)):
  	s_unique.append(s[i])
  else:
    s_cnt[s_unique.index(s[i])] += 1

# 最大カウントの要素で再構成
cnt_max = max(s_cnt)
s_max = []
for i in range(n):
  if (s_cnt[i] == cnt_max):
    s_max.append(s_unique[i])

s_max = sorted(s_max)
for s in s_max:
  print(s)

### FIXED CODE ###

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
s = Counter(s)
s = s.most_common()

# ansの初期化
ans = []
ans.append(s[0][0])
cnt = s[0][1]

if (len(s) != 1):
  for i in range(1, n):
    if (s[i][1] < cnt):
      break
    else:
      ans.append(s[i][0])

for s in sorted(ans):
  print(s)
### BUGGY CODE ###

import math
H, N = tuple(map(int, input().split(" ")))
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split(" "))))

minpower = 10 ** 10

# dp[n][h] = 0 ~ n - 1 番目の魔法を使えた時、残り体力がhのモンスターを倒すために必要な魔力
dp = [[minpower for _ in range(H + 1)] for __ in range(N)]
for h in range(H):
    dp[0][h] = math.ceil(h / AB[0][0]) * AB[0][1]

for n in range(N):
    dp[n][0] = 0

for h in range(H + 1):
    for n in range(N):
        a, b = AB[n]

        if h - a < 0:
            dp[n][h] = min(
                dp[n-1][h],
                b
            )
        else:
            dp[n][h] = min(
                dp[n-1][h],
                dp[n][h-a] + b)
print(dp[-1][H])

### FIXED CODE ###

import math
H, N = tuple(map(int, input().split(" ")))
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split(" "))))

minpower = 10 ** 8 + 1

# dp[n][h] = 0 ~ n - 1 番目の魔法を使えた時、残り体力がhのモンスターを倒すために必要な魔力
dp = [[minpower for _ in range(H + 1)] for __ in range(N)]
for h in range(H):
    dp[0][h] = math.ceil(h / AB[0][0]) * AB[0][1]

for n in range(N):
    dp[n][0] = 0

for h in range(H + 1):
    for n in range(N):
        a, b = AB[n]

        if h - a < 0:
            dp[n][h] = min(
                dp[n-1][h],
                b
            )
        else:
            dp[n][h] = min(
                dp[n-1][h],
                dp[n][h-a] + b)
print(dp[-1][H])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from pprint import pprint
N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

X = 10**5+2

c_s = [[0 for _ in range(X)] for _ in range(C)]
c_t = [[0 for _ in range(X)] for _ in range(C)]

# チャンネルごとにマッピング
for s,t,c in stc:
    c_s[c-1][s] += 1
    c_t[c-1][t] -= 1

# for c in range(C):
#     pprint(c_s[c][:14])
#     pprint(c_t[c][:14])
# print()

# チャンネルごとにいもす累計
c_rec = [[0 for _ in range(X)] for _ in range(C)]
for c in range(C):
    c_rec[c][0] = c_s[c][0] + c_t[c][0]
    for i in range(1,X):
        c_rec[c][i] = c_rec[c][i-1] + c_s[c][i] + c_t[c][i]

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# チャンネルごとのスタートを0.5分ずらす
for c in range(C):
    for i in range(X-1):
        diff = c_rec[c][i+1] - c_rec[c][i]
        if diff > 0: # 負はずらさない
            c_rec[c][i] += diff

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# 合計する
sumlist = [0 for _ in range(X)]
for c in range(C):
    for i in range(X):
        sumlist[i] += c_rec[c][i]

# pprint(sumlist[:14])

print(max(sumlist))



### FIXED CODE ###

# -*- coding: utf-8 -*-
from pprint import pprint
N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

X = 10**5+2

c_s = [[0 for _ in range(X)] for _ in range(C)]
c_t = [[0 for _ in range(X)] for _ in range(C)]

# チャンネルごとにマッピング
for s,t,c in stc:
    c_s[c-1][s] += 1
    c_t[c-1][t] -= 1

# for c in range(C):
#     pprint(c_s[c][:14])
#     pprint(c_t[c][:14])
# print()

# チャンネルごとにいもす累計
c_rec = [[0 for _ in range(X)] for _ in range(C)]
for c in range(C):
    c_rec[c][0] = c_s[c][0] + c_t[c][0]
    for i in range(1,X):
        c_rec[c][i] = c_rec[c][i-1] + c_s[c][i] + c_t[c][i]

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# チャンネルごとのスタートを0.5分ずらす
for c in range(C):
    for i in range(X-1):
        diff = c_rec[c][i+1] - c_rec[c][i]
        if diff > 0: # 負はずらさない
            c_rec[c][i] += diff

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# 合計する
sumlist = [0 for _ in range(X)]
for c in range(C):
    for i in range(X):
        sumlist[i] += c_rec[c][i]

# pprint(sumlist[:14])

print(max(sumlist))
### BUGGY CODE ###

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

tot=0

for i in range(len(num)):

  tot += (num[i] % (10**9+7) * sum(num[i+1:]) % (10**9+7))
  tot = tot % (10**9+7)

print(tot)

### FIXED CODE ###

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

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())

N = ni()
g1, s1, b1 = nm()
g2, s2, b2 = nm()


def solve():
    # Start
    don = N
    # A
    don_max = N
    for kg in range(don // g1 + 1):
        don1 = don - kg * g1
        temp1 = kg * g2
        for ks in range(don1 // s1 + 1):
            don2 = don1 - ks * s1
            temp2 = ks * s2
            if b2 > b1:
                kb = don2 // b1
                don3 = don2 - kb * b1
                temp3 = kb * b2
            else:
                kb = 0
                don3 = don2
                temp3 = 0
            if don_max < don3 + temp1 + temp2 + temp3:
                don_max = don3 + temp1 + temp2 + temp3
                # print(f"1> don_max={don_max} g:{kg} s:{ks} b:{kb}")

    don = don_max
    for kg in range(don // g2 + 1):
        don1 = don - kg * g2
        temp1 = kg * g1
        for ks in range(don1 // s2 + 1):
            don2 = don1 - ks * s2
            temp2 = ks * s1
            if b1 > b2:
                kb = don2 // b2
                don3 = don2 - kb * b2
                temp3 = kb * b1
            else:
                kb = 0
                don3 = don2
                temp3 = 0
            if don_max < don3 + temp1 + temp2 + temp3:
                don_max = don3 + temp1 + temp2 + temp3
                # print(f"2> don_max={don_max} g:{kg} s:{ks} b:{kb}")
    return don_max


print(solve())


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())

N = ni()
g1, s1, b1 = nm()
g2, s2, b2 = nm()

INF = 10 ** 15


def solve():
    x1 = [g1, s1, b1]
    x2 = [g2, s2, b2]

    # dp[i] := max future donguri when we use i donguri
    dp = [-INF] * (N + 1)
    dp[0] = N
    for i in range(3):
        t1 = x1[i]
        t2 = x2[i]
        if t1 >= t2:
            continue
        for j in range(t1, N + 1):
            r = dp[j - t1] - t1
            if r >= 0 and dp[j] < r + t2:
                dp[j] = r + t2

    don = max(dp)
    dp = [0] * (don + 1)
    dp[0] = don
    for i in range(3):
        t1 = x1[i]
        t2 = x2[i]
        if t1 <= t2:
            continue
        for j in range(t2, don + 1):
            r = dp[j - t2] - t2
            if r >= 0 and dp[j] < r + t1:
                dp[j] = r + t1
    return max(dp)


print(solve())
### BUGGY CODE ###

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,m = i_map()

    c = [[INF]*n for _ in range(n)]
    for i in range(n):
        c[i][i] = 0

    for _ in range(m):
        a,b = i_map()
        c[a-1][b-1] = 1
        c[b-1][a-1] = 1

    for i,k in enumerate(c[0]):
        if k == 1:
            if c[i][-1] == 1:
                print("POSSIBLE")
                exit()
    print("IMPOSSIBLE")


if __name__=="__main__":
    main()


### FIXED CODE ###

N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
    if 1 == L[i][0]:
        s.append(L[i][1])
    if 1 == L[i][1]:
        s.append(L[i][0])
        
for i in range(M):
    if N == L[i][0]:
        g.append(L[i][1])
    if N == L[i][1]:
        g.append(L[i][0])
        
if set(g)&set(s):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

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

mod = 10**9 + 7
ans = 0
for i in range(N):
    for j in range(i,N):
        if i != j:
            ans += A[i]*A[j]

print(ans%mod)

### FIXED CODE ###

mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

#累積和のリストを作成
S = [0]*(N+1)
ans = 0
for i in range(N):
    S[i+1] = A[i] + S[i]%mod

#累積和って感じですね
for i in range(N):
    sum = S[N] - S[i + 1]
    if sum < 0:
        sum += mod
    ans += A[i] * sum

print(ans % mod)
### BUGGY CODE ###

def scoring(T):
    score = 0
    last = [0] * 26
    for d, t in enumerate(T, 1):
        score += S[d - 1][t - 1]
        last[t - 1] = d
        for c, l in zip(C, last): score -= c * (d - l)
    return score

D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input()) for _ in range(D)]
M = int(input())
for _ in range(M):
    d, q = map(int, input().split())
    T[d - 1] = q
    print(scoring(T))

### FIXED CODE ###

from bisect import bisect_left

D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input()) for _ in range(D)]
days = [[0] for _ in range(26)]

def init():
    global T, days
    score = 0
    last = [0] * 26
    for d, t in enumerate(T, 1):
        score += S[d - 1][t - 1]
        last[t - 1] = d
        for c, l in zip(C, last): score -= c * (d - l)
        days[t - 1].append(d)
    for i in range(26): days[i].append(D+1)
    return score

def diff(d, q):
    global score, T, C, S, days
    p = T[d - 1]
    score += S[d - 1][q - 1] - S[d - 1][p - 1]
    idx_p = bisect_left(days[p - 1], d)
    bef_p, aft_p = days[p - 1][idx_p - 1], days[p - 1][idx_p + 1]
    del days[p - 1][idx_p]
    idx_q = bisect_left(days[q - 1], d)
    bef_q, aft_q = days[q - 1][idx_q - 1], days[q - 1][idx_q]
    days[q - 1].insert(idx_q, d)
    score += C[q - 1] * (d - bef_q) * (aft_q - d) - C[p - 1] * (d - bef_p) * (aft_p - d)
    T[d - 1] = q
    return score
    
score = init()
M = int(input())
for _ in range(M):
    d, q = map(int, input().split())
    print(diff(d, q))
### BUGGY CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

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

n=max(A)+5

#is_prime[i]にはi-1画素数か否かを示すboolが入る，[0]に1の素数判定がある．
is_prime = [True]*(n+1)
is_prime[0] = False

for i in range(2, n+1):
    if is_prime[i-1]:
        j = 2 * i
        while j <= n:
            is_prime[j-1] = False
            j += i

table = [ i for i in range(1, n+1) if is_prime[i-1]]
#print(table)


for i in range(N):
    a=A[i]
    for j in table:
        temp=0
        while a%j==0:
            a=a//j
            temp+=1
        lcm[j]=max(lcm[j],temp)
        if a==1 or j*j>A[i]:
            break
    if a!=1:
        lcm[a]=max(lcm[a],1)
                
        
l=1
for d in lcm.items():
    l*=pow(d[0],d[1])
    
ans=0
mod=10**9+7

for i in range(N):
    ans+=l//A[i]
    ans%=mod
    
print(ans%mod)

### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

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


for i in range(N):
    a=A[i]
    for j in range(2,a):
        temp=0
        while a%j==0:
            a=a//j
            temp+=1
        lcm[j]=max(lcm[j],temp)
        if a==1 or j*j>A[i]:
            break
    if a!=1:
        lcm[a]=max(lcm[a],1)
                
        
l=1
for d in lcm.items():
    l*=pow(d[0],d[1])
    

ans=0
mod=10**9+7

for i in range(N):
    ans+=l//A[i]
    
print(ans%mod)
### BUGGY CODE ###

X,K,D = map(int,input().split())

X = abs(X) 
cnt = 0

if X == 0:
    if K%2==0:
        ans = 0
    elif K%2==1:
        ans = D
else:
    while K > cnt:
        X = X - D
        cnt += 1
        if X<=0:
            if (K-cnt)%2 == 0:
                ans = abs(X)
                break
            elif (K-cnt)%2 == 1:
                ans = abs(X+D)
                break
        ans = X
               
print(abs(ans))

### FIXED CODE ###

X,K,D = map(int,input().split())

X = abs(X) 

if X >= K*D:
    ans = X-K*D
else:
    x = X//D 
    if (K - x)%2 == 0:
        ans = X - x*D
    else:
        ans = abs(X - x*D -D)

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


if __name__ == '__main__':
    n = int(input())
    l = list(map(int,input().split()))

    l = sorted(l, reverse=True)

    answer = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if l[i] < l[j] + l[k]:
                    answer += 1
                else :
                    break

    print(answer)


### FIXED CODE ###

import bisect

if __name__ == '__main__':
    n = int(input())
    l = list(map(int,input().split()))

    l = sorted(l)

    answer = 0
    for i in range(0,n):
        for j in range(i+1,n):
            k = bisect.bisect_left(l, l[i]+l[j])
            answer += max(0,k-(j+1))

    print(answer)
### BUGGY CODE ###

s = input()
Q = int(input())

f = 0

for _ in range(Q):
    q = input()
    if int(q[0]) == 1:
        f = abs(f-1)
        continue
    
    _, F, c = q.split()
    if f+int(F) % 2 == 1:
        s = c + s
    else:
        s = s + c
        
if f:
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

from queue import deque
s = deque([i for i in input()])
Q = int(input())
 
f = 0
 
for _ in range(Q):
    q = input()
    if int(q[0]) == 1:
        f = abs(f-1)
        continue
    
    _, F, c = q.split()
    if f+int(F) % 2 == 1:
        s.appendleft(c)
    else:
        s.append(c)
        
if f:
    print(''.join(reversed(s)))
else:
    print(''.join(s))
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
cnt = 0
for n in range(N):
    if n == 0:
        cnt += 1
    else:
        if P[n] <= min(P[:n]):
            cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
cnt = 0
res = float('Inf')
for n in range(N):
    if P[n] < res:
        res = P[n]
        cnt += 1
print(cnt)
### BUGGY CODE ###

N = int(input())
P = tuple(map(int, input().split()))

m = 0

for i in range(0, N, 1):
    if P[i] == min(P):
        m += 1
        break
    elif P[i] == min(P[:i+1]):
        m += 1

print(m)

### FIXED CODE ###

N = int(input())
P = tuple(map(int, input().split()))

pmin = P[0]

m = 1

for i in range(1, N, 1):
    if P[i] < pmin:
        pmin = P[i]
        m += 1

print(m)
### BUGGY CODE ###

import numpy as np 
N = int(input())
A = list(map(int, input().split()))
A =np.array(A,dtype=int)
id =np.arange(1,N+1)

count =0
for i in range(1,N+1):
    x1 = A +A[i-1]
    x2 = abs(id -i)
    count += np.count_nonzero(x1 -x2 ==0)     
print(count//2)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
l =[]
r =[]
for id,h in enumerate(A,start=1):
    r.append(id -h)
    l.append(id +h)

r_cou =Counter(r)
l_cou =Counter(l)
ans =[]
for i in l_cou.keys():
    ans.append(l_cou[i] *r_cou.get(i,0))

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

N, K = map(int, input().split())
H = tuple(map(int, input().split()))

table = [0] * N
for i in range(1, N):
    table[i] = min(abs(H[i] - H[j]) + table[j] for j in range(max(0, i - K), i))

print(table[N-1])

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64)

table = np.full(N + K, 10 ** 10, dtype=np.int64)
table[0] = 0

for i in range(1, N):
    table[i:i + K] = np.minimum(table[i:i + K], np.abs(H[i:i + K] - H[i - 1]) + table[i - 1])

print(table[N - 1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d

"""
import sys


from itertools import product

def solve(X, Y, Z, K, A, B, C):
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    while len(A)-1 * len(B)-1 * len(C)-1 > K and len(A) * len(B) * len(C) >= 10000:
        m = sorted([[A[0], 'a'], [B[0], 'b'], [C[0], 'c']])
        _, mi = m.pop(0)
        if mi == 'a':
            A.pop(0)
        elif mi == 'b':
            B.pop(0)
        else:
            C.pop(0)

    return sorted([sum(p) for p in product(A, B, C)], reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d

"""
import sys


from itertools import product

def solve(X, Y, Z, K, A, B, C):
    # TLE
    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]
    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

#coding:utf-8

n = int(input())
s = input()

count = 0
r, g, b = 0, 0, 0

for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    elif i == 'B':
        b += 1

count = r * g * b

for i in range(n-2):
    si = s[i]
    for j in range(i+1,n-1):
        sj = s[j]
        if si == sj:
            continue
        c_set = {'R','G','B'} - {si, sj}
        nk = 2 * j - i
        if not (2 * j - i) < n:
            continue
        if s[nk] in c_set:
            count -= 1

print("{}".format(count))

### FIXED CODE ###

#coding:utf-8

n = int(input())
s = input()

count = 0
r, g, b = 0, 0, 0

for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    elif i == 'B':
        b += 1

count = r * g * b

for i in range(n-2):
    si = s[i]
    for j in range(i+1,n-1):
        sj = s[j]
        nk = 2 * j - i
        if not nk < n:
            break
        snk = s[nk]
        if {si, sj, snk} == {'R','G','B'}:
            count -= 1

print("{}".format(count))
### BUGGY CODE ###

from collections import deque
import copy
import numpy as np

H, W = map(int, input().split())
maps = [[j=="#" for j in input()] for i in range(H)]
q = deque([(i, j) for i in range(H) for j in range(W) if maps[i][j]])

count = 0
for i in range(H*W):
  nq = deque()
  while len(q) > 0:
    x, y = q.popleft()
    if x > 0 and not maps[x-1][y]:
      maps[x-1][y] = True
      nq.append([x-1,y])
    if y > 0 and not maps[x][y-1]:
      maps[x][y-1] = True
      nq.append([x,y-1])
    if x < H-1 and not maps[x+1][y]:
      maps[x+1][y] = True
      nq.append([x+1,y])
    if y < W-1 and not maps[x][y+1]:
      maps[x][y+1] = True
      nq.append([x,y+1])
  if nq:
    q = copy.copy(nq)
  else:
      break
  count += 1
print(i)

### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy
 
def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)
 
if __name__ == "__main__":
  main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > pow(10, 18):
    print("-1")
else:
    print(ans)


### FIXED CODE ###


n = int(input())
a = list(map(int, input().split()))
ans = 1
a.sort()
if a[0] == 0:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > pow(10, 18):
        print(-1)
        exit()
else:
    print(ans)
### BUGGY CODE ###

import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())

    ok =0
    ng =N//2
    ans =0
    for i in range(N-1):
        for j in range(i+1,N):
            for k in range(0,min(j-i,N-j)):
                if S[i+k] != S[j+k]:
                    ans =max(ans,k)
                    break
            else:
                ans = max(ans,k+1)
    print(ans)







if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, q = map(int, input().split())
stx = [tuple(int(x) for x in input().split()) for _ in range(n)]
d = [int(input()) for _ in range(q)]

e = []

for s, t, x in stx:
    e.append([s-x, 1, x])
    e.append([t-x, -1, x])

e.sort()
e.append([10 ** 9, 1, 10 ** 9])

h = set()
h.add(10 ** 9)
i = 0

for p in d:
    while e[i][0] <= p:
        if e[i][1] == 1:
            h.add(e[i][2])
        else:
            h.remove(e[i][2])
        i += 1
    ans = min(h)
    if ans == 10 ** 9:
        print(-1)
    else:
        print(min(h))


### FIXED CODE ###

from bisect import bisect_left
from operator import itemgetter

n, q = map(int, input().split())
stx = [tuple(int(x) for x in input().split()) for _ in range(n)]
d = [int(input()) for _ in range(q)]

ans = [-1] * q
skip = [-1] * q

stx.sort(key=itemgetter(2))

for s, t, x in stx:
    L = bisect_left(d, s-x)
    R = bisect_left(d, t-x)
    while L < R:
        if skip[L] == -1:
            ans[L] = x
            skip[L] = R
            L += 1
        else:
            L = skip[L]

for x in ans:
    print(x)
### BUGGY CODE ###

N = int(input())
p_list  = list(map(int,input().strip().split(" ")))

c = 1

for i in range(1, N):
    mi = min(p_list[:i+1])
    if mi == p_list[i]:
        c += 1
        
print(c)


### FIXED CODE ###

N = int(input())
p_list  = list(map(int,input().strip().split(" ")))

ans = 1
mi = p_list[0]

for i in range(1, N):
    if mi >= p_list[i]:
        ans += 1
        mi = p_list[i]
        
print(ans)
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]
list.sort(S)
i = 0
y = []
MAX = 0
while i < N:
    a = S.count(S[i])
    if MAX < a:
        MAX = a
        y.clear()
        y.append(S[i])
    elif MAX == a:
        y.append(S[i])
    i+=a
for i in y:
    print(i)


### FIXED CODE ###

N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
Max = max(d.values())
keys = [k for k, v in d.items() if v == Max]
keys.sort()
for k in keys:
    print(k)