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

import sys
N, Ma, Mb = map(int, input().split())

a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
  a[i], b[i], c[i] = map(int, input().split())

M = 401
INF = 1000000000
dp = [ [ INF ] * 500 for _ in range(M) ]

dp[0][0] = 0
for k in range(N):
  for i in reversed(range(0, M)):
    for j in reversed(range(0, M)):
      if i + a[k] < M and j + b[k] < M:
        dp[i+a[k]][j+b[k]] = min(dp[i+a[k]][j+b[k]], dp[i][j] + c[k])

ans = INF
x = 1
while Ma * x < M and Mb * x < M:
  ans = min(ans, dp[Ma * x][Mb * x])
  x += 1
if ans >= INF:
  ans = -1
print(ans)


### FIXED CODE ###

N, Ma, Mb = map(int, input().split())

G = []
for i in range(N):
 a, b, c = map(int, input().split())
 G.append( (a,b,c) )

M = 1 + min(sum([ a for a, b, c in G ]),
            sum([ b for a, b, c in G ]) )
INF = 1000000000
dp = [INF] * (M * M)
dp[0] = 0
for a, b, c in G:
  i = M - a - 1
  while i >= 0:
    j = M - b - 1
    while j >= 0:
      dp[(i+a)*M+(j+b)] = min(dp[(i+a)*M+(j+b)], dp[i*M+j] + c)
      j -= 1
    i -= 1

ans = INF
x = 1
while Ma * x < M and Mb * x < M:
  ans = min(ans, dp[Ma * x * M + Mb * x])
  x += 1
if ans >= INF:
  ans = -1
print(ans)
### BUGGY CODE ###

temp=input()
S=list(temp)
counter1=0
counter2=0
counter3=0 
i=len(S)-1

while True:
    if S[i-1]=='B' and S[i]=='W':
        S[i-1]='W'
        S[i]='B'
        counter1 +=1
    i -=1
    if i ==0:
        if counter1==counter2:
            break
        counter2=counter1
        counter3+=1
        i=len(S) - counter3

print(counter1)

### FIXED CODE ###

S=input()
counter=0
result = 0

for i in range(len(S)):
    if S[i]=='B':
        counter+=1
    else:
        result +=counter

print(result)
### BUGGY CODE ###

import itertools
N=int(input())
L=list(map(int,input().split()))
ans=0
C = list(itertools.combinations(L, 3))
for i in range(len(C)):
  if C[i][0]<C[i][1]+C[i][2]:
    if C[i][0]+C[i][1]>C[i][2]:
      if C[i][1]<C[i][0]+C[i][2]:
        ans+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    idx=bisect.bisect_right(l,l[i]+l[j]-1,j+1)
    ans+=idx-(j+1)
print(ans)
### BUGGY CODE ###

# キャンディーとN人の子供

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


def rev(X):
    return pow(X, mod-2, mod)


pow_sum = [[B[i]-A[i]+1 for j in range(C+1)] for i in range(N)]
pow_table = [[1 for j in range(B[i]+1)] for i in range(N)]
for cnt in range(C):
    for i in range(N):
        pow_sum[i][cnt+1] = 0
        for j in range(A[i], B[i]+1):
            pow_sum[i][cnt+1] += pow(j, cnt+1, mod)
        pow_sum[i][cnt+1] %= mod

ans_dp = [[0 for i in range(C+1)] for j in range(N+1)]
# ans_dp[x][y] = 0<=x<=N,0<=y<=C の場合のdp
ans_dp[0][0] = 1
for n in range(1, N+1):
    # ans_dp[n]の更新
    for c in range(C+1):
        # ans_dp[n][c]の更新
        for k in range(c+1):
            ans_dp[n][c] += ans_dp[n-1][k]*pow_sum[n-1][c-k]
        ans_dp[n][c] %= mod
print(ans_dp[N][C] % mod)

### FIXED CODE ###

# キャンディーとN人の子供

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


def rev(X):
    return pow(X, mod-2, mod)


pow_sum = [[B[i]-A[i]+1 for j in range(C+1)] for i in range(N)]
pow_table = [[1 for j in range(401)] for i in range(401)]
for i in range(401):
    for j in range(401):
        pow_table[i][j] = pow(i, j, mod)

for cnt in range(C):
    for i in range(N):
        pow_sum[i][cnt+1] = 0
        for j in range(A[i], B[i]+1):
            pow_sum[i][cnt+1] += pow_table[j][cnt+1]
        pow_sum[i][cnt+1] %= mod

ans_dp = [[0 for i in range(C+1)] for j in range(N+1)]
# ans_dp[x][y] = 0<=x<=N,0<=y<=C の場合のdp
ans_dp[0][0] = 1
for n in range(1, N+1):
    # ans_dp[n]の更新
    for c in range(C+1):
        # ans_dp[n][c]の更新
        for k in range(c+1):
            ans_dp[n][c] += ans_dp[n-1][k]*pow_sum[n-1][c-k]
        ans_dp[n][c] %= mod
print(ans_dp[N][C] % mod)
### BUGGY CODE ###

n = int(input())
numbers = [ int(i) for i in input().split()]

result = 1
for i in range(n):
    result *= numbers[i]    

if result > 10**18:
    print(-1)
else:
    print(result)

### FIXED CODE ###

n = int(input())
numbers = [ int(i) for i in input().split()]
if 0 in numbers:
    print(0)
else:
    result = 1

    max = 10**18
    for i in range(n):
        result *= numbers[i]    
        if result > max:
            break


    if result > max:
        print(-1)
    else:
        print(result)
### BUGGY CODE ###

from itertools import count

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

d_cumsum = [0] * 60
for v in a:
    for i in count():
        d_cumsum[i] += v % 2
        v //= 2
        if v == 0:
            break

res = 0
mod = 10**9 + 7
for i, d in enumerate(d_cumsum):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)


### FIXED CODE ###

from itertools import count

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

d_cumsum = [0] * 60
for v in a:
    for i in count():
        d_cumsum[i] += v % 2
        v //= 2
        if v == 0:
            break

res = 0
mod = 10**9 + 7
for i, d in enumerate(d_cumsum):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)
### BUGGY CODE ###

def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = 0
const = 1000000007

n = i_in()
a = l_in(int)

for i in range(n):
    for j in range(n - i-1):
        ans += a[i]*a[i+j+1]

ans %= const
print(ans)


### FIXED CODE ###

def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
const = 1000000007
ans = 0

n = i_in()
a = l_in(int)

ins = 0
for i in range(1, n):
    ins += a[i-1]
    ans += ins * a[i]

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

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[[] for i in range(s+1)] for _ in range(n+1)]
B[0][0].append(0)
ans=0
for i in range(n):
  a=A[i]
  if a<=s:
    B[i+1][a]+=[i+1]
  for j in range(s+1):
    B[i+1][j]+=B[i][j]
    if j-a>=0 and B[i][j-a]:
      B[i+1][j]+=B[i][j-a]
    
  for aa in B[i+1][s]:
    ans+=aa
  ans%=mod
print(ans)

### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[0]*(s+1) for _ in range(n+1)]
ans=0
for i in range(n):
  a=A[i]
  if a<s:
    B[i+1][a]+=i+1
  elif a==s:
    B[i+1][a]+=(i+1)*(n-i)
  for j in range(s+1):
    if j<=s:
      B[i+1][j]+=B[i][j]
    if 0<=j-a and j<s:
      B[i+1][j]+=B[i][j-a]
    if 0<=j-a and j==s:
      B[i+1][j]+=B[i][j-a]*(n-i)
    B[i+1][j]%=mod
print(B[n][s])
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li,reverse=True)
cnt = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        if li2[i] > li2[j] + li2[j+1]:
            break
        else:
            for k in range(j+1,n):
                if li2[i] < li2[j]+li2[k]:
                    cnt += 1
                else:
                    break
print(cnt)

### FIXED CODE ###

import bisect

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li)
cnt = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        cnt += bisect.bisect_left(li2,li2[i]+li2[j]) - (j+1) 
print(cnt)
### BUGGY CODE ###

n, m = map(int, input().split())
A = [int(i) for i in input().split()]

L = []
for i in range(m):
    b,c = map(int, input().split())
    L.append((b,c))
    
A = sorted(A)

from bisect import bisect_left
import numpy as np
A = np.array(A)
for l in L:
    tmp0 = l[0]
    tmp1 = l[1]
    A_len = bisect_left(A, tmp1)
    if A_len >= tmp0:
        A = np.insert(A, A_len, [tmp1 for i in range(tmp0)])[tmp0:]
    else:
        A[0:A_len] = tmp1
        
print(sum(A))

### FIXED CODE ###

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

D = {}
for i in range(M):
    b,c = map(int, input().split())
    if c in D:
        D[c] += b
    else:
        D[c] = b
        
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1
        
D_sort = sorted(D.items(), reverse=True)
check = 0
ans = 0
for d in D_sort:
    check += d[1]
    if check <= N:
        ans += d[0] * d[1]
    else:
        ans += d[0] * (d[1] - (check - N))
        break
print(ans)
### BUGGY CODE ###

T = input()
ans = ''
for t in T:
    if t == '?':
        ans += 'D'
    else:
        ans += t
print(ans) 

### FIXED CODE ###

T = input()

for t in T:
    if t == '?':
        print('D', end='')
    else:
        print(t, end='')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Contents   : ARC D問題
Author     : Kitaura Hiromi
LastUpdate : 20180526
Since      : 20180526
"""

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(i+1, N+1):
        tmp = 0
        for k in range(i, j):
            tmp ^= A[k]
        # print("sum", sum(A[i:j]), "xor",  int(tmp))
        if sum(A[i:j]) == int(tmp):
            cnt += 1
        else:
            break
print(cnt)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Contents   : ARC D問題
Author     : Kitaura Hiromi
LastUpdate : 20180527
Since      : 20180526
"""
from operator import xor
from functools import reduce

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

cnt = 0
r = 0
tmp = 0
for l in range(N):
    while r < N and tmp & A[r] == 0:
        # 区間の右端の要素を足す
        tmp ^= A[r]
        r += 1
    # print(l, r)
    cnt += (r - l)
    # 区間の左端の要素を引く
    tmp ^= A[l]
print(cnt)
### BUGGY CODE ###

a,b,n=map(int,input().split())
res=int((a*1.0)/b)-a*int(1.0/b)
for x in range(2,n+1):
  res2=int((a*x*1.0)/b)-a*int(x*1.0/b)
  if res2>res:
    res=res2
print(res)

### FIXED CODE ###

a,b,n=map(int,input().split())
print(int(a*min(b-1,n)/b))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
l=len(format(max(A),'b'))
Z=[0]*l
for a in A:
  a=format(a,'b').zfill(l)
  for i,ai in enumerate(a):
    if ai=='0':
      Z[i]+=1
x=1
ans=0
for z in Z[::-1]:
  ans+=x*(z*(N-z))
  x*=2
print(ans%(10**9+7))

### FIXED CODE ###

import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
l=len(format(A.max(),'b'))
MOD=10**9+7

tei=1
ans=0
for i in range(l):
  B=(A >> i) & 1
  one=np.count_nonzero(B)
  zero=N-one
  ans+=tei*one*zero
  tei*=2
print(ans%MOD)
### BUGGY CODE ###

#coding:utf-8
n,m = map(int,input().split())
List = list(map(int,input().split()))


forest = [i for i in range(n+1)]
rank = [0 for i in range(n+1)]

def unite(x,y):
    while forest[x] != x:
        x = forest[x]
    a = rank[x]
    
    while forest[y] != y:
        y = forest[y]
    b = rank[y]
    
    if a <= b:
        if a == b:
            rank[x] += 1
        forest[y] = x
    else:
        forest[x] = y


def Find(x):
    if forest[x] != x:
        rank[x] = 1
        forest[x] = Find(forest[x])
        return forest[x]
    else:
        return x
    
    for xi in Q:
        forest[xi] = x
        rank[xi] = 1
    
    return x

    
cnt = 0
for i in range(m):
    x,y = map(int,input().split())
    unite(x,y)

for i in range(1,n+1):
    x = Find(i)
    y = Find(List[i-1])
    if x == y:
        cnt += 1
print(cnt)
    


### FIXED CODE ###

#coding:utf-8

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

class UnionFind3:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for i in range(size)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return 1
        return 0


cnt = 0
tree = UnionFind3(n)
for i in range(m):
    x,y = map(int,input().split())
    tree.union(x-1,y-1)

for i in range(n):
    a = tree.find(i)
    b = tree.find(List[i]-1)
    if a == b:
        cnt += 1

print(cnt)
### BUGGY CODE ###

s = input()
n = len(s)

ans = 0
for i in range(n-3):
    for j in range(i+3,n):
        if int(s[i:j+1]) % 2019 == 0:
            ans += 1
            break
print(ans)



### FIXED CODE ###

s = input()[::-1]
a = 0
cnt = [0]*2019
cnt[0] = 1
d = 1
for c in s:
    a += int(c) * d
    a %= 2019
    d *= 10
    d %= 2019
    cnt[a] += 1

#slist = [(s%(10**i))%2019 for i in range(n+1)]
#print(slist)


ans = 0
for i in range(2019):
    ans += cnt[i]*(cnt[i]-1)//2

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

n,q=map(int,input().split())
S=input()
l=[]
r=[]
for i in range(q):
  li,ri=map(int,input().split())
  l.append(li)
  r.append(ri)
ans=[]
for i in range(q):
  s=S[l[i]-1:r[i]]
  cnt=s.count('AC')
  print(cnt)



### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*(n)
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    a[i+1]=a[i]+1
  else:
    a[i+1]=a[i]
for i in range(q):
  l,r=map(int,input().split())
  ans=a[r-1]-a[l-1]
  print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())


mod=10**9+7

T=[1]
for a in A:
	W=[0]		#WA:累積和
	L=T
	l=len(L)
	for j,x in enumerate(L):
		if j==0:	W.append(x)
		else:	W.append( W[-1]+x )

	T=[]  #Temporary
	for k in range( min (K+1,a+l) ):
		#print k, min( k+1, l), max(0,k-a), W[min( k+1, l)]-W[max(0,k-a)]
		T.append( W[min( k+1, l)]-W[max(0,k-a)] )


try:
	print T[K]%mod
except IndexError:
	print 0

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())


mod=10**9+7

T=[1]
for a in A:
	W=[0]		#WA:累積和
	l=len(T)
	for j,x in enumerate(T):
		if j==0:	W.append( x%mod )
		else:	W.append( (W[-1]+x)%mod )

	T=[]  #Temporary
	for k in range( min (K+1,a+l) ):
		#print k, min( k+1, l), max(0,k-a), W[min( k+1, l)]-W[max(0,k-a)]
		T.append( W[min( k+1, l)]-W[max(0,k-a)] )


try:
	print T[K]%mod
except IndexError:
	print 0
### BUGGY CODE ###

import numpy as np
n=int(input())
s=input().split()
ans=1
for i in range(n):
    ans=ans*int(s[i])
if ans>np.power(10,18):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

import numpy as np
import sys
n=int(input())
s=input().split()
ans=1
d=1;
e=1
for i in s:
    if i=='0':
        e=0


for i in range(n):
    ans=ans*int(s[i])
    if ans>np.power(10,18):
        d=0
        break;

if d==0 and e==1:
    print(-1)
elif e==0:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

X = int(input())


def cal(x, c):
    if x == 0 or x % 100 == 0:
        print(1)
        exit()

    else:
        now = x - 100
        for i in range(1, 6):
            if now < i:
                return 0
            else:
                if c[i] > 19:
                    continue
                else:
                    cal(now-i, c[0:i:]+[c[i]+1]+c[i+1::])
    return 0


if X >= 2000:
    print(1)
else:
    print(cal(X, [0 for _ in range(6)]))

    

### FIXED CODE ###

X = int(input())
for c in range(X//100 + 1):
    if 100*c <= X and X <= 105*c:
        print(1)
        exit()

print(0)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())

a = list(map(int, input().split()))
a.sort()
a = tuple(a)
cnt = 0

for i in range(n):
    for j in range(i+1):
        if i != n-1 and a[i] == a[i+1]:
            cnt += 1
            break
        if i!=j and a[i]%a[j]==0:
            cnt += 1
            break

print(n-cnt)

### FIXED CODE ###

n = int(input())

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

c = [0] * (10**6+1)
for i in a:
    c[i] += 1

uni = []
a = list(set(a))

for i in a:
    if c[i] == 1:
        uni.append(i)

b = [0 for _ in range(10**6+1)]

for i in a:
    for j in range(i*2, 10**6+1, i):
        b[j] = 1

cnt = 0
for i in uni:
    if b[i] == 0:
        cnt += 1

print(cnt)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = min(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    print(solve(N, K, h))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = min(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]

N, K = map(int, sys.stdin.readline().rstrip().split())
h = list(map(int, sys.stdin.readline().rstrip().split()))
print(solve(N, K, h))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
k1,v1=c.most_common(2)[0]
while v1>1:
    if v1>2:
        c[k1]-=2
    else:
        k2,v2=c.most_common(2)[1]
        if v2>0:
            c[k1]-=1
            c[k2]-=1
    k1,v1=c.most_common(2)[0]
cnt=0
for k in c.keys():
    if c[k]==1:
        cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
from collections import Counter
import heapq
cou=Counter(a)
c=[]
for k in cou.keys():
    c.append((-cou[k], k))
heapq.heapify(c)
v1,k1=heapq.heappop(c)
while v1<-1:
    if v1<-2:
        v1+=2
        heapq.heappush(c, (v1,k1))
    else:
        v2,k2=heapq.heappop(c)
        if v2<0:
            v1+=1
            v2+=1
            heapq.heappush(c, (v1,k1))
            heapq.heappush(c, (v2,k2))
    v1,k1=heapq.heappop(c)
    #print(v1,k1,c)
c.append((v1,k1))
cnt=0
for v,k in c:
    if v==-1:
        cnt+=1
print(cnt)
### BUGGY CODE ###

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

dp = [[[0] * 8 for _ in range(M + 1)] for _ in range(N + 1)]

for i in range(1, N + 1):
    x, y, z = cake[i - 1]
    for j in range(1, M + 1):
        for msk in range(8):
            mx = x * (1 - 2 * (msk >> 2 & 1))
            my = y * (1 - 2 * (msk >> 1 & 1))
            mz = z * (1 - 2 * (msk >> 0 & 1))
            dp[i][j][msk] = max(dp[i - 1][j][msk],
                                dp[i - 1][j - 1][msk] + mx + my + mz)

print(max(dp[N][M][i] for i in range(8)))

### FIXED CODE ###

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

INF = 10 ** 18
dp = [[[-INF] * 8 for _ in range(M + 1)] for _ in range(N + 1)]
for i in range(N + 1):
    for msk in range(8):
        dp[i][0][msk] = 0

for i in range(1, N + 1):
    x, y, z = cake[i - 1]
    for j in range(1, M + 1):
        for msk in range(8):
            mx = x * (1 - 2 * (msk >> 2 & 1))
            my = y * (1 - 2 * (msk >> 1 & 1))
            mz = z * (1 - 2 * (msk >> 0 & 1))
            dp[i][j][msk] = max(dp[i - 1][j][msk],
                                dp[i - 1][j - 1][msk] + mx + my + mz)

print(max(dp[N][M][i] for i in range(8)))
### BUGGY CODE ###

n = int(input())

alist = input().split(" ")

aint = []

for i in range(n-1):
    aint.append(int(alist[i]))

for i in range(1, n+1):
    co = aint.count(i)
    print(co)

### FIXED CODE ###

n = int(input())

alist = input().split(" ")

aint = []

sumlist = []

for i in range(n-1):
    aint.append(int(alist[i]))

for i in range(n):
    sumlist.append(0)

for i in aint:
    sumlist[i-1] = sumlist[i-1]+1

for i in sumlist:
    print(i)
### BUGGY CODE ###

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

### FIXED CODE ###

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

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)
### BUGGY CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	count = 0
	while count==0:
		for i in range(n):
			if  a.count(a[i])> 1:
				count+=1
				print('NO')
				break
	if count==0:
		print('YES')
main()

### FIXED CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	a.sort()
	c=0
	for i in range(n-1):
		if a[i] == a[i+1]:
			print('NO')
			c+=1
			break
	if c==0:
		print('YES')
main()
### BUGGY CODE ###

import numpy as np
S = input()
mod = 1000000007

n = len(S)
a = S[-1]
x = np.zeros(26, int)
l = [[13 - i * j % 13 for j in range(0, 10)] for i in [1, 10, 9, 12, 3, 4]] * (n // 6 + 1)
if a == "?":
    x[0:10] += 1
else:
    x[int(a)] += 1
for s, l_ in zip(S[-2::-1], l[1:]):
    x[13:] = x[:13]
    if s == "?":
        x[:13] = sum([x[v:v+13] for v in l_])
    else:
        v = l_[int(s)]
        x[:13] = x[v:v+13]
    x %= mod
print(x[5])

### FIXED CODE ###

#!python3

LI = lambda: list(map(int, input().split()))

# input
S = input()

MOD = 10 ** 9 + 7


def main():
    n = len(S)
    m = 5
    w = []
    p = 1
    for i in range(n):
        s = S[-1 - i]
        if s == "?":
            w.append(p)
        else:
            m = (m - int(s) * p) % 13
        p = p * 10 % 13

    n = len(w)
    l1 = [0] * 13
    l1[0] = 1
    for i in range(1, n + 1):
        l2 = [0] * 13
        for j in range(10):
            x = w[i - 1] * j % 13
            for k in range(13):
                t = (x + k) % 13
                l2[t] += l1[k]
        l1 = [y % MOD for y in l2]
    
    ans = l1[m]
    print(ans)


if __name__ == "__main__":
    main()