Harryxun/stf_run huggingface dataset:
N = int(input())
A = [int(a) for a in input().split()]
    
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if N <= 2000:
    L = [1]*N
    for i in range(1, N):
        L[i] *= L[i-1]*i
        L[i] %= mod
    
    ans = 0
    for i in range(1, N):
        ans += cmb(N-1, N-i, mod)*L[i-1]*L[N-i-1]*(A[N-1]-A[i-1])
        ans %= mod
        for j in range(i+1, N):
            ans += cmb(N-1, j-i+1, mod)*L[N-j+i-2]*L[j-i-1]*(A[j-1]-A[i-1])
            ans %= mod
        
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
    
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

L = [1]*N
for i in range(1, N):
    L[i] *= L[i-1]*i
    L[i] %= mod
    
ans = 0
for i in range(1, N):
    ans += cmb(N-1, N-i, mod)*L[i-1]*L[N-i-1]*(A[N-1]-A[i-1])
    ans %= mod
        
L2 = [0]*(N-1)
for i in range(N-1):
    L2[i] = A[i+1]-A[i]

S = [0]*N
for i in range(N-1):
    S[i+1] = S[i] + L2[i]
    
L3 = [0]*N
for i in range(1, N):
    if N-i-1 >= i:
        L3[i] = L3[i-1] + S[N-i-1] - S[i-1]
    else:
        L3[i] = L3[N-i-1]

for t in range(1, N-1):
    ans += cmb(N-1, t+1, mod)*L[N-t-2]*L[t-1]*L3[t]
    ans %= mod
        
print(ans)
import math
N= int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  X[i]=int(input())
  y[i]=int(input())
S = 0
nb =0
for i in range(N) :
  for j in range(0, i) :
    S += math.sqrt( (x[i]-x[j])**2 + (y[i]-y[j])**2 )
    nb += 1
print(S/nb)

### FIXED CODE ###

import math
N= int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i], y[i]=map(int, (input()).split() )
S = 0
nb =0
for i in range(N) :
  for j in range(0, i) :
    S += math.sqrt( (x[i]-x[j])**2 + (y[i]-y[j])**2 )
    nb += 1
print(S/nb*(N-1))
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def prime_factorize(N):
    res = []
    for i in range(2, int(math.sqrt(N)) + 1):
        if N % i != 0:
            continue

        num = 0
        while N % i == 0:
            N //= i
            num += 1
        
        res.append([i, num])

    if N != 1:
        res.append([N, 1])

    return res

A, B = LI()

g = math.gcd(A, B)
pf = prime_factorize(g)

print(len(pf) + 1)


### FIXED CODE ###

# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def prime_factorize(N):
    res = []
    for i in range(2, int(math.sqrt(N)) + 1):
        if N % i != 0:
            continue

        num = 0
        while N % i == 0:
            N //= i
            num += 1
        
        res.append([i, num])

    if N != 1:
        res.append([N, 1])

    return res

A, B = LI()

g = gcd(A, B)
pf = prime_factorize(g)

print(len(pf) + 1)
n = int(input())
m = int(n ** 0.5) + 1
j = 1
for i in range(2, m):
  if n % i ==0:
    j = n // i
print(i+j -2)

### FIXED CODE ###

n = int(input())
m = int( n ** 0.5) + 1
a,b = 1, 0
for i in range(2, m):
    if n % i == 0:
        a = n // i
        b = i
if b !=0:
    print(a + b - 2)
else:
    print(n - 1)
A, B, C, D = (int(x) for x in input().split())
if A + B < C + D:
  print('Right')
else:
  if A + B > C + D:
    print('Left')
  else:
    print('Balanced)


### FIXED CODE ###

A, B, C, D = (int(x) for x in input().split())
if A + B < C + D:
  print('Right')
if A + B > C + D:
  print('Left')
if A + B == C + D:
  print('Balanced')
import sys
input=sys.stdin.readline
from bisect import bisect_left, bisect_right

Q=int(input())
llr=[]
maxr=1
for i in range(Q):
    l,r=map(int,input().split())
    if r>maxr:
        maxr=r
    llr.append([l,r])
def isprime(n):
    if n==1:
        return 0
    m=int(n**(1/2))
    for i in range(2,m+1):
        if n%i==0:
            return 0
            break
    return 1
l2017=[]
for i in range(1,maxr+1,2):
    if isprime(i) and isprime((i+1)/2):
        l2017.append(i)
for i in range(Q):
    il=bisect_left(l2017,llr[i][0])
    ir=bisect_right(l2017,llr[i][1])
    print(ir-il

### FIXED CODE ###

import sys
input=sys.stdin.readline
from bisect import bisect_left, bisect_right

Q=int(input())
llr=[]
maxr=1
for i in range(Q):
    l,r=map(int,input().split())
    if r>maxr:
        maxr=r
    llr.append([l,r])
def isprime(n):
    if n==1:
        return 0
    m=int(n**(1/2))
    for i in range(2,m+1):
        if n%i==0:
            return 0
            break
    return 1
l2017=[]
for i in range(1,maxr+1,2):
    if isprime(i) and isprime((i+1)/2):
        l2017.append(i)
for i in range(Q):
    il=bisect_left(l2017,llr[i][0])
    ir=bisect_right(l2017,llr[i][1])
    print(ir-il)
import numpy as np
K = int(input())
a = np.arange(a,K+1)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print(np.sum(b))


### FIXED CODE ###

import numpy as np
K = int(input())
a = np.arange(1,K+1)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print(np.sum(b))
N, K = map(int, input().split())
dist = [[] for i in range(N)]
A = list(map(int, input().split()))
for i in range(N):
    dist[i].append(A[i] - 1)
dp = [[0, 0] for i in range(N)]

def dfs(pos, depth):
    # 初めての訪問なら
    if dp[pos][0] == 0:
        dp[pos][0] = depth
        for i in dist[pos]:
            dfs(i, depth + 1)
    elif dp[pos][1] == 0:
        dp[pos][1] = depth
        for i in dist[pos]:
            dfs(i, depth + 1)
dfs(0, 0)
for i in range(N):
    split = dp[i][1] - dp[i][0]
    if split != 0:
        if (K - dp[i][0]) % split == 0:
            print(i + 1)
            break

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
n, k = getList()
# dist
nums = [0] + getList()
cnt = 1
if k == 1:
    print(1)
    exit()
cur = 1
visited = [-1 for i in range(n + 1)]
visited[1] = 1
rooped = False
while True:
    # cur 行き先
    cur = nums[cur]
    cnt += 1

    # １回目に訪れていたら
    if visited[cur] != -1:
        # ループの周期
        roop = cnt - visited[cur]
        # 途中を飛ばす
        k -= ((k-cnt) // roop) * roop
        rooped = True
    if not rooped:
        # １回目に訪れたのであれば
        visited[cur] = cnt

    if cnt == k:
        print(nums[cur])
        break
a=input()
b=input()
c=input()

if a<c and b>c :
  print("Yes")
elif a>c and b<c :
  print("Yes")
else:
  print("No")


### FIXED CODE ###

x=input().split()
z=[int(v) for v in x]

if z[0]<z[2] and z[1]>z[2] :
  print("Yes")
elif z[0]>z[2] and z[1]<z[2] :
  print("Yes")
else:
  print("No")
import math
a, b, c, d = map(int, input().split())

p = math.floor((c * d) / math.gcd(c, d))

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())

p = (c * d) // gcd(c, d)

a_under = a-1

ans = (b - b//c - b//d + b//p) - (a_under - a_under//c - a_under//d + a_under//p)

print(ans)
n, m = map(int, input().split())

graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a][b] = 1
    graph[b][a] = 1

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in range(n):
        if graph[v][i] == 1:
            if memo[i] == 0:
                memo[i] = 1
                color[i] = (color[v]+1) % 2
                if color[i] == 0:
                    global black
                    black += 1
                else:
                    global white
                    white += 1
                search(i)
            else:
                if color[v] == color[i]:
                    global flag
                    flag = 1

memo[0] = 1
color[0] = 0
search(0)

if flag == 1:
    print(n*(n+1)/2 - m)
else:
    print(black * white - m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())

graph = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)
def kai():
    N=int(input())
    A=list(map(int,input().split()))
    
    if  0 in A:
        print(0)
        return
    
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return
kai()

### FIXED CODE ###

A,B=map(int,input().split())
print(A*B)
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}


### FIXED CODE ###

x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
[X,Y] = list(map(int,input().split()))

n = (-4*X+5*Y)//3)
m = (2*X-Y)//3)

if (X+Y)%3 !=0:
    print(0)

elif n<0 or m<0:
    print(0)

#コンビネーションを何回も計算する問題で使える関数
MAXN = (10**6)+10
MOD = 10**9 + 7
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


print(nCr(n+m,n,10**9 + 7))


### FIXED CODE ###


[X,Y] = list(map(int,input().split()))

n = (-1*X+2*Y)//3
m = (2*X-Y)//3

if (X+Y)%3 !=0:
    print(0)

elif n<0 or m<0:
    print(0)

else:
    MAXN = (10**6)+10
    MOD = 10**9 + 7
    f = [1]
    for i in range(MAXN):
        f.append(f[-1] * (i+1) % MOD)
    def nCr(n, r, mod=MOD):
        return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


    print(nCr(n+m,n,10**9 + 7))
A, B, C = map(int, input(),split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)
import math
x,y = map(int,input().split())
print(math.ceil(x/y))

### FIXED CODE ###

x,y = map(int,input().split())
if x >= 10:
	print(y)  
else:
	print(y+(100*(10-x)))
import math
while(True):
	date=input()
	date=date.split()
	date=int(date[0])+int(date[1])
	digit=int(math.log10(date))
	print(digit)

### FIXED CODE ###

while(True):
	try:
		date=input()
		a,b=map(int,date.split(" "))
		digit=len(str(a+b))
		print(digit)
	except:
		break
n=int(input())
def dsf(s):
  if int(s)>n:
    return0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))

### FIXED CODE ###

n=int(input())
def dsf(s):
  if int(s)>n:
    return 0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))
N, M = map(int, input().split())
A = list(map(int, input().split()))
s = sum(A)
min = s / (4 * M)
cnt = 0
for a in A:
  if a >= min:
    cnt += 1
if M <= cnt:
  print('Yes')
else:
  print('No')




### FIXED CODE ###

XYZ = input().split()
print(XYZ[2], XYZ[0], XYZ[1])
a = list(input())
b = 0
for i in a:
    b += i

print(b)

### FIXED CODE ###

a = list(input())
b = 0
for i in a:
    b += int(i)

print(b)
p = "_acababababa"
x, y = map(int, input().split())
print("YNeos"[p[x]!=p[y]::2])

### FIXED CODE ###

p = "_acababaababa"
x, y = map(int, input().split())
print("YNeos"[p[x]!=p[y]::2])
from collections import gcd
N=int(input())
def lcm(a,b):
    return a//gcd(a,b)*b
T=[]
for i in range(N):
    t=int(input())
    T.append(t)
a=1
for i in range(N):
    a=lcm(a,T[i])

print(a)

### FIXED CODE ###

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

N=int(input())
ans=1
for i in range(N):
    t=int(input())
    ans=lcm(ans, t)
print(ans)
#x = [int(i) for i in input().split()]
x = input()
import math
print(math.pi * x**2, math.pi * 2* x)


### FIXED CODE ###

#x = [int(i) for i in input().split()]
x = float(input())
print(3.141592653589793 * x**2, 3.141592653589793 * 2* x)
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
dic={}
for i in range(m):
  b,c=map(int,input().split())
  if c in dic:
    dic[c]+=b
  else:
    dic[c]=b
ol=sorted(dic.items(), reverse=True, key=lambda x:x[0])
index=0
loopstop=False
for li in ol:
  for i in range(li[1]):
    if li[0]>a[index]:
      a[index]=li[0]
      index+=1
    else:
      loopstop=True
      break;
  if loopstop:
    break
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
dic={}
for i in range(m):
  b,c=map(int,input().split())
  if c in dic:
    dic[c]+=b
  else:
    dic[c]=b
ol=sorted(dic.items(), reverse=True, key=lambda x:x[0])
index=0
loopstop=False
for li in ol:
  for i in range(li[1]):
    if li[0]>a[index]:
      a[index]=li[0]
      index+=1
      if index>=n:
        loopstop=True
        break;
    else:
      loopstop=True
      break;
  if loopstop:
    break
print(sum(a))
h,w=map(int,input().split())
a=[0]*h+2
a[0]='.'*(w+2)
a[h+1]=a[0]
for _ in range(1,h+1):
  a[_]='.'+input()+'.'
x='Yes'
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      if a[i-1][j]=='.' and a[i+1][j]=='.' and a[i][j-1]=='.' and a[i][j+1]=='.':
        x='No'
print(x)

### FIXED CODE ###

h,w=map(int,input().split())
a=[0]*(h+2)
a[0]='.'*(w+2)
a[h+1]=a[0]
for _ in range(1,h+1):
  j=input()
  a[_]='.'+j+'.'
x='Yes'
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j]=='#':
      if a[i-1][j]=='.' and a[i+1][j]=='.' and a[i][j-1]=='.' and a[i][j+1]=='.':
        x='No'
        break
print(x)
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

S.append(0)
cnt = 0
for i in range(q):
    j = 0
    S[n] = T[i]
    while S[j] != S[n]:
        j = j + 1
    if j != n:
        cnt = cnt + 1


print cnt

### FIXED CODE ###

n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for j in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
            break
        elif T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt
import numpy as np
a,b = map(int, input().split())
grid1 = np.full((50,100), '.')
grid2 = np.full((50,100), '#')
a = a-1
b = b-1
x = y = 1
grid2[1,1]

### FIXED CODE ###

import numpy as np
a,b = map(int, input().split())
grid1 = [['.' for j in range(100)] for i in range(50)]
grid2 = [['#' for j in range(100)] for i in range(50)]
a -= 1
b -= 1
x = y = 1

for i in range(a):
    grid2[x][y] = '.'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

x = y = 1
for i in range(b):
    grid1[x][y] = '#'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))
def ma():return map(int,input().split())
def nli(x):return [int(input()) for _ in range(x)]
def hukusuu():
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA

def ifif(s):
  if s:print("Yes")
  else:print("No")

n,k,q=ma()

b=[0]*q
for i in range(q):
  ai=int(input())-1
  b[ai]+=1 

for i in range(q):
  ifif(k-b[i]>0)

### FIXED CODE ###

def ma():return map(int,input().split())
def nli(x):return [int(input()) for _ in range(x)]
def hukusuu():
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA

def ifif(s):
  if s:print("Yes")
  else:print("No")

n,k,q=ma()

b=[0]*n
for i in range(q):
  ai=int(input())-1
  b[ai]+=1 

for i in range(n):
  ifif(k-q+b[i]>0)
[a, b] = map(int, input().split())
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else a == 0:
    print("a == 0")

### FIXED CODE ###

a,b=map(int,input().split())
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
N = str(input())
num = N[-1]
num = int(num)
 
if num == 3:
  print('bon')
elif num == 0:
  print('pon')
elif num == 1:
  print('pon')
elif num == 6:
  print('pon')
elif num == 8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')
N = str(input())
num = N[-1]
 
if num == 3:
  print('bon')
elif num == 0:
  print('pon')
elif num == 1:
  print('pon')
elif num == 6:
  print('pon')
elif num == 8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')

### FIXED CODE ###

N = str(input())
num = N[-1]
num = int(num)
 
if num == 3:
  print('bon')
elif num == 0:
  print('pon')
elif num == 1:
  print('pon')
elif num == 6:
  print('pon')
elif num == 8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')
import sys
args = sys.argv
a = int(args[1])
b = int(args[2])
c = int(args[3])

def restWater():
    restWater = c - (a - b)
    if restWater >= 0:
        print(restWater)
    else:
        print(0)

restWater()

### FIXED CODE ###

s = list(map(int, input().split()))
a = s[0]
b = s[1]
c = s[2]

def restWater():
    restWater = c - (a - b)
    if restWater >= 0:
        print(restWater)
    else:
        print(0)

restWater()
N=int(input())
A=list(map(int,input().split()))ans=0
flag=0

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1

print(ans)

### FIXED CODE ###

S=input()
ans=0
for s in S:
  if s=='1':
    ans+=1
print(ans)
# coding: utf-8
import sys
import numpy as np

N, W = map(int, sys.stdin.buffer.readline().split())
   
dp = np.zeros((N+1, W+1), dtype=int)

for i in range(1, N+1):
    w, v = map(int, sys.stdin.buffer.readline().split())
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i,j] = max(dp[i,j], dp[i-1,j-w[i]]+v[i])
        dp[i,j] = max(dp[i,j], dp[i-1,j])

# for i in range(N+1):
#     print(dp[i])

print(dp[N,W])

### FIXED CODE ###

def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()
n = int(input())
s = input()
t = s[:(n//2)] * 2
if s == t:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

r = int(input())
print(r**2)
def diverta192_b():
    N = int(input())
    P = [tuple(map(int, input().split())) for _ in range(N)]
    dcnt = defaultdict(int)
    for i in range(N):
        xi, yi = P[i]
        for j in range(i):
            xj, yj = P[j]
            if xi > xj: dx, dy = xi-xj, yi-yj
            else: dx, dy = xj-xi, yj-yi
            dcnt[(dx,dy)] += 1
    most = sorted(dcnt.values(), reverse=True)[0]
    ans = N - most
    print(ans)

diverta192_b()

### FIXED CODE ###

from collections import defaultdict

def diverta192_b():
    N = int(input())
    P = [tuple(map(int, input().split())) for _ in range(N)]
    if len(P) == 1:
        print(1)
        return
    dcnt = defaultdict(int)
    for i in range(N):
        xi, yi = P[i]
        for j in range(i):
            xj, yj = P[j]
            dx1, dy1 = xi-xj, yi-yj
            dx2, dy2 = xj-xi, yj-yi
            dcnt[(dx1,dy1)] += 1
            dcnt[(dx2,dy2)] += 1
    most = sorted(dcnt.values(), reverse=True)[0]
    ans = N - most
    print(ans)

diverta192_b()
b = input()
c = {"A":T,"C":G}
print(c[b])

### FIXED CODE ###

b = input()
c = {"A":"T","C":"G" ,"T":"A","G":"C"}
print(c[b])
import math
N=int(input())
n=math.sqart(n)

print(int(n)**2)

### FIXED CODE ###

import math
N=int(input())
n=math.sqrt(N)

print(int(n)**2)
import math


def lcm(x, y):  # 最小公倍数
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
all = b - (b // c + b // d - b // lcm(c, d))
part = (a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))


print(all - part)



### FIXED CODE ###

import fractions


def lcm(x, y):  # 最小公倍数
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
all = b - (b // c + b // d - b // lcm(c, d))
part = (a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))


print(all - part)
a = input(int())
s = input()

if a >= 3200 :
  print( 'red' )
else:
  print( s )

### FIXED CODE ###

a = int ( input() )
s = input()
 
if a >= 3200 :
  print( s )
else:
  print( 'red' )
n=int(input())
s=[]
t=[]
for i in range(n):
	st=list(input())
	s.append(st[0])
	t.append(st[1])
x=input()

print(sum(t[s.index(x):]))


### FIXED CODE ###

n=int(input())
s=[]
t=[]
for i in range(n):
	st=list(input().split())
	s.append(st[0])
	t.append(int(st[1]))
x=input()

print(sum(t[s.index(x)+1:]))
X=int(input())
ans=None

if X>=30:
    ans=Yes
else:
    ans=No

print(ans)

### FIXED CODE ###

X=int(input())
ans=None

if X>=30:
    ans="Yes"
else:
    ans="No"

print(ans)