Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
list=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
list=[0]*11
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
list=[0]*10**5+1
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for i in range(1,n+1):
    sum+=list[i]
    if sum>=k:
        print(i)
        exit()
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print(a[0].apper()+b[0].upper()+c[0].upper())
Problem p03738 (python)

Fixed submission:
a=int(input())
b=int(input())
if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")
Problem p03773 (python)

Fixed submission:
a,b=map(int,input().split())
if a+b>=24:
    print(a+b-24)
else:
    print(a+b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a+b>=24:
    print(a+b-24):
else:
    print(a+b)
Problem p03814 (python)

Fixed submission:
s=input()
a=0
z=0
i=0
j=len(s)-1
while a==0 :
    if s[i]=="A":
        a=1
    else:
        i+=1
while z==0:
    if s[j]=="Z":
        z=1
    else:
        j-=1
print(j-i+1)

Buggy submission (verdict: Runtime Error):
s=input()
a=0
z=0
i=0
j=len(s)-1
while a==0:
    if s[i]=="a":
        a=1
    else:
        i+=1
while z==0:
    if s[j]=="z":
        z=1
    else:
        j-=1
print(j-i+1)

Buggy submission (verdict: Runtime Error):
s=input()
a=0
z=0
i=0
j=0
while a==0:
    if s[i]=="a":
        a=1
    else:
        i+=1
while z==0:
    if s[len(s)-1-j]=="z":
        z=1
    else:
        j+=1
print(j-i+1)
Problem p03844 (python)

Fixed submission:
a,b,c=input().split()
if b=="+":
    print(int(a)+int(c))
else:
    print(int(a)-int(c))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
if b=="+":
print(int(a)+int(c))
else:
print(int(a)-int(c))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print(int(a)+b+int(c))
Problem p03845 (python)

Fixed submission:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    s=0
    for j in range(len(t)):
        if j==p-1:
            s+=x
        else:
            s+=t[j]
    print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input.split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    s=0
    for j in range(len(t)):
        if j==p-1:
            s+=x
        else:
            s+=t[j]
    print(s)
Problem p03846 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b):
        if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
            print(0)
            exit()
        i+=2
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if len(b)>1:
        if b[1]==0:
            print(0)
            exit()
    if b[0]!=0:
        print(0)
        exit()
    else:
        i=1
        while i<len(b):
            if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
                print(0)
                exit()
            i+=2
        print(2**(len(b)//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b):
        if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
            print(0)
            exit()
        i+=2
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if len(b)>1:
        if b[1]==0:
            print(0)
            exit()
    if b[0]!=0:
        print(0)
        exit()
    else:
        i=1
        while i<len(b):
            if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
                print(0)
                exit()
            i+=2
        print(2**(len(b)//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b)-2:
        if b[i]!=b[i+1] or b[i+2]!=b[i]+2:
            print(0)
            exit()
        i+=2
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if b[0]!=0 or b[1]==0:
        print(0)
        exit()
    else:
        i=1
        while i<len(b)-2:
            if b[i]!=b[i+1] or b[i+2]!=b[i]+2:
                print(0)
                exit()
            i+=2
        print(2**(len(b)//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b)-2:
        if b[i]!=b[i+1] or b[i+2]!=b[i]+2:
            print(0)
            exit()
        i+=2
    if b[-1]!=b[-2]:
        print(0)
        exit()
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if b[0]!=0:
        print(0)
        exit()
    else:
        i=1
        while i<len(b)-2:
            if b[i]!=b[i+1] or b[i+2]!=b[i]+2:
                print(0)
                exit()
            i+=2
        if b[-1]!=b[-2]:
            print(0)
            exit()
        print(2**(len(b)//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b):
        if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
            print(0)
            exit()
        i+=2
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if b[0]!=0:
        print(0)
        exit()
    else:
        i=1
        while i<len(b):
            if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
                print(0)
                exit()
            i+=2
        print(2**(len(b)//2)%(10**9+7))
Problem p03964 (python)

Fixed submission:
n=int(input())
x=1
y=1
for i in range(n):
    t,a=map(int,input().split())
    c=max(-(-x//t),-(-y//a))
    x=t*c
    y=a*c      
print(int(x+y))

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
    if i==0:
        x,y=map(int,input().split())
    else:
        t,a=map(int,input().split())
        if t==1 and a==1:
            x=max(x,y)
            y=max(x,y)
        else:
            t=t*max(int(x/t),int(y/a))
            a=a*max(int(x/t),int(y/a))
            x=t
            y=a
print(x+y)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
    if i==1:
        x,y=map(int,input().split())
    else:
        t,a=map(int,input().split())
        v=t
        w=a
        while t<x or a<y:
            v+=t
            w+=a
        x=v
        y=w
print(x+y)
Problem p03998 (python)

Fixed submission:
s1=input()
s2=input()
s3=input()
x=s1[0]
s1=s1[1:]
while (len(s1)!=0 or x!="a") and (len(s2)!=0 or x!="b") and (len(s3)!=0 or x!="c") :
    if x=="a":
        x=s1[0]
        s1=s1[1:]
 
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
  
    else:
        x=s3[0]
        s3=s3[1:]
    
if len(s1)==0 and x=="a":
    print("A")
elif len(s2)==0 and x=="b":
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()
s3=input()
x=s1[0]
s1.lstrip(x)
y=1
while y>0:
    if x=="a":
        x=s1[0]
        s1=s1[1:]
        if x=="a" and len(s1)==0:
            print("A")
            y=0
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
        if x=="b" and len(s2)==0:
            print("B")
            y=0
    else:
        x=s3[0]
        s3=s3[1:]
        if x=="c" and len(s3)==0:
            print("C")
            y=0

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()
s3=input()
x=s1[0]
s1.lstrip(x)
y=1
while y>0:
    if x=="a":
        x=s1[0]
        s1=s1[1:]
        if x=="a" and len(s1)==0:
            print("A")
            exit()
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
        if x=="b" and len(s2)==0:
            print("B")
            exit()
    else:
        x=s3[0]
        s3=s3[1:]
        if x=="c" and len(s3)==0:
            print("C")
            exit()
Problem p04012 (python)

Fixed submission:
s=input()
p=list(set(list(s)))
a=[]
for i in p:
    a.append(s.count(i))
for x in a:
    if x%2!=0:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
p=list(set(list(s)))
a=[]
for i in p:
    a.append(s.count(i))
for x in a:
    if x%2!==0:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
p=list(set(list(s)))
a=[]
for i in p
    a.append(s.count(i))
for x in a:
    if x%2!==0:
        print("No")
        exit()
print("Yes")
Problem p04030 (python)

Fixed submission:
c=list(input())
s=""
for x in c:
    if x!="B":
        s+=x
    else:
        s=s[:-1]
print(s)

Buggy submission (verdict: Runtime Error):
c=list(input())
s=""
for x in c:
    if x!=B:
        s+=x
    else:
        s=s[:-1]
print(s)

Buggy submission (verdict: Runtime Error):
c=list(input())
s=""
for i in c:
    if i=="B" and len(s)==0:
        pass
    elif i=="B":
        del(s[-1])
    elif i=="0":
        s+="0"
    else:
        s+="1"
print(s)
Problem p02787 (python)

Fixed submission:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
 
import itertools
 
#import bisect
 
import copy
 
 
def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
 
def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta
 
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
 
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
 
 
 
def main():
    h,n=map(int,input().split()) #n yen, m types
    a=[]
    b=[]
    for i in range(n):
        x,y=map(int,input().split())
        a.append(x)
        b.append(y)
 
    dp=[INFI for i in range(h+1)]
    dp[0]=0
    for i in range(n):
        for j in range(len(dp)):
            if j-a[i]<0:
                dp[j] = min(dp[j], dp[0] + b[i])
            else:
                dp[j]=min(dp[j],dp[j-a[i]]+b[i])
 
    print(dp[h])
 
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    h,n=map(int,input().split()) #n yen, m types
    ab=[list(map(int,input().split())) for i in range(n)]

    def f(h):
        if h <=0:
            return 0
        temp=INFI
        for a,b in ab:
            temp2=b+f(h-a)
            if temp2<temp:
                temp=temp2
            else:
                break
        return temp

    print(f(h))


if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=4
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    a = fractions.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a) and a!=1:
        sosu.add(a)
#    print(sosu)
    count+=len(sosu)
    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#import sys

#input = sys.stdin.readline

#import heapq
import math

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1
    c=math.sqrt(max(a,b))
    count=1
    sosu=[2,3]
    for i in range(len(sosu)):
        if a%sosu[i]==0 and b%sosu[i]==0:
            count+=1
            a//=sosu[i]
            b//=sosu[i]
        elif a%sosu[i]==0:
            a//=sosu[i]
        elif b%sosu[i]==0:
            b//=sosu[i]


    c = math.sqrt(max(a, b))
    while m < c:
        m = 6 * k +1
        if a % m == 0 and b % m == 0:
            count += 1
            while true:
                a//=m
                b//=m
                if a%m==0 and b%m==0:
                    continue
                else:
                    break
            c=math.sqrt(max(a,b))
        elif a%m==0:
            a//=m
            c=math.sqrt(max(a,b))
        elif b%m==0:
            b//=m
            c=math.sqrt(max(a,b))
 #           print(count)
        k += 1

    k = 1
    m = 2
    while m < c:
        m = 6 * k -1
        if a % m == 0 and b % m == 0:
            count += 1
            while true:
                a //= m
                b //= m
                if a % m == 0 and b % m == 0:
                    continue
                else:
                    break
            c=math.sqrt(max(a,b))
        elif a%m==0:
            a//=m
            c=math.sqrt(max(a,b))
        elif b%m==0:
            b//=m
            c=math.sqrt(max(a,b))
        k += 1

    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()
Problem p02928 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
rcount=0
lcount=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      rcount+=1

for i in range(n-1):
  for j in range(i+1,n):
    if a[i]<a[j]:
      lcount+=1

mod=10**9+7

print((k*(k+1)*rcount+k*(k-1)*lcount)//2%mod)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
rcount=0
lcount=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      rcount+=1

for i in range(n-1):
  for j in range(i+1,n):
    if a[i]<a[j]:
      lcount+=1

#print(count,countlast)
mod=10**9+7

print((k*(k+1)*rcount+k*(k-1)*lcountlast)/2%mod)
Problem p02946 (python)

Fixed submission:
a, b =map(int, input().split())
c = ""
for i in range(b -a+1, b+a):
	c = c + str(i) + " "
print(c)

Buggy submission (verdict: Runtime Error):
a, b =map(int, input().split())
c = ""
for i in range(b -a, b+a)
	c = c + str(i) + " "
print(c)
Problem p02957 (python)

Fixed submission:
a, b =map(int, input().split())
#A^2 -2AK-K^2=B^2 -2BK -K^2
#A^2-B^2=2(A-B)K

c = (a**2 -b**2)/(2*(a-b))
if c-int(c)!=0:
  print("IMPOSSIBLE")
else:
  print(int(c))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input().split()

b =[str(i+1) for i in range(len(s))]

count=0
for i in range(len(s)):
  if s[i]!=b[i]:
    count+=1
if count==0: print("YES")
elif count==2: print("YES")
else: print("NO")
Problem p02981 (python)

Fixed submission:
a, b, c =map(int,input().split())
if a*b>=c:
  print(c)
else:
  print(a*b)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
mod1 = []
mod2 = []
for i in range(l,r+1):
  mod1.append(i%2019)

for i in range(len(mod1)-1):
  for j in range(i+1,len(mod1)):
    mod2.append((mod1[i]*mod1[j])%2019)
print(min(mod2))
Problem p02999 (python)

Fixed submission:
x, a = map(int,input().split())
print(0) if x<a else print(10)

Buggy submission (verdict: Runtime Error):
w, h, x, y = map(int,input().split())
area=w*h/2
awee=0
if x==w/2 or y==h/2:
    awee=0
    if x==w/2 and y==h/2:
        awee=1
else:
    awee=0

print(str(area)+" "+str(awee))
Problem p03035 (python)

Fixed submission:
a,b=map(int,input().split())
if a>=13:
  print(b)
elif a<13 and a>=6:
  print(b//2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>=13:
  print(b)
elif a<13 and a>=6
  print(b//2)
else:
  print(0)
Problem p03085 (python)

Fixed submission:
s = input()
print(s.translate(str.maketrans({"A":"T","T":"A","C":"G","G":"C"})))

Buggy submission (verdict: Runtime Error):
s = input()
print(s.translate(str.maketrans({"A":"T","T":"A","C":"G","G":"C"})
Problem p02641 (python)

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

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = 0
    for i in range(1, 200):
        if i not in nums:
            ans = ans if abs(ans-x) <= abs(i-x) else i
    print(ans)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

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

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if len(ans) == 1:
        print(ans[0])
        exit()
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

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

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if len(ans) == 1:
        print(ans[0])
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

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

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()
Problem p02684 (python)

Fixed submission:

url = "https://atcoder.jp/contests/abc162/tasks/abc162_d"
import itertools


def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    route = []
    istuka = [0] * (n+1)
    next = 1
    # 同じ街に訪れるまでループ
    for _ in range(k):
        if istuka[next] == 1:
            break
        else:
            istuka[next] = 1
            route.append(next)
        next = a[next - 1]
    if n >= k:
        print(next)
        exit()
    ans = route[route.index(next):]
    idx = (k - route.index(next)) % len(ans)
    print(ans[idx])



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

url = "https://atcoder.jp/contests/abc162/tasks/abc162_d"
import itertools


def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    route = []
    istuka = [0] * (n+1)
    next = 1
    # 同じ街に訪れるまでループ
    for _ in range(k):
        if istuka[next] == 1:
            break
        else:
            istuka[next] = 1
            route.append(next)
        next = a[next - 1]
    ans = route[route.index(next):]
    idx = (k - route.index(next)) % len(ans)
    print(ans[idx])



if __name__ == '__main__':
    main()
Problem p02718 (python)

Fixed submission:
url = "https://atcoder.jp/contests/abc161/tasks/abc161_b"


def main():
    n, m = list(map(int, input().split()))
    n_li = list(map(int, input().split()))
    n_li = sorted(n_li, reverse=True)
    all_num = sum(n_li)
    for i in range(1, m + 1):
        if all_num / (4 * m) > n_li[i - 1]:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
url = "https://atcoder.jp/contests/abc161/tasks/abc161_b"

def main():
    n, m = list(map(int, input().split()))
    n_li = list(map(int, input().split()))
    n_li = sorted(n_li, reverse=True)
    all = sum(n_li)
    for i in range(1, m + 1):
        if all // (4 * m) > n_li[i]:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()