Harryxun/stf_run huggingface dataset:
r, c = map(int, input().split())

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

dp_table = [[[False] * 6400 for _2 in range(c)] for _1 in range(r)]

dp_table[0][0][abs(A[0][0] - B[0][0])] = True

for i in range(1, r):
    temp = A[i][0] - B[i][0]
    up_list = dp_table[i - 1][0]
    for idx, up in enumerate(up_list):
        if up:
            dp_table[i][0][abs(idx + temp)] = True
            dp_table[i][0][abs(idx - temp)] = True

for j in range(1, c):
    temp = A[0][j] - B[0][j]
    left_list = dp_table[0][j]
    for idx, left in enumerate(left_list):
        if left:
            dp_table[0][j][abs(idx + temp)] = True
            dp_table[0][j][abs(idx - temp)] = True

for i in range(1, r):
    for j in range(1, c):
        temp = A[i][j] - B[i][j]
        up_list = dp_table[i - 1][j]
        for idx, up in enumerate(up_list):
            if up:
                dp_table[i][j][abs(idx + temp)] = True
                dp_table[i][j][abs(idx - temp)] = True
        left_list = dp_table[i][j - 1]
        for idx, left in enumerate(left_list):
            if left:
                dp_table[i][j][abs(idx + temp)] = True
                dp_table[i][j][abs(idx - temp)] = True

print(dp_table[r - 1][c - 1].index(True))

### FIXED CODE ###

R, C = map(int, input().split())

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

dp = [0] * C
dp[0] = s = 1 << 6400

for row_a, row_b in zip(A, B):
    for i, (a, b) in enumerate(zip(row_a, row_b)):
        d = abs(a - b)
        if i > 0:
            dp[i] |= dp[i - 1]
        dp[i] = (dp[i] << d) | (dp[i] >> d)

g = dp[-1]
for i in range(6401):
    if g & (s << i) or g & (s >> i):
        print(i)
        quit()
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    dp = [0] *(N+2)
    ckc = [True] * (N+2)
    for i in a:
        ckc[i] = False

    def f(n: int):
        if(dp[n] != 0):
            return dp[n]

        if n <= 0:
            dp[n] = 0
        else:
            if not ckc[n-1] and not ckc[n-2]:
                dp[n] = 0
            elif not ckc[n-1]:
                dp[n] = f(n-2) % MOD
            elif not ckc[n-2]:
                dp[n] = f(n-1) % MOD
            else:
                dp[n] = (f(n-1) + f(n-2)) % MOD
            
        return dp[n]

    dp[0] = 1
    f(N)
    print(dp[N])
    # print(dp)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    if(len(a) >= 2):
        l = [a[i+1]-a[i] for i in range(M-1)]
        if(len(l) and min(l)<=1):
            print(0)
            exit()

    dp = [1] * (N+1)
    dp[1] = 1
    if(N >= 2):
        dp[2] = 2
    x = 0
    # if(M == 0):
    #     for i in range(2,N+1)
    
    for i in range(2,N+1):
        if(len(a) and a[x] == i-1):
            dp[i] = dp[i-2] % MOD
            # x = min(x+1,M-1)
        elif(len(a) and a[x] == i-2):
            dp[i] = dp[i-1] % MOD
            x = min(x+1,M-1)
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
    print(dp[N])
    
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()
N= int(input())
ans =0
if N<=2:
    print('0')
else:
    ans=N//3
    print(ans)

### FIXED CODE ###

N = int(input())
ans =0
if N<=2:
    print('0')
else:
    ans=N//3
    print(ans)
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10**8)
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):

    # 最小公倍数
    lcm = np.lcm.reduce(A)
    ans = np.mod(np.sum(lcm//A, dtype=np.int64), MOD)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter
import math
MOD = 1000000007  # type: int


def factorial(n):
    prime_count = Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % MOD
    elif y % 2 == 0:
        return power(x, y//2)**2 % MOD
    else:
        return power(x, y//2)**2 * x % MOD


def div(a, b):
    return (a * power(b, MOD-2)) % MOD


def solve(N: int, A: "List[int]"):

    lcm = Counter()
    for a in A:
        c = factorial(a)
        for k in c:
            lcm[k] = max(c[k], lcm[k])
    # print(lcm)

    LCM = 1
    for k, v in lcm.items():
        LCM *= power(k, v)
        LCM %= MOD
    # print(LCM)

    tot = 0
    for a in A:
        tot += div(LCM, a)
    print(tot % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()
import numpy as np

#まず一行目の"N M"を取得
N,M=map(int, input().split()) 

#2-M+1行目を入力する
arr_path=np.array([0,0])
#空のarrayを値0として定義した
for i in range(M):
    a,b=map(int,input().split())
    arr=np.array([a,b])
    arr_path=np.vstack([arr_path,arr])    

#もはや入れ子構造のリストを使うことにして、level_0のような表現は必要ない
#層の全体を格納するリストのリスト（index0,1,2..と引数に対応して、層0,1,2...と対応する）
class_layer=[]
class_layer.append([1])

#部屋xからの移動先を出力する関数
def transit(x):
    path=arr_path[np.any(arr_path==x, axis=1)]
    #これはいま部屋iを考えている（levelという層にある部屋）
    #pathをarrayから抽出して、その部屋から移動することを考える
    path=path[path != x]
    trans_list=path.tolist()
    return trans_list

#層構造(x層)を1上げて上の層を出力する関数を定義する
def level_up(x):
    now=class_layer[x]
    pre=[]
    if x >=1:
        pre=class_layer[x-1]
    li=[] 
    for i in now:
        for j in transit(i):
            if j in now:
                continue
            elif j in pre:
                continue
            else:
                li.append(j)
    class_layer.append(li)
    
for i in range(M):
    level_up(i)


#1つの部屋に対して、その部屋が何番目の層なのか出力する
def layer_finder(x):
    for i in range(M):
        for j in class_layer[i]:
            if j==x:
                global ans
                ans=i
                #local変数になってしまっていて、関数外でいまいちうまく使えないので、変数を置く前にglobal宣言というものをしてglobal変数にする
                break
            else:
                continue
    return ans


#部屋xが何番の矢印を示せばいいのか出力
def path_get(x):
    #部屋xは層が幾つなのか
    X=layer_dict[x-1]
    #(X-1)層の部屋番号を出力
    li1=class_layer[X-1]
    
    #部屋xからの移動先
    path=arr_path[np.any(arr_path==x, axis=1)]
    path=path[path != x]
    li2=path.tolist()
    
    #l1とl2の共通部分を出す
    #setと&を使うといいらしい!
    li_common=list(set(li1) & set(li2))
    
    print(li_common[0])
    

    
print("yes")
for i in range(2,N+1):
    path_get(i)


### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K)/N
    for k in range(1, K):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
else:
    for k in range(1, N+1):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
print(pro)


### FIXED CODE ###

import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = 10 ** 10
for _ in range(N):
  x, y = map(int, input().split())
  if x != y: f = 0
  if x > y:
    t = min(t, y)
  res += y
if f:
  print(0)
  exit(0)

print(res - t)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
c = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  if x == y: c += 1
  res += x
if c == N:
  print(0)
  exit(0)
print(res - t)
x = int(input())
x_list = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
print(y[x])


### FIXED CODE ###

x = int(input())
y = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
print(y[x-1])
n, a, b, c, d, e = [int(input()) for _ in range(6)]
r = [h for h in [a,b,c,d,e] if h != 1]
if 1 in [a,b,c,d,e]:
  r -= 1
dd, ii = modf(n/min(r))

### FIXED CODE ###

n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)
daydream = ['reamd','reamerd','rasee','rasere']
S = input()
S = strip(S[0])
if 'reamd' in S:
    S = S.strip('reamed')
if 'reamrd' in S:
    S = S.strip('reamerd')
if 'rasee' in S:
    S = S.strip('rasee')
if 'rasere' in S:
    S = S.strip('rasere')
if not str:
    print('NO')
else:
    print('YES')

### FIXED CODE ###

s = input()
if 'eraser' in s:
    s = s.replace('eraser','')
if 'erase' in s:
    s = s.replace('erase','')
if 'dreamer' in s:
    s = s.replace('dreamer','') 
if 'dream' in s:
    s = s.replace('dream','') 
emp = len(s)
if emp == 0:
    print('YES')
else:
    print('NO')
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
L = LI()
cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if len({[L[i], L[j], L[k]]}) != 3:
                continue
            Li = [L[i], L[j], L[k]]
            Li.sort()
            if Li[2] <= Li[0] + Li[1]:
                cnt += 1

print(cnt)
                
            

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
L = LI()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            Li = [L[i], L[j], L[k]]
            if len(set(Li)) != 3:
                continue
            Li.sort()
            if Li[2] < Li[0] + Li[1]:
                cnt += 1

print(cnt)
a,b=[int(x) for x in input().split(" ")]
x=(b-2a)/2
y=(4a-b)/2
print("Yes" if x>0 and y>0 and x%1==0.0 and y%1==0.0 else "No")

### FIXED CODE ###

a,b=[int(x) for x in input().split(" ")]
x=(b-2*a)/2
y=(4*a-b)/2
print("Yes" if x>=0 and y>=0 and x%1==0.0 and y%1==0.0 else "No")
T = input()
	print(T.replace('?','D'))

### FIXED CODE ###

T = input()
print(T.replace('?','D'))
a, b = int(input())
ans = 0
ans += max(a, b)*2 - 1
print(ans)

### FIXED CODE ###

a, b = map(int, input().split())
ans = 0
ans += max(a, b)
ans += max(ans-1, min(a, b))
print(ans)
#! python3
def main():
    N = input()
    ans = 0
    for i in range(1,N+1):
        ans += i
    print(ans)
main()

### FIXED CODE ###

#! python3
def main():
    N = int(input())
    ans = 0
    for i in range(N):
        ans += (i+1)
    print(ans)
main()
s=input()
a=0
for i in range(3):
  if i%2==0 and s[i]=="0":
  	a=1
  if i%2==1 and s[i]=="1":
  	a+=1  
print(min(a,len(s)-a))

### FIXED CODE ###

s=input()
a=0
for i in range(len(s)):
  if i%2==0 and s[i]=="0":
  	a+=1
  if i%2==1 and s[i]=="1":
  	a+=1  
print(min(a,(len(s)-a)))
groups = [[1, 3, 5, 7, 8, 12], [4, 6, 9, 11], [2]]
gg = lambda t: [i for i in range(0, 3) if t in groups[i]][0]
x, y = map(int, input().split())
print('Yes' if gg(x) == gg(y) else 'No')

### FIXED CODE ###

groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
gg = lambda t: [i for i in range(0, 3) if t in groups[i]][0]
x, y = map(int, input().split())
print('Yes' if gg(x) == gg(y) else 'No')
a,b,c=map(int,input().split())
print(max(abc)*10 + a + b + c - max(abc))


### FIXED CODE ###

a,b,c=map(int,input().split())
print(max(a,b,c)*10 + a + b + c - max(a,b,c))
N = int(input())
A = [int(input()) for i in range(N)]
A_count = [0] * max(A)

for i in A:
    if A_count[i-1] == 0:
        A_count[i-1] = 1
    elif A_count[i-1] == 1:
        A_count[i-1] = 0

print(sum(A_count))

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
sorted_A = sorted(A)

pre = sorted_A[0]
ans = 0
if len(sorted_A) == 1:
    print(1)
else:
    count = 1
    for i in range(1, len(sorted_A)):
        if sorted_A[i] == pre:
            count += 1
            if i == len(sorted_A)-1:
                if count % 2 == 1:
                    ans += 1
        else:
            if i == len(sorted_A)-1:
                ans += 1
            if count % 2 == 1:
                ans += 1
            pre = sorted_A[i]
            count = 1
    print(ans)
while 1:
        n = input()
        a,b = (0,0)
        for i in range(n):
                x = map(int, raw_input().split())
                if x[0] > x[1]:
                        a += x[0] + x[1]
                elif x[0] < x[1]:
                        b += x[0] + x[1]
                else:
                        a += x[0]
                        b += x[0]
        print str(a) + ' ' + str(b)

### FIXED CODE ###

while 1:
        n = input()
        if n == 0: break
        a,b = (0,0)
        for i in range(n):
                x = map(int, raw_input().split())
                if x[0] > x[1]:
                        a += x[0] + x[1]
                elif x[0] < x[1]:
                        b += x[0] + x[1]
                else:
                        a += x[0]
                        b += x[0]
        print str(a) + ' ' + str(b)
s = list(map(int,input().split()))
cnt = 0
for i in range(3):
  if s[i]!==s[i+1]:
    cnt=i
    break
if cnt>=2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
mae_n = n[:-1]
ushiro_n = n[1:]
if (len(set(mae_n))==1)or(len(set(ushiro_n))==1):
  print("Yes")
else:
  print("No")
N = int(input(''))
if (N % 2) == 0:
  print(round(2/N),10)
else:
  print(round((N+1)/2N),10)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))
x = input()
print('A') if isupper(x) else print('a')

### FIXED CODE ###

x = input()
print('A') if x.isupper() else print('a')
import re
S = input()
l = len(S)
while True:
  if re.sub('01|10','',S) == S
  	break
  else:
    S = re.sub('01|10','',S)
print(l-len(S))

### FIXED CODE ###

S = input()
print(min(S.count('0'),S.count('1'))*2)
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

dx = [-1,0,1,0]
dy = [0,-1,0,1]

def readInts():
  return list(map(int,input().split()))
def search(S,x,y,h,w):
    #全探索で間に合うべ
    cnt = 0
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < w and 0 <= ny < h:
            if S[nx][ny] == '#':
                cnt += 1
    if not cnt:#隣接する#が一つもない
        return False
    else:
        return True

def main():
    h,w = readInts()
    S = [list(input()) for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if S[i][j] == '#':
                if search(S,i,j,h,w):
                    pass
                else:
                    print('No')
                    exit()
    print('Yes')


if __name__ == '__main__':
  main()


### FIXED CODE ###

#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

dx = [-1,0,1,0]
dy = [0,-1,0,1]

def readInts():
  return list(map(int,input().split()))
def search(S,y,x,h,w):
    #全探索で間に合うべ
    cnt = 0
    #print(y,x)
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        #print('nya',ny,nx)
        if 0 <= nx < w and 0 <= ny < h:
            #print('here',nx,ny)
            if S[ny][nx] == '#':
                cnt += 1
    #print(cnt)
    if cnt == 0:#隣接する#が一つもない
        return False
    else:
        return True

def main():
    h,w = readInts()
    S = [input() for _ in range(h)]
    #print(S)
    for i in range(h):
        for j in range(w):
            if S[i][j] == '#':
                #print(i,j)
                if search(S,i,j,h,w):
                    pass
                else:
                    print('No')
                    exit()
    print('Yes')


if __name__ == '__main__':
  main()
2000000000 0 0 2000000000

### FIXED CODE ###

a,b,c,k = map(int, input().split())

x = k - a
if x <= 0:
    print(k)
else:
    y = x - b
    if y <= 0:
        print(a)
    else: 
        print(a + ((k - (a + b)) * (-1)))
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

if N==K: #全部
    ans=1
    for i in range(N):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()
if max(A)<0 and K%2==1: #答えがマイナス
    A.sort(reverse=True)
    ans=1
    for i in range(K):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()

plus=[]
minus=[]
for i in range(N):
    if A[i]>=0:
        plus.append(A[i])
    else:
        minus.append(A[i])
plus.sort(reverse=True) #5,3,1
minus.sort() #-5,-3,-1
plus_k=0
minus_k=0
if K%2==0:
    ans=1
else:
    ans=plus[0]
    plus_k=1

for _ in range(K):
    if plus_k+minus_k==K:
        break
    if plus_k==len(plus)-1:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
    if minus_k==len(minus)-1:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    if plus[plus_k]*plus[plus_k+1]>minus[minus_k]*minus[minus_k+1]:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    else:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

if N==K: #全部
    ans=1
    for i in range(N):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()
if max(A)<0 and K%2==1: #答えがマイナス
    A.sort(reverse=True)
    ans=1
    for i in range(K):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()

plus=[]
minus=[]
for i in range(N):
    if A[i]>=0:
        plus.append(A[i])
    else:
        minus.append(A[i])
plus.sort(reverse=True) #5,3,1
minus.sort() #-5,-3,-1
plus_k=0
minus_k=0
if K%2==0:
    ans=1
else:
    ans=plus[0]
    plus_k=1

for _ in range(K):
    if plus_k+minus_k==K:
        break
    if plus_k>=len(plus)-1:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
    if minus_k>=len(minus)-1:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    if plus[plus_k]*plus[plus_k+1]>minus[minus_k]*minus[minus_k+1]:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    else:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
print(ans)
import sys
#input = sys.stdin.readline
#sys.setrecursionlimit(10**6)

def main():
    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)

    p = p[:x]
    q = q[:y]
    p.sort()
    q.sort()
    for ir in range(c):
        if ir <= x  and ir <= y:
            if p[ir] < q[ir]:
                if p[ir] < r[ir]:
                    p[ir] = r[ir]
            else:
                if q[ir] < r[ir]:
                    q[ir] = r[ir]
        elif ir <= x:
            if p[ir] < r[ir]:
                p[ir] = r[ir]
        elif ir <= y:
            if q[ir] < r[ir]:
                q[ir] = r[ir]

    print(sum(p) + sum(q))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
#input = sys.stdin.readline
#sys.setrecursionlimit(10**6)

def main():
    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)

    p = p[:x]
    q = q[:y]

    all = []
    all.extend(p)
    all.extend(q)
    all.extend(r)
    all.sort(reverse=True)
    all = all[:x+y]



    print(sum(all))


if __name__ == '__main__':
    main()