Harryxun/stf_run huggingface dataset:
# ABC148B

n = int(input)
s, t = input().split()
print(''.join([i+j for i, j in zip(s, t)]))


### FIXED CODE ###

# ABC148B

n = int(input())
s, t = input().split()
print(''.join([i+j for i, j in zip(s, t)]))
N = int(input())
A = int(input())

N %= 500

if N <= a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
a = int(input())
n%=500

if n<=a:
  print('Yes')
else:
  print('No')
i = int(input().replace(' ',''))
if i == int(i ** 0.5) ** 2
    print("Yes")
else:
    print("No")


### FIXED CODE ###

i = int(input().replace(' ',''))
if i == int(i ** 0.5) ** 2:
    print("Yes")
else:
    print("No")
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[0] = 0
if n < 2:
  print(0)
if n == 2:
  print(min(arr[0]-arr[1]))
vis[1] = min(arr[0]-arr[1])
def count(n):
  	if n < 0:
      return 0
    if n in vis:
        return vis[n]
    else:
      vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n-1))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
import sys
if n==1:
  print(0)
  sys.exit()
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
  


### FIXED CODE ###

# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
n = int(input)
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n

### FIXED CODE ###

n = int(input())
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)
s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B' and len(lst)!=0:
        del lst[-1]
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append('{}'.format(j))

print(''.join(lst))

### FIXED CODE ###

s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B':
        if len(lst)!=0:
            del lst[-1]
        else:
            continue
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append(str(j))

print(''.join(lst))
s1 s2 s3 = map(int,input().split())
list = [s1,s2,s3]
print(list.count[1])

### FIXED CODE ###

print(input().count("1"))
S = input()
if len(S)==2:
    print(S)
else:
    print(reverse(S))


### FIXED CODE ###

S = input()
if len(S)==2:
    print(S)
else:
    print(S[::-1])
from collections import deque

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

q = deque()
q.append((0, 0, 0))
S[0][0] = "#"
while q:
    y, x, cnt = q.popleft()
    for dy, dx in [[1, 1], [-1, 1], [1, -1], [-1, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and S[y + dy][x + dx] == ".":
            q.append(y + dy, x + dx, cnt + 1)
            S[y + dy][x + dx] = "#"
if S[H-1][W-1] == ".":
    print(-1)
else:
    score = H * W - (cnt + 1)
    print(score)


### FIXED CODE ###

from collections import deque

H, W = map(int,input().split())
S = []
wall = 0
for i in range(H):
    s = list(input())
    wall += s.count("#")
    S.append(s)
q = deque()
q.append([0, 0, 0])
S[0][0] = "#"
while q:
    y, x, cnt = q.popleft()
    if y == H-1 and x == W-1:
        break
    for dy, dx in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and S[y + dy][x + dx] == ".":
            q.append([y + dy, x + dx, cnt + 1])
            S[y + dy][x + dx] = "#"

if S[H-1][W-1] == ".":
    print(-1)
else:
    score = H * W - (cnt + 1) - wall
    print(score)
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    while i >= 0:
        c = A[i] // l
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 2
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        print(left,right,middle)
        if not cut(middle,A,K):
            left = middle + 1
        else:
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
    print(middle)

### FIXED CODE ###

import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    if l == 0:
        return False
    while i >= 0:
        c = math.ceil(A[i] / l) - 1
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 0
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        if cut(middle,A,K):
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
        else:
            left = middle + 1
    print(middle)
N, M = map(int, input().split())
A = list(list(range(int(i/2),M+1,2*int(i/2))) for i in map(int, input().split()))
P = set(A[0]).intersection(*A[1:])
print(len(P))

### FIXED CODE ###

N, M = map(int, input().split())
A = set(i//2 for i in map(int, input().split()))
B = []
for i in A:
	B = B + [0]
	while i % 2 == 0:
		i //= 2
		B[-1] += 1
if len(set(B)) == 1:
	m = max(A)
	A.remove(m)
	base = 0
	for i in range(m,M+1,2*m):
		semi = True
		for j in A:
			if i % j != 0 or (i // j) % 2 == 0:
				semi = False
				break
		if semi:
			base = i
			break
	if base == 0:
		print(0)
	else:
		print(((M // base) + 1)//2)
else:
	print(0)
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

def ran(S, N):
    bit_count = S.count("1")

    #bit数
    calc_dict = {i:-1 for i in range(22000)}
    res_dict =  {i:-1 for i in range(2*(10**5))}

    res_dict = {i:-1 for i in range(1001)}
    res_dict[0]=0

    for i in range(1, 1001):
        if calc_dict[i]==-1:
            calc_dict[i] = bin(i).count("1")

        res_dict[i] = i%calc_dict[i]+1


    bit_count = S.count("1")
    for i in range(len(S)):
        if S[i]=="0":

            bit_count+=1
            num = int(S,2) + 2**(N-i-1)
            if num==0:
                print(0)
            else:
                print(res_dict[num%bit_count]+1)
            bit_count-=1
        else:

            bit_count-=1
            num = int(S,2) - 2**(N-i-1)
            if num==0:
                print(0)
            else:
                print(res_dict[num%bit_count]+1)
            bit_count+=1

ran(S,N)

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

bit_count = S.count("1")
S_num = int(S,2)
S_min = S_num % (bit_count-1) if bit_count-1!=0 else 0
S_plu = S_num % (bit_count+1)




# calc_dict = {i:-1 for i in range(10000)}
# res_dict =  {i:-1 for i in range(10**4)}

# for i in range(1, 10000):
#     if calc_dict[i]==-1:
#         calc_dict[i] = bin(i).count("1")

#     res_dict[i] = i%calc_dict[i]+1

def mods(temp, count):
    count+=1
    if temp!=0:

#         if temp in res_dict:
#             return count+res_dict[temp]
        
#         if temp not in calc_dict:
#             calc_dict[temp]= bin(temp).count("1") 
        count = mods(temp%bin(temp).count("1") , count)

    return count

for i in range(N):
    if S[i]=="0":
        part = pow(2, (N-i-1), bit_count+1)
        num = (S_plu + part ) % (bit_count+1)
        print(mods(num, 0))
    else:
        if S_num == 2**(N-i-1):
            print(0)
            continue
        part = pow(2, (N-i-1), bit_count-1)
        num = (S_min - part)%(bit_count-1)
        print(mods(num, 0))
da = list(map(int,input().split()))

k = [[0 for i in range(2)]for j in range(10001)]

i = 0

su = 0

j = 0

while da[0] != 0 and da[1] != 0:

	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = list(map(int,input().split()))
		su += k[i][0] * k[i][1]


	sorted(k,key = lambda x: x[1],reverse = True)
	while da[1] != 0 or j != i:
		if da[1] >= k[j][0]:
			su -= k[j][0] * k[j][1]
			da[1] -= k[j][0]
			j += 1

		elif da[1] < k[j][0]:
			su -= da[1] * k[j][1]
			da[1] = 0

	print(su)

	da = list(map(int,input().split()))
	if da[0] == 0 and da[1] == 0:
		break
	k = [[0 for i in range(2)]for j in range(10001)]


### FIXED CODE ###

da = list(map(int,input().split()))

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] + da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())


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

	while j != i + 1:
		if da[1] > k[j][0]:
			da[1] -= k[j][0]
			j += 1
		elif da[1] <= k[j][0] and da[1] > 0:
			su += (k[j][0] - da[1]) * k[j][1]
			da[1] = 0
			j += 1
		else:
			su += k[j][0] * k[j][1]
			j += 1

	print(su)

	da = list(map(int,input().split()))

	k = [[0 for i in range(2)]for j in range(10001)]
N,K = map(int,input().split())
S = []
d = {}
d[0] = 0
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i >= K:
        x = S.pop(0)
        d[x] -= 1
    else:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)
S = input()
S.sort()
if S == "abc":
	print("Yes")
else: print("No")

### FIXED CODE ###

S =list(input())
S.sort()
if S ==["a","b","c"]:
    print("Yes")
else: print("No")
N = int(input())
Arr = list(map(int, input().split()))
for i in range(N):
 if i==N-1:
  print(Arr[0])
 else:
  print(Arr[N-1-i] + " ")

### FIXED CODE ###

N = int(input())
Arr = list(map(int, input().split()))
for i in range(N-1):
 print("{} ".format(Arr[N-1-i]), end="")
print(Arr[0])
n, a = map(int, input().split())
x = list(map(int, input().split()))

#aとの差を記録してリストに入れなおす
x = list(map(lambda i: i-a, x))
#print(x)

#dp初期値
dp = {0: 1}

#dpにぶち込む値をxから取り出す
for num in x:
  #dpにあるすべてのkey,valueに対して、すでにdpにkeyがi+kのデータがあればそのvalueなければ,0を返し、それ+vをdpとする。
  for k,v in list(dp.items()):
    dp[i+k]=dp.get(i+k,0)+v
    
  #print(dp)
#全部使わない選択肢だけ引いておく  
print(dp[0]-1)
#print(dp)

### FIXED CODE ###

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

#aとの差を記録してリストに入れなおす
x = list(map(lambda i: i-a, x))
#print(x)

#dp初期値
dp = {0: 1}

#dpにぶち込む値をxから取り出す
for num in x:
  #dpにあるすべてのkey,valueに対して、すでにdpにkeyがi+kのデータがあればそのvalueなければ,0を返し、それ+vをdpとする。
  for k,v in list(dp.items()):
    dp[num+k]=dp.get(num+k,0)+v
    
  #print(dp)
#全部使わない選択肢だけ引いておく  
print(dp[0]-1)
#print(dp)
print(''.join((a + b for a, b in zip(input(), input()+'\n'))).splitlines()[0])


### FIXED CODE ###

a, b, c = map(int, input().split())
print('YES' if b - a == c - b else 'NO')
N = int(input())
A = map(int, input().split())
ans = 0
count = 0
for i in range(N-1):
  if A[i]>=A[i+1]:
    count += 1
  else:
    ans = max(ans,count)
    count = 0
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
count = 0
for i in range(N-1):
    if A[i]>=A[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
ans = max(ans,count)
print(ans)
N, R = map(int, input().split())
if N<10:
  print(R+100*(10-K))
else:
  print(R)

### FIXED CODE ###

N, R = map(int, input().split())
print(R+100*(10-N) if N<10 else R)
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
d = {}
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
B = []
for t in T:
    B.extend([t[0]] * t[1])
    if len(B) > N: break
N = min(N, len(B))
c = N
for i in range(N):
    if A[i] > B[i]:
        c = i
        break
ans = sum(B[:c])
if c < len(A): ans += sum(A[c:])
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    if not a in d: d[a] = 0
    d[a] += 1
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
ans = 0
cnt = 0
for t in T:
    if t[1] <= N - cnt:
        ans += t[0] * t[1]
        cnt += t[1]
    else:
        ans += t[0] * (N - cnt)
        break
print(ans)
a = input()

if a == "ABC":
    print("ARC")
else a == "ARC":
    print("ABC")

### FIXED CODE ###

a = input()

if a == "ABC":
    print("ARC")
elif a == "ARC":
    print("ABC")
# http://wakabame.hatenablog.com/entry/2017/09/03/213522
# おまじない
import sys
input = sys.stdin.readline

# ノード数
N = int(input())

# 各要素は(元ノード, 先ノード, コスト)のタプルになっている
edges = [list(map(int, input().split())) for i in range(N)]

# クエリ数と経由ノード
Q, K = map(int, input().split())

# クエリ一覧
xy = [list(map(int, input().split())) for i in range(Q)]


# まず経由地から各ノードのへの距離をメモする
def BFS(K, edges, N):
    # ノード分のリストを持ったリストの定義
    # ノード番号はインデックス-1に対応．つながっている先のノードとそこへのコストのタプルが入る
    roots = [ [] for i in range(N) ]
    for a, b, c in edges:
        roots[a-1] += [(b-1, c)]
        roots[b-1] += [(a-1, c)]
    # memo
    dist = [-1] * N
    # たどり着いたノードのリスト
    stack = []
    stack.append(K)
    dist[K] = 0
    while stack:
        label = stack.pop(-1)
        for i, c in roots[label]:
            # 初到達ならmemoしてstackに追加
            # これはグラフが木構造であるから言えること．そうでなければコスト最小値しか採用しては行けない？
            if dist[i] == -1:
                dist[i] = dist[label] + c
                stack += [i]
    return dist

distance = BFS(K - 1, edges, N)

for i in range(Q):
    print(distance[xy[i][0] - 1] + distance[xy[i][1] - 1])
            




### FIXED CODE ###

# http://wakabame.hatenablog.com/entry/2017/09/03/213522
# おまじない
import sys
input = sys.stdin.readline

# ノード数
N = int(input())

# 各要素は(元ノード, 先ノード, コスト)のタプルになっている
edges = [list(map(int, input().split())) for i in range(N - 1)]

# クエリ数と経由ノード
Q, K = map(int, input().split())

# クエリ一覧
xy = [list(map(int, input().split())) for i in range(Q)]


# まず経由地から各ノードのへの距離をメモする
def BFS(K, edges, N):
    # ノード分のリストを持ったリストの定義
    # ノード番号はインデックス-1に対応．つながっている先のノードとそこへのコストのタプルが入る
    roots = [ [] for i in range(N) ]
    for a, b, c in edges:
        roots[a-1] += [(b-1, c)]
        roots[b-1] += [(a-1, c)]
    # memo
    dist = [-1] * N
    # たどり着いたノードのリスト
    stack = []
    stack.append(K)
    dist[K] = 0
    while stack:
        label = stack.pop(-1)
        for i, c in roots[label]:
            # 初到達ならmemoしてstackに追加
            # これはグラフが木構造であるから言えること．そうでなければコスト最小値しか採用しては行けない？
            if dist[i] == -1:
                dist[i] = dist[label] + c
                stack += [i]
    return dist

distance = BFS(K - 1, edges, N)

for i in range(Q):
    print(distance[xy[i][0] - 1] + distance[xy[i][1] - 1])
N, M, K = map(int, input().split())
 
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
def solve(A, N, B, M, K):
  
  def cumsum(l):
    rt = [0]
    s = 0
    for n in l:
      s += n
      rt.append(s)
    return rt
  
  preA = cumsum(A)
  preB = cumsum(B)
  
  total = N + M
  s, e = 0, total - 1
  
  def can_read(num):
    for i in range(N + 1):
      j = num - i
      if j < (M + 1) and (preA[i] + preB[j]) <= K:
      	return True
    return False

  res = 0
  while s < e:
    mid = s + (e - s) // 2
    can = can_read(mid)
    
    if can:
      res = mid
      s = mid + 1
    else:
      e = mid - 1
  
  return res

res = solve(A, N, B, M, K)
print(res)

### FIXED CODE ###

N, M, K = map(int, input().split())
 
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
def solve(A, N, B, M, K):
  
  def cumsum(l):
    rt = [0]
    s = 0
    for n in l:
      s += n
      rt.append(s)
    return rt
  
  preA = cumsum(A)
  preB = cumsum(B)
  
  s, e = 0, N + M
  
  def can_read(num):
    for i in range(N + 1):
      j = num - i
      if j >= 0 and j < (M + 1) and (preA[i] + preB[j]) <= K:
      	return True
    return False

  res = 0
  while s <= e:
    mid = s + (e - s) // 2
    can = can_read(mid)
    
    if can:
      res = mid
      s = mid + 1
    else:
      e = mid - 1
  
  return res

res = solve(A, N, B, M, K)

print(res)
import sys
input = lambda: sys.stdin.readline().rstrip()

n= int(input())
a=list(input())

v=a.count('1')

ans=[0]*n
A=[0]*n
# n以下の残り回数を記録
for i in range(v+1):
    x=i
    cnt=0
    while x>0:
        cnt+=1
        r = 0
        for j in range(20):
            if (x>>j)&1:
                r+=1
            if x>>j==0:
                break
        x=x%r
    ans[i]=cnt


# 各桁をv＋１で割ったあまり
q = [0]*n
# 各桁をv-1で割ったあまり
r = [0]*n
for i in range(n):
    if a[i]=='1':
        if v!=0:
            q[i] = pow(2, n-i-1,v+1)
        if v!=1:
            r[i] += pow(2, n-i-1,v-1)
qq=sum(q)
rr=sum(r)

for i in range(n):
    if a[i]=='1':
        if v!=1:
            z = rr - pow(2,n-i-1,v-1)
            cnt = z % (v - 1)
            A[i] = 1 + ans[cnt]
    else:
        z=qq+pow(2,n-i-1,v+1)
        cnt=z%(v+1)
        A[i]=1+ans[cnt]

for i in A:
    print(i)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

n= int(input())
a=list(input())

v=a.count('1')

ans=[0]*n
A=[0]*n
# n以下の残り回数を記録
for i in range(n):
    x=i
    cnt=0
    while x>0:
        cnt+=1
        r = 0
        for j in range(19):
            if (x>>j)&1:
                r+=1
            if x>>j==0:
                break
        x=x%r
    ans[i]=cnt

# 各桁をv＋１で割ったあまり
q = [0]*n
# 各桁をv-1で割ったあまり
r = [0]*n
for i in range(n):
    if a[i]=='1':
        if v!=0:
            q[i] = pow(2, n-i-1,v+1) 
        if v!=1:
            r[i] += pow(2, n-i-1,v-1) 
qq=sum(q)
rr=sum(r)

for i in range(n):
    if a[i]=='1':
        if v!=1:
            z = rr - pow(2,n-i-1,v-1)
            cnt = z % (v - 1)
            A[i] = 1 + ans[cnt]
    else:
        z=qq+pow(2,n-i-1,v+1)
        cnt=z%(v+1)
        A[i]=1+ans[cnt]

for i in A:
    print(i)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
wv = [inpl() for _ in range(n)]
rwv = wv[::-1]
# print(rwv)
udp = [[0] * t for _ in range(n)]
ddp = [[0] * t for _ in range(n)]

for i in range(n-1):
    w,v = wv[i]
    for j in range(t):
        if j < w:
            udp[i+1][j] = udp[i][j]
        else:
            udp[i+1][j] = max(udp[i][j], udp[i][j-w] + v)
res = udp[n-1][t-1] + wv[n-1][1]

for i in range(n-1):
    w,v = rwv[i]
    for j in range(t):
        if j < w:
            ddp[i+1][j] = ddp[i][j]
        else:
            ddp[i+1][j] = max(ddp[i][j], ddp[i][j-w] + v)
    res = max(res,ddp[n-1][t-1] + wv[0][1])

for i in range(1,n-2):
    u = i; d = n-i-2
    mx = 0
    for j in range(t):
        tmp = udp[u][j] + ddp[d][n-1-j]
        mx = max(mx, tmp)
    res = max(res, mx)
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,w = inpl()
wv = [inpl() for i in range(n)]
dp = [[0 for i in range(w+1)] for j in range(n+1)]
wv.sort()
wv.sort(key=lambda x:x[1])
ww = [0] * n
vv = [0] * n
for i in range(n):
    ww[i],vv[i] = wv[i][0], wv[i][1]
for i in range(n-1):
    for j in range(w+1):
        if j >= ww[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-ww[i]]+vv[i])
        else:
            dp[i+1][j] = dp[i][j]
res = dp[n-1][w-1]+wv[n-1][1]

dp = [[0 for i in range(w+1)] for j in range(n+1)]
ww[-1],ww[-2] = ww[-2],ww[-1]
vv[-1],vv[-2] = vv[-2],vv[-1]
for i in range(n-1):
    for j in range(w+1):
        if j >= ww[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-ww[i]]+vv[i])
        else:
            dp[i+1][j] = dp[i][j]
print(max(res,dp[n-1][w-1]+vv[n-1]))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
#階乗#
lim = 10**5+1  #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

N, M = MAP()

if 1 < abs(N-M):
	print(0)
	exit()

zans = (fact[N]*fact[M])%mod

if N == M:
	ans = 2*ans%mod

print(ans)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
#階乗#
lim = 10**5+1  #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

N, M = MAP()

if 1 < abs(N-M):
	print(0)
	exit()

ans = (fact[N]*fact[M])%mod

if N == M:
	ans = 2*ans%mod

print(ans)
L, R = map(int, input().split())
ij = [_ % 2019 for _ in range(L, R+1)]
ij_s = sorted(ij)
if ij_s in 3 and 673:
    print(0)
else:
    print((ij_s[0]*ij_s[1]))

### FIXED CODE ###

l, r = map(int, input().split())
if r // 3 > (l - 1) // 3 and r // 673 > (l - 1) // 673:
    print(0)
else:
    print(min(i * j % 2019 for i in range(l, r + 1) for j in range(l, i)))