Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())

    if m - 2 * n >= 0:
        m -= 2 * n
        ans = n
        n = 0

        while True:
            if 2 * n >= m:
                ans += m // 2
                break
            else:
                n += 1
                m -= 2

    else:
        ans = m // 2

    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())

    if m - 2 * n >= 0:
        m -= 2 * n
        ans = n
        n = 0

        if (m - 2 * n) % 4 == 0:
            tmp = (m - 2 * n) // 4
        else:
            tmp = (m - 2 * n) // 4 + 1

        ans += (m - 2 * tmp) // 2

    else:
        ans = m // 2

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
abc = map(int, input().split())
abc.sort()
if abc[0] + abc[1] == abc[2]:
    print('Yes')
else:
    print('No')

Fixed submission:
abc = list(map(int, input().split()))
abc.sort()
if abc[0] + abc[1] == abc[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
	def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                    continue
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
lst = [sa,sb,sc]
count = [sa_count,sb_count,sc_count]
k = 0
abc = 'abc'
flag = False

for _ in range(len(sa)+len(sb)+len(sc)):
    for i in range(3):
        if lst[k][count[k]]==abc[i]:
            count[k] += 1
            count[i] += 1
            k = i
            if count[k]==len(lst[k])+1:
                flag = True
                break
    if flag:
        break

print(abc[k].upper())

Fixed submission:
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
tmp = 'a'

for _ in range(300):
    if tmp=='a':
        sa_count += 1
        if sa_count==len(sa)+1:
            print('A')
            break
        else:
            tmp = str(sa[sa_count-1])
    elif tmp=='b':
        sb_count += 1
        if sb_count==len(sb)+1:
            print('B')
            break
        else:
            tmp = str(sb[sb_count-1])
    elif tmp=='c':
        sc_count += 1
        if sc_count==len(sc)+1:
            print('C')
            break
        else:
            tmp = str(sc[sc_count-1])

Buggy python submission (verdict: Runtime Error):
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
lst = [sa,sb,sc]
count = [sa_count,sb_count,sc_count]
k = 0
abc = 'abc'
flag = False

for _ in range(len(sa)+len(sb)+len(sc)):
    for i in range(3):
        if lst[k][count[k]]==abc[i]:
            count[i] += 1
            if len(lst[k])==count[k]:
                flag = True
                break
            else:
                k = i
    if flag:
        break

print(abc[k].upper())

Fixed submission:
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
tmp = 'a'

for _ in range(300):
    if tmp=='a':
        sa_count += 1
        if sa_count==len(sa)+1:
            print('A')
            break
        else:
            tmp = str(sa[sa_count-1])
    elif tmp=='b':
        sb_count += 1
        if sb_count==len(sb)+1:
            print('B')
            break
        else:
            tmp = str(sb[sb_count-1])
    elif tmp=='c':
        sc_count += 1
        if sc_count==len(sc)+1:
            print('C')
            break
        else:
            tmp = str(sc[sc_count-1])
Buggy python submission (verdict: Runtime Error):
s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B' and len(lst)!=0:
        del lst[-1]
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append('{}'.format(j))

print(''.join(lst))

Fixed submission:
s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B':
        if len(lst)!=0:
            del lst[-1]
        else:
            continue
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append(str(j))

print(''.join(lst))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
st = set([])
for i in range(k):
  x,y = map(int,input().split())
  for z in range(x,y+1):
    st.add(z)
ans = [1]
for i in range(1,n):
  s = 0
  for x in st:
    if i >= x:
      s = s + ans[i-x]
  ans.append(s % 998244353)   
  
print(ans[-1])  
  
  
    
  

Fixed submission:
s = input()
if s[-1] == 's':
  print(s+'es')
else:
  print(s+'s')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
st = set([])
for i in range(k):
  x,y = map(int,input().split())
  for z in range(x,y+1):
    st.add(z)
ans = [1]
for i in range(1,n):
  s = 0
  for x in st:
    if i >= x:
      s = s + ans[i-x]
  ans.append(s % 998244353)   
  
print(ans[-1])  
  
  
    
  

Fixed submission:
n,k = map(int,input().split())
st = []
for i in range(k):
  x,y = map(int,input().split())
  st.append((x,y))
total = [1]

for i in range(1,n):
  s = 0
  for (x,y) in st:
    if i > y:
      s = (s + total[i-x] - total[i-y-1]) % 998244353
    elif i >= x:
      s = (s + total[i-x]) % 998244353
  total.append((s+total[-1]) % 998244353)   
  
print((total[-1]-total[-2]) % 998244353)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
st = set([])
for i in range(k):
  x,y = map(int,input().split())
  for z in range(x,y+1):
    st.add(z)
ans = [1]
for i in range(1,n):
  s = 0
  for x in st:
    if i >= x:
      s = s + ans[i-x]
  ans.append(s % 998244353)   
  
print(ans[-1])  
  
  
    
  

Fixed submission:
n,k = map(int,input().split())
st = []
for i in range(k):
  x,y = map(int,input().split())
  st.append((x,y))
total = [1]

for i in range(1,n):
  s = 0
  for (x,y) in st:
    if i > y:
      s = (s + total[i-x] - total[i-y-1]) % 998244353
    elif i >= x:
      s = (s + total[i-x]) % 998244353
  total.append((s+total[-1]) % 998244353)   
  
print((total[-1]-total[-2]) % 998244353)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
ans = [0]*(n+1) #ans[k]:入力値kでの答え
#初期値３、４、５
ans[3] = 1
ans[4] = 1
ans[5] = 1

if n == 1 or n == 2:
  print(0)
  sys.exit()
  
if 3<= n <=5:
  print(1)
  sys.exit()
for i in range(6,n+1):
  start = 3
  stop = i-3
  s = 1
  for j in range(start,stop+1):
    s = (s+ans[j]) % (10**9+7)
    
  ans[i] = s
  
print(ans[-1])  

Fixed submission:
n = int(input())
s = n // 3

def cmb2(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


total = 0
for i in range(s):
  y = n - 3*(i+1)
  x = cmb2(y+i,i,p)
  total = (total + x) % (10**9+7)
  
print(total)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0]*(n+1) #ans[k]:入力値kでの答え
#初期値３、４、５
ans[3] = 1
ans[4] = 1
ans[5] = 1

for i in range(6,n+1):
  start = 3
  stop = i-3
  s = 1
  for j in range(start,stop+1):
    s = (s+ans[j]) % (10**9+7)
    
  ans[i] = s
  
print(ans[-1])  

Fixed submission:
n = int(input())
s = n // 3

def cmb2(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


total = 0
for i in range(s):
  y = n - 3*(i+1)
  x = cmb2(y+i,i,p)
  total = (total + x) % (10**9+7)
  
print(total)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
lst = list(map(int,input().split()))

l = lst[0]
g = lst[0]
pair_coprime = True
set_coprime = False
for i in range(1,n):
  if set_coprime == False:
    g = math.gcd(g,lst[i])
    if g == 1:
      set_coprime = True
      
  if pair_coprime == True:
    g_l = math.gcd(l,lst[i])
    if g_l == 1:
      l = l*lst[i]//g_l
    else:
      pair_coprime = False
    
if set_coprime == False:
  print('not coprime')
  
elif pair_coprime == False:
  print('setwize coprime')
else:
  print('pairwize coprime')
  

Fixed submission:
d,t,s = map(int,input().split())
if d/s <= t:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int,input().split()))
s = 0
for i in range(n-1):
  for j in range(i+1,n):
    a = (lst[i]*lst[j])% (10**9+7)
    s += a
    
print(s%(10**9+7))    
    



Fixed submission:
import numpy as np
n = int(input())
lst = list(map(int,input().split()))
s = 0
t = 0
for x in lst:
  s += x
  t += (x ** 2) % (10**9+7)

w = (s**2-t) % (10**9+7)
if w % 2 == 0:
  print(w//2)
else:
  print((w+10**9+7)//2)
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int,input().split())
if x >= 0:
  min_p = x//d
  min_n = min_p + 1
  rest_p = x- d*min_p
  rest_n = rest_p - d
  if (k-min_p) % 2 == 0:
    print(rest_p)
  else:
    print(abs(rest_n))
    
if x <0:
  min_n = abs(x)//d
  min_p = min_p + 1
  rest_n = x + d*min_p
  rest_p = rest_p + d
  if (k-min_p) % 2 == 0:
    print(rest_p)
  else:
    print(abs(rest_n))
  

Fixed submission:
x,k,d = map(int,input().split())

min_p = abs(x)//d
min_n = min_p + 1
rest_p = abs(x)- d*min_p
rest_n = rest_p - d

if k < min_p:
  print(abs(x) - k*d)
elif (k-min_p) % 2 == 0:
  print(rest_p)
else:
  print(abs(rest_n))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k >= n-1:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
    
print(num)      
      
    

Fixed submission:
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k >= n-1:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if j +i == n:
        k = j
        break
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
      
print(num)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k == n:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
    
print(num)      
      
    

Fixed submission:
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k >= n-1:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if j +i == n:
        k = j
        break
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
      
print(num)
Buggy python submission (verdict: Runtime Error):
import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      start += 1

num = start
lst = [0]
M = 0

for i in range(len(a)):
  while a[i] > t:
    b_ = b.pop()
    t = t+b_
    num -= 1
  t -= a[i]
  num += 1
  
 
  if lst[-1] < num:
    M = num
  lst.append(num)    
    
print(M)    
  

Fixed submission:
import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b2 = []
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      b2.append(b[start])
      start += 1
num = start
lst = [start]
M = start

for i in range(len(a)):
  if a[i] > t and b2 == []:
    print(M)
    sys.exit()
  while a[i] > t and b2 != []:
    b_ = b2.pop()
    t = t+b_
    num -= 1
    
  if a[i] <= t:
    t -= a[i]
    num += 1
  
 
  if M < num:
    M = num
  lst.append(num)    
    
  
  
  
  
print(M)

Buggy python submission (verdict: Runtime Error):
import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      start += 1

num = start
lst = [0]
M = 0
print(start,t)
for i in range(len(a)):
  while a[i] > t:
    b_ = b.pop()
    t = t+b_
    num -= 1
  t -= a[i]
  num += 1
  print(num,t)
 
  if lst[-1] < num:
    M = num
  lst.append(num)    
    
print(M)    
  

Fixed submission:
import sys
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b2 = []
t = k
start = 0
while True:
  if start == len(b):
    break
  else:
    if t - b[start] < 0:
      break
    else:  
      t -= b[start]
      b2.append(b[start])
      start += 1
num = start
lst = [start]
M = start

for i in range(len(a)):
  if a[i] > t and b2 == []:
    print(M)
    sys.exit()
  while a[i] > t and b2 != []:
    b_ = b2.pop()
    t = t+b_
    num -= 1
    
  if a[i] <= t:
    t -= a[i]
    num += 1
  
 
  if M < num:
    M = num
  lst.append(num)    
    
  
  
  
  
print(M)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = 0
for i in range(1,n+1):
  a = n//i
  j = i * a
  s = (i+j)*a//2
  S += s
  
print(S)  
  

Fixed submission:
n = int(input())
S = 0
for i in range(1,n+1):
  a = n//i
  j = i * a
  s = (i+j)*a//2
  S += s
  
print(S)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = list(map(int,input().split()))

lst = sorted(lst)
bol = [True]*n
s=0
for i in range(n-1):
  if bol[i] == True:
    bol[i] = False
    if lst[i] != lst[i+1]:
      s += 1
    
    for j in range(i+1,n):
      if bol[j] == True and lst[j] % lst[i] == 0:
        bol[j] = False

if bol[n-1] == True:
  s += 1
  
print(s)  


Fixed submission:
lst = list(map(int,input().split()))

for x in lst:
  if x == 0:
    s = lst.index(x) + 1
    
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = list(map(int,input().split()))
s = 1
for i in range(N):
  s = s*lst[i]
if s>10**18:
  print(-1)
else:
  print(s)

Fixed submission:
N = int(input())
lst = list(map(int,input().split()))
if 0 in lst:
  s = 0
else:
  s = 1
  for x in lst:
    s = s*x
    if s > 10**18:
      s = -1
      break
print(s)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
L = list(map(int,input().split()))
X = [0]*(n+1)
X[0] = 1
for i in range(n):
  if L[X[i]-1] in X:
    X[i+1] = L[X[i]-1]  
    break
  X[i+1] = L[X[i]-1]
    
def f(lst,value):
  return [i for i,x in enumerate(lst) if x == value]
for x in X:
  if X.count(x) == 2:
    a = f(X,x)
    X_ans = X[a[0]:a[1]]
    break

if k <= a[0]:
  print(X[k])
else:
  b = (k - a[0] + 1) % (a[1]-a[0])
  print(X_ans[b-1])



Fixed submission:
S = input()
T = input()
if len(T) == len(S) + 1 and T[:len(S)] == S:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
L = list(map(int,input().split()))
X = [0]*(n+1)
X[0] = 1
for i in range(n):
  if L[X[i]-1] in X:
    X[i+1] = L[X[i]-1]  
    break
  X[i+1] = L[X[i]-1]
    
def f(lst,value):
  return [i for i,x in enumerate(lst) if x == value]
for x in X:
  if X.count(x) == 2:
    a = f(X,x)
    X_ans = X[a[0]:a[1]]
    break

if k <= a[0]:
  print(X[k])
else:
  b = (k - a[0] + 1) % (a[1]-a[0])
  print(X_ans[b-1])



Fixed submission:
n,k = map(int,input().split())
lst = list(map(int,input().split()))

loop = []
mark = ['t'] *n
i = 0
loop.append(1)
mark[0] = 0
while True:
  if mark[lst[i]-1] != 't':
    start = mark[lst[i]-1]
    last = mark[i]
    break
  else:
    mark[lst[i]-1] = mark[i] + 1
    loop.append(lst[i])
  i = lst[i]-1
  
  
loop_len = last - start +1
loop_num = loop[start:last+1]
first = start-1

if k <= first:
  print(loop[k])
else:
  q = (k-first) % loop_len
  print(loop_num[q-1])
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m,q = map(int,input().split())
score = {}
for i in range(1,10):
  for j in range(2,11):
    score[(i,j)] = [0 for k in range(10)]
    
for i in range(q):
  a,b,c,d = map(int,input().split())
  score[(a,b)][c] = d


total = []
dic = {}
for i in range(m):
  dic[(i,)] = score[(1,2)][i]
total.append(dic)

M = []
for i in range(2,n):
  Max = 0
  d = {}
  for k in range(m):
    for tup in total[-1].keys():
      s = total[-1][tup]
      if tup[-1] <= k:
        for j in range(1,i):
          s += score[(j+1,i+1)][k-tup[j-1]] 
        s += score[(1,i+1)][k]  
        ky = tup + (k,)
        d[ky] = s
        if s > Max:
          Max = s
  total.append(d)
  M.append(Max)

print(M[-1])
  
              
  
  
  

Fixed submission:
import sys

n,m,q = map(int,input().split())
score = {}
for i in range(1,10):
  for j in range(2,11):
    score[(i,j)] = [0 for k in range(10)]
    
for i in range(q):
  a,b,c,d = map(int,input().split())
  score[(a,b)][c] = d


total = []
dic = {}
for i in range(m):
  dic[(i,)] = score[(1,2)][i]
total.append(dic)

if n == 2:
  print(max(score[(1,2)]))
  sys.exit()

M = []
for i in range(2,n):
  Max = 0
  d = {}
  for k in range(m):
    for tup in total[-1].keys():
      s = total[-1][tup]
      if tup[-1] <= k:
        for j in range(1,i):
          s += score[(j+1,i+1)][k-tup[j-1]] 
        s += score[(1,i+1)][k]  
        ky = tup + (k,)
        d[ky] = s
        if s > Max:
          Max = s
  total.append(d)
  M.append(Max)

print(M[-1])
Buggy python submission (verdict: Runtime Error):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
print(s%10**9+7)

Fixed submission:
import math
a = input()
b = math.pi
print(2*int(a)*b)

Buggy python submission (verdict: Runtime Error):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
  print(s%10**9+7)

Fixed submission:
import math
a = input()
b = math.pi
print(2*int(a)*b)

Buggy python submission (verdict: Runtime Error):
N = int(input())

List1 = [int(a) for a in input().split(" ")]
List2 = [0]*N

for x in List1:
  List2[x-1] = List2[x-1] + 1
  
for y in List2:
  print(y)

Fixed submission:
import math
a = input()
b = math.pi
print(2*int(a)*b)

Buggy python submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split(" "))
List= [int(y) for y in input().split(" ")]

if sum(List)>N:
  print(-1)
else:
  print(N -sum(List))

Fixed submission:
import math
a = input()
b = math.pi
print(2*int(a)*b)
Buggy python submission (verdict: Time Limit Exceeded):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
print(s%(10**9+7))

Fixed submission:
n,k = map(int,input().split())

a = (n-k+2)*(((k+n+1)*(n+1))+2)//2
b = (((n+1)*(n+2)))*(2*n+3)//6
c = (((k-1)*k))*(2*k-1)//6

print((a-b+c)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
lst = list(map(int,input().split()))
s = 0
total = sum(lst)
for i in range(n):
  if lst[i] >= total/(4*m):
    s += 1
    
if s >= m:
  print('Yes')
else:
  print('No')
        



Fixed submission:
import sys
k = int(input())
lst = [[0]*10 for i in range(10)]
for i in range(10):
  lst[0][i] = 1
l_sum = [9]  


for i in range(1,10):
  s = 0
  for j in range(10):
    if j == 0:
      lst[i][j] = lst[i-1][j] + lst[i-1][j+1]
    elif j == 9:
      lst[i][j] = lst[i-1][j] + lst[i-1][j-1] 
    else:
      lst[i][j] = lst[i-1][j-1] + lst[i-1][j] + lst[i-1][j+1] 
      
    if j !=0:
      s += lst[i][j]
  l_sum.append(s+l_sum[-1])
    

#表を逆から辿っていく、さらに手直し
i = 0
if k < l_sum[0]:
  print(k)
  sys.exit()
else:
  while True:
    if k < l_sum[i]:
      break
    i += 1
  k = k - l_sum[i-1]
   
  ans = []
  for j in reversed(range(0, i+1)):
    
    if j == i:
      p = 1
      while True:
        if k - lst[j][p] <= 0:
          ans.append(p)
          break
        else:
          k -= lst[j][p]
          p += 1
          
    else:
      if p == 0:
        if k <= lst[j][p]:
          ans.append(p)
        else:
          k -= lst[j][p]
          p += 1
          ans.append(p)
          
      elif p == 9:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          ans.append(p)
          
      else:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          if k <= lst[j][p]:
            ans.append(p)
          else:
            k -= lst[j][p]
            p = p+1
            ans.append(p)
              
l_s = [str(q) for q in ans]
print(''.join(l_s))