Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 20:49:53 2017

@author: thvinmei
"""

import numpy as np

if __name__ == '__main__':
    answer = False
    N,M,K=map(int,input().split())

    tile = np.zeros((N,M))
    
    if( K > N*M):
        print("No")
        
    for j in range(M):
        for i in range(N):
            tile[i,j] = 1

        if np.sum(tile)==K:
            answer = True
    
        if (np.sum(tile)>K):
            for i in range(N):
                tile[i,j] = 0
            break
    
    for i in range(N):
        for j in range(M):
            if tile[i,j] == 0:
                tile[i,j] = 1
            else:
                tile[i,j] = 0
        
        if np.sum(tile)==K:
            answer = True
            break

    if answer == True:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 20:49:53 2017

@author: thvinmei
"""

if __name__ == '__main__':
    S=input()
    
    if (S[0:4]=="YAKI"):
        print("Yes")
    else:
        print("No")
import math
import re
import copy
import sys
import numpy as np

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

for i in range(n):
    c += min(a[i],b[i])
    if a[i] < b[i]:
        a[i+1] -= b[i]-a[i]
        c += b[i]-a[i]

print(c)

### FIXED CODE ###

import math
import re
import copy
import sys

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

for i in range(n):
    c += min(a[i],b[i])
    if a[i] < b[i]:
        c += min(a[i+1],b[i]-a[i])
        a[i+1] -= min(a[i+1],b[i]-a[i])

print(c)
import statistics
import math
N, A, B = map(int, input().split())
v = [int(x) for x in input().split()]
v.sort()

base = v[N-A:]
rem = v[:N-A]
mean_max = statistics.mean(base)
cnb = 0
while mean_max == statistics.mean(base):
    same = base.count(base[0])
    extra = rem.count(base[0])
    cnb += math.factorial(same+extra)/math.factorial(same)/math.factorial(extra)
    base.append(rem[len(rem)-1])
    rem = rem.pop
print(mean_max)
print(math.floor(cnb))

### FIXED CODE ###

N, A, B = map(int, input().split())
V = sorted([int(x) for x in input().split()],reverse=True)
from statistics import mean
from math import comb
maxmean = mean(V[:A])
if V[0] != V[A-1]:
    n = V.count(V[A-1])
    k = V[:A].count(V[A-1])
    way = comb(n, k)
else:
    n = V.count(V[A-1])
    way = sum(comb(n, k) for k in range(A, min(n,B)+1))
print(maxmean)
print(way)
n,l=map(int,input().split())

taste = []
taste_abs = []

for i in range(n):
    taste.append(l+i)
    taste_abs.append(abs(taste[i]))

sum_taste = sum(taste)
min_abs = min(taste_abs)
print(sum_taste - min_abs)

### FIXED CODE ###

num = input()
#num = str(code)

if num[0] == num[1] or num[1] == num[2] or num[2] == num[3]:
    print('Bad')
else:
    print('Good')
from math import factorial
N,M=map(int,input().split())
list1=[]
ANS=0
for i in range(M):
  A=int(input())
  list1+=[A]
  if i>=1:
    DAN=A-list1[i-1]-1
    B=DAN-DAN//2
    if A==list1[i-1] or A==list1[i-1]+1:
      print(0)
      break
    for k in range(B):
      a = factorial(B) / factorial(k) / factorial(B - k)
      ANS+=a
  else:
    DAN=A
    B=DAN-DAN//2
    for k in range(B):
      a = factorial(B) / factorial(k) / factorial(B - k)
      ANS+=a
DAN=N-A-1
B=DAN-DAN//2
for t in range(B):
  a = factorial(B) / factorial(t) / factorial(B - t)
  ANS+=a
print(int(ANS)%1000000007)

### FIXED CODE ###

import sys
N,M=map(int,input().split())
dp=[1]*N
listA=[]
for i in range(M):
  a=int(input())
  listA+=[a]
  dp[a-1]=0
for i in range(1,M):
  if listA[i]==listA[i-1]:
    print(0)
    sys.exit()
setA=set(listA)    
if (1 not in setA) and (2 not in setA) and N!=1:
  dp[1]=2
for i in range(2,N):
  if i+1 not in setA:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[-1]%(10**9+7)
print(ans)
import numpy as np
N,Q = map(int,input().split(' '))
s = input()
td = [input().split(' ') for i in [0]*Q]

l = np.array([1] * (N+2))

dic = {}

for c in s:
	if not c in dic:
		dic[c] = np.array([i for i,c2 in enumerate(s) if c == c2])

for t,d in td:
	if not t in s:
		continue
	indeces = dic[t]
	if d == 'L':
		ap = l[indeces+1]
		l[indeces+1] = 0
		l[indeces] += ap
	else:
		ap = l[indeces+1]
		l[indeces+1] = 0
		l[indeces+2] += ap

print(sum(l[1:-1]))





### FIXED CODE ###

A,B,C = map(int,input().split(' '))

if A == B and B == C:
	print("Yes")
else:
	print("No")
import sys

def isEmpty(S):
  if len(S) == -1:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print 'Error'
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print 'Error'
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []

for i in range(a):
  text = raw_input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if int(x_list_list[0][1]) > b:
    x_list_list[0][1] -= int(b)
    for j in range(flag):
      x_list_list[j][2] += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  elif int(x_list[0][1]) <= b:
    for j in range(flag):
      x_list_list[j][2] += x_list_list[0][1]
    x_list_list[0][1] = 0
    flag -= 1
    print x_list_list[0][0],x_list_list[0][2]
    dequeue(x_list_list)

### FIXED CODE ###

import sys

def isEmpty(S):
  if len(S) == 0:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print 'Error'
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print 'Error'
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []
run_time = 0

for i in range(a):
  text = raw_input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if x_list_list[0][1] > b:
    x_list_list[0][1] -= int(b)
    run_time += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  else:
    run_time += x_list_list[0][1]
    x_list_list[0][2] = run_time
    x_list_list[0][1] = 0
    flag -= 1
    print x_list_list[0][0],x_list_list[0][2]
    dequeue(x_list_list)
lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k = int(input())
index = 0
while True:
	if len(lun_luns) >= k:
		break
	num = lun_luns.pop(index)
	lun_luns.insert(index, num)
	mod = num % 10
	n = num * 10
	if mod == 9:
		lun_luns.extend([n+mod-1, n+mod])
	else:
		lun_luns.extend([n+mod-1, n+mod, n+mod+1])
	index += 1
print(lun_luns[k-1])

### FIXED CODE ###

x, y, z = map(int, input().split())
a = y
b = x
c = z
a = c
c = y
print(a, b, c)
lst = [map(int, input().split())]
lst.sort()
 
print(lst[0] +lst[1])

### FIXED CODE ###

lst = list(map(int, input().split()))
lst.sort()
 
print(lst[0] +lst[1])
from sys import stdin
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
	c1 = readLine_int_list()
	c2 = readLine_int_list()
	
	if c1[0] == c2[-1] and c1[1] == c2[1] and c1[-1] == c2[0]:
	    print("YES")
    else:
        print("NO")
        
if __name__ == "__main__": main()

### FIXED CODE ###

def main():
	c1 = input()
	c2 = input()
	
	if c1[0] == c2[-1] and c1[1] == c2[1] and c1[-1] == c2[0]:
	    print("YES")
	else:
	    print("NO")
        
if __name__ == "__main__": main()
K = int(input())
S = list(input())
S2 = []

for i in range(K):
    n = S[i]
    S2.append(n)

S2.append('...')
print(''.join(S2))
    

### FIXED CODE ###

K = int(input())
S = list(input())
S2 = []

if len(S) <= K:
    print(''.join(S))
else:
    for i in range(K):
        n = S[i]
        S2.append(n)
if len(S2) == K:
    print(''.join(S2) + '...')
while True:
    m,f,r =[int(i) for i in input().split()]

    if m == f == r ==-1:
        break

    total =m+f
    if m ==-1 or f == -1 or total <30:
        print("F")

    elif total < 50 and r < 50:
        print("D")
    
    elif total <65
        print("C")

    elif total <80:
        pirnt("B")

    else:
         print("A")

### FIXED CODE ###

while True:
    m, f, r = [int(i) for i in input().split()]
 
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
 
    elif total < 50 and r < 50:
        print('D')
 
    elif total < 65:
        print('C')
         
    elif total < 80:
        print('B')
         
    else:
        print('A')
a, b = list(map(int, input().split()))

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, max):
  output += f'{i} '

output.rstrip()

print(output)

### FIXED CODE ###

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  hoge = str(i) + ' '
  output += hoge

output.rstrip()

print(output)
a,b = map(int,input().split())
k = [2,5,5,4,5,6,3,7,6]

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

c.sort()
cc = [[c[i],k[c[i]-1]] for i in range(b)]
ccc = [[c[i],k[c[i]-1]] for i in range(b)]
dp = [-1 for i in range(a+1)]
cc.sort(key = lambda x:x[1])
for j in range(b):
	for i in range(a+1):
		if dp[i-cc[j][1]] >= 0:
			dp[i] = max(dp[i-cc[j][1]]+1,dp[i])

k = a
co = ''
for i in range(dp[a]):
	for j in range(b):
		if dp[k-ccc[j][1]] == dp[k] and k-ccc[j][1] >= 0:
			co += str(ccc[j][0])
			k -= ccc[j][1]
			break
print(co)

### FIXED CODE ###

a,b = map(int,input().split())
k = [2,5,5,4,5,6,3,7,6]

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

c.sort()
cc = [[c[i],k[c[i]-1]] for i in range(b)]
ccc = [[c[i],k[c[i]-1]] for i in range(b)]
dp = [-1 for i in range(a+1)]
dp[0] = 0
cc.sort(key = lambda x:x[1])
for j in range(b):
	for i in range(a+1):
		if i-cc[j][1] >= 0 and dp[i-cc[j][1]] >= 0:
			dp[i] = max(dp[i-cc[j][1]]+1,dp[i])
ccc.reverse()
k = a
co = ''
for i in range(dp[a]):
	for j in range(b):
		if k-ccc[j][1] >= 0 and dp[k-ccc[j][1]] == dp[k] - 1:
			co += str(ccc[j][0])
			k -= ccc[j][1]
			break
print(co)
n,m=map(int,input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())-1
s=[0]*n

if a[0] == 0:
  s[0] = 0
  s[1] = 1
elif a[0] == 1:
  s[0] = 1
  s[1] = 0
else:
  s[0] = 1
  s[1] = 2
  
for i in range(2,n):
  #壊れている
  if i in a:
    s[i] = 0
  else:
    s[i] = s[i-1]+s[i-2]
print(s[n-1]%1000000007)


### FIXED CODE ###

n,m=map(int,input().split())
a = [0]*n
if n!=1:
  if m!=0:
    for i in range(m):
      a[int(input())-1] = 1

  s=[0]*n
  if a[0]==1 and a[1] == 1:
    s[0] = 0
    s[1] = 0
  elif a[0] == 1:
    s[0] = 0
    s[1] = 1
  elif a[1] == 1:
    s[0] = 1
    s[1] = 0
  else:
    s[0] = 1
    s[1] = 2

  for i in range(2,n):
    #壊れている
    if a[i] == 1:
      s[i] = 0
    else:
      s[i] = s[i-1]+s[i-2]
  print(s[n-1]%1000000007)
else:
  print(1)
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()

td_1 = [0]*N
td_rem = []
for i in range(N):
    t,d = rl()
    t -= 1
    if td_1[t] == 0:
        td_1[t] = d
    else:
        if d <= td_1[t]:
            td_rem += [d]
        else:
            td_rem += td_1[t]
            td_1[t] = d


td_1.sort(reverse=True)
td_rem.sort(reverse=True)

ans = [0 for _ in range(K+1)]
sum_l = 0
for i in range(1,K+1):
    if td_1[i-1] != 0 and len(td_rem)>=K-i:
        ans[i] = i*i + sum(td_1[:i]) + sum(td_rem[:(K-i)])

#print(td_1)
#print(td_rem)
#print(ans)
print(max(ans))


### FIXED CODE ###

ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()
td = [rl() for _ in range(N)]

from operator import itemgetter
key0 = itemgetter(0)
key1 = itemgetter(1)
td.sort(key=key1,reverse=True)

netas = set()
dup = []

for t,d in td[:K]:
    if t in netas:
        dup.append(d)
    else:
        netas.add(t)

score = len(netas)**2 + sum(map(key1,td[:K]))
ans = score
for t,d in td[K:]:
    if t not in netas and dup != []:
        netas.add(t)
        dup_ = dup.pop(-1)
        score += 2*len(netas)-1 + d - dup_
        ans = max(ans,score)
print(ans)
import sys
 
while True :
    a, b = map(int, sys.stdin.readline().stlip())
    if (a == 0) & (b == 0) :
        break
    
    if a < b : print(a, b)
    else : print(b, a)

### FIXED CODE ###

import sys
   
while True:
    (x, y) = [int(i) for i in sys.stdin.readline().split(' ')]
   
    if x == 0 and y == 0:
        break
   
    if x > y:
        z = x
        x = y
        y = z
   
    print(x, y)
n=int(input())
p=n%10
if(p==2||p==4||p==5||p==7||p==9):
  print("hon")
elif(p==3):
  print("pon")
else:
  print("bon")


### FIXED CODE ###

n=int(input())
p=n%10
if(p==2 or p==4 or p==5 or p==7 or p==9):
  print("hon")
elif(p==3):
  print("bon")
else:
  print("pon")
import sys
sys.setrecursionlimit(10**8)
h, w = [int(i) for i in sys.stdin.readline().split()]
s_ls = []
bl_ls = []
for i in range(h):
    s = [1 if i == "#" else -1 for i in sys.stdin.readline().strip()]
    for j, k in enumerate(s):
        if k == 1:
            bl_ls.append((i, j))
    s_ls.append(s)

def dfs(y, x, col):
    res = 0
    if col == -1:
        res += 1
    already.add((y, x))
    for move_y, move_x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        next_y = y + move_y
        next_x = x + move_x
        if 0 <= next_x < w and 0 <= next_y < h and s_ls[next_y][next_x] == (-1) * col and (next_y, next_x) not in already:
            res += dfs(next_y, next_x, (-1) * col)
    return res

ans = 0
for bl in bl_ls:
    already = set()
    ans += dfs(*bl, 1)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
h, w = [int(i) for i in sys.stdin.readline().split()]
s_ls = []
bl_ls = []
for i in range(h):
    s = [1 if i == "#" else -1 for i in sys.stdin.readline().strip()]
    for j, k in enumerate(s):
        if k == 1:
            bl_ls.append((i, j))
    s_ls.append(s)

memo_ls = dict()
def dfs(y, x, col):
    if (y, x) in memo_ls:
        return memo_ls[(y, x)]
    res = 0
    if col == -1:
        res += 1
    already.add((y, x))
    for move_y, move_x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        next_y = y + move_y
        next_x = x + move_x
        if 0 <= next_x < w and 0 <= next_y < h and s_ls[next_y][next_x] == (-1) * col and (next_y, next_x) not in already:
            res += dfs(next_y, next_x, (-1) * col)
    return res

ans = 0
for bl in bl_ls:
    already = set()
    stack = [(bl[0], bl[1], 1, 0)]
    cnt = 0
    while len(stack) > 0:
        y, x, col, _sum = stack.pop(-1)
        if (y, x) in memo_ls:
            cnt = memo_ls[(y, x)]
            break
        if col == -1:
            cnt += 1
        already.add((y, x))
        for move_y, move_x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            next_y = y + move_y
            next_x = x + move_x
            if 0 <= next_x < w and 0 <= next_y < h and s_ls[next_y][next_x] == (-1) * col and (
            next_y, next_x) not in already:
                stack.append((next_y, next_x, (-1) * col, _sum))
                already.add((next_y, next_x))
    res = cnt
    ans += res
    for al in list(already):
        memo_ls[al] = res
print(ans)
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return (f(n)%WARU) // ((f(r)*f(n-r))%WARU)


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1))%WARU)


### FIXED CODE ###

from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    if i <= N-K:
        print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)
    else:
        print(0)
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(1000000000)
#メモ化再帰
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1) % mod
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))

### FIXED CODE ###

n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child = child * (x-i)%mod
        mother = mother * (i+1)%mod
    return child * pow(mother,mod-2,mod) % mod
ans = pow(2,n,mod) - 1
ans -= comb(n,a)
ans %= mod
ans -= comb(n,b)
ans %= mod
print(ans)
import numpy as np
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
dp=[np.inf]*n
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
    for j in range(1,k+1):
        dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i])
print(dp[-1])

### FIXED CODE ###

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
dp=[10**9]*n
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i])
print(dp[-1])
import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
n=len(c.keys())
w=1
for i in c.keys():
  if c.values(i)>=N:
    k=math.ceil(c.values(i)/N)
    w=w*(i**k)
print(w)
    
    

### FIXED CODE ###

import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.floor(c[i]/N)
    w=w*(i**k)
  else:
    w=w
print(w)
import collections

n, m = map(int, input().split())
if m == 0:
    print(1)
    exit()
if m == 1:
    print(2)
    exit()
ids = {i: 0 for i in range(1, n+1)}
id = 1
for _ in range(m):
    a, b = map(int, input().split())
    if ids[a] == 0 and ids[b] != 0:
        ids[a] = ids[b]
    elif ids[a] != 0 and ids[b] == 0:
        ids[b] = ids[a]
    elif ids[a] == 0 and ids[b] == 0:
        ids[a] = id
        ids[b] = id
        id += 1
tmp = collections.Counter(ids.values())
tmp.pop(0)
print(max(tmp.values()))


### FIXED CODE ###

import collections

n, m = map(int, input().split())
if m == 0:
    print(1)
    exit()
if m == 1:
    print(2)
    exit()
boss = list(range(n))

def look_boss(target):
    num = target
    while num != boss[num]:
        num = boss[num]
    boss[target] = num
    return num

for _ in range(m):
    a, b = map(int, input().split())
    boss_a = look_boss(a-1)
    boss_b = look_boss(b-1)
    if boss_a != boss_b:
        boss[boss_b] = boss_a

count = [0]*n
for i in range(n):
    count[look_boss(i)] += 1
print(max(count))
import sys
from collections import deque
from heapq import heapify, heappop, heappush

def solve():
    inf = 100000000
    input = sys.stdin.readline
    
    V, E = map(int, input().split())
    edge = [[] for _ in range(V)]
    wf = dict()
    next_id = dict() #iからjに行くときにiの次に訪れる地点
    for i in range(V):
        wf[i] = dict()
        next_id[i] = dict()
        for j in range(V):
            next_id[i][j] = j
            wf[i][j] = (0 if i == j else inf)
    for _ in range(E):
        u, v, d = map(int, input().split())
        edge[u - 1].append((d, v - 1))
        edge[v - 1].append((d, u - 1))
        wf[u - 1][v - 1] = d
        wf[v - 1][u - 1] = d

    for k in range(V):
        for i in range(V):
            for j in range(V):
                if wf[i][j] > wf[i][k] + wf[k][j]:
                    wf[i][j] = wf[i][k] + wf[k][j]
                    next_id[i][j] = next_id[i][k] 

    T = int(input())
    order = set()
    stuck_order = set()

    command = [None] * T
    car_status = -2 #-2なら店、iならiへ向かって移動中
    heading = 0 #次に向かう地点
    dist_left = 0 #次に向かう地点までの残り距離
    final_dist = 0
    for t in range(T):
        N = int(input()) #注文の発生
        if N == 1:
            id, dst = map(int, input().split())
            if car_status == -2: order |= {dst - 1}
            else: stuck_order |= {dst - 1}
        
        if car_status == -2: #店にいるときの処理
            if order == {}: command[t] = -1
            else:
                for k in order:
                    final_dist = k
                    heading = next_id[0][k]
                    dist_left = edge[0][heading][0] - 1
                    car_status = heading
                    command[t] = heading
                    break
        
        else:
            if dist_left > 0:
                command[t] = heading
                dist_left -= 1
            else:
                if heading in order: order -= {heading} #荷物の積み下ろし

                if len(order) > 0: #まだ配達すべき荷物があるとき
                    for k in order:
                        current = heading
                        final_dist = k
                        heading = next_id[current][final_dist]
                        dist_left = edge[current][heading][0] - 1
                        car_status = heading
                        command[t] = heading
                        break
                
                else: #荷物が無いので店に戻る
                    final_dist = 0
                    current = heading
                    heading = next_id[current][final_dist]
                    dist_left = edge[current][heading][0] - 1
                    car_status = heading
                    command[t] = heading

    for t in command: print(t)

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

for i in range(10000): print(-1)
import itertools
import heapq
n,k = map(int,input().split())
a = list(map(int,input().split()))
if n>=2*k:
  a_plus = heapq.nlargest(k, a)
  a_minus = heapq.nsmallest(k, a)
  a_new = a_plus+a_minus
  comb = itertools.combinations(a_new,k)
else:
  comb = itertools.combinations(a,k)
  
l = []
for i in comb:
  l.append(list(i))
  
A = []
for i in range(len(l)):
  for j in range(k):
    A.append(1*=l[i][j])
    
l_max = max(one)
waru = 10**9 + 7
 
mod = l_max % waru
print(mod)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
# -*- coding: utf-8 -*-
s = input("")
t = input("")
s_list = list(s)
t_list = list(t)
n = 0

for i in range(3):
  if s_list.get(i) = t_list.get(i):
    n += 1
print(n)

### FIXED CODE ###

s = input("")
t = input("")
s_list = list(s)
t_list = list(t)
n = 0

for i in range(3):
    if s_list[i] == t_list[i]:
        n += 1

print(n)
N = int(input())
S = input()
S = list(S)
count = 0
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count = count+1
print(count)

### FIXED CODE ###

N = int(input())
S = input()
S = list(S)
count = 0
for i in range(N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count+=1
print(count)
h, w = [ int(v) for v in input().split() ]

for i in range(k):
  s = input()
  print(s)
  print(s)

### FIXED CODE ###

h, w = [ int(v) for v in input().split() ]

for i in range(h):
  s = input()
  print(s)
  print(s)
a,b = int(input().split())
 
x = (a+b)/2
 
if x == int(x):
  print(x)
 
else:
  x += 1
  print(int(x))


### FIXED CODE ###

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

x = (a+b)/2
 
if x == int(x):
  print(int(x))
 
else:
  x += 1
  print(int(x))