Harryxun/stf_run huggingface dataset:
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]

def count(x,y):

    if c[x][y][0] == -1:
        n = 0
        while x+n < h and l[x+n][y] == ".":
            n += 1
        for i in range(n):
            c[x+i][y][0] = n
        
    if c[x][y][1] == -1:
        n = 0
        while y+n < w and l[x][y+n] == ".":
            n += 1
        for i in range(n):
            c[x][y+i][1] = n

    return c[x][y][0]+c[x][y][1]
ans = 0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            ans = max(ans,count(i,j))
print(ans-1)


### FIXED CODE ###

a,b,c = map(int,input().split())
print(a+b+c-max(a,b,c))
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)
from collections import defaultdict, deque
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
Q = [inpl() for _ in range(M)]
 
tree = [[-1, 1]  for _ in range(N+1)] # [next, rank]
  
def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
 
adj = [[] for _ in range(N+1)]  
 
for l, r, d in Q:
    if find(l) != find(r):
        unite(l, r)
    adj[l].append([r, d])
    adj[r].append([l, -d])
 
 
G = set([find(n) for n in range(1, N+1)])
 
X = [-1 for _ in range(N+1)]
searched = [False for _ in range(N+1)]
res = True
 
for g in G:
    X[g] = 0
    Q = deque([g])
    searched[g] = True
    while Q:
        p = Q.popleft()
        for np, d in adj[p]:
            if searched[np]:
                if X[np] != X[p] + d:
                    Q = []
                    res = False
                    break
            else:
                X[np] = X[p] + d
                Q.append(np)
                searched[np] = True
    if not res:
        break
 
if res:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return tuple(map(int, input().split()))
N = int(input())
A = inpl()
B = inpl()
res = 0
for i in range(N):
    res = max(res, sum(A[:i+1]) + sum(B[i:]))

print(res)
import numpy as np
import math
from functools import reduce

mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

l = [0] * (10 ** 6 + 1)

for i in range(n):
    soi = factorize(a[i])
    for j in range(len(soi)):
        l[soi[j][0]] = max(l[soi[j][0]], soi[j][1])

saiko = 1

for i in range(2, 10**6):
    saiko = (saiko * i ** l[i]) % mod

ans = 0

for i in range(n):
    ans += saiko * pow(a[i],mod - 2, mod)
    ans %= mod

print(ans)

### FIXED CODE ###

mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

l = [0] * (10 ** 6 + 1)

for i in range(n):
    soi = factorize(a[i])
    for j in range(len(soi)):
        l[soi[j][0]] = max(l[soi[j][0]], soi[j][1])

saiko = 1

for i in range(2, 10**6):
    saiko = (saiko * i ** l[i]) % mod

ans = 0

for i in range(n):
    ans += saiko * pow(a[i],mod - 2, mod)
    ans %= mod

print(ans)
from collections import Counter


H, W = map(int, input().split())
A = [input() for _ in range(H)]

char_to_cnt = Counter()
for h in range(H):
    for w in range(W):
        char_to_cnt.update(A[h][w])

def check(table):
    for i in range(H):
        if "".join(table[i]) != "".join(reversed(table[i])):
            return False
    for j in range(W):
        row = [table[i][j] for i in range(H)]
        if "".join(row) != "".join(reversed(row)):
            return False
    return True



ans = False
def dfs(i, j, table, remain):
    global ans
    if ans:
        return

    # print(i, j, table, remain)
    for char, cnt in remain.items():
        if cnt == 0:
            continue

        new_table = list(table)
        new_table[i][j] = char

        if i >= H // 2:
            if new_table[i][j] != new_table[(H - i - 1)][j]:
                continue

        if j >= W // 2:
            if new_table[i][j] != new_table[i][(W - j - 1)]:
                continue

        if i == H - 1 and j == W - 1:
            if check(new_table):
                ans = True
            return

        new_remain = Counter(remain)
        new_remain[char] -= 1

        if j == W - 1:
            dfs(i + 1, 0, new_table, new_remain)
        else:
            dfs(i, j + 1, new_table, new_remain)

table = [["" for _ in range(W)] for i in range(H)]
dfs(0, 0, table, char_to_cnt)

if ans:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

from collections import Counter


H, W = map(int, input().split())
A = [input() for _ in range(H)]

char_to_cnt = Counter()
for h in range(H):
    for w in range(W):
        char_to_cnt.update(A[h][w])

if H % 2 != 0 and W % 2 != 0:
    g1 = 1
    g2 = H // 2 + W // 2
    g4 = (H // 2) * (W // 2)
else:
    g1 = 0
    if H % 2 == 0 and W % 2 == 0:
        g2 = 0
    else:
        if H % 2 == 0:
            g2 = H // 2
        else:
            g2 = W // 2
    g4 = (H * W - g1 - g2 * 2) // 4

for _ in range(g1):
    for char in char_to_cnt.keys():
        cnt = char_to_cnt[char]
        if cnt % 4 == 1 or cnt % 4 == 3:
            char_to_cnt[char] -= 1
            break

for _ in range(g2):
    for char in char_to_cnt.keys():
        cnt = char_to_cnt[char]
        if cnt % 4 == 2:
            char_to_cnt[char] -= 2
            break

for _ in range(g4):
    for char in char_to_cnt.keys():
        cnt = char_to_cnt[char]
        if cnt != 0 and cnt % 4 == 0:
            char_to_cnt[char] -= 4
            break

for _, cnt in char_to_cnt.items():
    if cnt % 4 != 0:
        print("No")
        exit()

print("Yes")
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] >= li[i+1]:
    li_a.append(i)
li_b = []
for j in range(len(li_a)-2):
  li_b.append(li_a[j+1]-li_a[j])
li_b.append(li_a[0])
li_b.append(n - li_a[-1])
print(max(li_b))
  

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if n[0]==-1 and N==1:
    n[0]=0
if N=3:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
if N=2:
    if n[1]==-1:
        n[1]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')

### FIXED CODE ###

N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if n[0]==-1 and N==1:
    n[0]=0
if N==3:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
if N==2:
    if n[1]==-1:
        n[1]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')
A=int(input())
B=int(input())
 
if A >= 13 :
  X=B
  print( '%d' % X )
elif X<=12 and X>=6 :
  X=B/2
  print( '%d' % X )
else:
  print( '0')

### FIXED CODE ###

A,B = (int(i) for i in input().split()) 
C=B/2
if A >= 13 :
  print( '%d' % B )
elif A<=12 and A>=6 :
  print( '%d' % C )
else:
  print( '0')
Copy
Copy
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

### FIXED CODE ###


N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))
n , k=map(int,input().split())
l="p"
b=0
for o in range(0,n):
 l="b"+l+"p"+l+"b"
p=list(l)
for t in range(0,k):
 if p[t]=="p":
  b+=1
print(b)

### FIXED CODE ###

n,x=map(int,input().split())
plist=[1]
blist=[1]
for i in range(n):
  plist.append(plist[-1]*2+1)
  blist.append(blist[-1]*2+3)
def patty(n,x):
  if n==0:
    return 1
  else:
    if x==1:
      return 0
    elif 1<x and x<=blist[n-1]+1:
      return patty(n-1,x-1)
    elif x==blist[n-1]+2:
      return plist[n-1]+1
    elif 2+blist[n-1]<x and 2*blist[n-1]+2>=x:
      return plist[n-1]+patty(n-1,x-2-blist[n-1])+1
    else:
      return plist[n]
print(patty(n,x))
list=[int(input()) for i in range(5)]
sum=0
max=0
for x in list:
  y = -(-x//10)*10
  sum+=y
  max=(y-x, max)
  print(sum-max)

### FIXED CODE ###

X=[int(input()) for i in range(5)]
Y=[]
for x in X:
  Y.append(-(-x//10)*10-x)
print(sum(X)+sum(Y)-(max(Y)))
rainy_days = input()
if rainy_days == 'RRR':
    print(3)
elif rainy_days == 'RRS' or 'SRR':
    print(2)
elif rainy_days == 'RSR' or 'RSS' or 'SSR' or 'SRS':
    print(1)
else rainy_days == 'SSS':
    print(0)


### FIXED CODE ###

r = input()
if r == 'RRR':
    print(3)
elif r == 'RRS' or r == 'SRR':
    print(2)
elif r == 'RSR' or r == 'RSS' or r =='SSR' or r =='SRS':
    print(1)
elif r == 'SSS':
    print(0)
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd(),numbers)
prind(gcd_list(L))

### FIXED CODE ###

from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
print(gcd_list(L))
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

S = P[:X] + Q[:Y]
# print(S)

S_wa = []
wa = 0
for s in S[::-1]:
    wa += s
    S_wa.append(wa)
# print(S_wa)
big = S_wa[-1]
ans = S_wa[-1]

R_wa = []
wa = 0
for r in R:
    wa += r
    R_wa.append(wa)
# print(R_wa)

for i in range(len(R_wa)):
    ans = max(ans, big + R_wa[i] - S_wa[i])
print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

S = P[:X] + Q[:Y]
S.sort(reverse=True)

S_wa = []
wa = 0
for s in S[::-1]:
    wa += s
    S_wa.append(wa)
# print(S_wa)
big = S_wa[-1]
ans = S_wa[-1]

R_wa = []
wa = 0
for r in R:
    wa += r
    R_wa.append(wa)
# print(R_wa)

kazu = min(len(R_wa), len(S_wa))

for i in range(kazu):
    ans = max(ans, big + R_wa[i] - S_wa[i])
print(ans)
N, K, S = map(int, input().split())
ans = [str(S)] * K + [str(S//(N-K)+1)] * (N-K)
print(' '.join(ans))

### FIXED CODE ###

N, K, S = map(int, input().split())
ans = [S] * K 
if S != 10**9:
    ans += [S+1] * (N-K)
else:
    ans += [1] * (N-K)
print(' '.join([str(x) for x in ans]))
#!/usr/bin/env python3
from fractions import gcd
N = input()
A = list(map(int, input().split(" ")))
def lcm(x, y):
    return (x * y) // gcd(x, y)
tmp = 1
for i in A:
    tmp = lcm(tmp, i)
print(int(sum([tmp / i for i in A]) % (10**9 + 7)))

### FIXED CODE ###

#!/usr/bin/env python3
from fractions import gcd
N = input()
A = list(map(int, input().split(" ")))
def lcm(x, y):
    return (x * y) // gcd(x, y)
tmp = 1
for i in A:
    tmp = lcm(tmp, i)
print(sum([tmp // i for i in A]) % (10**9 + 7))
def solve():
    A, B, K = map(int, input().split())
    ans = list(range(A, B + 1))
    if B - A >= K * 2:
        ans = sorted((set(ans[:min(B-A, K)] + ans[min(0, -K):])), key=ans.index)

    for a in ans:
        print(a)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

def solve():
    A, B, K = map(int, input().split())
    for i in range(A, min(A+K, B+1)):
        print(i)
    for j in range(max(A+K, B-K+1), B+1):
        print(j)


if __name__ == "__main__":
    solve()
#n,l = map(int,input().split())
#l = kist(input())

l = kist(input())
cnt=0
ans=0

for i in range(n):
    if l[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans = max(ans,cnt)

print(ans)

### FIXED CODE ###

#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(input())
cnt=0
ans=0

for i in range(n):
    if l[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans = max(ans,cnt)

print(ans)
N = int(raw_input())
A = map(int, raw_input().split())

L = [ abs((N-1) - 2*i) for i in range(N)]

L.sort(); A.sort()

print(pow(2, (N-N%2)/2, 10**9+7) if L == A else 0)

### FIXED CODE ###

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

L = [abs((N-1) - 2*i) for i in range(N)]

L.sort(); A.sort()

print(pow(2, (N-N%2)//2, 10**9+7) if L == A else 0)
N = int(input())
numbers = list(map(int, input().split()))

numbers_abs = [abs(n) for n in numbers if n != 0]
sum_abs = sum(numbers_abs)
min_abs = min(numbers_abs)

count_negative = 0
count_zero = 0
for n in numbers:
  if (n < 0):
    count_negative += 1
  elif (n == 0):
    count_zero += 1

answer = sum_abs
if (count_negative % 2 == 1 and count_zero < 1):
  answer = sum_abs - 2 * min_abs

print(answer)


### FIXED CODE ###

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

numbers_abs = [abs(n) for n in numbers]
sum_abs = sum(numbers_abs)
min_abs = min(numbers_abs)

count_negative = sum([1 for n in numbers if n < 0])

answer = sum_abs
if (count_negative % 2 == 1):
  answer = sum_abs - 2 * min_abs

print(answer)
N = input()
S = input()
K = int(input())

tar = S[K-1]

lis = (_ if _==tar else "*" for _ in S]
print("".join(lis))

### FIXED CODE ###

N = input()
S = input()
K = int(input())

tar = S[K-1]

lis = (_ if _==tar else "*" for _ in S)
print("".join(lis))
a,b=input().split()
print((b+1)//a)

### FIXED CODE ###

a,b = list(map(int, input().split()))
i=0
while b>(a-1)*i+1:
	i+=1
print(i)
import numpy as np
import sys
H, W, M = map(int, input().split())
d = [[0]*H for _ in range(W)]
d = np.array(d)
for _ in range(M):
    h, w = map(int, input().split())
    d[h-1, w-1] = 1


tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []

for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)

for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if not d[h, w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

### FIXED CODE ###

import sys
H, W, M = map(int, input().split())
h_list, w_list = [0]*H, [0]*W
check = set()
for _ in range(M):
    h, w = map(int, input().split())
    check.add((h-1, w-1))
    h_list[h-1] += 1
    w_list[w-1] += 1
h_max, w_max = max(h_list), max(w_list)
h_bom = [i for i in range(H) if h_list[i]==h_max]
w_bom = [i for i in range(W) if w_list[i]==w_max]
for h in h_bom:
    for w in w_bom:
        if not (h, w) in check:
            print(h_max+w_max)
            sys.exit()
print(h_max+w_max-1)
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=576480000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
N = int(input())
A = list(map(int, input().split()))

result = 0
for b in range(60):
  bs = sum((e >> b) & 1 for e in A)
  result = (result + bs * (N　- bs) * (1 << b)) % 1000000007
print(result)


### FIXED CODE ###

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

    r = list(range(N - 2, -1, -1))
    result = 0
    for b in range(60):
        t = 0
        bs = (A[N - 1] >> b) & 1
        for i in r:
            if (A[i] >> b) & 1 == 0:
                t += bs
            else:
                t += (N - (i + 1)) - bs
                bs += 1
        result = (result + t * (1 << b)) % 1000000007
    print(result)
main()
N = int(input())
S = list(input())
T = list(input())
ans = ""
for i in range(N):
  ans += S[i] + T[i]
print(ans)

### FIXED CODE ###

N = int(input())
S,T = map(list, input().split())
ans = ""
for i in range(N):
  ans += S[i] + T[i]
print(ans)
n,m=map(int,input().split())
# Union-Find
a=list(range(n))
def find(x):
  if a[x]==x:
    return x
  a[x] = find(a[x])
  return a[x]

for _ in range(m):
  x,y=map(int,input().split())
  x,y=find(x-1),find(y-1)
  if x == y: continue
  a[y]=x

count=[0]*n
for i in range(n):
  count[find(i)] += 1
print(max(count))


### FIXED CODE ###

n,m=map(int,input().split())
# Union-Find
a=list(range(n))
def find(x):
  g = x
  while g != a[g]: g = a[g]
  a[x] = g
  return g

for _ in range(m):
  x,y=map(int,input().split())
  x,y=find(x-1),find(y-1)
  if x == y: continue
  a[y]=x

count=[0]*n
for i in range(n):
  count[find(i)] += 1
print(max(count))
import sys
sys.setrecursionlimit(100000000000)
N=int(input())
A=list(map(int,input().split()))
def f(i):
  if i==0:
    return 1
  else:
    return f(i-1)*A[i-1]
a=f(N)
print(a if a<=10**(18) else -1)








### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
k=0
if 0 in A:
  print(0)
else:
  for i in range(N):
    a*=A[i]
    if a>10**(18):
      k=1
      break
  if k==1:
    print(-1)
  else:
    print(a)
# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
max = max(a)
for i in range(n):
    index = a.pop(i)
    if index == max:
        print(max(a))
    else:
        print(max)
    a.insert(i, index)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = a_unique[0]
max_value_count = a.count(max_value)

if max_value_count == 1:
    for i in range(n):
        if a[i] == max_value:
            print(a_unique[1])
        else:
            print(max_value)
else:
    for i in range(n):
        print(max_value)
a = int(input())
r = a * a * 3,14
r2 = a * 2 * 3.14

print("%.10f %.10f" % (r, r))

### FIXED CODE ###

import math

a = float(input())

r = a * a * math.pi
r2 = a * 2 * math.pi

print("%.10f %.10f" % (r, r2))
X = input()
coin500, X = divmod(X, 500)
coin5, X = divmod(X, 5)
print(1000 * coin500 + 5 * coin5)

### FIXED CODE ###

X = int(input())
coin500, X = divmod(X, 500)
coin5, X = divmod(X, 5)
print(1000 * coin500 + 5 * coin5)
n,w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]
#dp[i][j]はi番目まででj(j<=w)になるもの
dp = [[0]*(w+1) for i in range(n)]
for k in range(w+1):
  if k >= wv[0][0]:
    dp[0][k] = wv[0][1]
  else:
    continue
for i in range(n-1):
  for j in range(w+1):
    if j >= wv[i+1][0]:
      dp[i+1][j] = max(dp[i][j-wv[i+1][0]]+wv[i+1][1],dp[i][j])
    else:
      dp[i+1][j] = dp[i][j]
print(dp[n-1][w])


### FIXED CODE ###

n,w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]
#dp[i][j]はi番目まででj(価値の合計)になる重さの最小値
sum_value = 0
for i in range(n):
  sum_value += wv[i][1]
dp = [[float("inf")]*(sum_value+1) for j in range(n)]
for k in range(sum_value+1):
  if k == wv[0][1]:
    dp[0][k] = wv[0][0]
for a in range(n-1):
  for b in range(sum_value+1):
    if dp[a][b-wv[a+1][1]] != float("inf"):
      dp[a+1][b] = min(dp[a][b-wv[a+1][1]]+wv[a+1][0],dp[a][b])
    elif b == wv[a+1][1]:
      dp[a+1][b] = min(wv[a+1][0],dp[a][b])
    else:
      dp[a+1][b] = dp[a][b]
ans = 0
for c in range(sum_value+1):
  if dp[-1][c] != float("inf") and w >= dp[-1][c]:
    ans = c
print(ans)
def whatIsRight(u,f):	
    r = 0
    if u == 1:
        if f == 2:
            r = 3
        elif f == 3:
            r = 5
        elif f == 4:
            r = 2
        elif f == 5:
            r = 4
        return r
	
    if u == 2:
        if f == 6:
            r = 3
        elif f == 3:
            r = 1
        elif f == 1:
            r = 4
        elif f == 4:
            r = 6
        return r

    if u == 3:
        if f == 5:
            r = 1
        elif f == 1:
            r = 2
        elif f == 2:
            r = 6
        elif f == 6:
            r = 3
        return r
			
    if u == 4:
        if f == 6:
            r = 2
        elif f == 2:
            r = 1
        elif f == 1:
            r = 5
        elif f == 5:
            r = 6 
        return r 
			
    if u == 5:
        if f == 3:
            r = 6
        elif f == 6:
            r = 4
        elif f == 4:
            r = 1
        elif f == 1:
            r = 3
	return r
		
    if u == 6:
        if f == 5:
            r = 3
        elif f == 3:
            r = 2
        elif f == 2:
            r = 4
        elif f == 4:
            r = 5
        return r
			
n = list(map(int,input().split()))
N = int(input())

for i in range(N):
    m = list(map(int,input().split()))
    num = []

    for j in range(len(m)):
        for k in range(len(n)):
            if m[j] == n[k]:
                num.append(k+1)
                break
	
    print(n[whatIsRight(num[0],num[1]) -1])

### FIXED CODE ###

def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
up,front,right,left,back,bottom = input().split()
direction = list(input())

for i in range(len(direction)):
    up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,direction[i])
    
print(up)
from math import sqrt
n = map(int, raw_input().split())
print "{0:.8f}".format(sqrt((n[0]-n[2])**2+(n[1]+n[3])**2))

### FIXED CODE ###

from math import sqrt
n = map(float, raw_input().split())
print "{0:.8f}".format(sqrt((n[0]-n[2])**2+(n[1]-n[3])**2))
a,b= map(int,input().split())
if A >= 13:
    print(b)
elif 6<=A:
    print(b/2)
else:
    print(0)

### FIXED CODE ###

a,b= map(int,input().split())
if a >= 13:
    print(b)
elif a > 5:
    print(b//2)
elif a <= 5:
    print(0)
a, b = map(int, input().split())
op = input()
 
print(a+b if op == "+" else a-b)

### FIXED CODE ###

a, op, b = map(str, input().split())

 
print(int(a)+int(b) if op == "+" else int(a)-int(b))