Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
score = [int(input().rstrip()) for _ in range(N)]
score.sort(reverse=1)

for s in score:
    if s % 10 != 0:
        break
else:
    print(0)


for i in range(N, 0, -1):
    for c in combinations(score, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c))
            exit()


Fixed submission:
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
score = [int(input().rstrip()) for _ in range(N)]
score.sort(reverse=1)

s_multiple_of_10 = [s for s in score if s % 10 == 0]
if len(s_multiple_of_10) == N: print(0)
s_not_multiple_of_10 = [s for s in score if s % 10 != 0]

# combinationsでも、先に１０の倍数を除外してから処理したらどうだろう
for i in range(len(s_not_multiple_of_10), 0, -1):
    for c in combinations(s_not_multiple_of_10, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c) + sum(s_multiple_of_10))
            exit()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
s = [int(input().rstrip()) for _ in range(N)]
s.sort(reverse=1)

for s in s:
    if s % 10 != 0:
        break
else:
    print(0)

for i in range(N, 0, -1):
    for c in combinations(s, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c))
            exit()

Fixed submission:
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
score = [int(input().rstrip()) for _ in range(N)]
score.sort(reverse=1)

s_multiple_of_10 = [s for s in score if s % 10 == 0]
if len(s_multiple_of_10) == N: print(0)
s_not_multiple_of_10 = [s for s in score if s % 10 != 0]

# combinationsでも、先に１０の倍数を除外してから処理したらどうだろう
for i in range(len(s_not_multiple_of_10), 0, -1):
    for c in combinations(s_not_multiple_of_10, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c) + sum(s_multiple_of_10))
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
s = [int(input().rstrip()) for _ in range(N)]
s.sort(reverse=1)

for i in range(N, 0, -1):
    for c in combinations(s, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c))
            exit()
else:
    print(0)

Fixed submission:
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
score = [int(input().rstrip()) for _ in range(N)]
score.sort(reverse=1)

s_multiple_of_10 = [s for s in score if s % 10 == 0]
if len(s_multiple_of_10) == N: print(0)
s_not_multiple_of_10 = [s for s in score if s % 10 != 0]

# combinationsでも、先に１０の倍数を除外してから処理したらどうだろう
for i in range(len(s_not_multiple_of_10), 0, -1):
    for c in combinations(s_not_multiple_of_10, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c) + sum(s_multiple_of_10))
            exit()
Buggy python submission (verdict: Runtime Error):
# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


    if a > b:
        ans = 0
    elif a == b:
        ans = 1
    elif b < a:
        if n == 1:
            ans = 0
        else:
            min_possible = a * (n - 1) + b
            max_possible = b * (n - 1) + a
            ans = max_possible - min_possible + 1
    
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]

    min_possible = a * (n - 1) + b
    max_possible = b * (n - 1) + a

    ans = max_possible - min_possible + 1
    print(max(ans, 0))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

if h % 3 == 0 or 2 % 3 == 0:
    print(0)
    exit()

if h % 3 == 1:
    d = h // 3 
else:
    d = h // 3 + 1
block = [w * d, (h-d) * (w // 2), (h-d) * (w - w // 2)]
for b in block:
    if b == int(b**0.5) ** 2:
        break
else:
    res1 = max(block) - min(block)

if w % 3 == 1:
    d = w // 3 
else:
    d = w // 3 + 1
block = [h * d, (w-d) * (h // 2), (w-d) * (h - h // 2)]
for b in block:
    if b == int(b**0.5) ** 2:
        break
else:
    res2 = max(block) - min(block)

print(min(res1, res2))

Fixed submission:
import sys
input = sys.stdin.readline

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

if h % 3 == 0 or 2 % 3 == 0:
    print(0)
    exit()

if h % 3 == 1:
    d = h // 3 
else:
    d = h // 3 + 1
block = [w * d, (h-d) * (w // 2), (h-d) * (w - w // 2)]
res1 = max(block) - min(block)
block = [w * d, w * d, w * (h - d * 2)]
res2 = max(block) - min(block)

if w % 3 == 1:
    d = w // 3 
else:
    d = w // 3 + 1
block = [h * d, (w-d) * (h // 2), (w-d) * (h - h // 2)]
res3 = max(block) - min(block)
block = [h * d, h * d, h * (w - d * 2)]
res4 = max(block) - min(block)

print(min(res1, res2, res3, res4))
Buggy python submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Fixed submission:
a, b, c = [int(x) for x in input().split()]

if c >= a and c <= b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline()

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Fixed submission:
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

th = 0
for i in range(1, 10**5+1):
    if arr[i] != 0:
        th += arr[i]
    if th >= K:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]

arr = []
for i in range(n):
    a, b = [int(x) for x in input().split()]
    arr += [a] * b

arr.sort()

print(arr[k-1])

Fixed submission:
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

th = 0
for i in range(1, 10**5+1):
    if arr[i] != 0:
        th += arr[i]
    if th >= K:
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):
n, W = [int(x) for x in input().split()]
weight = []
value = []
for i in range(n):
    wi, vi = [int(x) for x in input().split()]
    weight.append(wi)
    value.append(vi)

dp = [[0] * (W+1)] * (n+1)

for i in range(n):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
   
ans = dp[n][W]
print(ans)

Fixed submission:
import sys

n, W = map(int, sys.stdin.readline().split())
wv = map(int, sys.stdin.read().split())

wv = sorted(zip(*[wv] * 2))
min_w = wv[0][0]
W2 = 4 * n

def main():
    dp = [[[0] * (W2 + 1) for _ in range(n+1)] for _ in range(n+1)]
    
    for i in range(n):
        w, v = wv[i]
        w -= min_w - 1
        for j in range(1, i+2):
            for k in range(W2 + 1):
                if k + (min_w - 1) * j > W:
                    break
                dp[i+1][j][k] = dp[i][j][k]
                if k >= w:
                    dp[i+1][j][k] = max(dp[i][j][k], dp[i][j-1][k-w] + v)

    res = 0
    for j in dp[n]:
        res = max(res, max(j))

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()

i = 0
res = []
while True:
    if o[i]:
        res.append(o[i])
    else:
        break
    if e[i]:
        res.append(e[i])
        i += 1
    else:
        break

print(''.join(res))

Fixed submission:
o = input()
e = input()

lo = len(o)
le = len(e)
i = 0
res = []
while True:
    if i == len(o):
        break
    else:
        res.append(o[i])
    if i == len(e):
        break
    else:
        res.append(e[i])
        i += 1

print(''.join(res))

Buggy python submission (verdict: Runtime Error):
o, e = input().split()

i = 0
res = []
while True:
    if o[i]:
        res.append(o[i])
    else:
        break
    if e[i]:
        res.append(e[i])
        i += 1
    else:
        break

print(''.join(res))

Fixed submission:
o = input()
e = input()

lo = len(o)
le = len(e)
i = 0
res = []
while True:
    if i == len(o):
        break
    else:
        res.append(o[i])
    if i == len(e):
        break
    else:
        res.append(e[i])
        i += 1

print(''.join(res))

Buggy python submission (verdict: Runtime Error):
o, e = input().split()

i = 0
res = []
while True:
    res.append(o[i])
    if e[i]:
        res.append(e[i])
        i += 1
    else:
        break

print(''.join(res))

Fixed submission:
o = input()
e = input()

lo = len(o)
le = len(e)
i = 0
res = []
while True:
    if i == len(o):
        break
    else:
        res.append(o[i])
    if i == len(e):
        break
    else:
        res.append(e[i])
        i += 1

print(''.join(res))
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
import scipy.special

def comb(n, r):
    return scipy.special.comb(n, r, exact=True)

n, a, b, *v = map(int, sys.stdin.read().split())

def main():
    v.sort()

    ma = v[n-a:n]
    yield sum(ma) / a

    lo = ma[0]
    hi = ma[-1]

    res = 0
    lo_cnt = bi_r(v, lo) - bi_l(v, lo)
    if lo == hi:
        for c in range(a, min(b, lo_cnt) + 1):
            res += comb(lo_cnt, c)
    else:
        allowed_cnt = bi_r(ma, lo)
        res = comb(lo_cnt, allowed_cnt)
    
    yield res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Fixed submission:
from statistics import mean
n, a, b = [int(_) for _ in input().split()]
values = [int(v) for v in input().split()]
values.sort(reverse=True)
maximum_mean = mean(values[:a])
print(maximum_mean)

min_value = values[:a][-1]
accepted = values[:a].count(min_value)
full = values.count(min_value)

# 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
nCr = {}
def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]



if min_value == maximum_mean:
    ans = 0
    for r in range(a, b+1):
        ans += cmb(full, r)
else:
    ans = cmb(full, accepted)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from copy import deepcopy

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, ma, mb = I[:3]
a, b, c = I[3:].reshape(n, 3).T

def main():
    sa = np.sum(a)
    sb = np.sum(b)

    res = [[[[0, 0] for _ in range(sb+1)] for _ in range(sb + 1)] for _ in range(n+1)]
    res[0][0][0][0] = 1
    for i in range(n):
        res[i+1] = deepcopy(res[i])
        for j in range(sa+1):
            for k in range(sb+1):
                if j >= a[i] and k >= b[i]:
                    prev =  res[i][j-a[i]][k-b[i]]
                    if prev[0]:
                        res[i+1][j][k][0] = 1
                        if res[i+1][j][k][1]:
                            res[i+1][j][k][1] = min(prev[1] + c[i], res[i+1][j][k][1])   
                        else:    
                            res[i+1][j][k][1] = prev[1] + c[i]

    for i in range(1, min(sa//ma, sb//mb)+1):
        x = res[n][ma * i][mb * i]
        if x[0]:
            return x[1]
    return -1

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys

INF = float('inf')

n, ma, mb = map(int, sys.stdin.readline().split())
a, b, c = [], [], []
for _ in range(n):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    a.append(ai); b.append(bi); c.append(ci)

def main():
    sa = sum(a)
    sb = sum(b)
    res = [[[INF] * (sb + 1) for _ in range(sa + 1)] for _ in range(n + 1)]
    res[0][0][0] = 0
    for i in range(n):
        for j in range(sa + 1):
            for k in range(sb + 1):
                if j >= a[i] and k >= b[i]:
                    res[i+1][j][k] = min(res[i][j-a[i]][k-b[i]] + c[i], res[i][j][k])
                else:
                    res[i+1][j][k] = res[i][j][k]
    ans = INF
    for i in range(1, min(sa//ma, sb//mb)+1):
        ans = min(ans, res[n][ma * i][mb * i])
    
    if ans == INF:
        return -1
    else:
        return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ls = [char for char in s]
while True:
    if ls[0] != 'A':
        ls.pop(0)
    else:
        break
while True:
    if ls[-1] != 'Z':
        ls.pop(-1)
    else:
        break

print(len(ls))


Fixed submission:
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        a_index = i
        break

for j in range(-1, -(len(s)-a_index), -1):
    if s[j] == 'Z':
        z_index = j
        break

length = (len(s) + z_index) - a_index + 1
print(length)

Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        a_index = i

for j in range(-1, -(len(s)-a_index), -1):
    if s[j] == 'Z':
        z_index = j

length = (len(s) + z_index) - a_index + 1
print(length)


Fixed submission:
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        a_index = i
        break

for j in range(-1, -(len(s)-a_index), -1):
    if s[j] == 'Z':
        z_index = j
        break

length = (len(s) + z_index) - a_index + 1
print(length)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
ls = list(range(a, b+1))
count = [i % x for i in ls].count(0)

print(count)


Fixed submission:
a, b, x = map(int, input().split())

count = b//x - (a-1)//x if a > 0 else b//x + 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
count = 0
for i in range(a, b+1):
    if i % x == 0:
        count += 1

print(count)



Fixed submission:
a, b, x = map(int, input().split())

count = b//x - (a-1)//x if a > 0 else b//x + 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
count = 0
for i in a:
    if i > x:
        i = x
        count += i - x
b = a.copy()

count1 = count
for i in range(n-1):
    while a[i] + a[i+1] > x:
        if a[i] > 0:
            a[i] -= 1
        else:
            a[i+1] -= 1
        count1 += 1

count2 = count
for i in range(n-1):
    while b[i] + b[i+1] > x:
        
        if b[i+1] > 0:
            b[i+1] -= 1
        else:
            b[i] -= 1
        count2 += 1

count = min(count1, count2)
print(count)








Fixed submission:
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

count = 0
previous = 0

for i in a:
    if i + previous > x: 
        excess = i + previous - x
        count += excess
        previous = x - previous
    else: # if not exceeding x.
        previous = i

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(sys.stdin.readline().rstrip())
ab = map(int, sys.stdin.read().split())
ab = list(zip(ab, ab))

def main():
    c_a = ab[0][0]
    c_b = ab[0][1]
    for a, b in ab[1:]:
        ratio = a / b
        while c_a / c_b != ratio:
            if c_a / c_b < ratio:
                c_a += 1
            else:
                c_b += 1
    
    ans = c_a + c_b
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
ab = map(int, sys.stdin.read().split())
ab = zip(ab, ab)

def main():
    c_a = c_b = 1
    for a, b in ab:
        t_a = (c_a + a - 1) // a
        t_b = (c_b + b - 1) // b
        t = max(t_a, t_b)
        c_a = a * t
        c_b = b * t
    
    ans = c_a + c_b
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
# 2019-11-26 17:11:55(JST)
import sys
from string import ascii_lowercase as alph
ind_alph = dict((char, ind) for ind, char in enumerate(alph))

def main():
    s, k = sys.stdin.read().split()
    s = list(s)
    k = int(k)
    n = len(s)

    i = 0
    while k:
        j = ind_alph[s[i]]
        diff = (26 - j) % 26
        if diff <= k:
            s[i] = 'a'
            k -= diff
        if i == n - 1 and k:
                s[i] = alph[(s[i] + k) % 26]
                k = 0
        i += 1

    print(''.join(s))

if __name__ == '__main__':
    main()


Fixed submission:
# 2019-11-26 17:11:55(JST)
import sys
from string import ascii_lowercase as alph
ind_alph = dict((char, ind) for ind, char in enumerate(alph))

def main():
    s, k = sys.stdin.read().split()
    s = list(s)
    k = int(k)
    n = len(s)

    i = 0
    while k:
        j = ind_alph[s[i]]
        diff = (26 - j) % 26
        if diff <= k:
            s[i] = 'a'
            k -= diff
        if i == n - 1 and k:
                s[i] = alph[(ind_alph[s[i]] + k) % 26]
                k = 0
        i += 1

    print(''.join(s))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

n, a, *x = map(int, sys.stdin.read().split())

def main():
    m = max(n, a) * max(x)
    dp = np.zeros((n + 1, m + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(n):
        ndp = np.copy(dp)
        for j in range(1, n + 1):
            ndp[j][x[i]:] += dp[j-1][:m-x[i]+1]
        dp = ndp
    i = np.arange(1, n + 1)
    print(np.sum(dp[i, i * a]))

if __name__ ==  '__main__':
    main()

Fixed submission:
import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    ma = a * n
    res = [[[0] * (ma + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    res[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        for j in range(i+2):
            for k in range(ma + 1):
                res[i+1][j][k] += res[i][j][k]
                if k >= cur:
                    res[i+1][j][k] += res[i][j-1][k-cur]
    
    ans = 0
    for j in range(1, n+1):
        ans += res[n][j][j*a]

    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, a = map(int, input().split())
integers = list(int(x) - a for x in input().split())
count = 0
for i in range(1, len(integers)+1):
    for combs in itertools.combinations(integers, i):
        av = sum(combs) / i
        if av == 0:
            count += 1

print(count)


Fixed submission:
import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    ma = a * n
    res = [[[0] * (ma + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    res[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        for j in range(i+2):
            for k in range(ma + 1):
                res[i+1][j][k] += res[i][j][k]
                if k >= cur:
                    res[i+1][j][k] += res[i][j-1][k-cur]
    
    ans = 0
    for j in range(1, n+1):
        ans += res[n][j][j*a]

    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, a = map(int, input().split())
integers = list(map(int, input().split()))
count = 0
for i in range(1, len(integers)+1):
    for combs in itertools.combinations(integers, i):
        av = sum(combs) / i
        if av == a:
            count += 1

print(count)


Fixed submission:
import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    ma = a * n
    res = [[[0] * (ma + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    res[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        for j in range(i+2):
            for k in range(ma + 1):
                res[i+1][j][k] += res[i][j][k]
                if k >= cur:
                    res[i+1][j][k] += res[i][j-1][k-cur]
    
    ans = 0
    for j in range(1, n+1):
        ans += res[n][j][j*a]

    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def solve(ns, k):
    n = len(ns)
    tot = 1
    for i in xrange(k):
        tot *= ns[i]
    res = []
    pre = tot
    for i in xrange(k, n):
        tot /= ns[i - k]
        tot *= ns[i]
        if tot > pre:
            res.append(True)
        else:
            res.append(False)
        pre = tot
    return res

assert solve([96, 98, 95, 100, 20], 3) == [True, False]
assert solve([1001, 869120, 1001], 2) == [False]
assert solve([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9], 7) == [True, True, False, True, True, False, True, True]


n, k = map(int, raw_input().split())
ns = map(int, raw_input().split())

res = solve(ns, k)
for item in res:
    print 'Yes' if item else 'No'




Fixed submission:
def solve(ns, k):
    n = len(ns)
    tot = 1
    for i in xrange(k):
        tot += ns[i]
    res = []
    pre = tot
    for i in xrange(k, n):
        a = ns[i - k]
        b = ns[i]
        if a > b:
            # tot = tot / a * b
            tot = tot - 1
        elif a < b:
            tot = tot + 1
        else:
            pass
        if tot > pre:
            res.append(True)
        else:
            res.append(False)
        pre = tot
    return res

assert solve([1001, 869120, 1001], 2) == [False]
assert solve([96, 98, 95, 100, 20], 3) == [True, False]
assert solve([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9], 7) == [True, True, False, True, True, False, True, True]


n, k = map(int, raw_input().split())
ns = map(int, raw_input().split())

res = solve(ns, k)
for item in res:
    print 'Yes' if item else 'No'
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

(n, m) = map(int, raw_input().split())

d = defaultdict(list)

for i in xrange(m):
    (a, b) = map(int, raw_input().split())
    d[a].append(b)
    d[b].append(a)

pre = [0 for i in xrange(n + 1)]
cnt = 0

q = [1]
while q:
    cur = q.pop(0)
    for nxt in d[cur]:
        if pre[nxt] == 0:
            cnt += 1
            pre[nxt] = cur
            q.append(nxt)


if cnt < n - 1:
    print 'No'
else:
    print 'Yes'
    for i in xrange(2, n + 1):
        print pre[i]


Fixed submission:
from collections import defaultdict, deque

(n, m) = map(int, raw_input().split())

d = defaultdict(list)

for i in xrange(m):
    (a, b) = map(int, raw_input().split())
    d[a].append(b)
    d[b].append(a)

pre = [0 for i in xrange(n + 1)]
cnt = 0

q = deque([1])
while q:
    cur = q.popleft()
    for nxt in d[cur]:
        if pre[nxt] == 0:
            cnt += 1
            pre[nxt] = cur
            q.append(nxt)


if cnt < n - 1:
    print 'No'
else:
    print 'Yes'
    for i in xrange(2, n + 1):
        print pre[i]