Harryxun/stf_run huggingface dataset:
import sys
n = int(input())
graph = {i : [] for i in range(n)}
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

stack = [0]
already = set()
parent = [i for i in range(n)]
flg = False
while len(stack) > 0:
    cur = stack.pop(-1)
    already.add(cur)
    for _next in graph[cur]:
        if _next not in already:
            stack.append(_next)
            parent[_next] = cur
            if _next == n - 1:
                flg = True
                break
    if flg:
        break

path = []
cur = n - 1
while cur != 0:
    path.append(cur)
    cur = parent[cur]
path.append(0)
path.reverse()
flg_2 = len(path) % 2 != 0
left = path[len(path) // 2 - 1 + flg_2]
right = path[len(path) // 2 + flg_2]

def dfs(x, last):
    res = 1
    for _next in graph[x]:
        if _next != last:
           res += dfs(_next, x)
    return res

left_res = dfs(left, right)
#print(left_res)
print("Fennec" if left_res > (n - left_res) else "Snuke")


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
graph = {i : [] for i in range(n)}
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

stack = [0]
already = set()
parent = [i for i in range(n)]
flg = False
while len(stack) > 0:
    cur = stack.pop(-1)
    already.add(cur)
    for _next in graph[cur]:
        if _next not in already:
            stack.append(_next)
            parent[_next] = cur
            if _next == n - 1:
                flg = True
                break
    if flg:
        break

path = []
cur = n - 1
while cur != 0:
    path.append(cur)
    cur = parent[cur]
path.append(0)
path.reverse()
flg_2 = len(path) % 2 != 0
left = path[len(path) // 2 - 1 + flg_2]
right = path[len(path) // 2 + flg_2]

def dfs(x, last):
    res = 1
    for _next in graph[x]:
        if _next != last:
           res += dfs(_next, x)
    return res

left_res = dfs(left, right)
#print(left_res)
print("Fennec" if left_res > (n - left_res) else "Snuke")
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N,M,L=map(int,input().split())
    ABCQST=np.array(read().split(),np.int64)
    ABC=ABCQST[:3*M]
    A=ABC[::3]
    B=ABC[1::3]
    C=ABC[2::3]
    ST=ABCQST[3*M+1:]
    S=ST[::2]
    T=ST[1::2]

    graph1=csr_matrix((C,(A,B)),(N+1,N+1))
    graph1_dist=floyd_warshall(graph1,directed=False)

    graph2=np.full(((N+1),(N+1)),np.inf)
    np.fill_diagonal(graph2,0)
    graph2[graph1_dist<=L+0.5]=1

    graph2_dist=floyd_warshall(graph2,directed=False)
    graph2_dist[graph2_dist==np.inf]=0
    graph2_dist=(graph2_dist+0.5).astype(int)
    ans=graph2_dist[S,T]-1
    print("\n".join(ans.astype(str)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N,M,L=map(int,input().split())
    ABCQST=np.array(read().split(),np.int64)
    ABC=ABCQST[:3*M]
    A=ABC[::3]
    B=ABC[1::3]
    C=ABC[2::3]
    ST=ABCQST[3*M+1:]
    S=ST[::2]
    T=ST[1::2]

    graph1=csr_matrix((C,(A,B)),(N+1,N+1))
    graph1_dist=floyd_warshall(graph1,directed=False)

    graph2=np.full(((N+1),(N+1)),np.inf)
    np.fill_diagonal(graph2,0)
    graph2[graph1_dist<=L+0.5]=1

    graph2_dist=floyd_warshall(graph2,directed=False)
    graph2_dist[graph2_dist==np.inf]=0
    graph2_dist=(graph2_dist+0.5).astype(int)
    ans=graph2_dist[S,T]-1
    print("\n".join(ans.astype(str)))


if __name__ == '__main__':
    main()
import sys

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        return lst[0]
    if func(nh):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def findminsum(lst,K,N):
    inf=10**6
    dp=[[inf]*N for s in range(K+1)]
    for s in range(K+1):
        for j in range(N):
            if j==0 and s<=lst[j]:
                dp[s][j]=lst[0]
            elif s>lst[j] and j>0:
                dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
            elif s<=lst[j] and j>0:
                dp[s][j]=min(lst[j],dp[s][j-1])
    # print(lst)
    # print(dp[0][:])
    # print(dp[1][:])
    # print(dp[K][:])
    return dp[K][N-1]


def main():
    N,K=map(int,sys.stdin.readline().strip().split())
    cards=list(map(int,sys.stdin.readline().strip().split()))
    # cards=list(filter(lambda x:x<K,cards))
    # N=len(cards)
    cards.sort()
    ci=list(range(N))
    def func(h):
        c=cards[h]
        cards[h]=0
        ret=findminsum(cards,K-c,N)>=K
        cards[h]=c
        return ret
    #nn=0
    nn=biser(ci,func)
    # for i in range(N):
    #     if cards[i]<K:
    #         c=cards[i]
    #         cards[i]=0
    #         if findminsum(cards,K-c,N)>=K:
    #             nn+=1
    #         cards[i]=c
    #     else:
    #         break
    print(nn+1)

if __name__=='__main__':
    main()


### FIXED CODE ###

#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)
import math


n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = math.inf
okok = 0
for i in range(0,n):
  if(ans > abs(a-t-h[i]*0.006)):
    ans = abs(a-t-h[i]*0.006)
    okok = i+1

print(okok)

### FIXED CODE ###

n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = 1000000000
okok = 0

for i in range(0,n):
  if(ans > abs(a-(t-h[i]*0.006))):
    ans = abs(a-(t-h[i]*0.006))
    okok = i+1

print(okok)
n, k= map(int,input().split())
if k > (n-1)+(n-2):
    print(-1)
elif n == 2:
    if k == 0:
        print(1,2)
    else:
        print(-1)
else:
    for i in range(2,n+1):
        print(1,i)
    ima = (n-1)*(n-2) / 2
    #print(ima)
    hajime = 2
    owari = 3
    while(ima > k):
        print(hajime ,owari)
        ima -= 1
        if(owari < n):
            owari += 1
        else:
            hajime += 1
            owari = hajime + 1


### FIXED CODE ###

#n,q= map(int,input().split())
s = input()
a = 0
for i in range(len(s)-1):
    if s[i] == s[i+1] :
        print("Bad")
        break
else:
    print("Good")
N

### FIXED CODE ###

N=input()
if N[-1] == "3":
  print("bon")
elif int(N[-1]) in [2,4,5,7,9]:
  print("hon")
else:
  print("pon")
n = int(raw_input)
restaurants = []
for i in range(n):
    line = raw_input().split()
    restaurants.append((line[0], int(line[1]), i+1))
restaurants.sort(key=lambda x: (x[0], x[1]))
for i in range(n):
    print resutaurants[i][2]

### FIXED CODE ###

n = int(raw_input())
restaurants = []
for i in range(n):
    line = raw_input().split()
    restaurants.append((line[0], int(line[1]), i+1))
restaurants.sort(key=lambda x: (x[0], -x[1]))
for i in range(n):
    print restaurants[i][2]
# coding: utf-8
# Your code here!
k = int(input())
ans = 10**15
li = []
for i in reversed(list(range(1,10**15))):
    snk = sum([int(j) for j in str(i)])
    if(ans >= i/snk):
        ans = i/snk
        li.append(i)
        
for i in list(reversed(li))[:k]:
    print(i)

### FIXED CODE ###

# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)
N=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

### FIXED CODE ###

n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
a = set(a)

s[0] = 1
s[1] = 1 if n-1 not in a else 0

for i in range(2, n+1):
    if i in a:
        continue
    s[i] = (s[i-1] + s[i-2]) % 1000000007


print(s[n])

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    if m != 0:
        a = [int(input()) for _ in range(m)]
        a = set(a)
    else:
        a = set()
    
    s = [0] * (n+1)
    s[0] = 1
    s[1] = 1 if 1 not in a else 0

    for i in range(2, n+1):
        if i in a:
            continue
        s[i] = (s[i-1] + s[i-2]) % 1000000007

    print(s[n])

main()
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class BIT():
    def __init__(self, n):
        i = 1
        while 2**i <= n:
            i += 1
        self.H = i
        self.N = 2**i
        self.A = [0] * self.N

    def find(self, i):
        r = 0
        while i:
            r += self.A[i]
            i -= i & (i-1) ^ i
        return r

    def update(self, i, x):
        while i < self.N:
            self.A[i] += x
            i += i & (i-1) ^ i

    def query(self, a, b):
        return self.find(b-1) - self.find(a-1)

def main():
    n,m = LI()
    d = collections.defaultdict(list)
    for _ in range(n):
        l,r = LI()
        d[r-l+1].append((l,r))
    r = [n]
    bit = BIT(n+3)
    c = n
    for i in range(2,m+1):
        for a,b in d[i-1]:
            c -= 1
            bit.update(a,1)
            bit.update(b+1,-1)
        t = c
        for j in range(i,m+1,i):
            t += bit.find(j)
        r.append(t)

    return '\n'.join(map(str,r))


print(main())




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class BIT():
    def __init__(self, n):
        i = 1
        while 2**i <= n:
            i += 1
        self.H = i
        self.N = 2**i
        self.A = [0] * self.N

    def find(self, i):
        r = 0
        while i:
            r += self.A[i]
            i -= i & (i-1) ^ i
        return r

    def update(self, i, x):
        while i < self.N:
            self.A[i] += x
            i += i & (i-1) ^ i

    def query(self, a, b):
        return self.find(b-1) - self.find(a-1)

def main():
    n,m = LI()
    d = collections.defaultdict(list)
    for _ in range(n):
        l,r = LI()
        d[r-l+1].append((l,r))
    r = [n]
    bit = BIT(m+3)
    c = n
    for i in range(2,m+1):
        for a,b in d[i-1]:
            c -= 1
            bit.update(a,1)
            bit.update(b+1,-1)
        t = c
        for j in range(i,m+1,i):
            t += bit.find(j)
        r.append(t)

    return '\n'.join(map(str,r))


print(main())
n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), end=' ')
print(sum(si[:si.index('AC')].count('WA') for si in s))

### FIXED CODE ###

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

submission = []
for i in range(n):
    submission.append([])

for i in range(m):
    pi, si = input().split()
    submission[int(pi) - 1].append(si)
    
n_ac = 0
n_penalty = 0
for i in range(n):
    if "AC" in submission[i]:
        n_ac += 1
        ac_index = submission[i].index('AC')
        n_penalty += ac_index
print(n_ac, n_penalty)
# -*- coding: utf-8 -*-
from collections import deque


if __name__ == '__main__':

    n, m = [int(s) for s in input().split(" ")]
    M = [set() for j in range(n)]
    for _ in range(m):
        u, v = [int(s) for s in input().split(" ")]
        M[u].add(v)
        M[v].add(u)
        
    color = [0] * n
    def dfs(u, c):  # depth-first search
        color[u] = c
        for v in M[u]:
            if color[v] == 0:
                dfs(v, c)
    
    c = 1
    for u in range(n):
        if color[u] == 0:
            dfs(u, c)
            c += 1
    
    l = int(input())
    for _ in range(l):
        p, q = [int(s) for s in input().split(" ")]
        if color[p] == color[q]:
            print("yes")
        else:
            print("no")



### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
import sys
sys.setrecursionlimit(200000)


if __name__ == '__main__':

    n, m = [int(s) for s in input().split(" ")]
    M = [set() for j in range(n)]
    for _ in range(m):
        u, v = [int(s) for s in input().split(" ")]
        M[u].add(v)
        M[v].add(u)
        
    color = [0] * n
    def dfs(u, c):  # depth-first search
        color[u] = c
        for v in M[u]:
            if color[v] == 0:
                dfs(v, c)
    
    c = 1
    for u in range(n):
        if color[u] == 0:
            dfs(u, c)
            c += 1
    
    l = int(input())
    for _ in range(l):
        p, q = [int(s) for s in input().split(" ")]
        if color[p] == color[q]:
            print("yes")
        else:
            print("no")
n=int(input())
s=list(input())
v=[]
for i in range(1,n):
    if s[i]==s[i-1]:
        del(v[-1])
        v.append(1)
        
    else:
        v.append(0)


if v[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(v)):
    if v[i-1]==0:
        ans*=2
    elif v[i]==1:
        ans*=3
    else:
        continue
    

mod = 1000000007

print(ans%mod)
        

        
    


### FIXED CODE ###

n=int(input())
s=list(input())
v=[0]
for i in range(1,n):
    if s[i]==s[i-1]:
        del(v[-1])
        v.append(1)
        
    else:
        v.append(0)


if v[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(v)):
    if v[i-1]==0:
        ans*=2
    elif v[i]==1:
        ans*=3
    else:
        continue
    

mod = 1000000007

print(ans%mod)
N = int(input())
Xs = input()
Xlist = Xs.split(' ')
anslist = []
for P in range(int(Xlist[0]),int(Xlist[N - 1])+1):
    ans = 0
    for i in range(len(Xlist)):
        ans = ans + (int(Xlist[i]) - P)**2
    anslist.append(ans)
print(min(anslist))

### FIXED CODE ###

N = int(input())
Xs = input()
Xlist = Xs.split(' ')
Xlist.sort()
anslist = []
if len(set(Xlist)) != 1:
    for P in range(int(Xlist[0]),int(Xlist[N - 1])+1):
        ans = 0
        for i in range(len(Xlist)):
            ans = ans + (int(Xlist[i]) - P)**2
        anslist.append(ans)
    print(min(anslist))
else:
    print(0)
x=int(input())
ans=0
while i < x:
    i+=ans
    ans+=1
print(ans-1)


### FIXED CODE ###

x=int(input())
ans,i=0,0
while i < x:
    i+=ans
    ans+=1
print(ans-1)
#!/usr/bin/env python3
import sys

H, W = map(int, input().split())
a = ""
for i in range(H):
    a += input()

# count = {}
count_all = len(a)
count_4 = 0
count_2 = 0
count_1 = 0

for s in "abcdefghijklmnopqrstuvwxyz":
    # count[s] = a.count(s)
    c = a.count(s)
    count_4 += c//4
    c = c%4
    count_2 += c//2
    c = c%2
    count_1 += c

if W%2 == 1 and H%2 == 0:
    W, H = H, W

if W%2 == 0 and H%2 == 0:
    if count_4 < W*H//4:
        print("No")
    else:
        print("Yes")
elif W%2 == 0 and H%2 == 1:
    if count_4 < W*(H-1)//4:
        # print(count_4, W*(H-1)//4)
        sys.stderr.write((count_4, W*(H-1)//4))
        print("No")
    elif 2*(count_4 - W*(H-1)//4) + count_2 < W//2:
        print("No")
    else:
        print("Yes")
else:
    if count_4 < (W-1)*(H-1)//4:
        print("No")
    elif 2*(count_4 - (W-1)*(H-1)//4) + count_2 < (W+H-2)//2:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

#!/usr/bin/env python3

H, W = map(int, input().split())
a = ""
for i in range(H):
    a += input()

# count = {}
count_all = len(a)
count_4 = 0
count_2 = 0
count_1 = 0

for s in "abcdefghijklmnopqrstuvwxyz":
    # count[s] = a.count(s)
    c = a.count(s)
    count_4 += c//4
    c = c%4
    count_2 += c//2
    c = c%2
    count_1 += c

if W%2 == 1 and H%2 == 0:
    W, H = H, W

if W%2 == 0 and H%2 == 0:
    if count_4 < W*H//4:
        print("No")
    else:
        print("Yes")
elif W%2 == 0 and H%2 == 1:
    if count_4 < W*(H-1)//4:
        # print(count_4, W*(H-1)//4)
        print("No")
    elif 2*(count_4 - W*(H-1)//4) + count_2 < W//2:
        print("No")
    else:
        print("Yes")
else:
    if count_4 < (W-1)*(H-1)//4:
        print("No")
    elif 2*(count_4 - (W-1)*(H-1)//4) + count_2 < (W+H-2)//2:
        print("No")
    else:
        print("Yes")
# -*- coding: utf-8 -*-

import sys

primes = [2]
for i in range(3, 50010):
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

for line in sys.stdin:
    n = int(line)
    i = 0
    while primes[i] < n and i < len(primes):
        i += 1
    if primes[i] == n:
        s = primes[i-1]
    else:
        s = primes[i]
    m = primes[i+1]
    print s, m

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys

primes = [2]
for i in range(3, 50022):
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

for line in sys.stdin:
    n = int(line)
    i = 0
    while primes[i] < n and i < len(primes):
        i += 1
    if primes[i] == n:
        s = primes[i-1]
        m = primes[i+1]
    else:
        s = primes[i-1]
        m = primes[i]
    print s, m
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i-1)) for i in input().split()])
        for s in range(p):
                t = s|c
                new = dp[s] + a
                if dp[t] > new:
                    dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

n, m = map(int, input().split())
ac = []
for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(i)-1) for i in input().split()])
    ac.append([a, c])
dp = [float('inf')] * 2**n
dp[0] = 0
for s in range(2**n):
    for a, c in ac:
        t = s|c
        if dp[t] > dp[s] + a:
            dp[t] = dp[s] + a
ans = dp[-1]
if ans == float('inf'):
    ans = -1
print(ans)
print min(raw_input().count(i) for i in "KUPC")

### FIXED CODE ###

a = raw_input()
print min(a.count(i) for i in "KUPC")
n = int(input())
s = []
for i in range(n):
    s += [int(input())]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    a = []
    for i in range(n):
        a += [s[i]]
        if (sum(s) - sum(a)) % 10 != 0:
            print(sum(s) - sum(a))
            f = 0
            exit()
        else:
            f = 1
if f:
    print(0)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s += [int(input())]
s = sorted(s)
a = sum(s)
if a % 10 != 0:
    print(a)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            a -= s[i]
            if a % 10 != 0:
                print(a)
                f = 0
                exit()
        else:
            f = 1
if f:
    print(0)
x,y,a,b,c = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
res = 0

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

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

p_sum = sum(p)
q_sum = sum(q)

for i in r:
    p_temp = (p_sum - p[-1] + i)
    q_temp = (q_sum - q[-1] + i)
    if p_temp >= p_sum or q_temp >= q_sum:        
        if p_temp - p_sum > q_temp - q_sum:
            p_sum = p_temp
            p.pop(-1)        
        else:
            q_sum = q_temp
            q.pop(-1)

print(p_sum + q_sum)
    

### FIXED CODE ###

x,y,a,b,c = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
res = 0

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

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

p_sum = sum(p)
q_sum = sum(q)

p_num = -1
q_num = -1

for i in r:
    if p_num >= (len(p) * -1):
        p_temp = (p_sum - p[p_num] + i)
    else:
        p_temp = -1
    if q_num >= (len(q) * -1):
        q_temp = (q_sum - q[q_num] + i)
    else:
        q_temp = -1

    if p_temp >= p_sum or q_temp >= q_sum:        
        if p_temp - p_sum > q_temp - q_sum:
            p_sum = p_temp
            p_num -= 1        
        else:
            q_sum = q_temp
            q_num -= 1        
    else:
        break
    




print(p_sum + q_sum)
a=input()
b=input()
s=[]
if len(a)==len(b):
    for i in range(len(a)):
        s.append(a[i])
        s.append(b[i])
else:
    for i in range(len(b)):
        s.append(a[i])
        s.append(b[i])
    s.append(a[range(len(b))+1])
print("".join(s))

### FIXED CODE ###

a=input()
b=input()
s=[]
if len(a)==len(b):
    for i in range(len(a)):
        s.append(a[i])
        s.append(b[i])
else:
    for i in range(len(b)):
        s.append(a[i])
        s.append(b[i])
    s.append(a[-1])
print("".join(s))
s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if not s[i] in "LUD":
      print("No")
      exit()
print("Yes"


### FIXED CODE ###

s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if not s[i] in "LUD":
      print("No")
      exit()
print("Yes")
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
ans=0
for i in range(N):
    A = list(map(int, input().split()))
    ssum = sum([A[i]*B[i] for i in range(M)])+C
    if ssum>0:
        ans+=1
print(ans)

### FIXED CODE ###

H,W=map(int, (input().split()))
h,w=map(int, (input().split()))
ans=H*W-h*W-H*w+h*w
print(ans)