Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
for i in range(n-1):
  for j in range(m-1):
    t = (X[i+1]-X[i]) * (Y[j+1]-Y[j])
    t %= MOD
    t *= (n-i-1)*(i+1)
    t %= MOD
    t *= (m-j-1)*(j+1)
    t %= MOD
    ans += t
    ans %= MOD
print(ans)

Fixed submission:
n, m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10**9+7
sx, sy = 0, 0
for i in range(n):
  t = 2*i+1-n
  t *= X[i]
  t %= MOD
  sx += t
  sx %= MOD
for j in range(m):
  t = 2*j+1-m
  t *= Y[j]
  t %= MOD
  sy += t
  sy %= MOD
print(sx*sy%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np

n, k = map(int, input().split())
A = list(map(int, input().split()))
def solve(i):
  dp = np.zeros(k, dtype=bool)
  dp[0] = True
  for j in range(n):
    if j == i:
      continue
    a = A[j]
    dp[a:] |= dp.copy()[:-a]
  return np.any(dp[-A[i]:])

ans = 0
for i in range(n):
  if not solve(i):
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = np.zeros(k, dtype=np.int64)
dp[0] = 1
for i in range(n):
  a = A[i]
  dp[a:] += dp.copy()[:-a]

ans = 0
for i in range(n):
  a = A[i]
  for j in range(max(0, k-a), k):
    temp = dp[j::-a*2].sum()
    if j >= a:
      temp -= dp[j-a::-a*2].sum()
    if temp:
      break
  else:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
for i in range(n-1, 0, -1):
  if sum(A[:i]) >= (A[i]+1)//2:
    c += 1
  else:
    print(c)
    exit()
print(n)  

Fixed submission:
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
sumA = sum(A)
for i in range(n-1, 0, -1):
  sumA -= A[i]
  if sumA*2 >= A[i]:
    c += 1
  else:
    print(c)
    exit()
print(n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
for i in range(n-1, 0, -1):
  if sum(A[:i])*2 >= A[i]:
    c += 1
  else:
    print(c)
    exit()
print(n)  

Fixed submission:
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
sumA = sum(A)
for i in range(n-1, 0, -1):
  sumA -= A[i]
  if sumA*2 >= A[i]:
    c += 1
  else:
    print(c)
    exit()
print(n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
for i in range(n-1, 0, -1):
  if sum(A[:i])*2 >= A[i]:
    c += 1
  else:
    print(c)
    exit()
print(n)  

Fixed submission:
n = int(input())
A = sorted(list(map(int, input().split())))
c = 1
sumA = sum(A)
for i in range(n-1, 0, -1):
  sumA -= A[i]
  if sumA*2 >= A[i]:
    c += 1
  else:
    print(c)
    exit()
print(n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(800*n - 200*(n//15)

Fixed submission:
n = int(input())
print(800*n - 200*(n//15))
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
from itertools import accumulate

n, *A = map(int, read().split())
S = []
now = 0
for a in A:
  if now < a:
    now = a
    S.append(a)
l = len(S)
C = [0]*l
D = {e:i for i, e in enumerate(S)}
K = [-1]*l
for i, a in enumerate(A):
  idx = D[a]
  if K[idx] == -1:
    K[idx] = i
  C[idx] += 1
S = [0] + S
C = list(accumulate(C[::-1]))[::-1]
L = [0]*n
for i, k in enumerate(K):
  L[k] = (S[i+1]-S[i]) * C[i]
print(*L, sep="\n")

Fixed submission:
import sys
read = sys.stdin.read

n, *A = map(int, read().split())
S = sorted([(a, i) for i, a in enumerate(A)], reverse=True)
X, Y = zip(*S)
m = 10**9
L = [0]*n
for i, y in enumerate(Y):
  m = min(m, y)
  if i == n-1:
    L[m] += (i+1) * X[i]
  else:
    L[m] += (i+1) * (X[i] - X[i+1])
print(*L, sep="\n")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if l.index(a) > l.index(b):
  print("Alice")
elif l.index(a) < l,index(a):
  print("Bob")
else:
  print("Draw")

Fixed submission:
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if l.index(a) > l.index(b):
  print("Alice")
elif l.index(a) < l.index(b):
  print("Bob")
else:
  print("Draw")
Buggy python submission (verdict: Time Limit Exceeded):
n, ma, mb = map(int, input().split())
U = 400
dp = [[[float("inf")]*(U+1) for _ in range(U+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
  a, b, c = map(int, input().split())
  for j in range(U+1):
    for k in range(U+1):
      if j<a or k<b:
        dp[i+1][j][k] = dp[i][j][k]
      else:
        dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b]+c)
ans = float("inf")
for i in range(1, 1+U//max(ma, mb)):
  na, nb = i*ma, i*mb
  ans = min(ans, dp[-1][na][nb])
if ans == float("inf"):
  print(-1)
else:
  print(ans)

Fixed submission:
n, ma, mb = map(int, input().split())
U = 400
dp = [[[float("inf")]*(U+1) for _ in range(U+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
  a, b, c = map(int, input().split())
  for j in range(U+1):
    for k in range(U+1):
      if j<a or k<b:
        dp[i+1][j][k] = dp[i][j][k]
      else:
        dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b]+c)
ans = float("inf")
for i in range(1, 1+U//max(ma, mb)):
  na, nb = i*ma, i*mb
  ans = min(ans, dp[-1][na][nb])
if ans == float("inf"):
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
[NO][YES]?k2?K[1-d0<G+]dsGx0k3|Rp

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
c = 0
for i in A:
  if i%2:
    c += 1
if c%2==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

import heapq

def main():
  n = int(input())
  T = [[] for _ in range(n+1)]
  for i in range(1, n):
    T[int(input())].append(i)

  def dfs(v):
    if not T[v]:
      return 0
    L = []
    for i in T[v]:
      heapq.heappush(L, dfs(i)+1)
    temp = heapq.heappop(L)
    while L:
      temp = max(temp+1, heapq.heappop(L))
    return temp

  ans = dfs(1)
  print(ans)
  
if __name__ == "__main__":
  main()

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
for i in range(1, n):
  a = int(input())
  a -= 1
  T[a].append(i)

def dfs(v):
  if not T[v]:
    return 0
  L = [dfs(i)+1 for i in T[v]]
  L.sort()
  for i in range(len(T[v]) - 1):
    L[i+1] = max(L[i]+1, L[i+1])
  return L[-1]

ans = dfs(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I:
    c+=1
  else:
    c-=1
    ans = max(c, ans)
print(ans)

Fixed submission:
n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I":
    x+=1
    ans = max(x, ans)
  else:
    x-=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I:
    c+=1
  else:
    c-=1
    ans = max(c, ans)
print(ans

Fixed submission:
n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I":
    x+=1
    ans = max(x, ans)
  else:
    x-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "":
  peinr("YES")
else:
  print("NO")

Fixed submission:
if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "":
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print("A"+b[0]+"C")

Fixed submission:
a, b, c = map(str, input().split())
print("A"+b[0]+"C")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
read = sys.stdin.read
import numpy as np

n = int(input())
A = np.array(read().split(), dtype=np.int64)
m = 30
C = np.zeros(m, dtype=bool)
used = np.zeros(m, dtype=bool)
x = 0
for a in A:
  x ^= a
for i in range(m):
  idx = np.where(A>>i & 1)
  if np.any(~used[idx]):
    C[i] = True
  used[idx] = True
total = 0
ans = 0
for i in range(m-1, -1, -1):
  if (x>>i & 1) ^ total:
    if C[i]:
      ans += 1
      total ^= 1
    else:
      print(-1)
      break
else:
  print(ans)

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
m = 30
C = [False]*m
x = 0
for a in A:
  x ^= a
  for i in range(m):
    if a>>i & 1:
      C[i] = True
      break
total = 0
ans = 0
for i in range(m-1, -1, -1):
  if (x>>i & 1) ^ total:
    if C[i]:
      ans += 1
      total ^= 1
    else:
      print(-1)
      break
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
print(4<<int(input())-2)

Fixed submission:
x = int(input())
now = 3
for _ in range(x):
  now = now*2+1
print(now-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000)

def nat_sum(n):
  if n==0:
    pass
  else:
    k = 0
    for i in range(n):
      if i*(i+1)//2 < n <= (i+1)*(i+2)//2:
        k = i+1
        break
    print(k)
    nat_sum(n-k)
    
n = int(input())
nat_sum(n)


Fixed submission:
import sys
sys.setrecursionlimit(10000)

def nat_sum(n):
  if n==0:
    pass
  else:
    k = 0
    for i in range(n):
      if i*(i+1)//2 < n <= (i+1)*(i+2)//2:
        k = i+1
        break
    print(k)
    nat_sum(n-k)
    
n = int(input())
nat_sum(n)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
k = int(input())
VP = tuple(tuple(map(int, input().split())) for _ in range(k))
P = [-1]*(n+1)
A = [-1]*(n+1)
r, c = PV[0]
for v, p in VP:
  P[v] = p
C = [None]*(n+1)
def dfs1(v, par=-1, color=c%2):
  if P[v] == -1:
    l = -float("inf")
    r = float("inf")
  else:
    l = P[v]
    r = P[v]
  for nv in T[v]:
    if nv == par:
      continue
    nl, nr = dfs1(nv, v, color^1)
    l = max(l, nl-1)
    r = min(r, nr+1)
  if l ^ color:
    l += 1
  if r ^ color:
    r -= 1
  if l > r:
    print("No")
    exit()
  P[v] = (l, r)
  return P[v]
dfs1(r)
def dfs2(v, ini, par=-1):
  l, r = P[v]
  if l <= ini-1 <= r:
    A[v] = ini-1
  else:
    A[v] = ini+1
  for nv in T[v]:
    if nv == par:
      continue
    dfs2(nv, A[v], v)
dfs2(r, P[r][0])
print("Yes")
print(*A[1:], sep="\n")

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

INF = 10**10
n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
k = int(input())
VP = tuple(tuple(map(int, input().split())) for _ in range(k))
P = [-1]*(n+1)
A = [-1]*(n+1)
r, c = VP[0]
for v, p in VP:
  P[v] = p
def dfs1(v, par=-1, color=c%2):
  if P[v] == -1:
    l = -INF
    r = INF
  else:
    l = P[v]
    r = P[v]
  for nv in T[v]:
    if nv == par:
      continue
    nl, nr = dfs1(nv, v, color^1)
    l = max(l, nl-1)
    r = min(r, nr+1)
  if l&1 ^ color:
    l += 1
  if r&1 ^ color:
    r -= 1
  if l > r:
    print("No")
    exit()
  P[v] = (l, r)
  return P[v]
dfs1(r)
def dfs2(v, ini, par=-1):
  l, r = P[v]
  if l == r:
    A[v] = l
  else:
    if l <= ini-1 <= r:
      A[v] = ini-1
    else:
      A[v] = ini+1
  for nv in T[v]:
    if nv == par:
      continue
    dfs2(nv, A[v], v)
dfs2(r, P[r][0])
print("Yes")
print(*A[1:], sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
INF = 10**10

h, w = map(int, input().split())
C = [input().rstrip() for _ in range(h)]
def solve(b):
  cost = [[0]*(h+1) for _ in range(h+1)]
  dp = [[INF]*(h+1) for _ in range(h+1)]
  dp[0][0] = 0
  for i in range(h+1):
    for j in range(h+1):
      if i and j:
        cost[i][j] = cost[i-1][j-1] - (C[h-i][b] == C[h-j][b+1])
      else:
        for r in range(min(h-i, h-j)):
          cost[i][j] += C[j+r][b] == C[i+r][b+1]
      if i:
        dp[i][j] = min(dp[i][j], dp[i-1][j]+cost[i-1][j])
      if j:
        dp[i][j] = min(dp[i][j], dp[i][j-1]+cost[i][j-1])
  return dp[h][h]
ans = 0
for b in range(w-1):
  ans += solve(b)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
INF = 10**10
h, w = map(int, input().split())
C = [input().rstrip() for _ in range(h)]
def solve(b):
  cost = [[0]*(h+1) for _ in range(h+1)]
  dp = [[INF]*(h+1) for _ in range(h+1)]
  dp[0][0] = 0
  for i in range(h+1):
    for j in range(h+1):
      if i and j:
        cost[i][j] = cost[i-1][j-1] - (C[h-i][b] == C[h-j][b+1])
      else:
        for r in range(min(h-i, h-j)):
          cost[i][j] += C[j+r][b] == C[i+r][b+1]
      if i:
        dp[i][j] = min(dp[i][j], dp[i-1][j]+cost[i-1][j])
      if j:
        dp[i][j] = min(dp[i][j], dp[i][j-1]+cost[i][j-1])
  return dp[h][h]
ans = 0
for b in range(w-1):
  ans += solve(b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
w, h = map(int, input().split())
P = [int(input()) for _ in range(w)]
Q = [int(input()) for _ in range(h)]
que = [(0, 0, 0)]
t, y, x = 0, 0, 0
seen = [[False]*(w+1) for _ in range(h+1)]
ans = 0
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]
for _ in range((w+1)*(h+1)):
  while seen[y][x]:
    t, y, x = heapq.heappop(que)
  seen[y][x] = True
  ans += t
  for i in range(4):
    ny = y+dy[i]
    nx = x+dx[i]
    if 0<=ny<=h and 0<=nx<=w:
      if seen[ny][nx]:
        continue
      if dy[i]==0:
        heapq.heappush(que, (P[min(x, nx)], ny, nx))
      else:
        heapq.heappush(que, (Q[min(y, ny)], ny, nx))
print(ans)

Fixed submission:
import heapq
w, h = map(int, input().split())
P = [int(input()) for _ in range(w)]
Q = [int(input()) for _ in range(h)]
heapq.heapify(P)
heapq.heapify(Q)
ans = 0
count_x, count_y = 0, 0
while P or Q:
  if not P:
    temp = heapq.heappop(Q)
    ans += temp * (w+1-count_x)
    count_y += 1
  elif not Q:
    temp = heapq.heappop(P)
    ans += temp * (h+1-count_y)
    count_x += 1
  else:
    tp, tq = P[0], Q[0]
    if tp < tq:
      temp = heapq.heappop(P)
      ans += temp * (h+1-count_y)
      count_x += 1
    else:
      temp = heapq.heappop(Q)
      ans += temp * (w+1-count_x)
      count_y += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
while "ST" in s:
  s = s.replace("ST", "")
print(len(s))

Fixed submission:
A = input()
n = len(A)
A += "S"
sc, tc, c = 0, 0, 0
for i in range(n):
  if A[i] == "S":
    sc += 1
  else:
    tc += 1
    if A[i+1] == "S":
      if sc <= tc:
        c += sc
        sc = 0
        tc = 0
      else:
        c += tc
        sc -= tc
        tc = 0
print(n-2*c)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
while "ST" in s:
  s = s.replace("ST", "")
print(len(s))

Fixed submission:
A = input()
n = len(A)
A += "S"
sc, tc, c = 0, 0, 0
for i in range(n):
  if A[i] == "S":
    sc += 1
  else:
    tc += 1
    if A[i+1] == "S":
      if sc <= tc:
        c += sc
        sc = 0
        tc = 0
      else:
        c += tc
        sc -= tc
        tc = 0
print(n-2*c)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a%2 and b%2 and c%2:
  l = sorted(a, b, c)
  print(l[0]*l[1])
else:
  print(0)

Fixed submission:
a, b, c = map(int, input().split())
if a%2 and b%2 and c%2:
  l = sorted([a, b, c])
  print(l[0]*l[1])
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
X = list(map(int, input().split()))
dp = [ [[0]*(n*a+1) for j in range(i+1)] for i in range(n+1) ]
for i in range(n+1):
  dp[i][0][0] = 1
for i in range(n):
  for j in range(i+1):
    for k in range(n*a+1):
      if X[i] > k:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k]
      else:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-X[i]]
        else:
          dp[i+1][j+1][k] = dp[i][j][k-X[i]]
ans = 0
for i in range(1, n+1):
  ans += dp[n][i][a*i]
print(ans)

Fixed submission:
n, a = map(int, input().split())
X = list(map(int, input().split()))
dp = [ [[0]*(n*a+1) for j in range(i+1)] for i in range(n+1) ]
for i in range(n+1):
  dp[i][0][0] = 1
for i in range(n):
  for j in range(i+1):
    for k in range(n*a+1):
      if X[i] > k:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k]
      else:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-X[i]]
        else:
          dp[i+1][j+1][k] = dp[i][j][k-X[i]]
ans = 0
for i in range(1, n+1):
  ans += dp[n][i][a*i]
print(ans)
Buggy python submission (verdict: Runtime Error):
入力 = input()
for i in range(len(入力)-1):
  if 入力[i]==入力[i+1]:
    print(i+1, i+2)
    exit()
  elif i<n-2 and 入力[i]==入力[i+2]:
    print(i+1, i+3)
    exit()
print(-1, -1)

Fixed submission:
入力 = input()
for i in range(len(入力)-1):
  if 入力[i]==入力[i+1]:
    print(i+1, i+2)
    exit()
  elif i<len(入力)-2 and 入力[i]==入力[i+2]:
    print(i+1, i+3)
    exit()
print(-1, -1)
Buggy python submission (verdict: Runtime Error):
import bisect
n, k = input().split()
A = sorted(list({i for i in range(10)} - set(map(int, input().split()))))
greater = False
ans = ""
for i in n:
  if greater:
    ans += str(A[0])
  else:
    t = A[bisect.bisect_left(A, int(i))]
    if t > int(i):
      greater = True
    ans += str(t)
print(ans)

Fixed submission:
n, k = map(int, input().split())
A = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - set(input().split())
while True:
  s = set(str(n))
  if s <= A:
    print(n)
    break
  n += 1
Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
ans = n
y, x = n-x, x
while y != x:
  if x > y:
    y, x = x, y
  ans += 2*x
  y, x = y-x, x
ans += x
print(ans)

Fixed submission:
n, x = map(int, input().split())
ans = n
y, x = n-x, x
if x > y:
  y, x = x, y
while True:
  q, r = divmod(y, x)
  if r == 0:
    ans += (2*q-1)*x
    break
  ans += 2*q*x
  y, x = x, r
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
if s == 'RRR': print(3)
elif s == 'RRS' print(2)
elif s == 'SRR': print(2)
else: print(1)

Fixed submission:
s = input()
if s == 'RRR': print(3)
elif s == 'RRS': print(2)
elif s == 'SRR': print(2)
elif s == 'SSS': print(0)
else: print(1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
l = list(map(int, input().split()))
lo, hi = 0, 9999999999999999
while lo < hi:
    mid = (lo + hi) // 2
    cnt = 0
    for i in range(n):
        if l[i] % mid == 0: cnt += (l[i] // mid) - 1
        else: cnt += (l[i] // mid)
    if cnt <= k: hi = mid
    else: lo = mid + 1
print(lo)

Fixed submission:
n, k = map(int, input().split())
l = list(map(int, input().split()))
lo, hi = 1, 9999999999999999
while lo < hi:
    mid = (lo + hi) // 2
    cnt = 0
    for i in range(n):
        if l[i] % mid == 0: cnt += (l[i] // mid) - 1
        else: cnt += (l[i] // mid)
    if cnt <= k: hi = mid
    else: lo = mid + 1
print(lo)
Buggy python submission (verdict: Time Limit Exceeded):
import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * (n - k + 1)
x = 0
for i in range(1, n):
    l[i] *= l[i - 1]
for i in range(k - 1, n):
    if i == k - 1:
        ans[x] = l[i]
        x -= -1
    else:
        ans[x] = l[i] // l[i - k]
        x -= -1
for i in range(1, len(ans)):
    if ans[i] > ans[i - 1]: print('Yes')
    else: print('No')

Fixed submission:
n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(k, n):
    if l[i] > l[i - k]: print('Yes')
    else: print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = []
for i in range(1, n):
    l[i] *= l[i - 1]
for i in range(k - 1, n):
    if i == k - 1: ans.append(l[i])
    else:
        ans.append(l[i] // l[i - k])
for i in range(1, len(ans)):
    if ans[i] > ans[i - 1]: print('Yes')
    else: print('No')

Fixed submission:
n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(k, n):
    if l[i] > l[i - k]: print('Yes')
    else: print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
import math 
def factors(n):
    fact = []
    i = 1
    while i <= math.sqrt(n): 
        if (n % i == 0) : 
            if (n / i == i):
                fact.append(i) 
            else:
                fact.append(i)
                fact.append(n // i)
        i = i + 1
    return fact
n = int(input())
l = list(map(int, input().split()))
vis = [0] * 1000003
ans = 0
for i in l: vis[i] -= -1
for i in range(n):
    tmp = factors(l[i])
    check = 0
    for j in tmp:
        if vis[j]:
            if j == l[i] and vis[j] > 1: check = 1
            elif j != l[i] and vis[j] > 0: check = 1
        if check: break
    if check == 0: ans -= -1
print(ans)

Fixed submission:
import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n = int(input())
l = list(map(int, input().split()))
l.sort()
vis = [0] * 1000004
for i in l: vis[i] -= -1
for i in range(n):
    tmp = l[i]
    while tmp <= l[n - 1]:
        if vis[tmp]:
            if tmp == l[i]:
                if vis[tmp] > 1: vis[tmp] = 0
            else:
                vis[tmp] = 0
        tmp += l[i]
ans = 0
for i in vis: ans += i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math 
def factors(n):
    fact = []
    i = 1
    while i <= math.sqrt(n): 
        if (n % i == 0) : 
            if (n / i == i):
                fact.append(i) 
            else:
                fact.append(i)
                fact.append(n // i)
        i = i + 1
    return fact
n = int(input())
l = list(map(int, input().split()))
vis = [0] * 1000003
ans = 0
for i in l: vis[i] -= -1
for i in range(n):
    tmp = factors(l[i])
    cnt = 0
    for j in tmp:
        cnt += vis[j]
        if j == l[i]: cnt += -1
    if cnt == 0: ans -= -1
print(ans)

Fixed submission:
import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n = int(input())
l = list(map(int, input().split()))
l.sort()
vis = [0] * 1000004
for i in l: vis[i] -= -1
for i in range(n):
    tmp = l[i]
    while tmp <= l[n - 1]:
        if vis[tmp]:
            if tmp == l[i]:
                if vis[tmp] > 1: vis[tmp] = 0
            else:
                vis[tmp] = 0
        tmp += l[i]
ans = 0
for i in vis: ans += i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in l:
    ans *= i
if ans > 10 ** 18: ans = -1
print(ans)


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in l:
    if i == 0:
        print(0)
        exit()
for i in l:
    ans *= i
    if ans > 10 ** 18: 
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
t1 = []
t2 = []
for i in range(n):
    t1.append(l[i] + i)
    t2.append(i - l[i])
# print(t1, t2)
count = [0] * (2 * 100005)
for i in t1: count[i] -= -1
ans = 0
for i in t2:
    if i > 0:
        if count[i] != 0:
            ans += count[i]
print(ans)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
t1 = []
t2 = []
for i in range(n):
    t1.append(l[i] + i)
    t2.append(i - l[i])
count = {}
for i in t1: count[i] = 0
for i in t2: count[i] = 0
for i in t1: count[i] -= -1
ans = 0
for i in t2:
    if i > 0:
        if count[i] != 0:
            ans += count[i]
print(ans)