Harryxun/stf_run huggingface dataset:
# ABC54 D
n,ma,mb = map(int, input().split())
a = []
b = []
c = []
for i in range(N):
    ai,bi,ci = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    
max_sum = n * 10
max_cost = 100000000
dp = [[[max_cost for k in range(n+1)] for j in range(max_sum+1)] for i in range(max_sum+1)]

dp[0][0][0] = 0
for i in range(n):
    for ca in range(max_sum+1):
        for cb in range(max_sum+1):
            if(dp[i][ca][cb] == max_cost):
                continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])

ans = max_cost
for ca in range(max_sum+1):
    for cb in range(max_sum+1):
        if(ca*mb == cb*ma):
            ans = min(ans, dp[n][ca][cb])

if(ans == max_cost):
    print(-1)
else:
    print(ans)

### FIXED CODE ###

# ABC54 D
n,ma,mb = map(int, input().split())
a = []
b = []
c = []
for i in range(n):
    ai,bi,ci = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    
max_sum = n * 10
max_cost = 100000000
dp = [[[max_cost for k in range(max_sum+1)] for j in range(max_sum+1)] for i in range(n+1)]

dp[0][0][0] = 0
for i in range(n):
    for ca in range(max_sum+1):
        for cb in range(max_sum+1):
            if(dp[i][ca][cb] == max_cost):
                continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])

ans = max_cost
for ca in range(1,max_sum+1):
    for cb in range(1,max_sum+1):
        if(ca*mb == cb*ma):
            ans = min(ans, dp[n][ca][cb])

if(ans == max_cost):
    print(-1)
else:
    print(ans)
n = int(input())
memo = [0]*1010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])

### FIXED CODE ###

n = int(input())
memo = [0]*10010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])
import copy
s=input()
check="keyence"
tmp=0
if check in s:
  print("YES")
  exit()
for i in s:
  if i == check[tmp]:
    tmp+=1
  else:
    break
tmp2=copy.copy(tmp)
for i in s[tmp:]:
  if i != check[tmp]:
    tmp2+=1
  else:
    break

if tmp2 == len(s):
  print("NO")
  exit()

for i in s[tmp2:]:
  if i == check[tmp]:
    tmp+=1
  else:
    print("NO")
    exit()
print("YES")

### FIXED CODE ###

import copy
s=input()
check="keyence"
tmp=6
sNow=0
cNow=0
#一度目のチェック
for i in s:
  sNow+=1
  if i == check[cNow]:
    cNow+=1
  else:
    break
#最初に見つかれば終了
if cNow == 7:
  print("YES")
  exit()

#print(check[cNow:], s[-1*(7-cNow):])
"""
sの最後が"keyence"の残りの文字と一致すればOK
例：keyaence
最初の"key"は合っているので，残りは"aence"の内"a"を除いたもの
cNow=3, 7-cNow=4
後ろの４文字が"ence"ならばYESとなる
"""
if check[cNow:] == s[-1*(7-cNow):]:
  print("YES")
else:
  print("NO")
import bisect
a,b=map(int,input().split())
c=list(map(int,input().split()))

if a not in c:
    print(a)
    exit()

n=[i for i in range(-1,101)]

m=sorted(list(set(n)^set(c)))
bisect.insort_right(m,a)

m=sorted(list(set(m)))
if len(m)<3:
    print(m[m.index(a)-1])

elif b==0:
    print(a)

elif a==100:
    print(m[m.index(a)+1])

elif abs(a-m[m.index(a)-1])<abs(a-m[m.index(a)+1]):
    print(m[m.index(a)-1])

elif abs(a-m[m.index(a)-1])==abs(a-m[m.index(a)+1]):
    print(m[m.index(a)-1])

else:
    print(m[m.index(a)+1])

### FIXED CODE ###

a,b=map(int,input().split())
c=list(map(int,input().split()))
ans=0
for i in range(100):
    if a-i not in c:
        ans=a-i
        break
    elif a+i not in c:
        ans=a+i
        break
print(ans)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
  A,B = map(int,input().split())
  uf.union(A,B)

print(uf.group_count()-1)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
  A,B = map(int,input().split())
  uf.union(A-1,B-1)

print(uf.group_count()-1)
a = [str(i) for i in input()]

if len(a) > 6:
	print("NO")
	exit()

for bit in range(2 ** (len(a)+1)):
	s = a.copy()

	for i in range(0,len(a)+1):
		if (bit >> i) & 1:
			s.insert(i*2, "A")
			
	if "".join(s) == "AKIHABARA":
		print("YES")
		exit()

print("NO")

	

### FIXED CODE ###

a = [str(i) for i in input()]

if len(a) > 10:
	print("NO")
	exit()

for bit in range(2 ** (len(a)+1)):
	s = a.copy()

	for i in range(0,len(a)+1):
		if (bit >> i) & 1:
			s.insert(i*2, "A")
			
	if "".join(s) == "AKIHABARA":
		print("YES")
		exit()

print("NO")
a = input().split()
N = int(a[0])
H = a[1:]
len(H)



for i in range(len(H)):

    if(i==0):
        pass
    elif( int(H[-(i+1)]) >= 1 + int(H[-i]) ):
        answer = "No"
        break
    elif(int(H[-(i+1)]) == 1 + int(H[-i])):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)

### FIXED CODE ###

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

tem =0

for i in range(n):

    if(i==0):
        pass
    elif( int(h[-(i+1)]) > 1 + int(h[-i]) - tem ):
        answer = "No"
        break
    elif(int(h[-(i+1)]) == 1 + int(h[-i]) - tem  ):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)
a,b=map(int,input().split())
l = [list(map(int,input().split())) for i in range(a)]
l=sorted(l)
l=l[::-1]
sum = 0
for i in range(b-1):
  sum += l[i]
print(sum)
  

### FIXED CODE ###

a,b=map(int,input().split())
l = list(map(int,input().split()))
l=sorted(l)
l=l[::-1]
sum = 0
for i in range(b):
  sum += l[i]
print(sum)
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    s = tokens[0]

    return (s,)


def solve(s):
    
    acgt = set(["A", "C", "G", "T"])

    count = 0
    count_set = set()
    for i, c in enumerate(s):
        if c in acgt:
            count = count + 1
        else:
            count_set.add(count)
            count = 0

    return max(count_set)

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    s = tokens[0]

    return (s,)


def solve(s):

    m = 0
    for ss_length in range(len(s) + 1):
        for i in range(len(s)):
            if i+ss_length > len(s):
                break

            ss = s[i:i+ss_length]
#            print("ss=%s" % ss)
            count = 0
            for c in ss:
                if c in "ACGT":
                    count = count + 1
            if count == ss_length and m < ss_length:
                m = ss_length
                break


    return m

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n = ii1()
m = int(n**0.5)+1
count = 0
flag=0
for i in range(2,m):
    if n%i == 0:
        flag=1
        count+=1
        n=n//i
if flag == 1:
    print(1)
else:
    print(count)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
import bisect
for e in iter(input,'0'):
 n=int(e)
 c=[sorted(int(input())for _ in[0]*n)]
 c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
 t=f=0
 while 1:
  if not c[t]:break
  x=bisect.bisect(c[t],f)
  f=c[t].pop(x)if x<=len(c[t])else 0
  t^=1
 for i in[1,0]:print(len(c[i]))


### FIXED CODE ###

import bisect
for e in iter(input,'0'):
 n=int(e)
 c=[sorted(int(input())for _ in[0]*n)]
 c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
 t=f=0
 while 1:
  if not c[t]:break
  x=bisect.bisect(c[t],f)
  f=c[t].pop(x)if x<len(c[t])else 0
  t^=1
 for i in[1,0]:print(len(c[i]))
a, b, c = map(int,input().split())
if c-b <= 0:
 print("delicious")
elif a+b => c:
 print("safe")
else:
 print("dangerous")

### FIXED CODE ###

a, b, c = map(int,input().split())
if c-b <= 0:
 print("delicious")
elif a+b >= c:
 print("safe")
else:
 print("dangerous")
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

h,w=map(int,input().split())
ch, cw=map(int,input().split())
dh, dw=map(int,input().split())
m=[]
for i in range(h):
    m.append(input())
# h,w=map(int,readline().split())
# ch, cw=map(int,readline().split())
# dh, dw=map(int,readline().split())
# m=readlines()
ch-=1; cw-=1; dh-=1; dw-=1

ans=0

def valid(i, j):
    if 0<=i<=h-1 and 0<=j<=w-1:
        return True
    else:
        return False

def bfs(i, j, ans):
    #m[i][j]=str(ans)
    m[i]=m[i][:j]+str(ans)+m[i][j+1:]
    
    if (i,j)==(dh,dw):
        return 0
    
    if 0<=i-1 and (m[i-1][j]=='.' or (m[i-1][j]!='#' and int(m[i-1][j])>ans)):
        bfs(i-1, j, ans)
    if 0<=j-1 and (m[i][j-1]=='.' or (m[i][j-1]!='#' and int(m[i][j-1])>ans)):
        bfs(i, j-1, ans)
    if i+1<=h-1 and (m[i+1][j]=='.' or (m[i+1][j]!='#' and int(m[i+1][j])>ans)):
        bfs(i+1, j, ans)
    if j+1<=w-1 and (m[i][j+1]=='.' or (m[i][j+1]!='#' and int(m[i][j+1])>ans)):
        bfs(i, j+1, ans)
    
    for si in range(-2, 3):
        for sj in range(-2, 3):
            if valid(i+si, j+sj):
                if (si, sj) == (0, 0) or (si, sj) == (-1, 0) or (si, sj) == (0, -1) or (si, sj) == (1, 0) or (si, sj) == (0, 1):
                    pass
                else:
                    if m[i+si][j+sj]=='.' or (m[i+si][j+sj]!='#' and int(m[i+si][j+sj])>ans):
                        bfs(i+si, j+sj, ans+1)

bfs(ch, cw, 0)

print(m[dh][dw])
    

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# ---------標準入力時--------------
h,w=map(int,readline().split())
ch, cw=map(int,readline().split())
dh, dw=map(int,readline().split())
m=list(map(lambda x: list(x.decode()), readlines()))
# ---------標準入力時--------------

ch-=1; cw-=1; dh-=1; dw-=1

ad = [(-1,0), (0,-1), (1,0), (0,1)]
warp = [(-2, -2),(-2, -1),(-2, 0),(-2, 1),(-2, 2),
 (-1, -2),(-1, -1),(-1, 1),(-1, 2),
 (0, -2),(0, 2),
 (1, -2),(1, -1),(1, 1),(1, 2),
 (2, -2),(2, -1),(2, 0),(2, 1),(2, 2)]

for i in range(h):
    m[i] = ['#']*2 + m[i] + ['#']*2
    
m = [['#']*(w+4)]*2 + m + [['#']*(w+4)]*2
ch+=2; cw+=2; dh+=2; dw+=2

def bfs4():
    '''
    bfs3とほぼ同じ. 迷路の上下左右に2列ずつ壁追加
    '''
    que1=[]
    que2=[] # queueというよりはメモリ
    m[ch][cw]=str(0)
    que1.append((ch,cw))

    while que1!=[]:
        l1=len(que1)
        r1=0 # que1における使用済みindex

        # que1の要素(座標)から歩いていけるマス
        while r1<l1:
            i, j=que1[r1]
            r1+=1
            # 隣接したマスへの移動
            for si, sj in ad:
                if m[i+si][j+sj]=='.': 
                    m[i+si][j+sj]=m[i][j]
                    que1.append((i+si, j+sj))
                    l1+=1

        # 歩いていけないマス
        for i,j in que1:
            for si, sj in warp:
                if m[i+si][j+sj]=='.':
                    m[i+si][j+sj]=str(int(m[i][j])+1)
                    que2.append((i+si, j+sj))

        que1=que2
        que2=[]
###---------------------------------------

bfs4()


if m[dh][dw] == '.':
    print(-1)
else:
    print(m[dh][dw])
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(A[N])

### FIXED CODE ###

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(A[n-1])
import sys
n=input()
a=input()
b=input()
train=int(n)*int(a)
taxi=int(b)
if train>=taxi:
  print(train)
else:
  print(taxi)


### FIXED CODE ###

import sys

n,a,b=(int(x) for x in input().split())

train=n*a
taxi=b
if train>=taxi:
  print(taxi)
else:
  print(train)
A,B,K=map(int,input().split())
ans=[]
for i in range(1,A):
  if A%i==0 and B%i==0:
    ans.append(i)

if len(ans)==0:
  print(1)
else:
  print(ans[-K])

### FIXED CODE ###

A,B,K=list(map(int,input().split()))
ans=[]
c=min(A,B)
for i in range(1,c+1):
  if A%i==0 and B%i==0:
    ans.append(i)

print(ans[-K])
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

ac_list = [0]*n

for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        ac_list[i] = 1

for l, r in lr:
    l -= 1
    r -= 1
    print(ac_list[l:r].count(1))


### FIXED CODE ###

from itertools import accumulate

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

ac_list = [0]*n

for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        ac_list[i] = 1

ac_sum = list(accumulate(ac_list))

for l, r in lr:
    l -= 1
    r -= 1
    if l == 0:
        print(ac_sum[r-1])
        continue
    print(ac_sum[r-1] - ac_sum[l-1])
N, X = map(int, input().split())
2
3 a, p = [1], [1]
4 for i in range(N):
5 a.append(a[i] * 2 + 3)
6 p.append(p[i] * 2 + 1)
7
8 def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
9 if N == 0:
10 return 0 if X <= 0 else 1
11 elif X <= 1 + a[N-1]:
12 return f(N-1, X-1)
13 else:
14 return p[N-1] + 1 + f(N-1, X-2-a[N-1])
15
16 print(f(N, X))


### FIXED CODE ###

n, x = map(int, input().split())
ans = 0
 
hambargers = [1]
patties = [1]
 
for i in range(1, n+1):
    num = hambargers[i-1] * 2 + 3
    patty_num = patties[i-1] * 2 + 1
    hambargers.append(num)
    patties.append(patty_num)
 
def cal(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + hambargers[N-1]:
        return cal(N-1, X-1)
    else:
        return patties[N-1] + 1 + cal(N-1, X-2-hambargers[N-1])
 
print(cal(n, x))
import sys
import numpy as np

MOD = 10 ** 9 + 7

n, *a = map(int, sys.stdin.read().split())
a = np.array(a, dtype=np.int64)

powmod = [None] * 100
powmod[0] = 1
for i in range(60):
    powmod[i+1] = powmod[i] * 2 % MOD
    
def main():
    b = a >> np.arange(60).reshape(-1, 1) & 1
    x = np.count_nonzero(b, axis=1)
    x = x * (n - x)
    x *= powmod[:60]
    x %= MOD
    ans = np.sum(x) % MOD
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

### FIXED CODE ###

import sys
import numpy as np

MOD = 10 ** 9 + 7

N, *A = map(int, sys.stdin.read().split())
A = np.array(A, dtype=np.int64)

def main():
    answer = 0
    for n in range(60):
        B = (A >> n) & 1
        x = np.count_nonzero(B)
        y = N - x
        x *= y
        x *= pow(2, n, MOD)
        answer += x
    answer %= MOD
    return answer

if __name__ == '__main__':
    ans = main()
    print(ans)
#ABC163B
n,m = map(int,input().split())
a = list(map(int,inout().split()))
print(-1 if sum(a) >= n else n-sum(a))

### FIXED CODE ###

#ABC163B
n,m = map(int,input().split())
a = list(map(int,input().split()))
print(-1 if sum(a) > n else n-sum(a))
N, K = input().split(' ')

sunukekuns = [i for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for (kun in sunukekun):
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))


### FIXED CODE ###

lastWeek = input()

thisWeek = "ABC" if (lastWeek == "ARC") else "ARC"

print(thisWeek)
if 500*K < X:
	print("No")
else:
  print("Yes")

### FIXED CODE ###

K,X = map(int,input().split())
if 500*K<X:
  print("No")
else:
  print("Yes")
N = int(input())
X = str(input())
X = list(X)

base = [0 for _ in range(20)] #0から19までの答えを保存
for i in range(20):
  now = i
  temp = 0
  while now != 0:
    ones = 0
    tnow = now*1
    for t in range(5):
      if (now>>t)&1 == 1:
        ones += 1
    #print(i,ones,now)
    now = now%ones
    temp += 1
  base[i] = temp
#print(base)
A = []
for i in range(N): #i桁目を入れ替える
  suji = 0
  onekazu = 0
  for j in range(N):
    if i != j and X[j] == "1":
      suji += pow(2,N-1-j)
      onekazu += 1
    elif i == j and X[j] == "0":
      suji += pow(2,N-1-j)
      onekazu += 1
  #print(suji,onekazu)
  #if suji == 0:
  #  nxt = 0
  nxt = suji%onekazu
  ans = 1+base[nxt]
  A.append(ans)

print(*A,sep="\n")
      
  

        

### FIXED CODE ###

from collections import deque
N = int(input())
X = str(input())
X = list(X)
#motokosu = X.count("1")
motokosu = 0
only = float("inf")
for i in range(N):
  if X[i] == "1":
    motokosu += 1
    only = i
if motokosu != 1:
  only = float("inf")
#print(motosuji,motokosu)
MAX = 2*pow(10,5)+10
base = [0 for _ in range(MAX)] #0から19までの答えを保存
for i in range(MAX):
  now = i
  temp = 0
  while now != 0:
    ones = 0
    tnow = now*1
    for t in range(len(bin(now))-2):
      if (now>>t)&1 == 1:
        ones += 1
    #print(i,ones,now)
    now = now%ones
    #print(now,base[now])
    base[i] = base[now] + 1
    break
    #temp += 1
  #base[i] = temp
#print(base)
A = []
pkosu = motokosu+1
mkosu = motokosu-1
P = deque([])
M = deque([])
ptemp = 1; mtemp = 1
for i in range(N):
  P.appendleft(ptemp%pkosu)
  ptemp = ptemp*2%pkosu
  if mkosu < 1:
    M.appendleft(0)
  else:
    M.appendleft(mtemp%mkosu)
    mtemp = mtemp*2%mkosu

pmotosuji = 0; mmotosuji = 0
for i in range(N):
  if X[i] == "1":
    pmotosuji = (pmotosuji+P[i])%pkosu
    if mkosu >= 1:
      mmotosuji = (mmotosuji+M[i])%mkosu
#print(P,M,pkosu,mkosu,pmotosuji,mmotosuji)

for i in range(N): #i桁目を入れ替える
  if only == i:
    print(0)
    continue
  if X[i] == "0": #その桁が0なら1にする
    kosu = motokosu + 1
    suji = (pmotosuji + P[i])%kosu
  else: #その桁が1なら0にする
    kosu = motokosu - 1
    if kosu == 0:
      suji = -1
    else:
      suji = (mmotosuji - M[i])%kosu
    
  #print(suji,kosu)
  #if suji == 0:
  #  ans = 0
  if suji == -1:
    ans = 1
  else:
    nxt = suji%kosu
    ans = 1+base[nxt]
  #A.append(ans)
  print(ans)

#print(*A,sep="\n")
#print(2**17)
#print(motokosu)
from sys import stdin
import numpy as np

n,w = [int(x) for x in stdin.readline().rstrip().split()]
nw = [0]*n
nv = [0]*n
for i in range(n):
    nw[i],nv[i] = [int(x) for x in stdin.readline().rstrip().split()]
def knapsack(n,w,nw,nv):
    dp = [[0*(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - nw[i] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-nw[i]]+nv[i])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return dp[-1][-1]
print(knapsack(n,w,nw,nv))

### FIXED CODE ###

from sys import stdin
n,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
def knapsack(n,w,li):
    #li[i][0]が重さ,li[i][1]が価値
    dp = [[0 for i in range(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - li[i][0] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-li[i][0]]+li[i][1])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return max(dp[-1])
print(knapsack(n,w,li))
a = input().split()
b = a[0] + a[1]
if b%2 == 0:
  print(b/2)
else:
  print('IMPOSSIBLE')

### FIXED CODE ###

a = list(map(int, input().split()))
b = a[0] + a[1]
if b%2 == 0:
  print(int(b/2))
else:
  print('IMPOSSIBLE')
import math
A, B = (int(i) for i in input().split())
print(int(A*B / math.gcd(A, B)))


### FIXED CODE ###

def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

A, B = (int(i) for i in input().split())
print(int(A*B / gcd(A, B)))
import math

from fractions import Fraction as frac

MOD = 1e9 + 7

def gcd(a, b):

    if b == 0:

        return a

    return gcd(b, a % b)

def lcm(a, b):

    return a * b // gcd(a, b)

def solve(case_no):

    s = str(input())

    if s[len(s) - 1] == 's':

    	print(s + "es")    else:

    	print(s + 's')

t = 1

# t = int(input())

for i in range(1, t + 1):

    solve(i)

### FIXED CODE ###

import math

from fractions import Fraction as frac

MOD = 1e9 + 7

def gcd(a, b):

    if b == 0:

        return a

    return gcd(b, a % b)

def lcm(a, b):

    return a * b // gcd(a, b)

def solve(case_no):

    s = str(input())

    if s[len(s) - 1] == 's':

    	print(s + "es")
    else:

    	print(s + 's')

t = 1

# t = int(input())

for i in range(1, t + 1):

    solve(i)
#最初に入力される情報を整理する
str_input_list = input().rstrip().split(' ')

int_input_list = []
for a in str_input_list:
    int_input_list.append(int(a))

length = int_input_list[0]
amount = int_input_list[1]

#文字列を受け取りリストに格納
mojiretu_list = []
for a in range(amount):
    mojiretu_list.append(input())

#文字列を小さい順に並べ、結合
sorted_list = sorted(mojiretu_list)
min_mojiretu = ''
for a in range(amount):
    min_mojiretu += sorted_list[a]

#出力
print(min_mojiretu)

### FIXED CODE ###

amount, length = map(int, input().split())
S = sorted([input() for a in range(amount)])
print(''.join(S))
n=input()
print(n.count('1')

### FIXED CODE ###

n=input()
print(n.count('1'))