Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
import math
MOD = 998244353

n = int(input())
d = [int(_) for _ in input().split()]

ans = 1
if not d[0]  == 0:
    ans = 0
else:
    D = sorted(collections.Counter(d).most_common())
    for i in range(1, max(d)+1):
        ans = ans * pow(D[i-1][1], D[i][1], MOD)
print(ans)

Fixed submission:
import collections
MOD = 998244353

n = int(input())
d = [int(_) for _ in input().split()]

ans = 1
if d[0] != 0:
    ans = 0
else:
    D = sorted(collections.Counter(d).most_common())
    if D[0][1] != 1:
        ans = 0
    else:
        cnt = 0
        prev = 1
        for i in D:
            if i[0] == cnt:
                ans = ans * pow(prev, i[1], MOD) % MOD
                prev = i[1]
            else:
                ans = 0
                break
            cnt += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(_) for _ in input().split()]

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a, b, c = l[i], l[j], l[k]
            if a < b+c:
                if b < c+a:
                    if c < a+b:
                        ans += 1
print(ans)

Fixed submission:
import bisect

n = int(input())
l = [int(_) for _ in input().split()]

l.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a, b = l[i], l[j]
        k = bisect.bisect_right(l, a+b-1)
        ans += k - j - 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
a.sort(reverse=True)

ans = 0
search_idx = 0

for i in range(m):
    max_idx = 0
    if search_idx+2 >= n:
        search_idx = n - 2
    for j in range(0, search_idx+2):
        if a[max_idx] < a[j]:
            max_idx = j
        if search_idx < max_idx:
            search_idx = max_idx
    a[max_idx] //= 2
    #print(a)

print(sum(a))

Fixed submission:
import heapq

# 「優先度付きキュー」の練習問題

n, m = map(int, input().split())
a = [int(_) for _ in input().split()]

# 各要素を-1倍する。最大値の取り出しができるように
a = list(map(lambda x: x*(-1), a))
# aの優先度付きキューに
heapq.heapify(a)

# 割引m回分ループ
for _ in range(m):
    popNum = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-popNum//2))

# 負で出力されているので戻す
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
cb = [0] * m
for i in range(m):
    bb, cc = map(int, input().split())
    cb[i] = (cc, bb)

cb.sort(reverse=True)

arr = []
l = 0
for i in range(m):
    if l + cb[i][1] > 10**5:
        add = 10**5 - l
        for j in range(add):
            arr.append(cb[i][0])
        break
    else:
        for j in range(cb[i][1]):
            arr.append(cb[i][0])

a = a + arr
a.sort(reverse=True)
print(sum(a[0:n]))

Fixed submission:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
cb = [0] * m
for i in range(m):
    bb, cc = map(int, input().split())
    cb[i] = (cc, bb)

cb.sort(reverse=True)

arr = []
l = 0
for i in range(m):
    if l + cb[i][1] > 10**5:
        add = 10**5 - l
        for j in range(add):
            arr.append(cb[i][0])
        break
    else:
        for j in range(cb[i][1]):
            arr.append(cb[i][0])
        l += cb[i][1]

a = a + arr
a.sort(reverse=True)
print(sum(a[0:n]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
cb = [0] * m
for i in range(m):
    bb, cc = map(int, input().split())
    cb[i] = (cc, bb)

cb.sort(reverse=True)

arr = []
l = 0
for i in range(m):
    if l + cb[i][1] > 10**5:
        add = 10**5 - l
        for j in range(add):
            arr.append(cb[i][0])
        break
    else:
        for j in range(cb[i][1]):
            arr.append(cb[i][0])

a = a + arr
a.sort(reverse=True)
print(sum(a[0:n]))

Fixed submission:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
cb = [0] * m
for i in range(m):
    bb, cc = map(int, input().split())
    cb[i] = (cc, bb)

cb.sort(reverse=True)

arr = []
l = 0
for i in range(m):
    if l + cb[i][1] > 10**5:
        add = 10**5 - l
        for j in range(add):
            arr.append(cb[i][0])
        break
    else:
        for j in range(cb[i][1]):
            arr.append(cb[i][0])
        l += cb[i][1]

a = a + arr
a.sort(reverse=True)
print(sum(a[0:n]))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
mr, mg, mb = N//R, N//G, N//B

ans = 0
for r in range(mr+1):
    for g in range(mg+1):
        val = N - r*R - g*G
        if val >= 0 and val % B == 0:
            ans += 1
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
mr, mg, mb = N//R, N//G, N//B

ans = 0
for r in range(mr+1):
    for g in range(mg+1):
        val = N - r*R - g*G
        if val >= 0 and val % B == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
ab, bc = map(int, input().split())
print(ab*bc/2)

Fixed submission:
ab, bc, ca = map(int, input().split())
print(int(ab*bc/2))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(_) for _ in input().split()]
dp = [1000000000] * n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
print(dp[n-1])


Fixed submission:
n, k = map(int, input().split())
h = [int(_) for _ in input().split()]
dp = [1000000000] * n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[0] * (W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(W+1):
        if item[n-1][0] <= w:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-item[n-1][0]] + item[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[0] * (W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(W+1):
        if item[n-1][0] <= w:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-item[n-1][0]] + item[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[0] * (W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(W+1):
        if item[n-1][0] <= w:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-item[n-1][0]] + item[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[1000000001] * (1000*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    for j in range(1000*N+1):
        if item[i-1][1] <= j:
            dp[i][j] = min(dp[i-1][j-item[i-1][1]] + item[i-1][0], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
ans = 0
for i in range(1000*N+1):
    if dp[N][i] <= W:
        ans = i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# LCS(Longest common subsequence)
s = input()
t = input()

def lcs(str1, str2):
    len1, len2 = len(str1), len(str2)
    lcs_dp = [[0]*(len2+1) for i in range(len1+1)]
    for i in range(len1-1, -1, -1):
        for j in range(len2-1, -1, -1):
            r = max(lcs_dp[i+1][j], lcs_dp[i][j+1])
            if str1[i] == str2[j]:
                r = max(r, lcs_dp[i+1][j+1]+1)
            lcs_dp[i][j] = r
    res = []
    i, j = 0, 0
    while i < len1 and j < len2:
        if str1[i] == str2[j]:
            res.append(str1[i])
            i += 1; j += 1
        elif lcs_dp[i][j] == lcs_dp[i+1][j]:
            i += 1
        elif lcs_dp[i][j] == lcs_dp[i][j+1]:
            j += 1
    return ''.join(res)

print(lcs(s, t))

Fixed submission:
# LCS(Longest common subsequence)
s = input()
t = input()

def lcs(str1, str2):
    len1, len2 = len(str1), len(str2)
    lcs_dp = [[0]*(len2+1) for i in range(len1+1)]
    for i in range(len1-1, -1, -1):
        for j in range(len2-1, -1, -1):
            r = max(lcs_dp[i+1][j], lcs_dp[i][j+1])
            if str1[i] == str2[j]:
                r = max(r, lcs_dp[i+1][j+1]+1)
            lcs_dp[i][j] = r
    res = []
    i, j = 0, 0
    while i < len1 and j < len2:
        if str1[i] == str2[j]:
            res.append(str1[i])
            i += 1; j += 1
        elif lcs_dp[i][j] == lcs_dp[i+1][j]:
            i += 1
        elif lcs_dp[i][j] == lcs_dp[i][j+1]:
            j += 1
    return ''.join(res)

print(lcs(s, t))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
#print(a)

ans_a = a[n-1]
maxi = 0
idx = 0
for i in enumerate(a):
    val = max(maxi, combinations_count(ans_a, i[1]))
    if maxi < val:
        idx = i[0]
        maxi = val
    #print(idx, maxi)
    else:
        break

ans_b = a[idx]
print(ans_a, ans_b)


Fixed submission:
import math
import numpy

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def get_nearest(li, num):
    index = numpy.abs(numpy.asarray(li) - num).argmin()
    return li[index]

n = int(input())
a = [int(_) for _ in input().split()]

if n == 2:
    print(max(a), 0)
    exit()

ans_a = max(a)
ans_b = get_nearest(a, ans_a/2)

print(ans_a, ans_b)

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
#print(a)

ans_a = a[n-1]
maxi = 0
idx = 0
for i in enumerate(a):
    val = max(maxi, combinations_count(ans_a, i[1]))
    if maxi < val:
        idx = i[0]
        maxi = val
    #print(idx, maxi)

ans_b = a[idx]
print(ans_a, ans_b)


Fixed submission:
import math
import numpy

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def get_nearest(li, num):
    index = numpy.abs(numpy.asarray(li) - num).argmin()
    return li[index]

n = int(input())
a = [int(_) for _ in input().split()]

if n == 2:
    print(max(a), 0)
    exit()

ans_a = max(a)
ans_b = get_nearest(a, ans_a/2)

print(ans_a, ans_b)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
if x == y:
    print(-1)
elif y == 1:
    print(-1)
else:
    for i in range(x, 10**18+1, x):
        if i % x == 0:
            if not i % y == 0:
                print(i)
                exit()


Fixed submission:
x, y = map(int, input().split())
if x % y == 0:
    print(-1)
else:
    print(x)

Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
if x == y:
    print(-1)
elif y == 1:
    print(-1)
else:
    cnt = x+1
    for i in range(cnt, 10**9):
        if i % x == 0:
            if not i % y == 0:
                print(i)
                exit()


Fixed submission:
x, y = map(int, input().split())
if x % y == 0:
    print(-1)
else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
ans = 1
num = a[0]
path = []
while num != 2:
    if len({num} & set(path)) > 0:
        ans = -1
        break
    path.append(num)
    num = a[num-1]
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = [0] * (n+1)
for i in range(n):
    a[i+1] = int(input())

ans = 0
idx = 1
for i in range(n-1):
    if a[idx] == 2:
        print(ans+1)
        exit()
    else:
        ans += 1
        idx = a[idx]
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
ans = 1
num = a[0]
while num != 2:
    if num == 1:
        ans = -1
        break
    num = a[num-1]
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = [0] * (n+1)
for i in range(n):
    a[i+1] = int(input())

ans = 0
idx = 1
for i in range(n-1):
    if a[idx] == 2:
        print(ans+1)
        exit()
    else:
        ans += 1
        idx = a[idx]
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
if a > b:
    print(0)
    exit()
elif a == b:
    print(1)
    exit()
elif n == 1 and b - a > 0:
    print(0)
    exit()
elif n == 2:
    print(1)
    exit()
else:
    mid_num = n - 2
    num_num = b - a + 1
    ans = 0
    for i in range(mid_num-1):
        ans += num_num-1
    ans += num_num
    print(ans)


Fixed submission:
n, a, b = map(int, input().split())
if a > b:
    print(0)
    exit()
elif a == b:
    print(1)
    exit()
elif n == 1 and b - a > 0:
    print(0)
    exit()
elif n == 2:
    print(1)
    exit()
else:
    mid_num = n - 2
    num_num = b - a + 1
    ans = 0
    ans += (num_num-1) * (mid_num-1) + num_num
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a, b = [0] * n, [0] * m
for i in range(n):
    a[i] = list(input())
for i in range(m):
    b[i] = list(input())

for sx in range(n-1):
    for sy in range(n-1):
        chk = True
        for tx in range(m):
            for ty in range(m):
                if a[sx+tx][sy+ty] == b[tx][ty]:
                    pass
                else:
                    chk = False
                    break
        if chk:
            print('Yes')
            exit()
print('No')


Fixed submission:
n, m = map(int, input().split())
a, b = [0] * n, [0] * m
for i in range(n):
    a[i] = list(input())
for i in range(m):
    b[i] = list(input())

if n == 1:
    if a[0] == b[0]:
        print('Yes')
    else:
        print('No')
    exit()

for sx in range(n-m):
    for sy in range(n-m):
        chk = True
        for tx in range(m):
            for ty in range(m):
                #print(sx+tx, sy+ty)
                if a[sx+tx][sy+ty] == b[tx][ty]:
                    pass
                else:
                    chk = False
        if chk:
            print('Yes')
            exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
dis = [_ for _ in input().split()]
for yen in range(1, 100000):
    if yen < n:
        pass
    else:
        if len(set(list(str(yen))) & set(dis)) == 0:
            print(yen)
            exit()


Fixed submission:
a, b, c = map(int, input().split())
abc = sorted([a, b, c])
if abc[0] == 5 and abc[1] == 5 and abc[2] == 7:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
for i in range(N):
    ans *= A[i]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag = 1
if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            flag = 0
            break

if flag == 0:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

ans = np.prod(A)

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag = 1
if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            flag = 0
            break

if flag == 0:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

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

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag = 1
if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            flag = 0
            break

if flag == 0:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = input()
Q = int(input())
a = deque(S)

for i in range(Q):
  A = input().split()
  if A[0] == "1":
    a.reverse()
  else:
    if A[1] == "1":      
      a.appendleft(A[2])
    else:
      a.append(A[2])
print("".join(a))

Fixed submission:
from collections import deque

S = input()
Q = int(input())
a = deque(S)

flag = 0

for i in range(Q):
  A = input().split()
  if A[0] == "1":
    if flag == 0:
      flag = 1
    else:
      flag = 0
  else:
    if A[1] == "1" and flag == 0 or A[1] == "2" and flag == 1:      
      a.appendleft(A[2])
    else:
      a.append(A[2])

if flag == 1:
  a.reverse()
print("".join(a))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = input()
Q = int(input())

for i in range(Q):
  A = input().split()
  if A[0] == "1":
    S = S[::-1]
  else:
    if A[1] == "1":
      a = deque(S)
      a.appendleft(A[2])
      S = list(a)
    else:
      a = deque(S)
      a.append(A[2])
      S = list(a)
print("".join(S))

Fixed submission:
from collections import deque

S = input()
Q = int(input())
a = deque(S)

flag = 0

for i in range(Q):
  A = input().split()
  if A[0] == "1":
    if flag == 0:
      flag = 1
    else:
      flag = 0
  else:
    if A[1] == "1" and flag == 0 or A[1] == "2" and flag == 1:      
      a.appendleft(A[2])
    else:
      a.append(A[2])

if flag == 1:
  a.reverse()
print("".join(a))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
s = []
for i in range(N):
    s.append(Counter(input()))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    if(s[i] == s[j]):
      ans += 1
    
print(ans)

Fixed submission:
A,B = map(int, input().split())
print(max(A+B, A-B, A*B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
tmp = [[] for i in range(N + 1)]
tmp[0] = [0]
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))
s.sort()

for i in range(1, N + 1):
    t_l = []
    for j in range(len(tmp[i - 1])):
        for k in range(12):
            a = tmp[i - 1][j] + s[k]
            if a <= N:
                t_l.append(a)
    tmp[i].extend(t_l)
    if N in tmp[i]:
        break
print(i)

Fixed submission:
N = int(input())
tmp = [-1 for i in range(N + 1)]
tmp[0] = 0
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))

for i in range(1, N+1):
    for j in range(N+1):
        if tmp[j] == i - 1:
            for k in range(12):
                a = j + s[k]
                if a <= N and tmp[a] == -1:
                    tmp[a] = i
    if tmp[N] > -1:
        break
print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
tmp = [[] for i in range(N + 1)]
tmp[0] = [0]
chk = []
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))
s.sort()

for i in range(1, N + 1):
    t_l = []
    for j in range(len(tmp[i - 1])):
        for k in range(12):
            a = tmp[i - 1][j] + s[k]
            if a <= N and a not in chk:
                t_l.append(a)
                chk.extend(t_l)
    tmp[i].extend(t_l)
    if N in tmp[i]:
        break
print(i)

Fixed submission:
N = int(input())
tmp = [-1 for i in range(N + 1)]
tmp[0] = 0
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))

for i in range(1, N+1):
    for j in range(N+1):
        if tmp[j] == i - 1:
            for k in range(12):
                a = j + s[k]
                if a <= N and tmp[a] == -1:
                    tmp[a] = i
    if tmp[N] > -1:
        break
print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
tmp = [[] for i in range(N + 1)]
tmp[0] = [0]
chk = []
flag = 0
s = [1]
for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))
s.sort()

for i in range(1, N + 1):
    t_l = []
    for j in range(len(tmp[i - 1])):
        for k in range(12):
            if tmp[i - 1][j] + s[k] <= N and tmp[i - 1][j] + s[k] not in chk:
                t_l.append(tmp[i - 1][j] + s[k])
    t_l = list(set(t_l))
    tmp[i].extend(t_l)
    chk.extend(t_l)
    if N in tmp[i]:
        break
print(i)

Fixed submission:
N = int(input())
tmp = [-1 for i in range(N + 1)]
tmp[0] = 0
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))

for i in range(1, N+1):
    for j in range(N+1):
        if tmp[j] == i - 1:
            for k in range(12):
                a = j + s[k]
                if a <= N and tmp[a] == -1:
                    tmp[a] = i
    if tmp[N] > -1:
        break
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A  = list(map(int,input().split()))

scores=[]
for i in range(0,K):
    scores.append(A[i])

for j in range(K,N):
    if 0 in scores:
        scores.pop(0)
        scores.append(A[j])
        if 0 in scores:
            print("No")
        else:
            print("Yes")
    elif scores.pop(0)<A[j]:
        print("Yes")
        scores.append(A[j])
    else:
        print("No")
        scores.append(A[j])

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

from collections import deque
scores=deque()

for i in range(0,K):
    scores.append(A[i])

for j in range(K,N):
#     if 0 in scores:
#         scores.pop(0)
#         scores.append(A[j])
#         if 0 in scores:
#             print("No")
#         else:
#             print("Yes")
    if scores.popleft()<A[j]:
        print("Yes")
        scores.append(A[j])
    else:
        print("No")
        scores.append(A[j])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1    
    elif A[i+1]>A[i]:
        #買う
        while money>=A[i]:
            money -= A[i]
            stocks+=1
    elif A[i+1]<A[i]:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1
print(money)

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

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        money+=(A[i]*stocks)
        stocks=0
    elif A[i+1]>A[i]:
        #買う
        plus_stock,money=divmod(money,A[i])
        stocks+=plus_stock
    elif A[i+1]<A[i]:
        #売る
        money+=(A[i]*stocks)
        stocks=0
print(money)