Harryxun/stf_run huggingface dataset:
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [i for i in range(n)]
        # 木の高さを格納する（初期状態は0）
        self.rank = [0] * (n)
    
    def find(self, x):
        """検索"""
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら、親の要素で再検索
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """併合"""
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        """同じ集合に属するか判定"""
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
*p, = map(int, input().split())
xy = [(*map(int,input().split()),) for _ in range(M)]
result = 0

union = UnionFind(N)
for x,y in xy:
    union.union(x-1,y-1)

for i in p:
    if union.same_check(p[i-1]-1,i-1):
        result += 1

print(result)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):

        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x

            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):

        return self.find(x) == self.find(y)


N, M = map(int, input().split())
*p, = map(int, input().split())
xy = [map(int,input().split()) for _ in range(M)]
result = 0

union = UnionFind(N)
for x,y in xy:
    union.union(x-1,y-1)

for i in p:
    if union.same_check(p[i-1]-1,i-1):
        result += 1

print(result)
# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
print(med)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))


### FIXED CODE ###

# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
med = median(b)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))
# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

keta=0

for i in range(30,-1,-1):
	if (K>>i)&1:
		keta=i+1
		break


C=[ 0 for i in range(keta) ]	#桁ごとのbit 1の出現回数

for a in A:
	for k in range(keta,-1,-1):
	#	print k, x>>k, (x>>k)&1
		if (a>>k)&1:		#その桁のbitが1なら、出現回数に+1
			C[k]+=1



X=0	# f(x)が最大となるX


for idx, i in enumerate(C):
	if i<=N/2:
		X+=2**idx	#桁ごとに見て、ゼロの数が多ければ、f(x)が最大となるXとなるXのidx番目の桁は1になる

ans=0
for a in A:
	ans+=X^a

print ans

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

keta=0

for i in range(50,-1,-1):
	if (K>>i)&1:
		keta=i+1
		break



C=[ 0 for i in range(keta) ]	#桁ごとのbit 1の出現回数


for a in A:
	for k in range(keta-1,-1,-1):
		#print "k, a>>k, (a>>k)&1 ::::: ",k, a>>k, (a>>k)&1
		if (a>>k)&1:		#その桁のbitが1なら、出現回数に+1
			C[k]+=1



X=0	# f(x)が最大となるX


len_c=len(C)

for i in range(len_c-1,-1,-1):
	ci=C[i]
	if  C[i]<(N+1)/2:
		if X+2**i<=K:
			X+=2**i		#桁ごとに見て、ゼロの数が多ければ、f(x)が最大となるXとなるXのidx番目の桁は1になる
					#1と0が同数の場合は、その桁を0にしたほうが、Xが小さくなるので有利

ans=0
for a in A:
	ans+=X^a

print ans
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            if i != k:
                                a.append([i, j, k])
    b = []
    for i in a:
        b.append(sorted(i))

    c = []
    c = sorted(b)

    cnt = 1
    t = c[0]
    for i in c:
        if t != i:
            cnt += 1
            t = i
    print(cnt)

### FIXED CODE ###

import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)
a, b = map(int, input().split())

c = a + b

if a == 1 and b == 2:
    print(3)
elif b == 1 and a == 2:
    print(3)
elif a == 1 and b == 3:
    print(2)
elif b == 1 and a == 3:
    print(2)
elif a == 2 and b == 3:
    print(1)
elif b == 2 and a == 3:
    print(1)

### FIXED CODE ###

A = int(input())
B = int(input())

c = A + B
 
if c == 3:
    print(3)
elif c == 4:
    print(2)
elif c == 5:
    print(1)
def main():
    N, M = map(int, input().split())
    V = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        V[a - 1].append(b - 1)
    C = [0] * N
    loop = []
    def dfs(n):
        if C[n] == 2:
            return False
        if C[n] == 1:
            loop.append(n)
            return True
        C[n] = 1
        for i in V[n]:
            if dfs(i):
                loop.append(n)
                return True
        C[n] = 2
        return False
    for i in range(N):
        if dfs(i):
            break
    if len(loop) == 0:
        print('-1')
        return
    for i in range(1, len(loop)):
        if loop[i] == loop[0]:
            break
    loop = loop[:i][::-1]

    def minimize(l):
        s = set(l)
        for i in range(len(l)):
            for j in V[l[i]]:
                if j == l[(i + 1) % len(l)]:
                    continue
                if j in s:
                    break
            else:
                continue
            break
        else:
            return l
        I = {m: k for k, m in enumerate(l)}
        j = I[j]
        if i < j:
            l = l[0:i + 1] + l[j:]
        else:
            l = l[j:i + 1]
        return l
    while True:
        t = len(loop)
        loop = minimize(loop)
        if len(loop) == t:
            break
    print(t)
    print('\n'.join(str(i + 1) for i in loop))
main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def main():
    N, M = map(int, input().split())
    V = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        V[a - 1].append(b - 1)
    C = [0] * N
    loop = []
    def dfs(n):
        if C[n] == 2:
            return False
        if C[n] == 1:
            loop.append(n)
            return True
        C[n] = 1
        for i in V[n]:
            if dfs(i):
                loop.append(n)
                return True
        C[n] = 2
        return False
    for i in range(N):
        if dfs(i):
            break
    if len(loop) == 0:
        print('-1')
        return
    for i in range(1, len(loop)):
        if loop[i] == loop[0]:
            break
    loop = loop[:i][::-1]

    def minimize(l):
        s = set(l)
        for i in range(len(l)):
            for j in V[l[i]]:
                if j == l[(i + 1) % len(l)]:
                    continue
                if j in s:
                    break
            else:
                continue
            break
        else:
            return l
        I = {m: k for k, m in enumerate(l)}
        j = I[j]
        if i < j:
            l = l[0:i + 1] + l[j:]
        else:
            l = l[j:i + 1]
        return l
    while True:
        t = len(loop)
        loop = minimize(loop)
        if len(loop) == t:
            break
    print(t)
    print('\n'.join(str(i + 1) for i in loop))
main()
# -*- coding: utf-8 -*-
multi_0 = [a for a in range(1,100)]
multi_100 = [a for a in range(100,10001) if a % 100 == 0]
multi_10000 = [a for a in range(10000, 1000001) if a % 10000 == 0]

D, N = map(int, input().split())
if D == 0:
    print(multi_0[N-1])
elif D == 1:
    print(multi_100[N-1])
elif D == 2:
    print(multi_10000[N-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
multi_0 = [a for a in range(1,100)]
multi_100 = [a for a in range(100,10000) if a % 100 == 0]
multi_10000 = [a for a in range(10000, 1000000) if a % 10000 == 0]

multi_0 += [101]
multi_100 += [10100]
multi_10000 += [1010000]

D, N = map(int, input().split())
if D == 0:
    print(multi_0[N-1])
elif D == 1:
    print(multi_100[N-1])
elif D == 2:
    print(multi_10000[N-1])
import numpy as np

A, B = [int(i) for i in input().split()]

print(np.lcm(A, B))


### FIXED CODE ###

import fractions

A, B = [int(i) for i in input().split()]

print(int(A*B/fractions.gcd(A, B)))
n=int(input)
s,t=input().split()
ans=''
for i in range(n):
  ans +=s[i]
  ans +=t[i]
print(ans)

### FIXED CODE ###

n=int(input())
s,t=input().split()
ans=''
for i in range(n):
  ans +=s[i]
  ans +=t[i]
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))

lst=[0]*35


for i in a:
  for j in range(35):
    if (i>>j)%2==1:
      lst[j]+=1

k=bin(k)[2:]
x=35-len(k)
k='0'*x+k
dp=[[0]*2 for i in range(36)]
flag=False


for i in range(35):
  if k[i]=='1':
    dp[i+1][0]=dp[i][0]+(n-lst[len(k)-i-1])*(2**(len(k)-i-1))
    dp[i+1][1]=dp[i][0]+lst[len(k)-i-1]*(2**(len(k)-i-1))
  
  else:
    dp[i+1][0]=dp[i][0]+lst[len(k)-i-1]*(2**(len(k)-i-1))

  if flag:
    dp[i+1][1]=max(dp[i+1][1],dp[i][1]+lst[len(k)-i-1]*(2**(len(k)-i-1)),dp[i][1]+(n-lst[len(k)-i-1])*(2**(len(k)-i-1)))
  
  if k[i]=='1':
      flag=True

print(max(dp[-1][0],dp[-1][1]))

### FIXED CODE ###

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

lst=[0]*50


for i in a:
  for j in range(50):
    if (i>>j)%2==1:
      lst[j]+=1

k=bin(k)[2:]

dp=[[0]*2 for i in range(len(k)+1)]


for i in range(len(k)):
  if k[i]=='1':
    dp[i+1][0]=dp[i][0]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1))
    dp[i+1][1]=dp[i][0]
  else:
    dp[i+1][0]=dp[i][0]

  if i==0:
      continue
  
  dp[i+1][1]=max(dp[i+1][1],dp[i][1],dp[i][1]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1)))


print(sum(a)+max(dp[-1][0],dp[-1][1]))
import sys

def main():
    arg = sys.argv[1:]
    a = int(arg[0])
    b = int(arg[2])
    op = arg[1]
    if a < 1 or b > 10 **9:
        return 0

    if op == "+":
        return a + b
    elif op == "-":
        return a - b
    else:
        return 0

print main()


### FIXED CODE ###

import sys

def main():
    arg = raw_input().split(" ")
    a = int(arg[0])
    b = int(arg[2])
    op = arg[1]
    if a < 1 or b > 10 **9:
        return 0

    if op == "+":
        return a + b
    elif op == "-":
        return a - b
    else:
        return 0

print main()
a, b = map(int, input().split())
import math

gcd = math.gcd(a, b)
i, cnt = 2, 1
while i * i <= gcd:
    flag = 0
    while gcd % i == 0:
        flag = 1
        gcd //= i
    if flag:
        cnt += 1
    i += 1
if gcd != 1:
    cnt += 1
print(cnt)


### FIXED CODE ###

a, b = map(int, input().split())
import math


def _gcd(x, y):
    if y == 0:
        return x
    return _gcd(y, x % y)


gcd = _gcd(a, b)
i, cnt = 2, 1
while i * i <= gcd:
    flag = 0
    while gcd % i == 0:
        flag = 1
        gcd //= i
    if flag:
        cnt += 1
    i += 1
if gcd != 1:
    cnt += 1
print(cnt)
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

gcd=gcd(first_distance[0],first_distance[1])
for i in range(2,n):
    gcd=gcd(gcd,first_distance[i])
print(gcd)

### FIXED CODE ###

num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)
a = int(input())
b = int(input())
print(a*b), print(2*(a+b))



### FIXED CODE ###

a,b = (int(x) for x in input().split())
print(a*b,2*(a+b))
import sys
from collections import defaultdict

n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353

d2 = [1]
tmp = 1
for i in range(n):
    tmp = tmp * 2 % MOD
    d2.append(tmp)

s = sum(aaa)
dp = [defaultdict(lambda: 0) for _ in [0] * (s + 1)]
dp[0][0] = 1
tmp_sum = 0
for a in aaa:
    for i in range(tmp_sum, -1, -1):
        dd = dp[i]
        if not dd:
            continue
        for k, p in dd.items():
            dp[i + a][k + 1] += p
    tmp_sum += a

ans = pow(3, n, MOD)
sub = 0
h = (s + 1) // 2
for dd in dp[h:]:
    for k, p in dd.items():
        sub += d2[n - k] * p * 3
    sub %= MOD
if s % 2 == 0:
    dd = dp[h]
    for k, p in dd.items():
        sub -= p * 3

ans = (ans - sub) % MOD
print(ans)


### FIXED CODE ###

n = int(input())
s = input()

f = [0]
tmp = 0
for c in s:
    if c == '#':
        tmp += 1
    f.append(tmp)

b = [0]
tmp = 0
for c in s[::-1]:
    if c == '.':
        tmp += 1
    b.append(tmp)
b.reverse()

# print(f)
# print(b)
print(min(map(sum, zip(f, b))))
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0: a.append(i)


num = int(input())
dis(num)
ans = 100000000
for e in a:
    ans = min(ans, e + num // e - 2)
print(ans)

### FIXED CODE ###

def solve(n):
    ans = int(1e12)
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0 and i + n // i - 2 < ans:
            ans = i + n // i - 2
    return int(ans)


num = int(input())
print(solve(num))
def main():
  xs <- input().split("")

  if "7" in xs:
    print("Yes")
  else:
    print("No")
    
if __name__ == '__main__':
  main()

### FIXED CODE ###

xs = input()

if "7" in xs:
  print("Yes")
else:
  print("No")
import sys
for line im sys.stdin:
	lis = []
	if line >= 2:
		lis.append(2)
	if  line >= 3:
		lis.append(3)
	if line >= 5:
		for i in xrange(5,line+1,2):
			for item in lis:
				if item > (i**0.5):
					lis.append(i)
					break
				if i % item == 0:
					break
			else:
				lis.append(i)
	print len(lis)

### FIXED CODE ###

import sys
N = 999999
lis = []
if N >= 2:
	lis.append(2)
if  N >= 3:
	lis.append(3)
if N >= 5:
	for i in xrange(5,N+1,2):
		for item in lis:
			if item > (i**0.5):
				lis.append(i)
				break
			if i % item == 0:
				break
		else:
			lis.append(i)
dp = [0]*999999
for item in lis:
	dp[item-1] += 1
for i in xrange(1,999999):
	dp[i] += dp[i-1]

for line in sys.stdin:
	num = int(line)
	print dp[num-1]
n = input()
max = 0
min = 0
sum = 0
for i in range(1,n+1):
    a=[int(x) for x in input().split()]
    if a[i] >= max: max = a[i]
    if a[i] <= min: min = a[i]
    sum += a[i]

print(min,max,sum)


### FIXED CODE ###

n = int(input())
a = sorted([int(x) for x in input().split()])
print(a[0],a[-1],sum(a))
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
sary = [sorted(stdin.readline().rstrip()) for _ in range(n)]

gr = groupby(sary.sort())

res = 0

for k, g in gr:
    if k >= 2:
        res += k * (k - 1) // 2

print(res)

### FIXED CODE ###

from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
sary = sorted(["".join(sorted(stdin.readline().rstrip())) for _ in range(n)])

gr = groupby(sary)

res = 0

for k, g in gr:
    num = len(list(g))
    if  num >= 2:
        res += num * (num - 1) // 2

print(res)
s = input().split()

if s[0] * s[0] % 2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

input_nums = input().split()

product = 1

for num in input_nums:
  product = product * int(num)
  
if(product % 2 == 0):
  print('Even')
else:
  print('Odd')
from scipy.sparse import*;f=lambda:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=zip(*map(f,[0]*M));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

### FIXED CODE ###

from scipy.sparse import*
N,M,R=map(int,raw_input().split())
r=[int(e) for e in raw_input().split()]
a,b,c=zip(*(map(int,raw_input().split())for _ in range(M)))
a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r)
print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))
M = 'abcdefghijklmnopqrstuvwxyz'
S = input()

if len(S) != 26:
    print(S + sorted(list(set(M) - set(S)))[0])
else:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(26):
            if S[i] != M[i]:
                ans = S[: i - 1] + M[i]
                break
        print(ans)

### FIXED CODE ###

S = input()
 
chars = "abcdefghijklmnopqrstuvwxyz"
char_set = set(chars)
 
if len(S) == 26:
    for i in range(len(S)-1, -1, -1):
        x = chars.index(S[i])
        y = sorted(set(chars[x+1:])-set(S[:i]))
        # print(i, y)
        if len(y):
            print(S[:i]+y[0])
            exit()
else:
    t = sorted(set(chars)-set(S))[0]
    print(S+t)
    exit()
print(-1)
S = array(input())
print(S)

### FIXED CODE ###

S = list(input().strip())
is_irrversible = 0
answer = 0
position_key_sum = 0
number_of_white = 0
sigma = 0
for i in range(len(S)):
    if S[i] == 'W':
        position_key_sum += (i+1)
        number_of_white += 1
        sigma += number_of_white
answer = position_key_sum - sigma
print(answer)
n=int(input())
al=list(map(int,input().split()))

counter=[0]*n
for a in al:
    nums[a]+=1

sum=0
for c in counter:
    sum+=c*(c-1)//2

for a in al:
    print(sum-(counter[a]-1))


### FIXED CODE ###

n=int(input())
al=list(map(int,input().split()))

counter=[0]*(n+1)
for a in al:
    counter[a]+=1

sum=0
for c in counter:
    sum+=c*(c-1)//2

for a in al:
    print(sum-(counter[a]-1))
A,B=map(int,input().split())
if A==B:
  print('Draw')
else if A=='1':
  print('Alice')
else if B=='1':
  print('Bob')
else if A>B:
  print('Alice')
else:
  print('Bob')

### FIXED CODE ###

A,B=map(int,input().split())
if A==B:
  print('Draw')
elif A==1:
  print('Alice')
elif B==1:
  print('Bob')
elif A>B:
  print('Alice')
else:
  print('Bob')
n, k = map(int, input().split())
a = set()

for _ in range(k):
  d = int(input())
  a.append(map(int, input().split()))

print(n - len(a))


### FIXED CODE ###

n, k = map(int, input().split())
a = []

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split()]

print(n - len(set(a)))
r, g, b = map(int,input().split())

if (100*r + 10*g + b) % 4 == 0:
    print(f'YES')
else:
    print(f'NO')

### FIXED CODE ###

r, g, b = map(int,input().split())

if (100*r + 10*g + b) % 4 == 0:
    print('YES')
else:
    print('NO')
r,c=map(int,raw_input().split())
A=[]
for i in range(r):
    A.append(map(int,raw_input().split()))
    A[i].append(sum(A[i]))
A.append([sum([A[i][j] for i in range(r)]) for j in range(c)])
print(A)
for i in range(r):
    print(' '.join(A[i]))
    

### FIXED CODE ###

r,c=map(int,raw_input().split())
A=[]
for i in range(r):
    A.append(map(int,raw_input().split()))
    A[i].append(sum(A[i]))
A.append([sum([A[i][j] for i in range(r)]) for j in range(c+1)])
for i in range(r+1):
    print(' '.join(map(str,A[i])))
x,n = map(int,input().split())
if n != 0:
    l = list(map(int,input().split()))
else:
    print(x)
    exit()

if x not in l:
    print(x)
    exit()

tmp = []
for i in range(x-50,x+50):
    tmp.append(i)

ans = []
for j in tmp:
    if j not in l:
        ans.append(j)

tmp1 = 100
for k in ans:
    tmp2 = abs(x-k)
    if tmp2 != 0:
        if tmp1 >= tmp2:
            tmp1 = tmp2

ans2 = []
for m in ans:
    a = abs(m-x)
    if a == tmp1:
        ans2.append(m)

print(min(ans2))

### FIXED CODE ###

import sys

x,n = map(int,input().split())
if n != 0:
    l = list(map(int,input().split()))
else:
    print(x)
    sys.exit()

if x not in l:
    print(x)
    sys.exit()

tmp = []
for i in range(x-60,x+60):
    tmp.append(i)

ans = []
for j in tmp:
    if j not in l:
        ans.append(j)

tmp1 = 100
for k in ans:
    tmp2 = abs(x-k)
    if tmp2 != 0:
        if tmp1 >= tmp2:
            tmp1 = tmp2

ans2 = []
for m in ans:
    a = abs(m-x)
    if a == tmp1:
        ans2.append(m)

print(min(ans2))
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
B = [0, 0]
for i in A.keys():
    if A[i] >= 2:
        B.append(v)
    if A[i] >= 4:
        B.append(v)
B.sort()
print(B[-1]*B[-2])

### FIXED CODE ###

from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
B = [0, 0]
for i in A.keys():
    if A[i] >= 2:
        B.append(i)
    if A[i] >= 4:
        B.append(i)
B.sort()
print(B[-1]*B[-2])
s=sorted(str(input())
t=sorted(str(input(),reverse=True))
if s<=t:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b = map(int, input().split())
print(int((a+b+2-1)/2))
from heapq import *

a,b,c,K = int(input()),int(input()),int(input()),int(input())
A = sorted([int(x) for x in input().split(' ')], reversed=True)
B = sorted([int(x) for x in input().split(' ')], reversed=True)
C = sorted([int(x) for x in input().split(' ')], reversed=True)

res = []
i, j, k = 0, 0, 0
while len(res) < K:
  heappush(res, A[i]+B[j]+C[k])
  heappush(res, A[i+1]+B[j]+C[k])
  heappush(res, A[i]+B[j+1]+C[k])
  heappush(res, A[i]+B[j]+C[k+1])
  i,j,k = i+1, j+1, k+1
res = nlargeest(K, res)
for i in res:
  print(i)

### FIXED CODE ###

from heapq import *

X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = sorted([int(x) for x in A], reverse=True)
B = sorted([int(x) for x in B], reverse=True)
C = sorted([int(x) for x in C], reverse=True)

res = []
memo = []
ans = []
heappush(res, (-A[0]-B[0]-C[0], 0, 0, 0))
while len(ans) < K:
  e, i, j, k = heappop(res)
  ans.append(-e)
  if i+1 < X and [i+1, j, k] not in memo:
    heappush(res, (-A[i+1]-B[j]-C[k], i+1, j, k))
    memo.append([i+1, j, k])
  if j+1 < Y and [i, j+1, k] not in memo:
    heappush(res, (-A[i]-B[j+1]-C[k], i, j+1, k))
    memo.append([i, j+1, k])
  if k+1 < Z and [i, j, k+1] not in memo:
    heappush(res, (-A[i]-B[j]-C[k+1], i, j, k+1))
    memo.append([i, j, k+1])

for i in ans:
  print(i)
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
w.sort()
del w[0]
s=list(s)
s.sort()
M=0
for i in w:
    for j in range(len(s)-1,-1,-1):
        t=s[j]/i
        if t*100<=E:
            if t>M and i+s[j]<=F:
                W,S=i,s[j]
                M=t
            break
print(W+S,S)

### FIXED CODE ###

A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
w.sort()
del w[0]
s=list(s)
s.sort()
M=-1
for i in w:
    for j in range(len(s)-1,-1,-1):
        if s[j]*100<=E*i:
            if s[j]>M*i and i+s[j]<=F:
                W,S=i,s[j]
                M=s[j]/i
print(W+S,S)