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

num = int(input())
emp = []
for i in range(num):
   string = input()
   emp.append(string)
   string = ""
d = {i:emp.count(i) for i in emp}

maximum = max(d.values())
keys = [key for key, value in d.items() if value == maximum]
keys.sort()
for i in keys:
   print(i)


### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
### BUGGY CODE ###

import sys
N = int(input())
A = [int(i) for i in input().split()]
for i,a in enumerate(A):
    if a in A[i+1:]:
        print("NO")
        sys.exit(0)
print("YES")

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def test(A):
    return len(A)!= len(set(A))
if test(A)==False:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  tf=[1]*n
  n=n-1
#r=[]
#print(n)
#print(a)
  #notdiv=True
  #firstyn=0
  for i in range(n,-1,-1):
  #print(i)
  #notdiv=True
    if tf[i] ==0:
      continue
    for j in range(i):
    #print(a[j])
      if a[i]%a[j] == 0:
        tf[i]=0
        if a[i]==a[j]:
          tf[j]=0
        break
  print(sum(tf))
main()

### FIXED CODE ###

def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()
### BUGGY CODE ###


import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

H, W = read_values()
def f(F, h, w):
    S = deque()
    S.append((h, w))
    P = {(h, w)}
    res = 0
    while S:
        h, w = S.popleft()
        for hh, ww in [(h + 1, w), (h - 1, w), (h, w + 1), (h, w - 1)]:
            if not (0 <= hh < H and 0 <= ww < W):
                continue
            if (hh, ww) in P:
                continue
            if F[hh][ww] == F[h][w]:
                continue
            P.add((hh, ww))
            res += 1 if F[hh][ww] == "." else 0
            S.append((hh, ww))
    return res


def main():
    F = [input().strip() for i in range(H)]
    
    res = 0
    for h in range(H):
        for w in range(W):
            if F[h][w] == "#":
                res += f(F, h, w)
    print(res)
    

if __name__ == "__main__":
    main()



### FIXED CODE ###


import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

H, W = read_values()
P = [[False for _ in range(W)] for _ in range(H)]
F = [input().strip() for i in range(H)]

def f(h, w):
    S = deque()
    S.append((h, w))
    P[h][w] = True
    T = [0, 1]
    while S:
        h, w = S.popleft()
        for hh, ww in [(h + 1, w), (h - 1, w), (h, w + 1), (h, w - 1)]:
            if not (0 <= hh < H and 0 <= ww < W):
                continue
            if P[hh][ww]:
                continue
            if F[hh][ww] == F[h][w]:
                continue
            P[hh][ww] = True
            t = 0 if F[hh][ww] == "." else 1
            T[t] += 1
            S.append((hh, ww))
    return T[0] * T[1]


def main():
    res = 0
    for h in range(H):
        for w in range(W):
            if P[h][w] or F[h][w] != "#":
                continue
            res += f(h, w)
    print(res)
    

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

n, m = map(int, input().split())
s = [int(input()) for _ in range(m)]
s.append(n + 1)

dp = [0] * (n + 1)
dp[0] = 1

for i in range(1, n + 1):
    if i not in s:
        x = dp[i - 1]
        if i > 1:
            x += dp[i - 2]
        x %= 10 ** 9 + 7
        dp[i] = x

print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
s = [int(input()) for _ in range(m)]
s.append(n+1)

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1

for i in range(n - 1):
    dp[i + 2] = dp[i + 1] + dp[i]
mae = 0
ans = 1
for i in s:
    if i == mae:
        ans=0
    else:
        ans *= dp[i - 1 - mae]

    mae = i + 1
print(ans % (10 ** 9 + 7))
### BUGGY CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        if A == B:
            break
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > 41:
        K = 41
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

tree=[[] for i in range(n)]
for a,b in l:
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

ans_num=0
for i in tree:
  ans_num=max(ans_num,len(i))

col=[[0] for i in range(n)]

que=deque()
que.append(0)

ans_dict={}
while que:
  x=que.popleft()

  c=1
  for i in tree[x]:
    if col[i]==[0]:
      que.append(i)

      while True:
        if c in col[x]:
          c+=1
        else:
          break

      col[x].append(c)
      col[i].append(c)
      ans_dict[(x+1,i+1)]=c
      ans_dict[(i+1,x+1)]=c

print(ans_num)
for i in l:
  print(ans_dict[tuple(i)])

### FIXED CODE ###

from collections import deque

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

tree=[[]for _ in range(n)]
for a,b in l:
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(b)

ans_num=0
for i in tree:
  ans_num=max(ans_num,len(i))

dq=deque()
dq.append((0,0))

seen=set()
seen.add(0)

ans_dict={}
while dq:
  x,color=dq.pop()

  i=0
  for nx in tree[x]:
    if nx in seen:
      continue

    i+=1
    if i==color:
      i+=1

    seen.add(nx)
    dq.append((nx,i)),
    ans_dict[x+1,nx+1]=i
    ans_dict[nx+1,x+1]=i

print(ans_num)
for i in l:
  print(ans_dict[tuple(i)])
### BUGGY CODE ###

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

s = (1000, 0, 0)
mmax = 1000

q = []
q.append(s)
while len(q) > 0:
    m,k,d = q.pop()
    if d == N-1:
        m += k*A[d]
        if mmax < m:
            mmax = m
    elif d == N-2:
        if A[d] > A[d+1]:
            if k > 0:
                q.append((m+k*A[d], 0, d+1))
            else:
                q.append((m,k,d+1))
        else:
            nk,nm = k,m
            if k > 0:
                nm = m + k * A[d]
                nk = 0
            if nm > A[d]:
                x = nm //A[d]
                q.append((nm-x*A[d], nk+x, d+1))
            else:
                q.append((m,k,d+1))
    else:
        q.append((m,k,d+1))
        if m > A[d]:
            x = m // A[d]
            nm = m-x*A[d]
            nk = k+x
            q.append((nm,nk,d+1))
        if k > 0:
            nm = m+k*A[d]
            q.append((nm, 0, d+1))
            x = nm // A[d]
            if x > 0:
                q.append((nm - x*A[d], x, d+1))
print(mmax)  


### FIXED CODE ###

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

m = 1000
k = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        m += k * A[i]
        k = 0
    elif A[i] < A[i+1]:
        m += k * A[i]
        k = m // A[i]
        m -= k * A[i]
    else:
        pass
m += (k * A[-1])
print(m)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))

N = int(input())
A = list(map(int, input().split()))
answer = 1
for i in range(N):
    answer *= A[i]

if answer > 1000000000000000000:
    print(-1)
else:
    print(answer)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
import sys
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    if A[i] == 0:
        print(0)
        sys.exit(0)
answer = 1
for i in range(N):
    answer *= A[i]
    if answer > 1000000000000000000:
       print(-1)
       sys.exit(0)

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

import fractions
import functools

MOD = int(1e9) + 7

def lcm(a, b):
    return a // fractions.gcd(a, b) * b


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x, MOD - 2)


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

v = functools.reduce(lcm, A)
ans = 0
for a in A:
    ans = (ans + v // a) % MOD
print(ans)

### FIXED CODE ###

import fractions
import functools

MOD = int(1e9) + 7


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x % MOD, MOD - 2)


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

MAX_A = 1000010

facts = [0] * MAX_A
p = [False] * MAX_A

def prime():

    for i in range(2, MAX_A):
        p[0] = p[1] = True
        if not p[i]:
            j = 2 * i
            while j < MAX_A:
                p[j] = True
                j += i

prime()

for a in A:
    i = 2
    while i * i <= a:
        if a % i == 0:
            ii = a // i
            c1 = 0
            while a % i == 0:
                c1 += 1
                a //= i
            c2 = 0
            while not p[ii] and a % ii == 0:
                c2 += 1
                a //= ii
            facts[i] = max(facts[i], c1)
            facts[ii] = max(facts[ii], c2)
        i += 1
    if not p[a]:
        facts[a] = max(facts[a], 1)

tar = 1
for idx, c in enumerate(facts):
    if c == 0:
        continue
    tar *= Inv.pow(idx, c)
    tar %= MOD

ans = 0
for a in A:
    ans += tar * Inv.inv(a) % MOD
    ans %= MOD

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

S = input()

N = len(S)
table = [-1] * N
T = [-1] * N
prev = 0
for i, s in enumerate(reversed(S)):
    prev += (int(s) * (10 ** i)) % 2019
    prev %= 2019
    T[i] = prev

DP = [0] * 2019
for t in T:
    DP[t] += 1

ans = DP[0]
for num in DP:
    ans += num * (num - 1) // 2

print(ans)

### FIXED CODE ###

S = input()

N = len(S)
table = [-1] * N
T = [-1] * N
prev = 0
for i, s in enumerate(reversed(S)):
    prev += (int(s) * pow(10, i, 2019)) % 2019
    prev %= 2019
    T[i] = prev

DP = [0] * 2019
for t in T:
    DP[t] += 1

ans = DP[0]
for num in DP:
    ans += num * (num - 1) // 2

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

e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[{0}for _ in range(w)]
dp[0]={a[0][0]-b[0][0],b[0][0]-a[0][0]}
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    t=set()
    if i:
      for v in dp[j]:
        t|={v+x-y}
        t|={v-x+y}
    if j:
      for v in dp[j-1]:
        t|={v+x-y}
        t|={v-x+y}
    if i+j:dp[j]=t
print(min(map(abs,dp[w-1])))

### FIXED CODE ###

e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[0]*w
c=13000
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    x=abs(x-y)
    if i==j==0:
      dp[j]=2**c<<x
      continue
    t=0
    if j:
      t|=dp[j-1]<<x
      t|=dp[j-1]>>x
    if i:
      t|=dp[j]<<x
      t|=dp[j]>>x
    dp[j]=t
*a,=map(int,(bin(dp[w-1])[2:]).zfill(26001))
print(min([i for i,f in e(a[13000:])if f]+[i for i,f in e(a[13000::-1])if f]))
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))
for i in range(n):
  b = a.pop(i)
  print(max(a))
  a.insert(i,  b)

### FIXED CODE ###

n = int(input())
d = []
for _ in range(n):
  d.append(int(input()))
a = sorted(d)
for i in range(n):
  if a[-1] == d[i]:
    print(a[-2])
  else:
    print(a[-1])
### BUGGY CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def binary_search(li,item):#二分探索
	left,right = 0, len(li)
	while left<=right:
		mid = (left+right)//2
		if li[mid]==item:
			return mid
		elif li[mid]<item:
			left = mid+1
		else:
			right = mid-1
	return -1

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
c=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])
for r in rgb["R"]:
	for g in rgb["G"]:
		if len(S)>2*max(r,g)-min(r,g) and S[2*max(r,g)-min(r,g)]=="B":
			s+=1
for r in rgb["R"]:
	for g in rgb["B"]:
		if len(S)>2*max(r,g)-min(r,g) and S[2*max(r,g)-min(r,g)]=="G":
			s+=1
for r in rgb["B"]:
	for g in rgb["G"]:
		if len(S)>2*max(r,g)-min(r,g) and S[2*max(r,g)-min(r,g)]=="R":
			s+=1

ans=c-s
print(ans)



### FIXED CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def binary_search(li,item):#二分探索
	left,right = 0, len(li)
	while left<=right:
		mid = (left+right)//2
		if li[mid]==item:
			return mid
		elif li[mid]<item:
			left = mid+1
		else:
			right = mid-1
	return -1

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
c=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])
for i in range(N):
	for j in range(i+1,N):
		k = 2*j-i
		if k>=N:
			continue
		if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
			s+=1

ans=c-s
print(ans)
### BUGGY CODE ###

import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

R,C,K = LI()
r,c,v = LIR(K,3)

a = [[0]*C for _ in range(R)]
for i in range(K):
    a[r[i]-1][c[i]-1] = v[i]

dp = [[[0]*4 for _ in range(C)] for _ in range(R)]
if a[0][0]:
    dp[0][0][1] = a[0][0]

for i in range(R):
    for j in range(C):
        for k in range(4):
            if i == j == 0:
                continue
            val1 = 0
            val2 = 0
            val3 = 0
            val4 = 0
            if j >= 1:
                val1 = dp[i][j-1][k]
            if k == 0 and i != 0:
                val2 = max(dp[i-1][j])
            if a[i][j] != 0:
                if k == 1 and i >= 1:
                    val3 = max(dp[i-1][j]) + a[i][j]
                if k >= 1 and j >= 1:
                    val4 = dp[i][j-1][k-1] + a[i][j]
            dp[i][j][k] = max(val1,val2,val3,val4)

print(max(dp[R-1][C-1]))

### FIXED CODE ###

import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

R,C,K = LI()
r,c,v = LIR(K,3)

def index(i,j,k):
    return k*C*R + i*C + j

a = [[0]*C for _ in range(R)]
for i in range(K):
    a[r[i]-1][c[i]-1] = v[i]

dp = [0]*(4*C*R)
dp[index(0,0,1)] = a[0][0]

for i in range(R):
    for j in range(C):
        if i == j == 0:
            continue
        upper_max = 0
        if i >= 1:
            for k in range(4):
                upper_max = max(upper_max,dp[index(i-1,j,k)])
        for k in range(4):
            val1 = 0
            val2 = 0
            val3 = 0
            val4 = 0
            if j >= 1:
                val1 = dp[index(i,j-1,k)]
            if k == 0 and i >= 1:
                val2 = upper_max
            if a[i][j] != 0:
                if k == 1 and i >= 1:
                    val3 = upper_max + a[i][j]
                if k >= 1 and j >= 1:
                    val4 = dp[index(i,j-1,k-1)] + a[i][j]
            dp[index(i,j,k)] = max(val1,val2,val3,val4)

ans = 0
for k in range(4):
    ans = max(ans,dp[index(R-1,C-1,k)])

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

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
c = [A.count(i + 1) for i in range(N)]
ans = [c[i] * (c[i] - 1) // 2 for i in range(N)]
Sum = sum(ans)

for val in A:
  m = c[val - 1] - 1
  print(Sum - m)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
c = [0 for i in range(N)]

for i in range(N):
  c[A[i] - 1] += 1

ans = [c[i] * (c[i] - 1) // 2 for i in range(N)]
s = sum(ans)

for val in A:
  m = c[val - 1] - 1
  print(s - m)
### BUGGY CODE ###

# D - RGB Triplets

def get_rgb():
	i = 1
	
	for s in S:
		if s == 'R':
			r_list.append(i)
		elif s == 'G':
			g_list.append(i)
		else:
			b_list.append(i)
		
		i += 1
# -----------------------------


N = int(input())
S = input()

r_list = []
g_list = []
b_list = []
get_rgb()

ans = 0

for r in r_list:
	for g in g_list:
		for b in b_list:
			list = [r, g, b]
			list.sort()
			i, j, k = list
			
			if j - i != k -j:
				ans += 1

print(ans)

### FIXED CODE ###

# D - RGB Triplets
	
N = int(input())
S = input()
	
r, g, b = 0, 0, 0
	
for s in S:
	if s == 'R':
		r += 1
	elif s == 'G':
		g += 1
	else:
		b += 1
	
ans = r * g * b
	
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		k = j * 2 - i
			
		if k < N:
			if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
				if j -i == k -j:
					ans -= 1
	
print(ans)
### BUGGY CODE ###

N = input()
inp = input()
listA = inp.split(' ')
out = 'YES'
for k in listA:
    count = 0
    for j in listA:
        if k == j:
            count += 1
            if count >= 2:
                out = 'NO'
                break
print(out)

### FIXED CODE ###

N = int(input())
inputA = input()
listA = inputA.split(' ')
listA.sort()
output = 'YES'
for i in range (len(listA) - 1):
    if listA[i] == listA[i + 1]:
        output = 'NO'
print(output)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n,ma,mb=MI()
	dp=[[10**6]*(n*10+15) for i in range(n*10+15)]
	for i in range(n+1):
		dp[0][0]=0

	for _ in range(n):
		a,b,c=MI()
		for aa in range(n*10+1,-1,-1):
			for bb in range(n*10+1,-1,-1):
				dp[a+aa][b+bb]=min(dp[aa][bb]+c,dp[a+aa][b+bb])

	ans=10**6

	for i in range(1,1000):
		try:
			ans=min(ans,dp[ma*i][mb*i])
		except:
			break

	print(ans if ans<10**6 else -1)





























if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n,ma,mb=MI()
	dp=[[10**6]*(n*10+15) for i in range(n*10+15)]
	for i in range(n+1):
		dp[0][0]=0

	for _ in range(n):
		a,b,c=MI()
		for aa in range(n*10+1,-1,-1):
			for bb in range(n*10+1,-1,-1):
				dp[a+aa][b+bb]=min(dp[aa][bb]+c,dp[a+aa][b+bb])

	ans=10**6

	for i in range(1,1000):
		try:
			ans=min(ans,dp[ma*i][mb*i])
		except:
			break

	print(ans if ans<10**6 else -1)





























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

import sys
input = sys.stdin.buffer.readline

N = int(input())
A = [int(i) for i in input().split()]
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    while m != 0:
        n, m = m, n % m
    return n

def lcm(n, m):
    return n * m // gcd(n, m)

L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for i, a in enumerate(A):
    ans += L // a
    if i == N // 2:
        ans %= MOD

print(ans % MOD)


### FIXED CODE ###

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(n, m):
    return n * m // gcd(n, m)

L = A[0]
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans += L // a

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

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

ans = 1

for i in range(N):
    ans *= A[i]

print(ans if ans <= 10**18 else '-1')



### FIXED CODE ###

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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 10**18:
            print(-1)
            return
    print(prod)

main()