Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
a = list(map(int,input().split()))

a_p =[]
a_m =[]
for i in a:
    if i >= 0:
        a_p.append(i)
    else :
        a_m.append(i)

a_p.sort()
a_m.sort(reverse=True)


a_select =[]

if n == k:
    a_select = a
elif len(a_p) == 0:
    for i in range(k):
        a_select.append(a_m[i])


while len(a_select) < k:
    if len(a_select) == k - 1:
        a_select.append(a_p[-1])
        break
    if len(a_p) == 1 and (k-len(a_select))%2 == 1:
        a_select.append(a_p.pop(-1))
    elif len(a_p) == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_m) <= 1:
        a_select.append(a_p.pop(-1))
    elif a_p[-1]*a_p[-2] > a_m[-1]*a_m[-2] :
        a_select.append(a_p.pop(-1))
    else:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))

#print(a_select)
ans = 1
for i in a_select:
    ans = ans*i % (10**9 + 7)

print(ans)


### FIXED CODE ###

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

a_p =[]
a_m =[]
for i in a:
    if i >= 0:
        a_p.append(i)
    else :
        a_m.append(i)

a_p.sort()
a_m.sort(reverse=True)


a_select =[]

if n == k:
    a_select = a
elif len(a_p) == 0 and k%2 == 1:
    for i in range(k):
        a_select.append(a_m[i])


while len(a_select) < k:
    if len(a_select) == k - 1:
        a_select.append(a_p[-1])
        break
    if len(a_p) == 1 and (k-len(a_select))%2 == 1:
        a_select.append(a_p.pop(-1))
    elif len(a_p) == 1 and (k-len(a_select))%2 == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_p) == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_m) <= 1:
        a_select.append(a_p.pop(-1))
    elif a_p[-1]*a_p[-2] > a_m[-1]*a_m[-2] :
        a_select.append(a_p.pop(-1))
    else:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))

#print(a_select)
ans = 1
for i in a_select:
    ans = ans*i % (10**9 + 7)

print(ans)
a,b,c = map(int, input().split())
 
if a==b:
	print(c)
if a==c:
	print(b)
else:
	print(a)
a,b,c = map(int, input().split())

if a==b:
	print(c)
elif a==c:
	print(b)
else:
	print(a)


### FIXED CODE ###

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

if a==b:
	print(c)
elif a==c:
	print(b)
else:
	print(a)
N = int(input())
R = int(input())
 
if N < 10:
  N = R + 100 * (10 - N) 
  print(n)
  
if N >= 10:
  N = R
  print(N)

### FIXED CODE ###

N, R = (int(x) for x in input().split())
 
if N < 10:
  N = R + 100 * (10 - N) 
  print(N)
  
else:
  N = R
  print(N)
n=int(input())
ifbreak = "FALSE"
for i in range(n**0.5):
  for j in range(**0.5):
    print(i,j)


### FIXED CODE ###

n=int(input())
ifbreak = "FALSE"
for i in range(9):
  for j in range(9):
    if n == ((i+1)*(j+1)):
      print("Yes")
      ifbreak = "TRUE"
      break
  if ifbreak=="TRUE":
    break
if ifbreak == "FALSE":
  print("No")
n = input().split()

for i in range(len(n)):
    if n[i] == 'C':
        cflag = 1
    elif cflag == 1 and n[i] == 'F':
        print('Yes')
        exit()

print('No')

### FIXED CODE ###

n = input()

cflag = False

for i in range(len(n)):
    if n[i] == 'C':
        cflag = True
    elif cflag == True and n[i] == 'F':
        print('Yes')
        exit()

print('No')
a,b = map(int,input().split())
if(a >= 13):
	print(b)
else if(a >= 6):
	print(b // 2)
else:
	print(0)

### FIXED CODE ###

a,b = map(int,input().split())
if(a >= 13):
	print(b)
elif(a >= 6):
	print(b // 2)
else:
	print(0)
n,m=map(int,input().split())
x=9999999999999999
s=[list(map(int,input().split())) for i in range(m)]
s=sorted(s)
for i in range(m):
  if s[i][0]==1 and s[i][1]==0:
    x=-1

for i in range(m):
  for j in range(m):
    if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:
      x=-1

a=[0]*n
ans=0
for i in range(m):
  a[s[i][0]-1]=s[i][1]

if a[0]==0:
  a[0]=1

for i in range(m):
  ans+=a[i]*10**(n-i-1)


print(min(x,ans))

### FIXED CODE ###

n,m=map(int,input().split())
x=99999
s=[list(map(int,input().split())) for i in range(m)]
s=sorted(s)
for i in range(m):
    if s[i][0]==1 and s[i][1]==0 and n!=1:
        x=-1

for i in range(m):
    for j in range(m):
        if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:
            x=-1

a=[0]*n
ans=0
for i in range(m):
    a[s[i][0]-1]=s[i][1]

if a[0]==0 and n!=1:
    a[0]=1

for i in range(n):
    ans+=a[i]*(10**(n-i-1))


print(min(x,ans))
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = {}
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.append(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    roop = memo[key:]
    print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

### FIXED CODE ###

def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = set([])
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.add(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    if K < key:
        print(lst_memo[K] + 1)
    else:
        roop = lst_memo[key:]
        print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)
# ret = []
N = int(input())
L = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    L = newL.copy()
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

### FIXED CODE ###

# ret = []
N = int(input())
newL = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    L = newL.copy()
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))
k= int(input())
s= input().rsprit().split()
a = int(s[0])
b = int(s[1])
f = "NG"
for i in range(a,b):
  if i%k == 0:
    f = "OK"
print(f)

### FIXED CODE ###

k= int(input())
s= input().rstrip().split()
a = int(s[0])
b = int(s[1])
f = "NG"
for i in range(a,b+1):
  if i%k == 0:
    f = "OK"
if a == b:
  if a%k == 0:
    f = "OK"
print(f)
lis=list(map(int,input(),split()))

print(lis.index(0)+1)

### FIXED CODE ###

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

print(lis.index(0)+1)
# coding: utf-8
import collections
list = input().split()
N = int(list[0])
M = int(list[1])
a = input().split()
x = 0
hako = [0]
for i in a:
    hako.append(int(i))
B = []
b = 0
for i in hako:
    b += i
    B.append(b%M)
c = collections.Counter(B)
aaa =[]
for i in c:
    if c[i] >= 2:
        aaa.append(c[i])
def kaijo(n):
    if n == 0:
        return 1
    else:
        return n*kaijo(n-1)
def kumi(n):
    return int(kaijo(n)/(2*kaijo(n-2)))
for i in aaa:
    x += kumi(i)
print(x)

### FIXED CODE ###

# coding: utf-8
import collections
import math
list = input().split()
N = int(list[0])
M = int(list[1])
a = input().split()
x = 0
hako = [0]
for i in a:
    hako.append(int(i))
B = []
b = 0
for i in hako:
    b += i
    B.append(b%M)
c = collections.Counter(B)
aaa =[]
for i in c:
    if c[i] >= 2:
        aaa.append(c[i])
def kumi(n):
    return int(math.factorial(n)/(2*math.factorial(n-2)))
for i in aaa:
    x += kumi(i)
print(x)
X,Y = [int(i) for i in input().split()]
def check(x,y):
    if x/2 == y:
        return 0
    elif x/2 < y:
        return 1
    else:
        return 9
cnt = 0
possible = True

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def cmb(n,r):
    m = 10**9+7
    res = 1
    for i in range(1,n+1):
        res = res*i%m
    for i in range(1,r+1):
        res = res*mod_inv(i,m)%m
    for i in range(1,n-r+1):
        res = res*mod_inv(i,m)%m
    return res

while True:
    check_num =  check(X,Y)
    if check_num == 0:
        break
    elif check_num == 1:
        X += 1
        Y -= 1
        cnt += 1
    else:
        possible = False
        break
if possible == True:
    n = X / 2 
    r = cnt
    print(cmb(n,r))
else:
    print(0)

### FIXED CODE ###

def getComb(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD
    
X,Y = [int(i) for i in input().split()]
def check(x,y):
    if x/2 == y:
        return 0
    elif x/2 < y:
        return 1
    else:
        return 9
cnt = 0
possible = True
MOD = 10**9 + 7

while True:
    check_num =  check(X,Y)
    if check_num == 0:
        break
    elif check_num == 1:
        X += 1
        Y -= 1
        cnt += 1
    else:
        possible = False
        break
if possible == True:
    n = X // 2 
    r = cnt
    print(getComb(n,r,MOD))
else:
    print(0)
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False
 
print(ans)

### FIXED CODE ###

import bisect as bc

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

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        if dp[ai*j]:
            dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)
import sys
input = sys.stdin.readline

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[i] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if sumN(i,N,f) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()
from scipy.sparse.csgraph import bellman_ford, NegativeCycleError
from scipy.sparse import dok_matrix

N,M,P = map(int,input().split())

adj = [list() for _ in range(N)]
reachable = {N-1}


for _ in range(M):
    a,b,c = map(int,input().split())
    adj[b-1].append((a-1,c))
stack = [N-1]
while stack:
    v = stack.pop()
    for u,_ in adj[v]:
        if u not in reachable:
            stack.append(u)
            reachable.add(u)

G = dok_matrix((N,N))
for u,l in enumerate(adj):
    if u not in reachable:
        continue
    for v,c in l:
        if v not in reachable:
            continue
        w = -c+P
        w = 0.00000001 if w == 0 else w
        G[v,u] = w
try:
    D = bellman_ford(G, indices=0)
    print(max(0, int(-D[-1])))
except NegativeCycleError:
    print(-1)



### FIXED CODE ###

N,M,P = map(int,input().split())

adj = [list() for _ in range(N)]
inv = [list() for _ in range(N)]
edges = []

for _ in range(M):
    a,b,c = map(int,input().split())
    inv[b-1].append(a-1)
    adj[a-1].append(b-1)
    edges.append((a-1,b-1,P-c))

stack = [N-1]
reachable1 = {N-1}
while stack:
    v = stack.pop()
    for u in inv[v]:
        if u not in reachable1:
            stack.append(u)
            reachable1.add(u)

stack = [0]
reachable2 = {0}
while stack:
    v = stack.pop()
    for u in adj[v]:
        if u not in reachable2:
            stack.append(u)
            reachable2.add(u)

reachable = reachable1 & reachable2
edges = [(a,b,w) for a,b,w in edges if a in reachable and b in reachable]

dist = [float('inf')]*N
dist[0] = 0

for i in range(len(reachable)-1):
    for a,b,w in edges:
        dist[b] = min(dist[a]+w, dist[b])

# negative cycle
for a,b,w in edges:
    if dist[b] > dist[a] + w:
        print(-1)
        break
else:
    print(max(0,-dist[-1]))
N = int(input())
for h in range(1,3501):
  for n in range(1,3501):
    a = 4 * h * n - N * (h + n)
    if a > 0:
      w,b = divmod(N * h * n, mod)
      if b == 0:
        print(h,n,w)
        exit()
        

### FIXED CODE ###

N = int(input())
for h in range(1,3501):
  for n in range(1,3501):
    a = 4 * h * n - N * (h + n)
    if a > 0:
      w,b = divmod(N * h * n, a)
      if b == 0:
        print(h,n,w)
        exit()
L()=lambda:list(map(int,input().split()))
I()=lambda:input()
s=int(I())
d=["Sunny","Cloudy","Rainy","Sunny"]
print(d[d.index(s)+1])

### FIXED CODE ###

L=lambda:list(map(int,input().split()))
I=lambda:input()
s=I()
d=["Sunny","Cloudy","Rainy","Sunny"]
print(d[d.index(s)+1])
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))
  


### FIXED CODE ###

N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]=="R":
    X+=1
  else:
    Y=max([X,Y])
    X=0
print(max([X,Y]))
n, m = map(int, input().split())
# n: ketasuu
# m: num of list
data = [[0] * 2] * m
for i in range(m):
    a, b = map(int, input().split())
    # data[i][0], data[i][1] = a, b  >>>間違い
    data[i] = a, b
dataSort = sorted(data)
start = dataSort[0][0]
strVal = dataSort[0][1]

aList = [0, 0, 0]
flag = True
for i in range(m):
    tar = dataSort[i][0]
    tarVal = dataSort[i][1]

    if (tar == 1 and tarVal == 0):
        # print('-1')
        ans = -1
        flag = False
        break
    if (tar == start):
        if (tarVal != strVal):
            ans = -1
            flag = False
            break

    else:
        start = tar
        strVal = tarVal

    aList[tar - 1] = tarVal


if (flag == True):
    ans = str(aList[0]) + str(aList[1]) + str(aList[2])

print(ans)


### FIXED CODE ###

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

temp = list(['?'] * n)

# print(temp)
if (m == 0):
    if (n == 1):
        ans = 0
    else:
        ans = '1' + '0' * (n - 1)

else:
    for _ in range(m):
        s, c = map(int, input().split())
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        else:
            pass

        if (temp[s-1] == '?'):
            temp[s - 1] = str(c)
        elif (temp[s - 1] == str(c)):
            pass
        else:
            print(-1)
            exit()

    if (temp[0] == '?'):
        temp[0] = '1'

    ans01 = ''.join(temp)
    ans = ans01.replace('?', '0')

print(ans)
F = {}

def fib(n):
  global F
  if n < 0:
    print("error")
    exit()
  if n < 2:
    F[n] = 1
    return F[n]
#  F[n] = fib(n-1) + fib(n-2)
  F[n] = F[n-1] + F[n-2]
  return F[n]

n = int(input())
print(fib(n))
#n = int(input())
#print(fib(n))
#fib(44)
#for i in range(5+1):
#  print(F[i])

### FIXED CODE ###

def fibr(n):
    if arr[n] != 0:
        return arr[n]
    if n < 2:
        arr[n] = 1
    else:
        arr[n] = fibr(n-1) + fibr(n-2)
    return arr[n]

n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))
a = input()
s = input()
  if a >= 3200:
  	print("red")
  else:
    print(s)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
import sys,math
input = sys.stdin.readline

N,M = list(map(int,input().split()))
S = input().rstrip()
T = input().rstrip()

lcm = N*M//math.gcd(N,M)
X_S=list("#"*lcm)
for i in range(N):
    X_S[i*lcm//N] = S[i]

for i in range(M):
    if X_S[i*lcm//M] == T[i] or X_S[i*lcm//M] == '#':
        continue
    else:
        print(-1)
print(lcm)


### FIXED CODE ###

import sys,math
input = sys.stdin.readline

N,M = list(map(int,input().split()))
S = input().rstrip()
T = input().rstrip()

L = N*M//math.gcd(N,M)

sn = L//M
tm = L//N

for i in range(N//sn):
    if S[i*sn] == T[i*tm]:
        continue
    else:
        print(-1)
        exit()
print(L)
S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)
n = int(input())
if len(n)==2:
    print(n)
else:
    print(n[::-1])

### FIXED CODE ###

n = input()
if len(n)==2:
    print(n)
else:
    print(n[::-1])
n, k = map(int, input().split())
if min(n, k) ==1:
    print("0")
else:
    if n < k:
        n, k = k, n
    while n % k != 0:
        n, k = k, n % k
    print(k)

### FIXED CODE ###

n, k = map(int, input().split())
a = n % k
b = k - a
print(min(a, b))
A,B,K = list(map(int,input().split(" ")))

if A >= K:
  print(A-k, B)
elif A + B >= K:
  print(0, A+B-K)
else:
  print("0 0")

### FIXED CODE ###

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

if A >= K:
  print(A-K, B)
elif A + B >= K:
  print(0, A+B-K)
else:
  print("0 0")
import itertools

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

a=[]
for i in range(N):
    a.append(i+1)

L=list(itertools.permutations(a))


cnt=0

for l in L:
    tmp=1
    if l[0]!=1:
        break
    for j in range(N-1):
        if ([l[j],l[j+1]] in S) or ([l[j+1],l[j]] in S):
            tmp=1
        else:
            tmp=0
            break
    if tmp==1:
        cnt+=1

print(cnt)

### FIXED CODE ###

import itertools

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

a=[]
for i in range(N):
    a.append(i+1)

L=list(itertools.permutations(a))


cnt=0

for l in L:
    tmp=1
    if l[0]!=1:
        break
    for j in range(N-1):
        if ([l[j],l[j+1]] in S) or ([l[j+1],l[j]] in S):
            tmp=1
        else:
            tmp=0
            break
    if tmp==1:
        cnt+=1

print(cnt)
def get_answer(input_list):
    so = input_list[0]
    s = so[0]
    s_index = 1
    s_len = len(so)
    t = input_list[1]
    ret = -1

    """
    """
    for i in range(1000):
        find_flag = True
        ss = s
        for tt in t:
            ii = ss.find(tt)
            if ii < 0:
                find_flag = False
                break
            ss = ss[ii + 1:]
        if find_flag:
            ret = len(s)
            break
        s += so[s_index]
        s_index = (s_index + 1) % s_len

    return ret


if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))


### FIXED CODE ###

def get_answer(input_list):
    so = input_list[0]
    t = input_list[1]

    s_len = len(so)

    """
    contest son
    s:5
    o:1 7+2
    n:2 7+3
    
    aabbcc abca
    a:0 0
    b:2 2
    c:4 4
    a:0 0 +6
    
    aa aaaa
    a:0
    a:1
    a:0 + 2
    a:1 + 2   
    
    aabbcc abccba
    a 0
    b 2
    c 4
    c 5
    b 2 6
    a 0 12 = 13
    """

    t_i = [-1] * len(t)
    s = so + so
    s_index = 0
    for i in range(len(t)):
        index = s.find(t[i], s_index)
        if index < 0:
            break
        index = index % s_len
        t_i[i] = index
        s_index = index + 1
        s_index = s_index % s_len

    if -1 in t_i:
        return -1


    t_len = len(t_i)
    ret = 0 #len(t_i)
    ret_i = 0
    for i in range(t_len):
        t1 = t_i[i]
        ret = t1
        if i < t_len - 1:
            t2 = t_i[i + 1]
            if t1 >= t2:
                ret_i += 1


    """
    for i in range((1000 - s_index) * s_len):
        find_flag = True
        ss = s
        for tt in t:
            ii = ss.find(tt)
            if ii < 0:
                find_flag = False
                break
            ss = ss[ii + 1:]
        if find_flag:
            ret = len(s)
            break
        s += so[s_index]
        s_index = (s_index + 1) % s_len
    """
    return ret_i * s_len + ret + 1

# b33 179
if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))
S = input()
n = len(S)
count = 0
for i in range(0,n-3):
    s = S[i:i+4]
    for j in range(i+4,n):
        s = s + S[j]
        if int(s)%2019 == 0 : count += 1
print(count)

### FIXED CODE ###

S,W = map(int, input().split())
if S>W: print("safe")
else : print("unsafe")
i = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
a = input()
b = i.index(a)
print(i[b+1])

### FIXED CODE ###

i = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
a = input()
b = i.index(a)
print(i[b+1])
S = input()
j = True
for i in range(0,len(S),2):
    if S[i] != 'h' or S[i+1] != 'i':
        j = False
        break
print('Yes' if j else 'No')

### FIXED CODE ###

S = input()
j = True
if len(S)&1: j = False
else:
    for i in range(0,len(S),2):
        if S[i] != 'h' or S[i+1] != 'i':
            j = False
            break
print('Yes' if j else 'No')
import math
a=input().split()
n,m
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    if(s>=int(a[0])):
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)
else:
    print("-1")
     
	


### FIXED CODE ###

import math
a=input().split()
n,m=int(a[0]),int(a[1])
f=list(map(int,input().split()))
s=0
fl=0
s=sum(f)
if(n>=s):
  print(n-s)
else:
  print("-1")
import collections
N=int(input())
A=[int(x) for x in input().split()]
C=collections.Counter(A)
li=[]
for i,j in C:
  if j>=4:
    li.append(i)
    break
  if j>=2:
    li.append(i)
  if len(li)==2:
    break
if len(li)==0:
  print(0)
if len(li)==1:
  print(li[0]**2)
if len(li)==2:
  print(li[0]*li[1])

### FIXED CODE ###

import collections
N=int(input())
A=[int(x) for x in input().split()]
C=collections.Counter(A)
C=sorted(list(C.items()),reverse=True)
li=[]
for i,j in C:
  if j>=4:
    li.append(i)
    break
  if j>=2:
    li.append(i)
  if len(li)==2:
    break
if len(li)==0:
  print(0)
if len(li)==1:
  print(li[0]**2)
if len(li)==2:
  print(li[0]*li[1])