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

from scipy.sparse import coo_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np

N,M = map(int,input().split())
#V=[[] for _ in range(N)]
row=[]
col=[]
data=[1]*(2*M)
for _ in range(M):
    a,b = map(int, input().split())
    row.append(a-1)
    col.append(b-1)
    row.append(b-1)
    col.append(a-1)

s=0
graph=coo_matrix((data, (row, col)), shape=(N,N))
dist_matrix,predecessors = dijkstra(csgraph=graph, directed=False, indices = s, unweighted=True, return_predecessors=True)
#print(dist_matrix)
#print(predecessors)
print('Yes')
print(*[e+1 for e in predecessors[1:]],sep='\n')

### FIXED CODE ###

from collections import deque

N,M = map(int,input().split())
V=[[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    V[a-1].append(b-1)
    V[b-1].append(a-1)
state=[0]*N
q=deque()
ans=[0]*(N)

state[0]=1
q.append(0)
while len(q) > 0:
    v=q.popleft()
    for u in V[v]:
        if state[u]==0:
            state[u]=1
            ans[u]=v+1
            q.append(u)
print('Yes')
print(*ans[1:],sep='\n')
### BUGGY CODE ###

import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    S = sc.strarr()[0]

    array = []
    for i in range(N):
        for j in range(i+1, N):
            Marray = []
            for m in range(j+1, N):
                Marray.append(S[m])
                Marray = list(set(Marray))
                if len(Marray) == 10:
                    break
                num = S[i] + S[j] + S[m]
                array.append(num)
                if len(array) >= 1000:
                    array = list(set(array))
                    if len(array) == 999:
                        print("999")
                        return
    array = set(array)
    print(len(array))


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    _ = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0

    for i in range(1000):
        # print("--------")
        lucky = format_str(i)
        first = S.find(lucky[0])
        third = S.rfind(lucky[2])

        if first == -1 or third == -1:
            continue
        elif first < third:
            if lucky[1] in S[first + 1:third]:
                count += 1
    print(count)


def format_str(num):
    if num < 10:
        return "00" + str(num)
    elif num < 100:
        return "0" + str(num)
    else:
        return str(num)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()
### BUGGY CODE ###



n, w = map(int, raw_input().split())
items = []
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))

dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    wi, vi = items[i - 1]
    for j in range(1, w + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if j >= wi:
            dp[i][j] = max(dp[i][j], vi + dp[i - 1][j - wi])
print(dp[n][w])


### FIXED CODE ###


n, w = map(int, raw_input().split())
items = []
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))

dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    wi, vi = items[i - 1]
    for j in range(1, w + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if j >= wi:
            dp[i][j] = max(dp[i][j], vi + dp[i - 1][j - wi])
print(dp[n][w])
### BUGGY CODE ###

S = list(input())
c=0
while True:
  if S[0] == 'W':
    oku = 'B'
  else:
    oku = 'W'
  S.insert(0,oku)
  S[1] = oku
  isbreak = False
  for i in range(2,len(S)):
    if S[i] != oku:
      S[i] = oku
    else:
      isbreak = True
      break
      
  if not isbreak:
    break
  c+=1
print(c)
   

### FIXED CODE ###

S = list(input())
c=0
first = S[0]
for i in range(1,len(S)):
  if S[i] != first:
    c+=1
    first = S[i]
print(c)
### BUGGY CODE ###

n = int(input())
l = [int(input()) for _ in range(n)]
m = l.copy()
m = m[::-1]

for i in range(len(l)):
    num = m.pop()
    print(max(m))
    m.insert(0, num)

### FIXED CODE ###

n = int(input())
l = [int(input()) for _ in range(n)]
max_num = max(l)
second_num = sorted(l)[-2]

for i in range(n):
   if l[i] == max_num:
       print(second_num)
   else:
       print(max_num)
### BUGGY CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

q = 3 if S[0] == '?' else 1
a = b = c = 0
if S[0] in 'A?':
    a = 1
for i, s in enumerate(S[1:], 1):
    if s == '?':
        c = c * 3 + b
        b = b * 3 + a
        a = a * 3 + q
        q *= 3
    elif s == 'A':
        a += q
    elif s == 'B':
        b += a
    elif s == 'C':
        c += b

ans = c % MOD
print(ans)

### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MOD
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = (dp[0] * 3) % MOD

ans = dp[-1] % MOD

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

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

max_count = 0

for X in range(1, 10**5):
    count = 0
    for i in A:
        if X-1 <= i <= X+1:
            count += 1
        if count > max_count:
            max_count = count

print(max_count)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A_count = [0] * (max(A)+1)

for i in A:
    A_count[i] += 1

max_count = 0
if len(A_count) < 4:
    print(sum(A_count))
else:
    for X in range(1, len(A_count)-1):
        count = A_count[X-1] + A_count[X] + A_count[X+1]
        if count > max_count:
            max_count = count
    print(max_count)
### BUGGY CODE ###

import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*M
C=[0]*M
D=[]
for i in range(M):
    B[i],C[i]=map(int,input().split())
    D+=[C[i]]*B[i]
D=np.sort(D)[::-1]
A = np.sort(A)

for i in range(sum(B)):
    if A[i] < D[i]:
        A[i]=D[i]
    else:
        break
    if i==N-1:
        break
print(sum(A))      




### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
count_b = 0

for a in a_list:
    if count_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            s += a
            continue
        count_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        s += c
    else:
        s += a
    count_b += 1

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

import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

inf = float('inf')

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

    K = N//2
    DP = [[-inf] * (K)  for _ in range(N)]

    DP[0][0] = A[0]
    DP[1][0] = max(A[0], A[1])
    for i in range(2, N):
        i2 = i+1
        start = max(0, i2//2 - 1)
        end = min((i2 + 1)//2, K)
        for j in range(start, end):
            if j == 0:
                DP[i][j] = max(A[i], DP[i-1][j])
            else:
                DP[i][j] = max(DP[i-2][j-1] + A[i], DP[i-1][j])

    ans = DP[N-1][K-1]
    #print(DP)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

inf = float('inf')
#inf = pow(10, 10)

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

    K = N//2
    DP0 = [-inf] * N
    DP1 = [-inf] * N
    DP2 = [-inf] * N

    DP2[0] = A[0]
    DP2[1] = max(A[0], A[1])
    DP1[:2] = [0] * 2
    DP0[:4] = [0] * 4
    for i in range(2, N):
        if i%2 == 0:
            DP2[i] = DP2[i-2] + A[i]
            DP1[i] = max(DP2[i-1], DP1[i-2] + A[i])
            DP0[i] = max(DP1[i-1], DP0[i-2] + A[i])
        else:
            DP2[i] = max(DP2[i-2] + A[i], DP2[i-1])
            DP1[i] = max(DP1[i-1], DP1[i-2] + A[i])
            DP0[i] = max(DP0[i-1], DP0[i-2] + A[i])

    if N%2 == 0:
        ans = DP2[N-1]
    else:
        ans = DP1[N-1]

    #print(DP0)
    #print(DP1)
    #print(DP2)
    print(ans)


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

n,k=map(int,input().split())
k_list=[]

for i in range(k):
    l,r=map(int,input().split())
    k_list.append([l,r])

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

for i in range(1,n):
    dpsum[i]=dp[i]+dpsum[i-1]
    for j in range(k):
        l,r=k_list[j]
        li=i+l
        ri=i+r+1
        if li<=n:
            dp[li]+=dpsum[i]
        if ri<=n:
            dp[ri]-=dpsum[i]

print(dp[n]%998244353)


### FIXED CODE ###

n,k=map(int,input().split())
k_list=[]

for i in range(k):
    l,r=map(int,input().split())
    k_list.append([l,r])

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

for i in range(1,n):
    dpsum[i]=dp[i]+dpsum[i-1]
    for j in range(k):
        l,r=k_list[j]
        li=i+l
        ri=i+r+1
        if li<=n:
            dp[li]+=dpsum[i]
            dp[li]=dp[li]%998244353
        if ri<=n:
            dp[ri]-=dpsum[i]
            dp[ri]=dp[ri]%998244353

print(dp[n])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

from collections import Counter

C=Counter(A)

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

MAX=LIST[-1]

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

        BASESUM+=LIST[-k]

        REST=SUM-BASESUM
        REST0=REST

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

        if LIST[-1]*k-BASESUM<=REST:
            sys.stdout.write(str(SUM//k)+"\n")
            continue

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

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

            #print(MAX,MIN,mid,REST)

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

        sys.stdout.write(str(MIN)+"\n")


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

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

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

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

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

H, W, K = map(int, input().split())
A = [[0] * W for _ in range(H)]
for i in range(K):
    y, x, v = map(int, input().split())
    A[y - 1][x - 1] = v
dp = [[[0] * 4 for i in range(W)] for j in range(H)]
dp[0][0][1] = A[0][0]
for i in range(H):
    for j in range(W):
        for k in range(4):
            if i:
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + A[i][j])
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k])
            if j:
                if k < 3:
                    dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j - 1][k] + A[i][j])
                dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k])
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, max(dp[i][j]))
print(ans)


### FIXED CODE ###

H, W, K = map(int, input().split())
A = [[0] * W for _ in range(H)]
for i in range(K):
    y, x, v = map(int, input().split())
    A[y - 1][x - 1] = v
dp = [[0] * 4 for i in range(W)]
pre = []
dp[0][1] = A[0][0]
for i in range(H):
    for j in range(W):
        for k in range(4):
            if i:
                if k == 1:
                        dp[j][k] = max(dp[j][k], max(pre[j]) + A[i][j])
                if k == 0:
                        dp[j][k] = max(dp[j][k], max(pre[j]))
            if j:
                if 0 < k:
                    dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + A[i][j])
                dp[j][k] = max(dp[j][k], dp[j - 1][k])
    pre = dp
ans = 0
for j in range(W):
    ans = max(ans, max(dp[j]))
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
a_l = list(map(int, input().split()))
base = set(a_l)
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    for idx, v in enumerate(base):
        ans.append(a_l.count(v))
    print(sum(sorted(ans)[:num]))

### FIXED CODE ###

n, k = map(int, input().split())
a_l = sorted(list(map(int, input().split())))
base = list(set(a_l))
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    c_idx = 1
    c_num = a_l[0]
    for idx, v in enumerate(a_l[1:]):
        if c_num == v:
            c_idx += 1
            continue
        else:
            ans.append(c_idx)
            c_idx = 1
            c_num = v
    ans.append(c_idx)

    print(sum(sorted(ans)[:num]))
### BUGGY CODE ###

from math import factorial

x, y = map(int, input().split())

if (x + y) % 3 or (x > y * 2) or (x * 2 < y):
  print(0)
else:
  a = (x + y) // 3
  b = (a - abs(x - y)) // 2
  c = 1
  for x in range(a, a-b, -1):
    c *= x
  print(c // factorial(b) % (10**9+7))

### FIXED CODE ###

x, y = map(int, input().split())

if (x + y) % 3 or (x > y * 2) or (x * 2 < y):
  print(0)
else:
  MOD = 10 ** 9 + 7
  MAX = 10 ** 6

  fac = [1] * MAX
  inv = [1] * MAX
  finv = [1] * MAX
  for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = (- inv[MOD % i] * (MOD // i)) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

  def com(n, k):
    if n < 0 or k < 0:
      return 0
    if n < k:
      return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

  a = (x + y) // 3
  b = (a - abs(x - y)) // 2
  print(com(a, b))
### BUGGY CODE ###

n = int(input())
L =[]
for i in range(n):
    x = int(input())
    L.append(x)

m = L[1]-L[0]

for x in range(n-1):

    for i in range(x,n-1):

        if m <= L[i+1]-L[x]:
            m = L[i+1]-L[x]
        else:
            pass

print (m)

### FIXED CODE ###

n = int(input())
L =[]
for i in range(n):
    x = int(input())
    L.append(x)

ma = L[1]-L[0]
mi = L[0]
for x in range(n-1):
    ma = max([ma,L[x+1]-mi])
    mi = min(mi,L[x+1])


print (ma)
### BUGGY CODE ###

def main2():
    N = int(input().strip())
    r_stack=[]
    stack=[]
    for n in input().split():
        n = int(n)
        if len(r_stack)==0:
            stack.append(n)
            r_stack.append(n)
        elif len(r_stack)%2!=0:
            stack.append(n)
            r_stack.insert(0,n)
        else:
            stack.insert(0,n)
            r_stack.append(n)
    if N % 2 ==0:
        print(*r_stack)
    else:
        print(*stack)

if __name__ == "__main__":
    main2()

### FIXED CODE ###

from collections import deque
def main3():
    d = deque()
    rd= deque()
    N = int(input().strip())
    for n in input().split():
        if len(rd)%2!=0:
            d.append(n)
            rd.appendleft(n)
        else:
            rd.append(n)
            d.appendleft(n)
    if N % 2 ==0:
        print(*rd)
    else:
        print(*d)

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

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n

for i in range(1, n):
    res = float("inf")
    for j in range(1, min(i, k)+1):
        res = min(res, abs(h[i] - h[i-j]) + dp[i-j])
    dp[i] = res

print(dp[n-1])


### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n

for i in range(1, n):
    res = float("inf")
    for j in range(1, min(i, k)+1):
        res = min(res, abs(h[i] - h[i-j]) + dp[i-j])
    dp[i] = res

print(dp[n-1])
### BUGGY CODE ###

X, Y, A, B, C = list(map(lambda x: int(x) ,input().split(" ")))
li = []
p = list(map(lambda x: int(x) ,input().split(" ")))
q = list(map(lambda x: int(x) ,input().split(" ")))
r = list(map(lambda x: int(x) ,input().split(" ")))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]

for j, y  in enumerate(r):
  for i, x in enumerate(p):
    if x > y:
      continue
    p[i] = y
    r[j] = x
for j, y  in enumerate(r):
  
  for i, x in enumerate(q):
    if x > y:
      continue
    q[i] = y
    r[j] = x
print(sum(p) + sum(q))



### FIXED CODE ###

X, Y, A, B, C = list(map(lambda x: int(x) ,input().split(" ")))
li = []
p = list(map(lambda x: int(x) ,input().split(" ")))
q = list(map(lambda x: int(x) ,input().split(" ")))
r = list(map(lambda x: int(x) ,input().split(" ")))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]
r.extend(p)
r.extend(q)
r.sort(reverse=True)
print(sum(r[:X+Y]))
### BUGGY CODE ###

r, g, b, n = map(int, input().split())

li = [r, g, b]
li.sort(reverse=True)

num_max_0 = n//li[0]
num_max_1 = n//li[1]
ans = 0
for num_0 in range(num_max_0 + 1):
    for num_1 in range(num_max_1 + 1):
        ball_2 = n - num_0*li[0] - num_1*li[1]
        if ball_2 >= 0 and ball_2 % li[2] == 0:
            ans += 1
print(ans)

### FIXED CODE ###

r, g, b, n = map(int, input().split())

num_max_r = n//r

ans = 0
for num_r in range(num_max_r + 1):
    
    n_r = n - num_r*r
    num_max_g = n_r//g
    
    for num_g in range(num_max_g + 1):
        n_r_g = n_r - num_g*g
        
        if n_r_g >= 0 and n_r_g % b == 0:
            ans += 1

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

n = int(input())
l = list(map(int,input().split()))
ans = [str(l.index(i)+1) for i in range(1,n+1)]
print(' '.join(ans))

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
n = [i for i in range(1,n+1)]
d = dict(zip(l,n))
print(' '.join(map(str,list(d.values()))))
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
K = 0
ans = 0

for i in range(N):
    k = a.pop(0)
    if k == K + 1:
        K = k
    else:
        ans += 1

if K == 0:
    ans = -1

print(ans)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
K = 0
ans = 0

for i in range(N):
    k = a[i]
    if k == K + 1:
        K = k
    else:
        ans += 1

if K == 0:
    ans = -1

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

from fractions import gcd
  
a, b = map(int, input().split())
max_d = gcd(a, b)
li = []
for i in range(2, max_d + 1):
  if a % i == 0 and b % i == 0:
    if len(li) == 0:
      li.append(i)
    else:
      ap = 0
      for l in li:
        if i % l == 0:
          ap = 1
          break
      if ap == 0:
        li.append(i)
    
print(len(li) + 1)

### FIXED CODE ###

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
a, b = map(int, input().split())
la = prime_decomposition(a)
lb = prime_decomposition(b)
la_lb_and = list(set(la) & set(lb))
    
print(len(la_lb_and) + 1)
### BUGGY CODE ###

N,Ma,Mb=map(int,input().split())
a=[0 for k in range(N)]
b=[0 for k in range(N)]
c=[0 for k in range(N)]
import copy
for k in range(N):
    a[k],b[k],c[k]=map(int,input().split())
Sa=sum(a)
Sb=sum(b)
dp =[[5000 for k in range(Sb+1)]for k in range(Sa+1)]
dp[0][0]=0
for k in range(N):
    listj=[]
    listl=[]
    co=copy.deepcopy(dp)
    for j in range(Sa-a[k]+1):
        for l in range(Sb-b[k]+1):
            if dp[j][l]!=5000:
                listj.append(j)
                listl.append(l)
    for m in range(len(listl)):
        dp[listj[m]+a[k]][listl[m]+b[k]]=min(co[listj[m]][listl[m]]+c[k], co[listj[m]+a[k]][listl[m]+b[k]])
ans=[5000]
for k in range(1, min(Sa//Ma,Sb//Mb)+1):
    ans.append(dp[Ma*k][Mb*k])
if min(ans)==5000:
    print(-1)
else:
    print(min(ans))

### FIXED CODE ###

N,Ma,Mb=map(int,input().split())
a=[0 for k in range(N)]
b=[0 for k in range(N)]
c=[0 for k in range(N)]
import copy
for k in range(N):
    a[k],b[k],c[k]=map(int,input().split())
Sa=sum(a)
Sb=sum(b)
dp =[[[5000 for k in range(Sb+1)]for k in range(Sa+1)]for k in range(N+1)]
dp[0][0][0]=0
for k in range(N):
    listj=[]
    listl=[]
    for j in range(Sa-a[k]+1):
        for l in range(Sb-b[k]+1):
            if dp[k][j][l]!=5000:
                listj.append(j)
                listl.append(l)
    for m in range(len(listl)):
        dp[k+1][listj[m]+a[k]][listl[m]+b[k]]=min(dp[k][listj[m]][listl[m]]+c[k], dp[k][listj[m]+a[k]][listl[m]+b[k]])
        dp[k+1][listj[m]][listl[m]]=min(dp[k][listj[m]][listl[m]], dp[k+1][listj[m]][listl[m]])
ans=[5000]
for k in range(1, min(Sa//Ma,Sb//Mb)+1):
    ans.append(dp[-1][Ma*k][Mb*k])
if min(ans)==5000:
    print(-1)
else:
    print(min(ans))
### BUGGY CODE ###

mod = 998244353

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

a.sort()

while a[-1] > s:
    a.pop(-1)
    if a == []:
        print(0)
        exit()

dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    newdp = [2 * j % mod for j in dp]
    for j in range(s - i + 1):
        newdp[j+i] += dp[j]
    dp = newdp

print(dp[s] * pow(2, n - len(a), mod) % mod)

### FIXED CODE ###

mod = 998244353

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

a.sort()

while a[-1] > s:
    a.pop(-1)
    if a == []:
        print(0)
        exit()

su = sum(a)
if su < s:
    print(0)
    exit()
if su == s:
    print(pow(2, n - len(a), mod))
    exit()

dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    newdp = [2 * j for j in dp]
    for j in range(s - i + 1):
        newdp[j+i] += dp[j]
    dp = newdp

print(dp[s] * pow(2, n - len(a), mod) % mod)
### BUGGY CODE ###

def prepare(n, MOD):

    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


k = int(input())
s = input()
length = len(s)
MOD = 10**9 + 7

fact, inv = prepare(k + length, MOD)

ans = 0

for i in range(length, length + k + 1):
    coef = fact[i - 1] * inv[i - length] * inv[length - 1] % MOD
    ans += coef * pow(25, i - length, MOD) * pow(26, length + k - i, MOD) % MOD

print(ans % MOD)

### FIXED CODE ###

def solve(k, length, MOD, div, dp):
    for i in range(1, k + 1):
        dp[0] = dp[0] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
        dp[1] = (dp[1] + dp[0]) % MOD

    return(dp[1])


k = int(input())
s = input()
length = len(s)
MOD = 10**9 + 7
div = pow(26, -1, MOD)

dp = [pow(26, k, MOD)] * 2

print(solve(k, length, MOD, div, dp))