Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def abc2(x,y):
    if y%2!=0:
        return print("No")
    kame = (y//2)-x
    if (kame>=0)&(kame<=x):
        return print("Yes")
    else:
        return print("No")
x,y = map(int,input().split())
abs2(x,y)

Fixed submission:
x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
ans = 'No'
    for a in range(X + 1):
        b = X - a
        if 2 * a + 4 * b == Y:
            ans = 'Yes'
print(ans)

Fixed submission:
x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
ans = 'No'
    for a in range(X + 1):
        b = X - a
        if 2 * a + 4 * b == Y:
        ans = 'Yes'
print(ans)

Fixed submission:
x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
if y%2!=0:
    print("No")
kame=(y//2)-x
tsuru = (-y//2)+2x
if kame + tsuru == x:
    print("Yes")
else:
    print("No")

Fixed submission:
x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        return print(0)
    prod = 1
    for n in A:
        prod *= n
    if prod > 1000000000000000000:
        prod = -1
    return print(prod)

main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        return print(0)
    prod = 1
    for n in A:
        prod *= n
        if prod > 1000000000000000000:
            return print(-1)
    return print(prod)

main()
Buggy python submission (verdict: Runtime Error):
A,B = input().split()
B = int(B*100)
A = int(A)
print(int(A*B//100))

Fixed submission:
A,B = input().split()
B = int(B.replace(".",""))
A = int(A)
print(int(A*B//100))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    si = input()
    if si not in S:
        S = S + [si]
print(len(S))

Fixed submission:
S,W = map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    si = input()
    S = S + [si]
print(len(set(S)))

Fixed submission:
S,W = map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        elif diff < K/2:
            diff_list.append(diff)
            return print(min(diff_list))
        else:
            diff_list.append(diff)
    
N,K = map(int,input().split())
abc161_C(N,K)

Fixed submission:
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    N = N%K
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        elif diff < K/2:
            diff_list.append(diff)
            return print(min(diff_list))
        else:
            diff_list.append(diff)
    
N,K = map(int,input().split())
abc161_C(N,K)

Buggy python submission (verdict: Time Limit Exceeded):
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        elif diff == 0:
            return print(0)
        else:
            diff_list.append(diff)
            
    
N,K = map(int,input().split())
abc161_C(N,K)

Fixed submission:
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    N = N%K
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        elif diff < K/2:
            diff_list.append(diff)
            return print(min(diff_list))
        else:
            diff_list.append(diff)
    
N,K = map(int,input().split())
abc161_C(N,K)

Buggy python submission (verdict: Time Limit Exceeded):
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        else:
            diff_list.append(diff)
            
    
N,K = map(int,input().split())
abc161_C(N,K)

Fixed submission:
def abc161_C(N,K):
    if K == 1:
        return print(0)
    Min = 0
    N = N%K
    diff_list = [N]
    while 1:
        diff = abs(N - K)
        N = diff
        if diff in diff_list:
            return print(min(diff_list))
        elif diff < K/2:
            diff_list.append(diff)
            return print(min(diff_list))
        else:
            diff_list.append(diff)
    
N,K = map(int,input().split())
abc161_C(N,K)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B = map(int,input().split())
balls = []
odd = 1
while len(balls)<=N:
    if odd == 1:
        for i in range(1,A+1):
            balls = balls + ["b"]
        odd = 0
    else:
        for i in range(1,B+1):
            balls = balls + ["r"]
        odd = 1
balls = balls[:N]
print(balls.count("b"))

Fixed submission:
N,A,B = map(int,input().split())
balls = A + B
N_surplus = N%balls
if N_surplus < A:
    blues = (N//balls)*A + N_surplus
else:
    blues = (N//balls)*A + A
print(blues)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
P_past = []
cnt = 0
for i in range(N+1):
    P_past.append(0) 
for i in range(N):
    if sum(P_past[0:P[i]+1])!=0:
        cnt +=1
    P_past[P[i]]=P[i]
cnt = len(P)-cnt
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
Min = P[0]
cnt = 0
for Pi in P:
    if Pi <= Min:
        Min = Pi
        cnt +=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
cnt = 0
for i in range(N):
    Pi = P[i]
    for j in range(i):
        Pj = P[j]
        #print(Pj)
        if Pi > Pj:
            cnt +=1
            break
cnt = len(P)-cnt
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
Min = P[0]
cnt = 0
for Pi in P:
    if Pi <= Min:
        Min = Pi
        cnt +=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
cnt = 0
for i in range(N):
    Pi = P[i]
    for j in range(i+1):
        Pj = P[j]
        if Pi > Pj:
            cnt +=1
            break
cnt = len(P)-cnt
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
Min = P[0]
cnt = 0
for Pi in P:
    if Pi <= Min:
        Min = Pi
        cnt +=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
S = list(S)
count = 0
for i in range(N-1):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count+=1
print(count)

Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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 submission:
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)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
S = list(S)
count = 0
for i in range(len(S)):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count = count+1
print(count)

Fixed submission:
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)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(K):
    if A>0:
        A-=1
    else:
        B-=1
print(A,B)

Fixed submission:
A,B,K = map(int,input().split())
A1=A
if A-K<0:
    A = 0
else:
    A = A - K
K=K-A1
if K >=0:
    B=B-K
if B <0:
    B=0
print(A,B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
thousand = 1000*M
thousand - N < 1000
print(M)

Fixed submission:
N = int(input())
print((1000 - N % 1000) % 1000 )
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

final = 1

for i in a:
    final *= i
    
if final > 1000000000000000000:
    print(-1)
else:
    print(final)

Fixed submission:
n = int(input())

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

final = 1

if 0 in a:
    print(0)
    
else:
    for i in a:
        final *= i
        if final > 1000000000000000000:
            break
    if final > 1000000000000000000:
        print(-1)
    else:
        print(final)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if k % 1000 == 0:
  print(0)
else:
  
	k = int(N/1000) + 1
    print(1000*k - N)

Fixed submission:
N = int(input())
if N % 1000 == 0:
  print(0)
else:
  k = int(N/1000) + 1
  print(1000*k - N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int,input().split()))

p = 1
for i in range(N):
  p*=arr[i]
    
if p > pow(10,18):
  print(-1)
else:
  print(p)


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

if 0 in arr:
  print(0)
else:
  p = 1
  for i in arr:
    p *= i
    if p>1000000000000000000:
      p = -1
      break
  print(p)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
a = int(a)
b = int(b*100)
p = (a*b)//100
print(p)

Fixed submission:
a,b = input().split()
a = int(a)
b = round(float(b)*100)
p = (a*b)//100
print(p)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
p = a*b
print(int(p))

Fixed submission:
a,b = input().split()
a = int(a)
b = round(float(b)*100)
p = (a*b)//100
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from random import randint

    def score(t):
        memo = [0] * 26
        ans = 0
        for i, tt in enumerate(t):
            ans += s[i][tt - 1]
            memo[tt - 1] = i + 1
            for m, cc in zip(memo, c):
                ans -= cc * (i + 1 - m)
        return ans

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    t = [0] * d
    r = [0] * d
    check = 0
    for i in range(d):
        t[i] = s[i].index(max(s[i])) + 1
        check = score(t)
    for i in range(10 ** 4):
        for j in range(d):
            r[j] = randint(1, 26)
        if check < score(r):
            t = r
    print('\n'.join(map(str, t)))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    for i in range(d):
        print(s[i].index(max(s[i])) + 1)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from random import randint

    def score(t):
        memo = [0] * 26
        ans = 0
        for i, tt in enumerate(t):
            ans += s[i][tt - 1]
            memo[tt - 1] = i + 1
            for m, cc in zip(memo, c):
                ans -= cc * (i + 1 - m)
        return ans

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    t = [0] * d
    r = [0] * d
    check = 0
    for i in range(d):
        t[i] = s[i].index(max(s[i])) + 1
        check = score(t)
    for i in range(10 ** 4):
        for j in range(d):
            r[j] = randint(1, d)
        if check < score(r):
            t = r
    print('\n'.join(map(str, t)))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    for i in range(d):
        print(s[i].index(max(s[i])) + 1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
ans = 1
for aa in a:
    ans *= aa
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
a.sort()
ans = 1
for aa in a:
    ans *= aa
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, s, *a = map(int, read().split())
dp = [0] * (s + 1)
dp[0] = 1
mod = 998244353
for aa in a:
    for j in range(s, -1, -1):
        ss = j + aa
        if ss <= s:
            dp[ss] += dp[j]
            dp[ss] %= mod
        dp[j] *= 2
        dp[j] %= mod
print(dp[-1])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, s, *a = map(int, read().split())
dp = [0] * (s + 1)
dp[0] = 1
mod = 998244353
for aa in a:
    for j in range(s, -1, -1):
        ss = j + aa
        if ss <= s:
            dp[ss] += dp[j]
            dp[ss] %= mod
        dp[j] *= 2
        dp[j] %= mod
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, s = map(int, readline().split())
a = list(map(int, readline().split()))
dp = [[0] * (s + 2) for _ in range(n + 1)]
dp[0][0] = 1
mod = 998244353
for i, aa in enumerate(a):
    for j in range(s + 1):
        ss = j + aa
        dp[i + 1][min(j + aa, s + 1)] += dp[i][j]
        dp[i + 1][j] += dp[i][j] * 2
        dp[i + 1][j] %= mod
print(dp[-1][-2])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, s, *a = map(int, read().split())
dp = [0] * (s + 1)
dp[0] = 1
mod = 998244353
for aa in a:
    for j in range(s, -1, -1):
        ss = j + aa
        if ss <= s:
            dp[ss] += dp[j]
            dp[ss] %= mod
        dp[j] *= 2
        dp[j] %= mod
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n, m = map(int, readline().split())
graph = [[0] * n for _ in range(n)]
ab = [list(map(int, readline().split())) for _ in range(m)]
for a, b in ab:
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1
ans = dijkstra(csr_matrix(graph), return_predecessors=True)
if any(int(v) == -9999 for v in ans[1][0][1:]):
    print('No')
else:
    print('Yes')
    print('\n'.join(map(str, ans[1][0][1:] + 1)))


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def bfs(s):
    from collections import deque
    check = [-1] * (n + 1)
    check[s] = 0
    q = deque([s])
    while q:
        now = q.popleft()
        for next in graph[now]:
            if check[next] == -1:
                check[next] = now
                q.append(next)
    return check


n, m = map(int, readline().split())
graph = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)
print('Yes')
for v in bfs(1)[2:]:
    print(v)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product

n, m, x = map(int, readline().split())
ca = [list(map(int, readline().split())) for _ in range(n)]
ans = float('inf')
for bit in product([0, 1], repeat=n):
    cnt = 0
    memo = [0] * n
    for i in range(n):
        if bit[i] == 1:
            cnt += ca[i][0]
            for j in range(m):
                memo[j] += ca[i][j + 1]
    for j in range(m):
        if memo[j] < x:
            break
    else:
        ans = min(ans, cnt)
if ans == float('inf'):
    ans = -1
print(ans)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product

n, m, x = map(int, readline().split())
ca = [list(map(int, readline().split())) for _ in range(n)]
ans = float('inf')
for bit in product([0, 1], repeat=n):
    cnt = 0
    memo = [0] * m
    for i in range(n):
        if bit[i] == 1:
            cnt += ca[i][0]
            for j in range(m):
                memo[j] += ca[i][j + 1]
    for j in range(m):
        if memo[j] < x:
            break
    else:
        ans = min(ans, cnt)
if ans == float('inf'):
    ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
roop = 0
dict = [False] * n
now = a[0]
for i in range(n + 1):
    if i + 1 == k:
        print(a[now - 1])
        exit()
    now = a[now - 1]
    if dict[now - 1]:
        k -= (i + 1)
        dict = [False] * n
        dict[now - 1] = True
        check = a[now - 1]
        for j in range(n + 1):
            print(dict)
            now = a[now - 1]
            if dict[now - 1]:
                k %= (j + 1)
                k += 1
                break
            else:
                dict[now - 1] = True
        break
    else:
        dict[now - 1] = True
now = check
for i in range(k):
    now = a[now - 1]
print(now)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
dict = [-1] * (n + 1)
now = a[0]
dict[0] = 0
for i in range(1, n * 2):
    if i == k:
        print(now)
        exit()
    now = a[now - 1]
    if dict[now] != -1:
        k -= (i + 1)
        k %= (i - dict[now])
        break
    else:
        dict[now] = i
for i in range(k):
    now = a[now - 1]
print(now)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

x = int(readline())
for i in range(100000):
    for j in range(-2000, i):
        v = i ** 5 - j ** 5
        if x == v:
            print(i, j)
            exit()
        if len(str(v)) >= 10 and j > 0:
            break


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

x = int(readline())
for i in range(-118, 119):
    for j in range(-119, 118):
        a = i ** 5 - j ** 5
        b = j ** 5 - i ** 5
        if x == a:
            print(i, j)
            exit()
        if x == b:
            print(j, i)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import floor

a, b, n = map(int, readline().split())
max = 0
for i in range(n + 1):
    v = floor(a * i / b) - a * floor(i / b)
    if v >= max:
        max = v
    else:
        break
print(max)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import floor

a, b, n = map(int, readline().split())
if b > n:
    print(floor(a * n / b) - a * floor(n / b))
else:
    print(floor(a * (b - 1) / b) - a * floor((b - 1) / b))
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cumsum = list(itertools.accumulate(a))
ans = [0] * n
cnt = 0
if cumsum[m] / sum_a >= 1 / (n * m):
    cnt += 1
for i in range(1, n - m + 1):
    if (cumsum[m + i - 1] - cumsum[i - 1]) / sum_a >= 1 / (n * m):
        cnt += 1
    if cnt >= m:
        print('Yes')
        exit()
if cnt >= m:
    print('Yes')
else:
    print('No')


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cnt = 0
for i in range(n):
    if a[i] / sum_a >= 1 / (4 * m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cumsum = list(itertools.accumulate(a))
ans = [0] * n
cnt = 0
if cumsum[m] / sum_a < 1 / (n * m):
    for i in range(m):
        ans[i] -= 1
for i in range(1, n - m + 1):
    if (cumsum[m + i - 1] - cumsum[i - 1]) / sum_a < 1 / (n * m):
        for j in range(i, m + 1):
            ans[j] -= 1
for i in range(n):
    if ans[i] == 0:
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cnt = 0
for i in range(n):
    if a[i] / sum_a >= 1 / (4 * m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')