Harryxun/stf_run huggingface dataset:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [sum(A[:i+1]) for i in range(len(A)) if sum(A[:i+1]) <= K]
B = [sum(B[:i+1]) for i in range(len(B)) if sum(B[:i+1]) <= K]

len_B = len(B)
res = []
for i, a in enumerate(A):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a + B[j] <= K:
            res.append(i+j+2)
            break
    len_B = j+1

print(max(res))

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

len_B = M+1
res = []
for i, a_ in enumerate(a):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a_ + b[j] <= K:
            res.append(i+j)
            break
    len_B = j+1

print(0 if len(res) < 1 else max(res))
¥n = int(input())

if n >= 195:
    print(5)
elif n >= 189:
    print(4)
elif n >= 165:
    print(3)
elif n >= 135:
    print(2)
elif n >= 105:
    print(1)
else:
    print(0)


### FIXED CODE ###

n = int(input())

if n >= 195:
    print(5)
elif n >= 189:
    print(4)
elif n >= 165:
    print(3)
elif n >= 135:
    print(2)
elif n >= 105:
    print(1)
else:
    print(0)
N=int(input())
X=list(map(int, input().split()))
minX=min(X)
maxX=max(X)
minE = 1000000000
for P in range(minX,maxX):
  sum = 0
  for i in X:
    sum = sum + (X[i]-P)**2
  if minE>sum:
    minE=sum
print(minE)

### FIXED CODE ###

N=int(input())
X=list(map(int, input().split()))
"""
minX=min(X)
maxX=max(X)
"""
minE = 1000000000
for P in range(101):
  sum = 0
  for Xi in X:
    sum = sum + (Xi-P)**2
  if minE>sum:
    minE=sum
print(minE)
def ans():
  N = int(input())
  A = list(map(int,input().split()))

  def gcd(m, n):
    while n:
      m, n = n, m%n
    return m

  res = set()
  x = min(A)
  for i in range(N):
    res.add(gcd(A[i], x))

  b = A[0]
  for a in A[1:]:
    b = gcd(a, b)
  print(list(res)[b-1])
ans()

### FIXED CODE ###

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

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

L = [0]
R = [0]
for i in range(N):
  L.append(gcd(L[i], A[i]))
  R.append(gcd(R[i], A[-(i+1)]))
R = R[::-1]
ans = 0
for i in range(N):
  ans = max(ans, gcd(L[i], R[i+1]))
print(ans)
n=input()
m=input()
print n*m

### FIXED CODE ###

l = map(int, raw_input().split())
print l[0]*l[1], l[0]*2+l[1]*2
n =  input()
print('No' int(n) % sum(map(int, n)) else 'Yes')

### FIXED CODE ###

n =  input()
print('No' if int(n) % sum(map(int, n)) else 'Yes')
h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))


### FIXED CODE ###

h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                if type(table[i+xy[k]][j+xy[k+1]]) == type(int()):
                    table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))
from math import gcd

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

### FIXED CODE ###

from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))
a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np



from collections import deque
ans = []
ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

b2 = np.array(b1)
a2 = np.array(a1)
a2 = a2.reshape(a,1)
ans = list(ans)
print(min( min(ans), np.min(a2+b2) ))


### FIXED CODE ###

a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np


from collections import deque
ans = []

ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)

print(min( min(ans), min(a1)+min(b1) ))
n,m=map(int,input().split())
h=list(map(int,input().split()))
final=[0]*n
for i in range(m):
  a,b=map(int,input().split())
    if h[a-1]<h[b-1]:
         final[a-1]=0
    elif h[a-1]>h[b-1]:
         final[b-1]= 0
    else:
         final[a-1]=0
         final[b-1]=0

print(sum(final))


### FIXED CODE ###

n,m=map(int,input().split())
h=list(map(int,input().split()))
final=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1]:
         final[a-1]=0
  elif h[a-1]>h[b-1]:
         final[b-1]=0
  else:
         final[a-1]=0
         final[b-1]=0

print(sum(final))
waaaaaaaaaaaaaaaaaaaaaannnnnnnnnn

### FIXED CODE ###

# D - Cake 123
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab=[i+j for j in b for i in a]
ab.sort(reverse=True)
abc=[i+j for j in c[:k] for i in ab[:k]]
abc.sort(reverse=True)

print(*abc[:k],sep='\n')
n = int(input())
num_list = map(int, input().split())

max = pow(10, 18)
result = 1
for num in num_list:
  if num == 0:
    print(0)
    break
    else:
      result = result * num
      if result > max:
        print(-1)
        break 
        print(result)

### FIXED CODE ###

def calc(num_list) -> int:
    result = 1
    max = 10**18

    if 0 in num_list:
        return 0

    for num in num_list:
        result *= num
        if result > max:
            return -1
    return result

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

print(str(calc(num_list)))
import math

a, b, x = map(int, input().split())

for i in range(int(x/a-1),10000000000000000000):
    if x < (a*i+b*int(math.log10(i)+1)):
        break

if i > 1:
    print(a*(i-1)+b*int(math.log10(i-1)+1))
elif i == 1:
    print(0)

### FIXED CODE ###

s = input()

if s == "SUN":
    print("7")
elif s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")
from math import factorial
n,m = map(int,input().split())

N = factorial(n)/factorial(2)/factorial(n-2)
M = factorial(M)/factorial(2)/factorial(m-2)

print(N+M)


### FIXED CODE ###

from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
elif n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
elif m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))
A = []
B = []
for i in range(5):
    x = input()
    if int(x[-1]) != 0:
        A.append(10 - int(x[-1]))
    B.append(int(x))

print(sum(A) + sum(B) - max(A))

### FIXED CODE ###

A = []
B = []
for i in range(5):
    x = input()
    if int(x[-1]) != 0:
        A.append(10 - int(x[-1]))
    B.append(int(x))

if A == []:
    print(sum(A) + sum(B))
else:
    print(sum(A) + sum(B) - max(A))
import math
  
input()
d = None
u = set()
r = 'pairwise'
for x in map(int, input().split()):
  d = math.gcd(d or x, x)
  s = set()
  i = 2
  while i * i <= n:
    while n % i == 0:
      if i in u:
        r = 'setwise'
      s.add(i)
      n //= i
    i += 1
  if n > 1:
    if n in u:
      r = 'setwise'
    s.add(n)
  u |= s
print((r, 'not')[d > 1], 'coprime')


### FIXED CODE ###

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
n = int(input())
a = [int(x) for x in input().split() if x > '1']
if len(a) > 1:
  u = set()
  i = None
  for x in a:
    s = set()
    while x > 1:
      p = spf[x]
      if p in u:
        r = 'setwise'
      s.add(p)
      x //= p
    u |= s
    if len(a) == n:
      if i is None: i = s
      else: i &= s
  if i:
    r = 'not'
print(r, 'coprime')
N = int(input())

H = list(list(map(int,input().split())) for _ in range(N))

#sub problem: min cost from 0 to i
def rec(i, choice):
  if i == len(H):
    return 0
  return max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
print(max(rec(0, j) for j in range(3)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
 
N = int(input())
H = list(list(map(int,input().split())) for _ in range(N))
#sub problem: max cost from 0 to ith day
memo = {}
def rec(i, choice):
  if (i, choice) in memo:
    return memo[(i, choice)]
  if i == len(H):
    return 0
  m = max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
  memo[(i, choice)] = m
  return m
print(max(rec(0, j) for j in range(3)))
N = int(input())
print(int((N-1)*N/2))

### FIXED CODE ###

S = input()
T = input()
cnt = 0
for i in range(len(S)):
    if S[i] == T[i]:cnt+=1
print(cnt)
M = int(input())
if M == M.upper():
  print("A")
else:
  print("a")

### FIXED CODE ###

N = input()
print('A' if N.isupper() else 'a')
n=input()
print 800*n -200(n/15)
  

### FIXED CODE ###

n=input()
x=800*n
y=200*(n/15)
print x-y
z = input()
d = {}

L = ['S','H','C','D']
for i in L:
    for j in range(1,14):
        d[i] = d.get(i,[]) + [str(j)]


while 1:
    x = raw_input().split()
    if x[0] == '0':
        break
    else:
        d[x[0]].remove(x[1])


for i in L:
    for j in sorted(d[i]):
        print i + " " + j

### FIXED CODE ###

z = input()
d = {}
c = 0

L = ['S','H','C','D']
for i in L:
    for j in range(1,14):
        d[i] = d.get(i,[]) + [j]


while c < z:
    x = raw_input().split()
    d[x[0]].remove(int(x[1]))
    c += 1


for i in L:
    for j in sorted(d[i]):
        print i + " " + str(j)
N, K = input().split()
N = list(N)
N[int(K)] = N[int(K)].lower()
print(''.join(N))


### FIXED CODE ###

N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))
x, y, a, b, c = map(int, input().split())

ra = list(map(int, input().split()))
gb = list(map(int, input().split()))
sc = list(map(int, input().split()))

ra.sort(reverse=True)
gb.sort(reverse=True)
sc.sort(reverse=True)

curr_red_min_val = ra[x-1]
curr_green_min_val = gb[y-1]
tmp_x = x
tmp_y = y

for i in range(c):
  if tmp_x > 0 and curr_red_min_val < curr_green_min_val:
    if sc[i] > curr_red_min_val:
      ra[tmp_x-1] = sc[i]
      tmp_x -= 1
      if tmp_x != 0:
        curr_red_min_val = ra[tmp_x-1]
      else:
        curr_red_min_val = ra[0]
  else tmp_y > 0:
    if sc[i] > curr_green_min_val:
      gb[tmp_y-1] = sc[i]
      tmp_y -= 1
      if tmp_y != 0:
        curr_green_min_val = gb[tmp_y-1]
      else:
        curr_green_min_val = gb[0]
      
print(sum(ra[:x])+sum(gb[:y]))

### FIXED CODE ###

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

ra = list(map(int, input().split()))
gb = list(map(int, input().split()))
sc = list(map(int, input().split()))

ra.sort(reverse=True)
gb.sort(reverse=True)
sc.sort(reverse=True)

curr_red_min_val = ra[x-1]
curr_green_min_val = gb[y-1]
tmp_x = x
tmp_y = y

for i in range(c):
  if tmp_x > 0 and curr_red_min_val < curr_green_min_val:
    if sc[i] > curr_red_min_val:
      ra[tmp_x-1] = sc[i]
      tmp_x -= 1
      if tmp_x != 0:
        curr_red_min_val = ra[tmp_x-1]
      else:
        curr_red_min_val = ra[0]
  elif tmp_y > 0:
    if sc[i] > curr_green_min_val:
      gb[tmp_y-1] = sc[i]
      tmp_y -= 1
      if tmp_y != 0:
        curr_green_min_val = gb[tmp_y-1]
      else:
        curr_green_min_val = gb[0]
      
print(sum(ra[:x])+sum(gb[:y]))
W, H, x, y, r = map(int, raw_input().split())
if r <= x <= W - r and r <= y <= H - r:
print "Yes"
else:
print "No"

### FIXED CODE ###

W,H,x,y,r = map(int, input().split())
if r <= x <= W-r and r <= y <= H-r:
    print ('Yes')
else:
    print ('No')
# -*- coding: utf-8 -*-


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x, xx) + abs(y, yy)
            distance.append(n)
        p_nums.append(min(distance))
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()


### FIXED CODE ###

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


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x - xx) + abs(y - yy)
            distance.append(n)
        min_distance_idx = distance.index(min(distance))
        p_nums.append(min_distance_idx + 1)
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()
s = input()
t = input()
flag = False
tq = '?'*len(t)
start = []
for i in range(len(s)-len(t)+1):
    if s[i] == t[0]:
        start.append(i)
        flag = True
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == '?':
                continue
            else:
                flag = False
                start.pop(-1)
    if s[i:i+len(t)] == tq:
        start.append(i)
        flag = True
stal = []
if flag:
    for i in start:
        stal.append(s[:i].replace('?','a') + t + s[i+len(t):].replace('?','a'))
    stal.sort()
    print(stal[0])
else:
    print('UNRESTORABLE')

### FIXED CODE ###

s = input()
t = input()
flag = False
tq = '?'*len(t)
start = []
for i in range(len(s)-len(t)+1):
    flag = True
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == '?':
            continue
        else:
            flag = False
            break
    if flag:
        start.append(i)
    
stal = []
if start:
    for i in start:
        stal.append(s[:i].replace('?','a') + t + s[i+len(t):].replace('?','a'))
    stal.sort()
    print(stal[0])
else:
    print('UNRESTORABLE')
B,W=map(int,input().split())
mod=10**9+7
kaijo=[1]
for i in range(1,1+B+W):
    kaijo.append((kaijo[-1])*i%mod)
from collections import deque
gyaku=deque()
gyaku.append(pow(kaijo[B+W],mod-2,mod))
for i in range(B+W,0,-1):
    gyaku.appendleft((gyaku[0]*i)%mod)
def conb(a,b):
    return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=[0],[0]
Xdiv=[pow(pow(2,i,mod),mod-2,mod) for i in range(1+B+W)]
for k in range(1,B+W):
    if k<B:
        Blost.append(0)
    elif k>=B:
        Blost.append((Blost[-1]++conb(k-1,B-1)*Xdiv[k])%mod)
    if k<W:
        Wlost.append(0)
    elif k>=W:
        Wlost.append((Wlost[-1]+conb(k-1,W-1)*Xdiv[k])%mod)
Blost.append(1)
Wlost.append(1)
for k in range(1,B+W+1):
    print(((1+Wlost[k-1]-Blost[k-1])*two)%mod)

### FIXED CODE ###

B,W=map(int,input().split())
mod=10**9+7
kaijo={0:1}
Xdiv={0:1}
two=pow(2,mod-2,mod)
for i in range(1,1+B+W):
    kaijo[i]=(kaijo[i-1]*i)%mod
    Xdiv[i]=(Xdiv[i-1]*two)%mod
gyaku={B+W:pow(kaijo[B+W],mod-2,mod)}
for i in range(B+W,0,-1):
    gyaku[i-1]=(gyaku[i]*i)%mod
def conb(a,b):
    if a<b:return 0
    return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=0,0
for k in range(1,B+W):
    print(((1+Wlost-Blost)*two)%mod)
    Blost=(Blost+conb(k-1,B-1)*Xdiv[k])%mod
    Wlost=(Wlost+conb(k-1,W-1)*Xdiv[k])%mod
print(((1+Wlost-Blost)*two)%mod)
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = 2*x - y
b = -x + 2*y
if a < 0 or b < 0:
    print(0)
    eixt()

a //= 3
b //= 3
MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))

### FIXED CODE ###

x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = 2*x - y
b = -x + 2*y
if a < 0 or b < 0:
    print(0)
    exit()

a //= 3
b //= 3
MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
  else:
    print("Heisei")


### FIXED CODE ###

S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")
n, m, l = (int(i) for i in input().split())
A = []
B = []
#C = [[0] * n] * l
C = [[0 for i in range(n)] for j in range(l)]
#??\?????????????????????????´?
for i in range(n):
    swap_list = input().split()
    A.append(swap_list)
for i in range(m):
    swap_list = input().split()
    B.append(swap_list)

#?????????????????????
for i in range(0,n):
    for j in range(0,l):
        for k in range(0,m):
            C[i][j] += int(A[i][k]) * int(B[k][j])
#?????????????????????
for i in range(0,n):
    print(" ".join(map(str, C[i][:])))

### FIXED CODE ###

n, m, l = (int(i) for i in input().split())
A = []
B = []
C = [[0 for i in range(l)] for j in range(n)]
#??\?????????????????????????´?
for i in range(n):
    swap_list = input().split()
    A.append(swap_list)
    #A.append([int(i) for i in input().split()])
for i in range(m):
    swap_list = input().split()
    B.append(swap_list)
    #B.append([int(i) for i in input().split()])
#????????????????¨????
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += int(A[i][k]) * int(B[k][j])
#?????????????????????
#for i in range(n):
#    for j in range(l):
#        print("{0}".format(C[i][j]), end="\b")
#    print("")
for i in range(n):
    print(" ".join(map(str, C[i][:])))
#for r in C:
#    print(" ".join([str(d) for d in r]))
n, m = map(int, input().split())
p, s = [], []
for i in range(n):
    pi, si = input().split()
    p.append(int(pi))
    s.append(si)

lst_ac = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(n):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1

print(ans_ac, out)

### FIXED CODE ###

n, m = map(int, input().split())
p, s = [], []
for i in range(m):
    pi, si = input().split()
    p.append(int(pi))
    s.append(si)

lst_ac = [0 for i in range(n+1)]
for i in range(m):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(m):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1
    if s[i] == 'AC' and lst_ac[p[i]] == 1:
        lst_ac[p[i]] = 2

print(ans_ac, out)
a=int(input('a'))
b=int(input('b'))
if (a*b)%2 ==1:
print ('Odd')
else:
  print ('Even')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 ==0:
  print('Even')
else:
  print('Odd')
n = input()
ans = 'Yes' if n == [::-1] else 'No'
print(ans)

### FIXED CODE ###

n = input()
ans = 'Yes' if n == n[::-1] else 'No'
print(ans)
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 2)


print(chouhoukei(0, 1, 0))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N - 1:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 1)


print(chouhoukei(0, 1, 0))
from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self, nodes):
        self.par = list(range(nodes + 1))
        self.sizes = [1] * (nodes + 1)

    def root(self, key):
        if key != self.par[key]:
            self.par[key] = self.root(self.par[key])
        return self.par[key]

    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

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

uni = UnionFind(N)
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)

### FIXED CODE ###

from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self, nodes):
        self.par = list(range(nodes + 1))
        self.sizes = [1] * (nodes + 1)

    def root(self, key):
        if key != self.par[key]:
            k0 = key
            while k0 != self.par[k0]:
                k0 = self.par[k0]
            self.par[key] = k0
        return self.par[key]

    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

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

uni = UnionFind(N)
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)
a = []
while True:
    n = input()
    if (n == -1):
        break
    a.append(n)

for i in range(len(a)):
    if(a[i]==0):
        break
    else:
        print('Case '+str(i)+': '+str(a[i]))

### FIXED CODE ###

i=1
while(1):
    n=input()
    if(int(n)==0):
        break
    else:
        print('Case '+str(i)+': '+n)
        i+=1
import functools
import math

N,X=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(X)
x_list.sort()
y_list=[]
for i in range(N):
    y_list.append(x_list[i+1]-x_list[i])
z_list=list(set(y_list))
gcd = functools.reduce(math.gcd, z_list)
print(gcd)


### FIXED CODE ###

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z


N,X=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(X)
x_list.sort()
y_list=[]
for i in range(N):
    y_list.append(x_list[i+1]-x_list[i])
z_list=list(set(y_list))
if len(z_list)==1:
    print(z_list[0])

else:
    for i in range(len(z_list)-1):
        z_list[i+1]=gcd(z_list[i],z_list[i+1])
    print(z_list[-1])