Harryxun/stf_run huggingface dataset:
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)

if length > 0:
  o_nums = list(input().split())

  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(diffs_abs[smallest_diff_index]) in diffs: # ターゲットよりも小さい、最も差分が小さい値を探す
    index = diffs.index(-(diffs_abs[smallest_diff_index]))
    print(nums[index])
  else:
    print(nums[smallest_diff_index])

else:
  print(target)

### FIXED CODE ###

class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  b = target + i
  if b not in nums:
    print(b)
    exit()
import sys
input=sys.stdin.readline
n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if a>b:
            a,b=a-1,b+1
            ans+="B"
        else:
            a,b=a+1,b-1
            ans+="A"
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if a>c:
            a,c=a-1,c+1
            ans+="C"
        else:
            a,c=a+1,c-1
            ans+="A"
        if min(a,c)==-1:
            print("No")
            break
    else:
        if b>c:
            b,c=b-1,c+1
            ans+="C"
        else:
            b,c=b+1,c-1
            ans+="B"
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])



### FIXED CODE ###

n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if a==1 and b==1 and i!=n-1:
            if s_[i+1][0]=="A":
                a,b,ans=(a+1,b-1,ans+"A")
            else:
                a,b,ans=(a-1,b+1,ans+"B")
            continue
        a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if a==1 and c==1 and i!=n-1:
            if s_[i+1][1]=="C":
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a+1,c-1,ans+"A")
            continue
        a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if c==1 and b==1 and i!=n-1:
            if s_[i+1][1]=="C":
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b+1,c-1,ans+"B")
            continue
        b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])
N, M = map(int, raw_input().split(" "))

xyz = []
for i in range(N):
    xyz.append(map(int, raw_input().split(" ")))
result = -1
i = j = k = 1

def compare(x, y):
    if i*x[0]+j*x[1]+k*x[2]>i*y[0]+j*y[1]+k*y[2]:
        return 1
    elif i*x[0]+j*x[1]+k*x[2]<i*y[0]+j*y[1]+k*y[2]:
        return -1
    else:
        return 0

def calculate(x, y):
    return [x[0]+y[0], x[1]+y[1], x[2]+y[2]]

for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            xyz.sort(compare)
            tmp = sum(map(abs, reduce(calculate, xyz[:M])))
            if tmp > result:
                result = tmp
print result


### FIXED CODE ###

N, M = map(int, raw_input().split(" "))

xyz = []
for i in range(N):
    xyz.append(map(int, raw_input().split(" ")))
result = -1
i = j = k = 1

def compare(x, y):
    if i*x[0]+j*x[1]+k*x[2]>i*y[0]+j*y[1]+k*y[2]:
        return 1
    elif i*x[0]+j*x[1]+k*x[2]<i*y[0]+j*y[1]+k*y[2]:
        return -1
    else:
        return 0

def calculate(x, y):
    return [x[0]+y[0], x[1]+y[1], x[2]+y[2]]

for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            xyz.sort(compare)
            tmp = 0 if M==0 else sum(map(abs, reduce(calculate, xyz[:M])))
            result = max(tmp, result)

print result
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print((K*X)+((N-K)*Y))
else:
    print(int(N*X))

### FIXED CODE ###

N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N>K:
    print(K*X+(N-K)*Y)
else:
    print(N*X)
a,b = map(int,input(),split())
if(a*b)%2 == 0 :
    print("Odd")

else:
    print("Even")



### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
from math import sqrt
from functools import reduce
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*b//gcd(a, b)
n = int(input())
n2 = n
pfs = []
isP = True
i = 2
while i <= int(sqrt(n)):
    while n % i == 0:
        pfs.append(i)
        n //= i
        isP = False
    i += 1
pfs.append(n)
"print (pfs)
if isP:
    ans =  (n2-1)
elif len(pfs) > 2:
    l = reduce(lcm, pfs)
    ans = l-1 + n2//l-1
else:
    ans = pfs[-1]-1 + n2//pfs[-1]-1
print (ans)

### FIXED CODE ###

from math import sqrt
n = int(input())
minSoFar = 10**12+1

for a in range(1, int(sqrt(n))+1):
    if n % a == 0:
        b = n // a
        minSoFar = min(minSoFar, a+b-2)
print(minSoFar)
N,Q= map(int, input().split())
es=[]
ope=[]
for _ in range(N-1):
    a,b=map(int, input().split())
    es.append((a,b))
for _ in range(Q):
    p,x=map(int, input().split())
    ope.append((p,x))
point=[0]*N
import numpy as np
point=np.array(point)
nodes=np.eye(N, dtype=int)
for e in es:
    if sum(nodes[e[0]-1])>=sum(nodes[e[1]-1]):
        nodes[e[0]-1][e[1]-1]=1
        nodes[:,e[1]-1]=np.logical_or(nodes[:,e[1]-1],nodes[:,e[0]-1])
    else:
        nodes[e[1]-1][e[0]-1]=1
        nodes[:,e[0]-1]=np.logical_or(nodes[:,e[1]-1],nodes[:,e[0]-1])
for o in ope:
    point+=nodes[o[0]-1]*o[1]
string=""
for i in range(N):
    string+=str(int(point[i]))+" "
print(string)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next , now)

dfs(0)
print(*point)
import  fructions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

def lcm_base(x, y):
    return (x * y) // math.fructions(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__=='__main__':
    main()


### FIXED CODE ###

import  fractions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    # tmp = lcm(*a)
    mod=pow(10,9) + 7
    m=0
    ans=0
    tmp = a[0]
    for i in range(1,len(a)):
        tmp = (tmp*a[i]) // fractions.gcd(tmp,a[i])
    
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m
    ans = ans % mod
    print(ans)


if __name__=='__main__':
    main()
from heapq import *
from itertools import chain
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
d=sorted(chain.from_iterable(b))
b=[d[0][1]]
for i,j in d[1:]:
    s=heappop(b)
    if i<=s:
        heappush(b,s)
        heappush(b,j)
    else:
        heppush(b,j)
print(len(b))

### FIXED CODE ###

from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
        else:
            b[h].append([i,j])
    else:
        b[h].append([i,j])
s=[0]*(2*10**5+2)
for i in b:
    for h,w in i:
        s[2*h-1]+=1
        s[2*w+1]-=1
print(max(list(ac(s))))
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
if n-s==-1:
  print(n)
  exit()
A=[]
for i in range(1,int((n-s)**(1/2))+3):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

### FIXED CODE ###

def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()
if s>n:
  print(-1)
  exit()

A=make_divisors(n-s)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)
import itertools
L,R = map(int,input().split())
if 2019 <= (R - L) + 1:
  print(0)
  exit()
  
lst = list(range(L,R+1))
md = [x * y % 2019 for x,y in itertools.combination(lst,2)]
md.sort()
print(md[0])

### FIXED CODE ###

import itertools
L,R = map(int,input().split())
if 2019 <= (R - L) + 1:
  print(0)
  exit()
  
lst = list(range(L,R+1))
md = [x * y % 2019 for x,y in itertools.combinations(lst,2)]
md.sort()
print(md[0])
while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  A = []
  for i in range(h):
    A.append(map(int,list(raw_input().replace(".", "1").replace("*", "0"))))
  B = A[:]
  C = []
  for j in range(1,h):
    m=[]
    for i in range(j,h):
      x=[e1&e2 for e1,e2 in zip(B[i-j],A[i])]
      B[i-j]=x
      m.append(max("".join(map(str,x)).split("0")))
    C.append(len(max(m))*(j+1))
  print max(C)

### FIXED CODE ###

while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  M = [0]*(h+1)
  a=[0]*w
  for i in range(h):
    x = raw_input()
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]=="*": c=0
      else: c=a[j]+1
      b[j]=c
      dw=c-sp
      if dw>0: C[sp+1:c+1]=[j]*dw
      elif dw<0:
        for k in range(c+1,sp+1): M[k]=max(M[k],j-C[k])
        C[c+1:sp+1]=[-1]*(-dw)
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0: M[k]=max(M[k],w-C[k])
    a=b
  s=max([a*b for a,b in zip(M, range(h+1))])
  print s
while True :
    (x,y) = int(i) for i in input().split()
    if 0 = x and 0 = y:
        break
    elif x <= y:
        print(x,y)
    else :
        print(y,x)

### FIXED CODE ###

while True:
    (x, y) = [int(i) for i in input().split()]
    
    if x == y == 0 :
        break

    if x <= y :
        print(x, y)
    else :
        print(y, x)
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])


### FIXED CODE ###

import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])
import math

A,B = map(int,input().split())

R = (A * B) / math.gcd(A, B)

print(int(R))

### FIXED CODE ###


A,B = map(int,input().split())

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

R = (A * B) / gcd(A, B)

print(int(R))
N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]

left = 1
right = max(h)//A + 1
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)
    


### FIXED CODE ###

N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]

left = 1
right = max(h)
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)
n=int(input())
A=list(map(int,input().split()))
A.sort()

a=A[-1]/2
tmp=A[-1]
ans=0
for i in range(n):
    if(abs(a-A[i]) < tmp):
        tmp=abs(a-A[i])
        ans=A[i]

print("{} {}".format(A[-1],ans))

### FIXED CODE ###

a,b,c=map(int,input().split())
if(a<=c and c<=a+b):
  print("YES")
else:
  print("NO")
n = int(input())
s = input()

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
          elif c == "G":
              ans += (ruisekiG[n] - ruisekiG[j])
            else:
                ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)

### FIXED CODE ###

n = input()
if '7' in n:
  print('Yes')
else:
  print('No')
N = int(input())
A, B, C = [0]*N, [0]*N, [0]*N 
for i in range(N):
    A[i], B[i], C[i] = [int(j) for j in input().split()]

ABC = [A, B, C]
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        dp[i+1][j] = max(dp[i][j-1] + ABC[i][j], dp[i][j-2] + ABC[i][j])

print(max(dp[-1]))

### FIXED CODE ###

N = int(input())
A, B, C = [0]*N, [0]*N, [0]*N 
for i in range(N):
    A[i], B[i], C[i] = [int(j) for j in input().split()]
    
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + A[i]
    dp[i+1][1] = max(dp[i][0], dp[i][2]) + B[i]
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + C[i]
    
print(max(dp[-1]))
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
output =(e(0)-e(2))*(e(1)-e(3))
print output

### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())
output = (H-h)*(W-w)
print (output)
n = int(input())
a = list(map(int,input().split()))

count = 0
temp = a[0]

for i in range(n):
  if a[i] >= temp:
    temp = a[i]
  else:
    count += temp - a[i]
print(count)

### FIXED CODE ###

N,X,T = map(int,input().split())
if N % X == 0:
  print(int(T*N/X))
else:
  print(T*(N//X+1))
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

roop = []
pre = 0
for i in range(2*n):
    roop.append(pre)
    pre = a[pre]
cnt = [0]*n
s = ""
for i in range(len(roop)):
    cnt[roop[i]]+=1
    if cnt[roop[i]]>=2 and cnt[roop[i]]<3:
        s += str(roop[i])
ff = int(s[0])
s2 = s
for i in range(len(roop)):
    if roop[i]!=ff:
        s2  = str(roop[i]) + s2
    else:
        check = i
        break
k -= check
k%=len(s)
print(a[check+k]+1)


### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

roop = [0]
for i in range(3*n):
    roop.append(a[roop[i]])
cnt =[0]*n
d = []
for i in range(len(roop)):
    cnt[roop[i]]+=1
    if cnt[roop[i]]>=3 and cnt[roop[i]]<4:
        d.append(roop[i])
for i in range(len(roop)):
    if roop[i] == d[0]:
        check = i
        break
if check == 0:
    k%=len(d)
    print(d[k]+1)
else:
    if k<check + len(d):
        print(roop[k]+1)
    else:
        k-=check
        k%=len(d)
        print(d[k]+1)
import heapq
x, y, z, k = map(int, input().split())

abc = []
heapq.heapify(abc)
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

s, t, u = 0,0,0

if x>1:
    abc.append([a[0]-a[1], 0])
if y>1:
    abc.append([b[0]-b[1], 1])
if z>1:
    abc.append([c[0]-c[1], 2])
heapq.heapify(abc)
s, t, u = 0,0,0
while len(abc)>0 and s*t*u<k:
    n, m = heapq.heappop(abc)
    if m == 0:
        s += 1
        if s < x:
            heapq.heappush(abc, [a[s-1]-a[s], 0])
    elif m == 1:
        t += 1
        if t < y:
            heapq.heappush(abc, [b[t-1]-b[t], 1])
    else:
        u += 1
        if u < z:
            heapq.heappush(abc, [c[u-1]-c[u], 2])
ABC = []
heapq.heapify(ABC)
for i in range(s):
    for j in range(t):
        for ij in range(u):
            heapq.heappush(ABC, -a[i]-b[j]-c[ij])
for _ in range(k):
    print(-heapq.heappop(ABC))

### FIXED CODE ###

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
N, W = list(map(int, input().split()))
WE = []
V = []
for i in range(N):
    w, v = list(map(int, input().split()))
    WE.append(w)
    V.append(v)

MAX_W = 10 ** 5

# DP[i][j]: i以降の品物で重さj以下のときの価値の最大
DP = []
for i in range(N):
    a = [None] * (MAX_W + 1)
    DP.append(a)
DP.append([0] * (MAX_W+1))

for i in range(N-1, -1, -1):
    for j in range(MAX_W+1):
        if i == N:  # i番目の品物はない
            DP[i][j] == 0
        elif j < WE[i]:  # この重さの品物は入れないから無視
            DP[i][j] = DP[i+1][j]
        else:
            DP[i][j] = max(DP[i+1][j], DP[i+1][j-WE[i]]+V[i])

# for i in range(N):
#     print(DP[i][:10])
print(DP[0][W])

### FIXED CODE ###

N, W = list(map(int, input().split()))
WE = []
V = []
INF = float('inf')
for i in range(N):
    w, v = list(map(int, input().split()))
    WE.append(w)
    V.append(v)

MAX_V = (10 ** 3) * 100 + 1

# DP[i+1][j]: i番目までの品物から価値の総和がjとなるように選んだときの、重さの総和の最小値
DP = []
for i in range(N+1):
    a = [INF] * (MAX_V + 1)
    DP.append(a)

DP[0][0] = 0

for i in range(N):
    for j in range(MAX_V):
        if j < V[i]:  # 作りたい価値の総和よりも、価値が大きい
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i][j-V[i]] + WE[i])

r = 0
for i in range(MAX_V+1):
    if DP[N][i] <= W:
        r = i

print(r)

# for i in range(N+1):
    # print(DP[i][:20])
M = 10**9 + 7
n, a, b = map(int, input().split())
r = (pow(2, n, M) - 1) % M
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M)


### FIXED CODE ###

input()
a = list(map(int, input().split()))
print(min(sum((x - p)**2 for x in a) for p in range(1, 101)))
n=int(input())
s=input()
if n%2==1:
  print(No)
  exit(0)
if s[:i//2]==s[i//2:]:
  print('Yes')
  exit(0)
print('No')
  

### FIXED CODE ###

# ABC145b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    # map(int,input().split())
    n = int(input())
    s = input()[:-1]
    print('Yes' if s[:n//2] == s[n//2:] else 'No')


if __name__ == '__main__':
    main()
a = input()
lists = [i+1 for i in range(a)]
for t in lists:
  if t % 5 == 0:
    lists.remove(t)
  elif t % 3 ==0:
    lists.remove(t)
    
print(sum(lists))

### FIXED CODE ###

a = int(input())
lists = [i+1 for i in range(a) if (i+1)%5!=0 and (i+1)%3!=0]

print(sum(lists))
n = int(input())
lst = [int(e) for e in input().split(' ')]

lst = sorted(lst)

valid_list = []
if n % 2 == 1:
    # 奇数
    valid_list.append(0)
    for i in range(1, int((n + 1) / 2)):
        valid_list.append(i * 2)
        valid_list.append(i * 2)
    if lst == valid_list:
        print(int(2 ** (((n - 1) / 2)) % 1000000007))
    else:
        print(0)
else:
    for i in range(1, int((n / 2) + 1)):
        valid_list.append((i * 2) - 1)
        valid_list.append((i * 2) - 1)
    if lst == valid_list:
        print(int(2 ** ((n / 2)) % 1000000007))
    else:
        print(0)


### FIXED CODE ###

## 2 * 100000 % 1000000007 の高速計算法がわからずOUT

n = int(input())
lst = [int(e) for e in input().split(' ')]

lst = sorted(lst)
result = 1

valid_list = []
if n % 2 == 1:
    # 奇数
    valid_list.append(0)
    for i in range(1, int((n + 1) / 2)):
        valid_list.append(i * 2)
        valid_list.append(i * 2)
    if lst == valid_list:
        for i in range(int((n - 1) / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)
else:
    for i in range(1, int((n / 2) + 1)):
        valid_list.append((i * 2) - 1)
        valid_list.append((i * 2) - 1)
    if lst == valid_list:
        for i in range(int(n / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)