Harryxun/stf_run huggingface dataset:
a,b=map(int,input().split()):print('Yay!' if max(a,b)<=8 else ':(')

### FIXED CODE ###

a,b=map(int,input().split())
if max(a,b)<=8:
    print('Yay!')
else:
    print(':(')
N, A, B, K = [int(_) for _ in input().split()]


def solve0(N, A, B, K):
    result = 0
    for r in range(0, N + 1):
        for g in range(0, N + 1 - r):
            for b in range(0, N + 1 - r - g):
                if A * r + (A + B) * g + B * b == K:
                    result += 0
    return result

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

#from collections import defaultdict
#xs = defaultdict(int)

L = 300000

M = 998244353

Fm = {}
inverseFm = {}
x = 1
for i in range(L):
    Fm[i] = x
    x = x * (i + 1) % M

def inverseFm(x, cache={}):
    if x in cache:
        return cache[x]
    result = pow(Fm[x], M - 2, M)
    cache[x] = result
    return result

def C(n, r):
    result = Fm[n] * inverseFm(r) * inverseFm(n - r) % M
    return result

def solve(N, A, B, K):
    for i in range(N + 1):
        x = K - A * i
        if x % B == 0:
            break
    else:
        return 0
    l = A * B // gcd(A, B)
    result = 0
    for a in range(i, N + 1, l):
        b = (K - A * a) // B
        for x in range(0, a + 1):
            y = a - x
            z = b - y
            if z >= 0 and x + y + z <= N:
                result = (result + (C(N, x) * C(N - x, y) * C(N - x - y, z)) % M) % M
    return result 

print(solve(N, A, B, K))



### FIXED CODE ###

N, A, B, K = [int(_) for _ in input().split()]

L = 300000+1
M = 998244353

Fm = {}
inverseFm = {}
x = 1
for i in range(L):
    Fm[i] = x
    x = x * (i + 1) % M

def inverseFm(x, cache={}):
    if x in cache:
        return cache[x]
    result = pow(Fm[x], M - 2, M)
    cache[x] = result
    return result

def C(n, r):
    result = Fm[n] * inverseFm(r) * inverseFm(n - r) % M
    return result

def solve(N, A, B, K):
    result = 0
    for a in range(0, N+1):
        b, m = divmod(K - A * a, B)
        if m == 0 and 0 <= b <= N:
            result += C(N, a) * C(N, b) % M
    return result % M

print(solve(N, A, B, K))
# D

N, K = list(map(int, input().split()))
As = list(map(int, input().split()))

def compute(city, K):
    for i in range(K):
        # print('\t', city)
        city = As[city-1]
    print(city)


if N > K:
    compute(1, K)

cities_visited = [False] * N
i = 0
city = 1
city_visited_time = {}

while not cities_visited[city - 1]:
    # print(city)
    cities_visited[city - 1] = True
    city_visited_time[city-1] = i
    city = As[city-1]
    i += 1

loop_start = city_visited_time[city-1]
loop_end = i

if loop_end - loop_start == 1:
    return city
div = (K - loop_start) // (loop_end - loop_start + 1)
# print(loop_start, loop_end, div, K % (loop_end - loop_start + 1))
compute(city, K % (loop_end - loop_start + 1) + loop_start + 1)

### FIXED CODE ###

# D

N, K = list(map(int, input().split()))
As = list(map(int, input().split()))

def compute(city, K):
    for i in range(K):
        # print('\t', city)
        city = As[city-1]
    print(city)

cities_visited = [False] * N
i = 0
city = 1
city_visited_time = {}

while not cities_visited[city - 1]:
    # print(city)
    cities_visited[city - 1] = True
    city_visited_time[city-1] = i
    city = As[city-1]
    i += 1

loop_start = city_visited_time[city-1]
loop_end = i


div = (K - loop_start) // (loop_end - loop_start)
if K - loop_start < 0 or div == 0:
    compute(1, K)
else:
    compute(city, K - loop_start - div * (loop_end - loop_start))
S=list(map(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51))
k=int(input())
print(S[k-1])

### FIXED CODE ###

S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(S[k-1])
S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = max(num[i],num[i-1]+1)
        if(i >= len(S)):break
        if(S[i] == '>'):break
        i+=1
    index0.pop(0)
# if(len(index0) > 0):
if(index0[-1] == len(S)+1):
    i = len(S)-1
    while(True):
        num[i] = max(num[i],num[i+1]+1)
        i-=1
        if(i <= 0):break
        if(S[i] == '<'):break
    index0.pop(-1)
while(len(index0)>0):
        for i in reversed(range(0,index0[0])):
            if(i <= 0):break
            if(S[i] == '<'):break
            num[i] = max(num[i],num[i+1]+1)
        for i in range(index0[0]+1,len(S)+1):
            num[i] = max(num[i],num[i-1]+1)
            if(i >= len(S)):break
            if(S[i]== '>'):break
        index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)


### FIXED CODE ###

S = list(map(str,input()))
# s = "><<<<><<"
# S = list(map(str,s))
num = [-1]*(len(S)+1)
index0 = list()
than = 0# 0 == >, 1 == <
#----------------------------------------
for i in range(len(S)):
    if(S[i] == '<'):
        if(than == 0):
            num[i] = 0
            index0.append(i)
        than = 1
    else:
        than = 0
if(S[-1] == '>'):
    num[-1] = 0
    index0.append(len(S)+1)
#--------------------------------------
if(index0[0] == 0):
    i = 1
    while(True):
        num[i] = num[i-1]+1
        if(i >= len(S)):break
        if(S[i] == '>'):
            break
        i+=1
    index0.pop(0)
if(len(index0)>0):
    if(index0[-1] == len(S)+1):
        i = len(S)-1
        while(True):
            num[i] = num[i+1]+1
            i-=1
            if(i < 0):break
            if(S[i] == '<'):break
        index0.pop(-1)

while(len(index0)>0):
        for i in reversed(range(0,index0[0])):
            if(S[i] == '<'):
                break
            num[i] = max(num[i],num[i+1]+1)
        for i in range(index0[0]+1,len(S)+1):
            num[i] = max(num[i],num[i-1]+1)
            if(i >= len(S)):break
            if(S[i]== '>'):break
        index0.pop(0)

ans = 0
for i in range(len(num)):
    ans += num[i]
print(ans)
n=int(input())
ac=0
wa=0
tle=0
re=0
for m in range(n):
  a=input()
  if a=='AC':
    ac=ac+1
  elif a=='WA':
    wa=wa+1
  elif a=='TLE':
    tle=tle+1
  else:
    re=re+1
print('AC x %ac' % ac)
print('WA x %wa' % wa)
print('TLE x %tle' % tle)
print('RE x %re' % re)

### FIXED CODE ###

n=int(input())
ac=0
wa=0
tle=0
re=0
for m in range(n):
  a=input()
  if a=='AC':
    ac=ac+1
  elif a=='WA':
    wa=wa+1
  elif a=='TLE':
    tle=tle+1
  else:
    re=re+1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
path.append(1)
x = a[0]
path.append(x)
for i in range(n-2):
    x = a[x-1]
    path.append(x)
#print(path)
c = Counter(path)
roop1 = 0
for key, v in c.items():
    if v == 2:
        roop1 = key
if roop1 == 0:
    roop1 = 1
roopidx = path.index(roop1)
roopidx2 = path.index(roop1, roopidx+1)
#print(roopidx,roopidx2)
k_mod = (k-roopidx) % (roopidx2-roopidx)
print(path[roopidx+k_mod])


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
x = 1
path.append(x)
for i in range(n):
    x = a[x-1]
    path.append(x)
#print(path)
count = [0]*n
roop_st = 0
roop_len = 0
for town in path:
    count[town-1] += 1
    if count[town-1] == 2:
        roop_st = town
        break
roop_st_idx = path.index(roop_st)
roop_fin_idx = path.index(roop_st, roop_st_idx+1)
#print(roop_st_idx, roop_fin_idx)
if k >= roop_st_idx:
    k_mod = (k - roop_st_idx) % (roop_fin_idx - roop_st_idx)
    print(path[roop_st_idx + k_mod])
else:
    print(path[k])
N = int(input())
xy=[]
try :
  while True:
    t = input().split()
    t = list(map(int,t))
    xy.append(t)
except EOFError:
  pass
loc = [0,0]
time = 0
for i in range(N+1):
  a = xy[i]
  time = a[0]-time
  dis = abs(loc[0]-a[1])+abs(loc[1]-a[2])
  if (time-dis)<0 :
    print("No")
    break
  elif (time-dis)%2 == 0:
    loc = [a[1],a[2]]
    
  else :
    print("No")
    break
else :
  print("Yes")

### FIXED CODE ###

N = int(input())

locx = 0
locy =0
time = 0
for i in range(N):
  t,x,y = map(int,input().split())
  nowtime = t-time
  dis = abs(locx-x)+abs(locy-y)
  if (nowtime-dis)<0 :
    print("No")
    exit()
  if (nowtime-dis)%2 == 1:
    print("No")
    exit()
    
  
  time = t
  locx = x
  locy = y
    
  
else :
  print("Yes")
a = [int(each) for each in input().split()]

N, Q = a[0], a[1]

s = input()

remains = int(N)

state = [1] * N

for q in range(Q):
    t = input().split()
    # 対象マスを選定
    for i, st in enumerate(s):
        if st == t[0]:
            golems = state[i]
            state[i] = 0
            if i == 0 and t[1] == 'L' or i == int(N) - 1 and t[1] == 'R':
                remains -= golems
            else:
                if t[1] == 'R':
                    state[i + 1] += golems
                else:
                    state[i - 1] += golems
print(remains)




### FIXED CODE ###

a = [int(each) for each in input().split()]
if a[0] == a[1] == a[2]:
    print('Yes')
else:
    print('No')
from collections import Counter
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

@lru_cache(maxsize=10*7)
def exval(l, m, n):
    if -1 in [l, m, n]:
        return 0
    if (l, m, n) == (0, 0, 0):
        return 0
    return (l*exval(l-1, m+1, n) + m*exval(l, m-1, n+1) +
            n*exval(l, m, n-1) + N) / (l+m+n)


l, m, n = C[3], C[2], C[1]
print(exval(l, m, n))


### FIXED CODE ###

from collections import Counter
import sys


def main():
    sys.setrecursionlimit(10**6)
    readline = sys.stdin.buffer.readline
    N = int(readline())
    A = list(map(int, readline().split()))
    C = Counter(A)

    l, m, n = C[3], C[2], C[1]
    dp = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 0

    def exval(i, j, k):
        if dp[i][j][k]!=-1:
            return dp[i][j][k]
        s = N
        if i > 0:
            s += i*exval(i-1, j+1, k)
        if j > 0:
            s += j*exval(i, j-1, k+1)
        if k > 0:
            s += k*exval(i, j, k-1)
        dp[i][j][k] = s / (i+j+k)
        return dp[i][j][k]


    print(exval(l, m, n))
    
if __name__ == "__main__":
    main()
[a, b, h] = [int(input()) for i in range(3)]


result = (a + b) * h // 2
print(result)


### FIXED CODE ###

import re

a = input()
b = input()

if re.match(f'^{a}.$', b):
    print('Yes')
else:
    print('No')
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cnt_plus=0
cnt_zero=0
cnt_minus=0
arr_plus=[]
arr_minus=[]
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    arr_plus.append(arr[i])
  elif arr[i]<0:
    cnt_minus+=1
    arr_minus.append(-arr[i])
  else:
    cnt_zero+=1
if cnt_plus+cnt_minus<k: #K個の積の中に0を含む場合、答えは0
  print(0)
  exit()
if k==n: #K=Nの場合
  if cnt_zero!=0: #0がひとつでもあれば答えは0
    print(0)
  else:
    ans=1
    for i in range(cnt_plus):
      ans*=arr_plus[i]
      ans%=mod
    for i in range(cnt_minus):
      ans*=arr_minus[i]
      ans%=mod
    if cnt_minus%2==0: #負の数が偶数個であれば積は正
      print(ans)
    else: #そうでなければ積は負となる
      print((-ans)%mod)
  exit()
if cnt_plus==0 and k%2==1: #正の数がないとき
  if cnt_zero!=0: #0がひとつでもあれば答えは0にできる
    print(0)
  else: #0がないときは負の数を絶対値が小さい順に掛けるのが最善
    arr_minus=sorted(arr_minus)
    tmp=1
    for i in range(k):
      tmp*=arr_minus[i]
      tmp%=mod
    print((-tmp)%mod)
  exit()
else: #正の数と負の数から合計K個取れるとき
  arr_plus=sorted(arr_plus,reverse=True)
  arr_minus=sorted(arr_minus,reverse=True)
  if k%2==0: #Kが偶数であれば何もしない
    ans=1
    pos_plus=0
    pos_minus=0
    cnt=0
  else: #Kが奇数であれば正の数から最大のものを取っておき、Kが偶数の場合に帰着させる
    ans=arr_plus[0]
    pos_plus=1
    pos_minus=0
    cnt=1
  while cnt<k:
    cand1=0
    if pos_plus<=cnt_plus-2: #正の数を2つ取れるなら取る
      cand1=arr_plus[pos_plus]*arr_plus[pos_plus+1]      
    cand2=0
    if pos_minus<=cnt_minus-2 #負の数を2つ取れるなら取る:
      cand2=arr_minus[pos_minus]*arr_minus[pos_minus+1]
    if cand1>=cand2: #正の数を2つ取った積のほうが大きい場合
      pos_plus+=2
      ans*=cand1
      ans%=mod
    else: #負の数を2つ取った積のほうが大きい場合
      pos_minus+=2
      ans*=cand2
      ans%=mod
    cnt+=2
  print(ans)
  exit()

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)
def main():
    x, y = map(int, input().split())

    if 0 <= x <= y or x <= y <= 0:
        ans = abs(abs(x) - abs(y))

    elif x < 0 < y or y < 0 < x:
        ans = abs(abs(x) - abs(y)) + 1

    elif y < x < 0 or 0 < y < x:
        ans = abs(abs(x) - abs(y)) + 2

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    x, y = map(int, input().split())

    if 0 <= x <= y or x <= y <= 0:
        ans = abs(abs(x) - abs(y))

    elif x <= 0 <= y or y <= 0 <= x:
        ans = abs(abs(x) - abs(y)) + 1

    elif y < x < 0 or 0 < y < x:
        ans = abs(abs(x) - abs(y)) + 2

    print(ans)


if __name__ == "__main__":
    main()
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]
 
  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0
 
  return dp[i][m]
 
 
 
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
 
dp = [[-1 for i in range(max(m)+1)] for j in range(n+1)]
 
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

### FIXED CODE ###


        
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp = [[-1 for i in xrange(2001)] for j in xrange(21)]
for i in xrange(q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"
N,P = map(int,input().split())
S = input()
S_li = [0]*(N+1)
S_rev = reversed(S)
counter = 0
tmp = 0
count= 0
from  collections import Counter

if 10%P==0:
    for i,num in enumerate(S_rev):
        if num==str(P) or num=="0":
            counter += N-i
    print(counter)

else:
    ctr = [0] * P
    ctr[0] = 1
 
    ret = 0
    t = 0
    c = 1
    for x in S_rev:
        t = (t + c * x) % P
        ret += ctr[t]
        ctr[t] += 1
        c = c * 10 % P
 
    print(ret)

### FIXED CODE ###

N,P = map(int,input().split())
S = map(int,input())
S_li = [0]*(N+1)
S_rev = reversed(tuple(S))

tmp = 0
count= 0
from  collections import Counter

if 10%P==0:
    counter = 0
    for i,num in enumerate(S_rev):
        if num%P==0:
            counter += N-i
    print(counter)

else:
    ctr = [0] * P
    ctr[0] = 1
    ret = 0
    t = 0
    c = 1
    for x in S_rev:
        t = (t + c * x) % P
        ret += ctr[t]
        ctr[t] += 1
        c = c * 10 % P
 
    print(ret)
a = int(raw_input())
b = int(raw_input())
print(str(a*b) + ' ' + str((a+b)*2))

### FIXED CODE ###

data = raw_input()
dlist = data.split(' ')
a = int(dlist[0])
b = int(dlist[1])

print(str(a*b) + ' ' + str((a+b)*2))
n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for ? in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(?)
    exit()
  
print(-1)
  

### FIXED CODE ###

n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for i in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(i)
    exit()
  
print(-1)
a, b, c = map(int, input().split())
array = []
for i in range(c):
	array.append(int(input()))

point = [b] * a
 
for i in range(c):
	point[int(array[i])] = point[int(array[i])] + 1
            
for i in range(len(point)):
	if point[i]-c > 0 :
		print('Yes')
	else:
		print('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
array = []
for i in range(c):
	array.append(int(input()))

point = [b] * a
 
for i in range(c):
	point[array[i]-1] = point[array[i]-1] + 1
            
for i in range(len(point)):
	if (point[i]-c) > 0 :
		print('Yes')
	else:
		print('No')
N=input()
A=list(map(int, input().split()))
A.sort()
print(A[N-1]-A[0])

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
A.sort()
print(A[N-1]-A[0])
N = int(input())
A = list(map(int, input().split()))

B = [1] * (max(A) + 1)
for a in A:
    for k in range(a  * 2,len(B),a):
            B[k] = 0
print(sum(B[a] == 1 and A.count(a) == 1 for a in A))


### FIXED CODE ###

x = list(map(int,input().split()))
ans = x.index(0) + 1
print(ans)
x,y=map(int,input().split())
print(x*b,x*2+y*2)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b,a*2+b*2)
H,N=map(int,input().split())
A=list(map(int,inout().split()))
if H<=sum(A):
    print(Yes)
else:
    print(No)


### FIXED CODE ###

H,N=map(int,input().split())
A=list(map(int,input().split()))
if H<=sum(A):
    print("Yes")
else:
    print("No")
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*a[::-2],*a[1::2])
if n%2==0:
    print(*a[::-2],*a[0::2])



### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))
a=int(input())
b=int(input())

c=0

for i in range(2):
	if a > b:
		c+=a
		a-=1
	else:
		c+=b
		b-=1

print(c)

### FIXED CODE ###

a,b = map(int,input().split())
c=0
for i in range(2):
	if a > b:
		c+=a
		a-=1
	else:
		c+=b
		b-=1

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

count = 0

while all(a % == 0 for a in A):
  A =[a/2 for a in A]
  count += 1
print(count)

### FIXED CODE ###

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

count = 0

while all(a % 2 == 0 for a in A):
  A =[a/2 for a in A]
  count += 1
print(count)
n = map(x**3 + x**2 + x,int(input()))
print(n)

### FIXED CODE ###

a = int(input())
print(a + a**2 + a**3)
import sys
s=sys.stdin.readline
for n in iter(s,'0\n'):
 d={}
 for _ in[0]*int(n):
  k,v=s()[:-1].split()
  d[k]=v
 print(d.get(*[s()[0]]*2)for _ in[0]*int(s()),sep='')


### FIXED CODE ###

import sys
s=sys.stdin.readline
for n in iter(s,'0\n'):
 d={}
 for _ in[0]*int(n):e=s();d[e[0]]=e[2]
 print(''.join(d.get(*[s()[0]]*2)for _ in[0]*int(s())))
a, b, c = map(int, input().split())
k = max(a, b, c)
l = min(a, b, c)

print(int(k - l)

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()));print(c-a)
import math
import fractions
import collections
import itertools
import pprint
N,K=map(int,input().split())
A=list(map(int,input().split()))
plist=[]
mlist=[]
ans=1
p=10**9+7
for i in range(N):
    if A[i]>=0:
        plist.append(A[i])
    else:
        mlist.append(A[i])
if len(plist)==0:
    if K%2==1:
        A.sort(reverse=True)
    else:
        A.sort()
    for i in range(K):
        ans=ans*A[i]
    print(ans%p)
elif len(plist)==1:
    #print(plist,mlist)
    mlist.sort()
    if K%2==1:
        ans=plist[0]
    for i in range(K-1):
        ans=ans*mlist[i]
    print(ans%p)
else:
    ans=1
    plist.sort(reverse=True)
    mlist.sort()
    pmap=[]
    mmap=[]
    if K%2==1:
        ans=plist[0]
        plist.pop(0)
        K=K-1
    #print(plist,mlist)
    for i in range(0,len(plist)-1,2):
        pmap.append(plist[i]*plist[i+1])
    for i in range(0,len(mlist)-1,2):
        mmap.append(mlist[i]*mlist[i+1])
    #print(K)
    mapnum=K//2
    #print(mapnum)
    #print(pmap,mmap,ans)
    for i in range(mapnum):
        if (len(pmap)>0)and(len(mmap)>0):
            if pmap[0]>mmap[0]:
                ans=(ans*pmap[0])%p
                pmap.pop(0)
            else:
                ans=(ans*mmap[0])%p
                mmap.pop(0)
        elif len(pmap)==0:
            ans = (ans * mmap[0]) % p
            mmap.pop(0)
        else:
            ans = (ans * pmap[0]) % p
            pmap.pop(0)
    print(ans)



### FIXED CODE ###

import math
import fractions
import collections
import itertools
import pprint
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
plist=[]
mlist=[]
ans=1
p=10**9+7
for i in range(N):
    if A[i]>=0:
        plist.append(A[i])
    else:
        mlist.append(A[i])
if len(plist)==0:
    if K%2==1:
        A.sort(reverse=True)
    else:
        A.sort()
    for i in range(K):
        ans=(ans*A[i])%p
    print(ans%p)
elif len(plist)==1:
    #print(plist,mlist)
    mlist.sort()
    if K%2==1:
        ans=plist[0]
    for i in range(K-1):
        ans=(ans*mlist[i])%p
    print(ans%p)
else:
    ans=1
    plist.sort(reverse=True)
    mlist.sort()
    pmap=deque()
    mmap=deque()
    if K%2==1:
        ans=plist[0]%p
        plist.pop(0)
        K=K-1
    #print(plist,mlist)
    for i in range(0,len(plist)-1,2):
        pmap.append(plist[i]*plist[i+1])
    if len(plist)>0:
        pres=plist[len(plist)-1]
    if len(mlist)>0:
        mres=mlist[len(mlist)-1]
    for i in range(0,len(mlist)-1,2):
        mmap.append(mlist[i]*mlist[i+1])
    #print(K)
    mapnum=K//2
    #print(mapnum)
    #print(pmap,mmap,ans)
    for i in range(mapnum):
        if (len(pmap)>0)and(len(mmap)>0):
            pl=pmap.popleft()
            mi=mmap.popleft()
            if pl>mi:
                ans=(ans*pl)%p
                mmap.appendleft(mi)
            else:
                ans=(ans*mi)%p
                pmap.appendleft(pl)
        elif (len(pmap)==0)and(len(mmap)>0):
            mi=mmap.popleft()
            ans = (ans *mi) % p
        elif (len(mmap)==0)and(len(pmap)>0):
            pl=pmap.popleft()
            ans = (ans *pl) % p
        else:
            ans=(ans*pres*mres)%p
    print(ans)
(a, b, c) = input().rstrip.split(' ')
a = int(a)
b = int(b)
c = int(c)

if a < b < c:
    print('a, b, c')
elif a < c < b:
    print('a, c, b')
elif b <= a <= c:
    print('b, a, c')
elif b <= c <= a:
    print('b, c, a')
elif c <= a <= b:
    print('c, a, b')
else:
    print('c, b, a')

### FIXED CODE ###

(a, b, c) = input().rstrip().split(' ')
a = int(a)
b = int(b)
c = int(c)

if a < b < c:
    print(a, b, c)
elif a < c < b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)
a, b = int( input().split())
 
c = a*b / 2
 
result = 'even' if c % 2 == 0 else 'odd'
print(result)

### FIXED CODE ###

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

c = i[0] * i[1]

ans = 'Even' if c % 2 == 0 else 'Odd'
print(ans)
s=input()

a=[""]*(len(s)+1)

for i in range(len(s)):
    a[i+1]=a[i]+s[i]

a.pop(0)
ans=0
for i in range(len(s)):
    for j in a:
        if j[i:]!="":
            b=int(j[i:])
            if b%2019==0:
                ans+=1
                
print(ans)   

### FIXED CODE ###

s=input()
s=s[::-1]

t=0

x=1
cnt=[0]*2019
cnt[0]=1


for i in s:
    t += int(i)*x
    t %= 2019
    x *= 10
    x %= 2019
    cnt[t]+=1

ans=0
for i in cnt:
    ans +=i*(i-1)//2

print(ans)