Harryxun/stf_run huggingface dataset:
# コンテスト中の考えは悪くなかったがN本に固執して貪欲的に考えていた。
# 敗因は動的計画法が思い浮かばず書けなかったこと。
# 提出4298627を参考にした


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

A.sort(reverse=True)  # 大きい方から探索したいため

# 各数字を作るのに必要なマッチの本数
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# dpをするための配列を用意
# pd[i]としたときに、i本のマッチで実現できる最大桁数を格納するものとする
# shapeは(N+1,) ∵ i=0~N本のときも考える
dp = [-1 * float("inf")] * (N + 1)

# 各数字を一つずつ使う場合は1桁だとわかりきっているので、初期化ができる
dp[0] = 0
for a in A:
    if num[a] <= N:  # ここは念のための処理、指定されたNがマッチで使う数字より少ないかもしれない。
        dp[num[a]] = 1

# dpのmain
for i in range(1, N + 1):  # dpに格納されているすべての要素をなめていく。
    for a in A:  # i本使うときの最大桁数を決定するためにはaを全探索して下式を最大となるものが取得できればよい
        if i - num[a] >= 0:  # 念の為の条件
            # この式については解説を参照のこと
            dp[i] = max(dp[i], dp[i - num[a]] + 1)

# 探索が終わったので答えを出す。
# 大きい桁にはなるべく大きな数字を割り振る
ans = ""
for i in range(dp[N]):  # dpによって得た桁数について上位桁から決定していく
    for a in A:  # すでに大きい順にソートしたので決定次第break
        if dp[N - num[a]] == dp[N] - 1:  # この条件についても解説を参照のこと
            ans += str(a)
            N -= num[a]  # マッチの本数から引くのを忘れずにね
            break

print(ans)


### FIXED CODE ###

# コンテスト中の考えは悪くなかったがN本に固執して貪欲的に考えていた。
# 敗因は動的計画法が思い浮かばず書けなかったこと。
# 提出4298627を参考にした


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

A.sort(reverse=True)  # 大きい方から探索したいため

# 各数字を作るのに必要なマッチの本数
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# dpをするための配列を用意
# pd[i]としたときに、i本のマッチで実現できる最大桁数を格納するものとする
# shapeは(N+1,) ∵ i=0~N本のときも考える
dp = [-1 * float("inf")] * (N + 1)

# 各数字を一つずつ使う場合は1桁だとわかりきっているので、初期化ができる
dp[0] = 0
for a in A:
    if num[a] <= N:  # ここは念のための処理、指定されたNがマッチで使う数字より少ないかもしれない。
        dp[num[a]] = 1

# dpのmain
for i in range(1, N + 1):  # dpに格納されているすべての要素をなめていく。
    for a in A:  # i本使うときの最大桁数を決定するためにはaを全探索して下式を最大となるものが取得できればよい
        if i - num[a] >= 0:  # 念の為の条件
            # この式については解説を参照のこと
            dp[i] = max(dp[i], dp[i - num[a]] + 1)

# 探索が終わったので答えを出す。
# 大きい桁にはなるべく大きな数字を割り振る
ans = ""
for i in range(dp[N]):  # dpによって得た桁数について上位桁から決定していく
    for a in A:  # すでに大きい順にソートしたので決定次第break
        # 1つ目の条件は探索中に配列外アクセスをするのを防ぐため。2つ目の条件についても解説を参照のこと
        if N - num[a] > -1 and dp[N - num[a]] == dp[N] - 1:
            ans += str(a)
            N -= num[a]  # マッチの本数から引くのを忘れずにね
            break

print(ans)
K = int(input())
L,r = K*9 if K%7 else K*9/7, 10
for i in range(1,L+1):
	r %= L
	if r == 1:
		print(i)
		exit()
	r *= 10
print(-1)

### FIXED CODE ###

K = int(input())
L,r = K*9 if K%7 else K*9//7, 10
for i in range(1,L+1):
	r %= L
	if r == 1:
		print(i)
		exit()
	r *= 10
print(-1)
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(n):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
A = [0]*n
ans = 0
def dfs(h):
    global ans
    if h == n-1:
        cnt = 0
        for i in range(q):
            if A[b[i]] - A[a[i]] == c[i]:
                cnt += d[i]
        ans = max(ans,cnt)
    else:
        for i in range(A[h],m+1):
            A[h+1] = i
            dfs(h+1)
    return

for i in range(1,m+1):
    A[0] = i
    dfs(0)
print(ans)


### FIXED CODE ###

import itertools
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans,tmp)
print(ans)
N = int(input())
A = list(map(int, input().split()))
B = [0] * 200000
ans = 0
for i in range(N):
	if A[i] < 200000:
		B[A[i]] += 1
	else:
		ans += 1
for i in range(200000):
  	if B[i] >= i:
	    ans += B[i] - i
	else:
    	ans += B[i]
print(ans)
	


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0] * 100001
ans = 0
for i in range(N):
	if A[i] <= 100000:
		B[A[i]] += 1
	else:
		ans += 1
for i in range(100001):
	if B[i] < i:
		ans += B[i]
	else:
		ans += B[i] - i
print(ans)
A = input("Please input 1st number: ")
B = input("Please input 2nd number: ")

if A <= 1 and A >= 100:
  if B <= 1 and B >= 100:
    C = A * B
    print("We have" + str(A) + " x " + str(B) + " = " + str(C) + ".")
  else:
    print("Please check Number B side (1 <= 100)")
else:
  print("Please check Number A side (1 <= 100)")

print("check end.")

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(c))

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ave1 = sum(A)//n
ave2 = ave1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-ave1)**2
    ans2 += (a-ave2)**2
print(min(ans1,ans2))
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N.
tmp = []
for i in range(N):.
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))

### FIXED CODE ###

N = int(input())
L = [input() for i in range(3)]
ans = [0] * N
tmp = []
for i in range(N):
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))
N = input()
num = input().split()

count = 0
while(True):
	div = []
	for i in num:
		if(i % 2 == 0):
			div.append(i/2)
    	else:
			print(count)
			break
	num = div
	count = count + 1



### FIXED CODE ###

n = input()
num = [int(i) for i in input().split()]
count = 0
end=False
while(True):
	div = []
	for i in num:
		if(i % 2 == 0):
			div.append(i/2)
		else:
			print(count)
			end = True
			break
	if(end == True):
		break
	num = div
	count = count + 1
import math

r = int(input())
print('{0} {1}'.format(math.pi*r**2,2*math.pi*r))

### FIXED CODE ###

import math

r = float(input())
print('{0} {1}'.format(math.pi*r**2,2*math.pi*r))
N=int(input())
S=input()
K=int(input())
ans=''
for i in range(N):
    if s[i]!=S[K-1]:
        ans+='*'
    else:
        ans+=S[i]
print(ans)


### FIXED CODE ###

N=int(input())
S=input()
K=int(input())
ans=''
for i in range(N):
    if S[i] != S[K-1]:
        ans += '*'
    else:
        ans += S[i]
print(ans)
import bisect

N,Q = map(int,(input().split()))
S = list(input())

l = []
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        l.append(i+1.5)
s = 0
for i in range(Q):
    a,b = map(int,(input().split()))
    print(bisect.bisect_left(l,b) - bisect.bisect_left(l,a))

### FIXED CODE ###

import bisect

N,Q = map(int,(input().split()))
S = list(input())

l = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        l.append(i+1.5)

for i in range(Q):
    a,b = map(int,(input().split()))
    print(bisect.bisect_left(l,b) - bisect.bisect_left(l,a))
d=int(input())
t=int(input())
s=int(input())

    
    if s*t >= d:
        print ('Yes')
    
    else:
        print ('No')

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.read()
    data = list(map(int, input.split()))

    a, b, c = data

    if b*c >= a:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()
n = input()
print(n.replace('1', '_').replace('9', '1').replace('_', '9')

### FIXED CODE ###

n = input()
print(n.replace('1', '_').replace('9', '1').replace('_', '9'))
A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
s.sort()
t = []
t.sort()
for i in range(B):
    t.append(int(input()))
x = []
for i in range(Q):
    x.append(int(input()))

for i in range(Q):
    sx, tx, sy, ty = [], [], [], []
    for j in range(A):
        sx.append(abs(s[j] - x[i]))
    for j in range(B):
        tx.append(abs(t[j] - x[i]))
    sxi = sx.index(min(sx))
    txi = tx.index(min(tx))
    for j in range(B):
        ty.append(abs(t[j] - s[sxi]))
    for j in range(A):
        sy.append(abs(s[j] - t[sxi]))
    a = min(sx) + min(ty)
    b = min(tx) + min(sy)
    if a < b:
        print(a)
    else:
        print(b)


### FIXED CODE ###

import bisect

A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF]
for i in range(A):
    S.append(int(input()))
S.append(INF)
T = [-INF]
for i in range(B):
    T.append(int(input()))
T.append(INF)
X = []
for i in range(Q):
    X.append(int(input()))

for x in X:
    a, b = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
    print(min(abs(s-t) + min(abs(s-x), abs(t-x))
              for s in S[a-1:a+1] for t in T[b-1:b+1]))
N = input(int())
ans = 1

list = [i for i in input().split()]

for a in range(N-1):
  ans = ans * i[a]

  if ans > 10**18:
    ans = -1

print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in a:
    print("0")
    exit()

for i in a:
    ans *= i

    if ans > 10**18:
        print("-1")
        exit()
        
print(ans)
#agc008-a
x,y=map(int,input().split())

if x<0:
    if y<0:
        ans=2+abs(y)-abs(x)
    else:
        if y<-x:
            ans=y-x
        else:
            ans=1+y+x
else:
    if y>x:
        ans=y-x
    elif y<0:
        ans=-y-x+1
print(ans)

### FIXED CODE ###

#agc008-a
x,y=map(int,input().split())
ans=float('inf')

#反転させるかどうか決めた後のx,yの上下関係を考える
#0,0
if y-x>0:
    ans=min(ans,y-x)
#1,0
if -x<=y:
    ans=min(ans,1+y+x)
#0,1
if x<=-y:
    ans=min(ans,1+-y-x)
#1,1
if -x<=-y:
    ans=min(ans,2+-y+x)
print(ans)
n, k = map(int, input().split())
num = [0] * 100000
for i in range(n):
  a, b = map(int, input().split())
  num[a - 1] += b
for i in range(100000 - 1):
  if num[i] > 0:
    k -= num[i]
    if k <= 0:
      ans = i + 1
      break
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
num = [0] * 100000
for i in range(n):
  a, b = map(int, input().split())
  num[a - 1] += b
for i in range(100000):
  if num[i] > 0:
    k -= num[i]
    if k <= 0:
      ans = i + 1
      break
print(ans)
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if input() == "AC":
        ac += 1
    elif input() == "WA":
        wa += 1
    elif input() == "TLE":
        tle += 1
    elif input() == "RE":
        re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

### FIXED CODE ###

n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s== "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)
a, b = map(int, input().split())
if b % a == 0:
  print(a + b)
else
  print(b - a) 



### FIXED CODE ###

a, b = map(int, input().split())
if b % a == 0:
  print(a + b)
else:
  print(b - a)
n = int(input())
print(sum(for i in range(1:n)))

### FIXED CODE ###

n = int(input())
s = 0
for i in range(1,n):
	s = s+i
print(s+n)
a = [list(map(int,input().split())) for i in range(3)] #ビンゴ表
n = int(input()) #回数
b = [int(input()) for i in range(n)] #出た数字

for number in b: #出た目を順番に確認
    for i in range(3):
        if number in a[i]: #numberがビンゴ表にあるかチェック
            a[i][a[i].index(number)] = 0 #i行のnumberに該当する要素を0に書き変え

if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')　#斜めのビンゴをチェック
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes') #行のビンゴをチェック
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes') #列のビンゴをチェック
            break
        else:
            print('No')


### FIXED CODE ###

a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')
n, k = map(int, input().split())
X = list(map(int, input().split()))

count_0 = X.count(0)

if k <= count_0:
    print(0)
    exit()

k -= count_0

neg = [x for x in X if x < 0]
pos = [x for x in X if x > 0]

neg_count = len(neg)
pos_count = len(pos)

if not neg:
    print(pos[k-1])
    exit()
if not pos:
  	print(neg[-k])
    exit()

res = []
for left in range(1, min(neg_count, k)):
    time1 = neg[-left]
    right = k - left - 1
    if right >= pos_count:
        continue
    elif right < 0:
        res.append(abs(time1))
    else:
        time2 = pos[right]
        res.append(time2-time1*2)

for right in range(min(pos_count, k)):
    time1 = pos[right]
    left = k - right - 1
    if left >= neg_count:
        continue
    elif left <= 0:
        res.append(abs(time1))
    else:
        time2 = neg[-left]
        res.append(time1*2-time2)


print(min(res))

### FIXED CODE ###

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

ans = []
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    if left * right < 0:
        result = min(abs(left), abs(right)) * 2 + max(abs(left), abs(right))
    else:
        result = max(abs(left), abs(right))
    ans.append(result)

print(min(ans))
_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = [[int(p) for p in i.split()] for i in _input[1:n]]

import collections

colored  = {}
edge_map = collections.defaultdict(list)
for e in edge:
    edge_map[e[0]].append(e[1])
    edge_map[e[1]].append(e[0])

root = edge[0][0]
colored[root] = k
for i, p in enumerate(edge_map[root]):
    colored[p] = k - (i + 1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = tuple([tuple([int(p) for p in i.split()]) for i in _input[1:n]])

factorial = [0] * (k + 1)
inverse = [0] * (k + 1)
MOD = 1000000007

# Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/175024
def mod_pow1(n, k, mod):
    a = 1
    while k:
        if (k & 1) == 1:
            a = (a * n) % mod
        n = (n * n) % mod
        k >>= 1
    return a

# Ref: https://www.smartbowwow.com/2018/10/mod1097.html
def mod_pow2(n, k, mod):
    if k == 0:
        return 1
    if k % 2 == 0:
        a = mod_pow2(n, k // 2, mod)
        return (a * a) % mod
    else:
        return (n * mod_pow2(n, k - 1, mod)) % mod

#mod_pow = mod_pow1
# It's better to use built-in function for speed.
mod_pow = pow

def mod_factorial_inverse(k, mod):
    factorial[0] = 1
    inverse[0] = 1

    # Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
    for i in range(1, k + 1):
        factorial[i] = ((i * factorial[i - 1]) % mod) # factrial[i]
        inverse[i] = mod_pow(factorial[i], mod - 2, mod) # inverse[i]
 
total = 1

if not edge:
    print(k)
else:
    all_edge = tuple([[] for _ in range(n + 1)])
    for e in edge:
        all_edge[e[0]].append(e[1])
        all_edge[e[1]].append(e[0])
    all_edge = [set(v) for v in all_edge]

    if [v for v in all_edge if len(v) >= k]:
        print(0)
    else:
        mod_factorial_inverse(k, MOD)

        root = edge[0]
        total = (factorial[k] * inverse[k - len(all_edge[root[0]]) - 1]) % MOD

        def dfs(current, from_):
            global total
            child = all_edge[current]
            if len(child) - 1 > 0:
                total = (total * factorial[k - 2] * inverse[k - 2 - (len(child) - 1)]) % MOD
            for c in child:
                if c != from_:
                    dfs(c, current)
        for c in all_edge[root[0]]:
            dfs(c, root[0])
        print(total)
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c_=c*A_//fractions.gcd(c,A_)
    a=(a*c_/c+c_//A_)%w
    c=c_
print(int(a))

### FIXED CODE ###

import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c=c*A_//fractions.gcd(c,A_)
for A_ in A:
    a+=c//A_
print(int(a%w))
n = int(input())

if n % 2 = 0:
  a = n / 2
  print(a)
  
else:
  b = n / 2 + 1
  print(b)
  

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
  a = n / 2
  print(int(a))
  
else:
  b = n / 2 + 1
  print(int(b))
n = int(input())
h = list(map(int, input().split()))

count
max_count = 0
for i in range(n-1):
  if h[i]>=h[i+1]:
    count += 1
  else: count = 0
  
  if count > max_count: max_count = count
print(max_count)

### FIXED CODE ###

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

count = 0
max_count = 0
for i in range(n-1):
  if h[i]>=h[i+1]:
    count += 1
  else: count = 0
  
  if count > max_count: max_count = count
print(max_count)
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
d, n = map(int, input().split())

if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)

### FIXED CODE ###

d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
N = int(input())
5
A = list(map(int,input().split()))
0 0 0 0 0

for i in range(N-1,0,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if s == 0:
        print('')
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1


### FIXED CODE ###

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

for i in range(N-1,-1,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1
# N, K = 9, 5
# X = [int(i) for i in '-9 -7 -4 -3 0 1 2 3 4'.split()]
N, K = map(int, input().split())
X = [int(i) for i in input().split()]
X_plus = []
X_minus = []
for i in range(N):
    if X[i] < 0:
        X_minus.append(X[i])
    else:
        X_plus.append(X[i])
# print(X_plus)
# print(X_minus)
res = []
len_plus = len(X_plus)
len_minus = len(X_minus)
if len_minus != 0:
    for i_plus in range(len_plus):
        if K-i_plus-1 <= len_minus:
            res.append(X_plus[i_plus]*2 - X_minus[-(K-i_plus-1)])
if len_plus >= K:
    res.append(X_plus[K-1])

if len_plus != 0:
    for i_minus in range(len_minus):
        if K-i_minus <= len_plus:
            res.append(abs(-X_minus[-i_minus-1])*2 + X_plus[K-i_minus-2])
if len_minus >= K:
    if len_plus > 0:
        if X_plus[0]==0
            res.append(-X_minus[-K+1])
    else:
        res.append(-X_minus[-K])
print(min(res))

### FIXED CODE ###

# N, K = 3, 2
# X = [int(i) for i in '10 20 30'.split()]
N, K = map(int, input().split())
X = [int(i) for i in input().split()]
X_plus = []
X_minus = []
for i in range(N):
    if X[i] < 0:
        X_minus.append(X[i])
    else:
        X_plus.append(X[i])
# print(X_plus)
# print(X_minus)

res = []
len_plus = len(X_plus)
len_minus = len(X_minus)
if len_minus != 0:
    for i_plus in range(len_plus):
        if K-i_plus-1 <= len_minus:
            res.append(X_plus[i_plus]*2 - X_minus[-(K-i_plus-1)])
if len_plus >= K:
    res.append(X_plus[K-1])
# print(res)

if len_plus != 0:
    for i_minus in range(len_minus):
        if K-i_minus-1 <= len_plus:
            res.append(abs(-X_minus[-i_minus-1])*2 + X_plus[K-i_minus-2])

if len_minus >= K:
    if len_plus > 0:
        if X_plus[0]==0:
            res.append(-X_minus[-K+1])
    else:
        res.append(-X_minus[-K])
# print(res)
print(min(res))
list = list(map(int(input())))
print(list)

### FIXED CODE ###

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

if list.count(5) == 2 and list.count(7) == 1:
  print('YES')
else:
  print('NO')
n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))

def check(i, m):
    if m == 0:
        return 1
    elif i >= n:
        return 0
    res = check(i+1, m) + check(i+1, m - seq[i])
    return res

for m in mlist:
    if(check(0,m) > 0):
        print('yes')
    else:
        print('no')


### FIXED CODE ###

n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
mins = min(seq)
sums = 0
for a in seq:
    sums += a

def check(i, m):
    global mins
    if m == 0:
        return True
    elif i >= n or mins > m:
        return False
    res = check(i+1, m) or check(i+1, m - seq[i])
    return res

for m in mlist:
    if (mins > m or sums < m):
        print('no')
    elif(check(0,m)):
        print('yes')
    else:
        print('no')
N=int(input())
if N%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)

### FIXED CODE ###

N=input()
if int(N)%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
    print(ans)
import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    
    ans = []
    for i in range(H):
        for j in range(W-1):
            if i%2 == 0:
                ans.append((i+1,j+1,i+1,j+2))
                last = W
            else:
                ans.append((i+1,W-j,i+1,W-j-1))
                last = 1
        if i != H-1:
            ans.append((i+1,last,i+2,last))
    
    print(len(ans))
    for x in ans:
        print(*x)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    
    ans = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j]%2 != 0:
                a[i][j+1] += 1
                ans.append((i+1,j+1,i+1,j+2))
                
    for i in range(H-1):
        if a[i][-1]%2 != 0:
            a[i+1][-1] += 1
            ans.append((i+1,W,i+2,W))
            
    print(len(ans))
    for x in ans:
        print(*x)

if __name__ == "__main__":
    main()
k,m = map(int, input().split())
a = list(map(int, input().split()))

# リストaの総投票数をsに格納する
s = sum(a)

# リストaを降順にソートする
a.sort(reverse=True)

if a[m] >= s*(1/4/m):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

s = sum(a)
a.sort()

if all(a[-i-1] >= s/4/m for i in range(m)):
    print('Yes')
else:
    print('No')