Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
class Problem:
  def __init__(self, score, number, bonus):
    self.score = score
    self.number = number
    self.bonus = bonus
    
  def score_at(self, number):
    if number >= self.number:
      return self.number * self.score + self.bonus
    return number * self.score


D, G = (int(x) for x in input().split())

problems = []

for i in range(1, D + 1):
  n, b = (int(x) for x in input().split())
  problems.append(Problem(i * 100, n, b))

memo = [[0] * 1001 for _ in range(D)]

def solve():
  for number in range(0, 1001):  # 解いた問題数
    for i in range(D):
      # 一行目の初期化
      if i == 0:
        memo[i][number] = problems[i].score_at(number)
      else:
        memo[i][number] = max(
          memo[i - 1][number - n] +problems[i].score_at(n)
          for n in range(0, number + 1)
        )
    if memo[D - 1][number] >= G:
      return number

print(solve())  

Fixed submission:
import sys

INF = sys.maxsize
D, G = map(int, input().split())

class P:
  def __init__(self, index, number, bonus):
    self.index = index
    self.number = number
    self.bonus = bonus
    
  @property
  def score(self):
    return (self.index + 1) * 100
   
  @property
  def complete_score(self):
    return self.score * self.number + self.bonus
  
  # score 獲得するのに必要な解答数
  def cost_of(self, score):
    if score > self.complete_score:
      return INF
    if score == 0:
      return 0
    if score < self.score:
      return 1
    return min(score // self.score, self.number)
  
problems = []
for i in range(D):
  p, c = map(int, input().split())
  problems.append(P(i, p, c))
  
min_number_of_solved = INF

for m in range(1 << D):
  total = 0
  number_of_solved = 0
  uncompleted = set()
  
  for i, p in enumerate(problems):
    if 1 << i & m:  # 完答
      total += p.complete_score
      number_of_solved += p.number
    else:
      uncompleted.add(p)

  # 他の問題を解かなくても条件を満たしている
  if total >= G:
    min_number_of_solved = min(
      min_number_of_solved, 
      number_of_solved
    )
  # 残りの必要点数を最小コストで獲得できる問題を中途半端に解く
  else:
    # 不足する点を最小コストで獲得できる問題を探す
    m = min(uncompleted, key=lambda x: x.cost_of(G - total))
        
    min_number_of_solved = min(
      min_number_of_solved, 
      number_of_solved + m.cost_of(G - total)
    )
                   
print(min_number_of_solved)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import namedtuple
from heapq import heappush, heappop

INF = sys.maxsize

P = namedtuple('P', 'cost v')
Edage = namedtuple('Edge', 'to cost')

n, m, s, t = map(int, input().split())

s, t = s - 1, t - 1

# 円とスヌークそれぞれグラフを構成する
Yen = [[] for _ in range(n)]
Snuuk = [[] for _ in range(n)]

for _ in range(m):
  u, v, a, b = map(int, input().split())
  
  u, v = u - 1, v - 1
  
  Yen[u].append(Edage(v, a))
  Yen[v].append(Edage(u, a))
  Snuuk[u].append(Edage(v, b))
  Snuuk[v].append(Edage(u, b))

  
def min_costs(graph, start):
  costs = [INF] * n
  costs[start] = 0
  
  q = [P(0, start)]
  
  while q:
    cost, v = heappop(q)
    if cost > costs[v]:
      continue
    for to, cost in graph[v]:
      if costs[to] > costs[v] + cost:
        costs[to] = costs[v] + cost
        heappush(q, P(costs[to], to))        
        
  return costs
  
total_costs = [
  min_costs(Yen, s)[i] + min_costs(Snuuk, t)[i] 
  for i in range(n)
]

# 両替所が閉鎖されていく
for i in range(n - 1, 0, -1):
  total_costs[i - 1] = min(total_costs[i - 1], total_costs[i])
                      
    
for i in range(n):
  print(10 ** 15 - total_costs[i])
  
  

Fixed submission:
import sys
from collections import namedtuple
from heapq import heappush, heappop


INF = sys.maxsize
Edge = namedtuple('Edge', 'to yen snuuk')
Vertex = namedtuple('Vertex', 'cost id')

n, m, s, t = map(int, input().split())

edges = [[] for _ in range(n + 1)]

for _ in range(m):
  u, v, a, b = map(int, input().split())
  edges[u].append(Edge(v, a, b))
  edges[v].append(Edge(u, a, b))

costs_in_yen = [INF] * (n + 1)
costs_in_snuuk = [INF] * (n + 1)

q = []

heappush(q, Vertex(0, s))
costs_in_yen[s] = 0

while q:
  v = heappop(q)
  if v.cost > costs_in_yen[v.id]:
    continue
  for edge in edges[v.id]:
    if v.cost + edge.yen < costs_in_yen[edge.to]:
      costs_in_yen[edge.to] = v.cost + edge.yen
      heappush(q, Vertex(costs_in_yen[edge.to], edge.to))
      
heappush(q, Vertex(0, t))
costs_in_snuuk[t] = 0

while q:
  v = heappop(q)
  if v.cost > costs_in_snuuk[v.id]:
    continue
  for edge in edges[v.id]:
    if v.cost + edge.snuuk < costs_in_snuuk[edge.to]:
      costs_in_snuuk[edge.to] = v.cost + edge.snuuk
      heappush(q, Vertex(costs_in_snuuk[edge.to], edge.to))      

# n 年後の手持ち snuuk の最大額
snuuk_in_hand = [0] * (n + 1)

for i in range(n - 1, -1, -1):
  snuuk_in_hand[i] = max(
    snuuk_in_hand[i + 1],
    10**15 - costs_in_yen[i + 1] - costs_in_snuuk[i + 1]
  )

for i in range(0, n):
  print(snuuk_in_hand[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

# 最大値
n = numbers.pop()

# nCk を k < n の範囲で事前に計算する
memo = [0] * (n + 1)

# nC1 = n
memo[1] = n

for i in range(2, n):
  # memo[i] = memo[i - 1] * (n - i + 1) // i
  memo[i] = 2

max_value = 0
max_at = 0

for i in numbers:
  if max_value < memo[i]:
    max_value = memo[i]
    max_at = i

print(n, max_at)        

Fixed submission:
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

n = numbers.pop()
r = min(numbers, key=lambda x: abs(x - n / 2))  # N

print(n, r)

Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

# 最大値
n = numbers.pop()

# nCk を k < n の範囲で事前に計算する
memo = [0] * (n + 1)

# nC1 = n
memo[1] = n

for i in range(2, n):
  memo[i] = memo[i - 1] * (n - i + 1) // i

max_value = 0
max_at = 0

for i in numbers:
  if max_value < memo[i]:
    max_value = memo[i]
    max_at = i

print(n, max_at)        

Fixed submission:
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

n = numbers.pop()
r = min(numbers, key=lambda x: abs(x - n / 2))  # N

print(n, r)

Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

# 最大値
n = numbers.pop()

# nCk を k < n の範囲で事前に計算する
memo = [0] * n

# nC1 = n
memo[1] = n

for i in range(2, n):
  memo[i] = memo[i - 1] * (n - i + 1) // i

max_value = 0
max_at = 0

for i in numbers:
  if max_value < memo[i]:
    max_value = memo[i]
    max_at = i
          
print(n, max_at)        

Fixed submission:
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

n = numbers.pop()
r = min(numbers, key=lambda x: abs(x - n / 2))  # N

print(n, r)
Buggy python submission (verdict: Time Limit Exceeded):
N, H = map(int, input().split())

A = []
B = []

for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  

def solve():
  count = 0
  remain = H
  
  B.sort()
  
  max_a = max(A)
  
  while B:
    if remain <= 0:
      return count
    
    b = B.pop()
    
    if b < max_a:
      break
      
    remain -= b
    count += 1
      
  while remain > 0:
    remain -= max_a
    count += 1
    
  return count

print(solve())

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

A = []
B = []

for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  

def solve():
  count = 0
  remain = H
  
  B.sort()
  
  max_a = max(A)
  
  while B:
    if remain <= 0:
      return count
    
    b = B.pop()
    
    if b < max_a:
      break
      
    remain -= b
    count += 1
  
  count += (remain + max_a - 1) // max_a
    
  return count

print(solve())
Buggy python submission (verdict: Runtime Error):
from bisect import bisect, bisect_left


size = 10 ** 5 + 1

is_prime = [True] * size
is_prime[0] = is_prime[1] = False

# √size まで
for i in range(2, 317):
  j = 2 * i
  while j < size:
    is_prime[j] = False
    j += i

like_numbers = [
  i 
  for i, x in enumerate(is_prime)
  if x and (i + 1) % 2 == 0 and is_prime[(i + 1) // 2]
]

Q = int(input())

for _ in range(Q):
  l, r = map(int, input().split())
  if l == r:
    print(1 if l in like_numbers else 0)
  else:
    print(bisect(like_numbers, r) - bisect_left(like_numbers, l))  
  

Fixed submission:
x = int(input())

print(48 - x)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))

count = 0

for i in range(N):
  if P[i] == i + 1:
    if i == N:
      P[i - 1], P[i] = P[i], P[i - 1]      
    else:
      P[i], P[i + 1] = P[i + 1], P[i]
    count += 1

print(count)    

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

count = 0

for i in range(N):
  if P[i] == i + 1:
    if i + 1 == N:
      P[i - 1], P[i] = P[i], P[i - 1]      
    else:
      P[i], P[i + 1] = P[i + 1], P[i]
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import namedtuple
from heapq import heappush, heappop

input = stdin.readline


class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n + 1)]
    self.size = [1] * (n + 1)

  def is_same(self, a, b):
    return self.find(a) == self.find(b)

  def unite(self, a, b):
    a = self.find(a)
    b = self.find(b)  
    if self.size[a] < self.size[b]:
      a, b = b, a
    self.par[b] = a
    self.size[a] += self.size[b]

  def size_of(self, a):
    return self.size[self.find(a)]

  def find(self, a):
    if a == self.par[a]:
      return a
    self.par[a] = self.find(self.par[a])
    return self.par[a]

Edge = namedtuple('Edge', 'w s t')
X = namedtuple('X', 'x i')
Y = namedtuple('Y', 'y i')

N = int(input())

edges = []
xg = []
yg = []

for i in range(N):
  x, y = map(int, input().split())
  xg.append(X(x, i))
  yg.append(Y(y, i))

xg.sort()
yg.sort()

for i in range(N - 1):
  x1, a = xg[i]
  x2, b = xg[i + 1]
  heappush(edges, Edge(abs(x1 - x2), a, b))

for i in range(N - 1):
  y1, a = yg[i]
  y2, b = yg[i + 1]
  heappush(edges, Edge(abs(y1 - y2), a, b))

u = UnionFind(N)
cost = 0

while edges:
  if u.size_of(0) >= N:
    break

  w, s, t = heappop(edges)
  if u.is_same(s, t):
    continue
  u.unite(s, t)
  cost += w

print(cost)


Fixed submission:
X, A, B = map(int, input().split())

if B - A <= 0:
  print('delicious')
elif B - A <= X:
  print('safe')
else:
  print('dangerous')
Buggy python submission (verdict: Runtime Error):
from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max

N = int(input())

numbers = [int(x) for x in input().split()]

left = numbers[:N]
heapify(left)

right = numbers[2 * N:]
_heapify_max(right)

for x in numbers[N:2 * N]:
  if left[0] < x < right[0]:
    if abs(left[0] - x) > abs(left[0] - x):
      heappushpop(left, x)
    else:
      _heappushpop_max(right, x)
  elif x > left[0]:
    heappushpop(left, x)
  elif -x > right[0]:
    heappushpop(right, -x)
    
print(sum(left) - sum(right))


Fixed submission:
from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max

N = int(input())

numbers = [int(x) for x in input().split()]

left = numbers[:N]
left_sum = sum(left)
left_memo = [0] * N
heapify(left)

right = numbers[2 * N:]
right_sum = sum(right)
right_memo = [0] * N
_heapify_max(right)

middle = numbers[N:2 * N]

for i in range(0, N):
  left_sum += (middle[i] - heappushpop(left, middle[i]))
  left_memo[i] = left_sum

for i in range(N - 1, -1, -1):
  right_sum += (middle[i] - _heappushpop_max(right, middle[i]))
  right_memo[i] = right_sum

left_memo.insert(0, sum(numbers[:N]))
right_memo.insert(0, None)
right_memo.append(sum(numbers[2 * N:]))
    
print(
  max([left_memo[i] - right_memo[i + 1] for i in range(N + 1)])
)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations, tee

N, M = map(int, input().split())
edges = set()
for _ in range(N):
   a, b = map(int, input().split())
   edges.add((a, b))   

def each_cons(iterable):
  a, b = tee(iterable)
  next(b, None)
  return zip(a, b)

cases = list(permutations(range(2, N + 1), N - 1))

count = 0

def is_available(edge):
  return edge in edges or edge[::-1] in edges

for numbers in cases:
  if all(map(is_available, each_cons((1,) + numbers))):
    count += 1
         
print(count)         

Fixed submission:
from itertools import permutations, tee

N, M = map(int, input().split())
edges = set()

for _ in range(M):
    edges.add(tuple(map(int, input().split())))


def each_cons(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


def is_available(edge):
    return edge in edges or edge[::-1] in edges


cases = permutations(range(2, N + 1), N - 1)

count = 0

for numbers in cases:
    if all(map(is_available, each_cons((1,) + numbers))):
        count += 1


print(count)
Buggy python submission (verdict: Runtime Error):
import math
from decimal import Decimal

a,b=map(float,input().split())

a=int(a)
x=math.floor(b)
y=decimal(b-x)

print(a*x+math.floor(a*y))


Fixed submission:
import math
from decimal import Decimal

a,b=map(str,input().split())

#パソコンは数値は2進数で表現しますが、2進数では小数点を正確に表現することができないため
#10進数表記に変える
#小数点を文字列型で定義する
a=Decimal(a)
b=Decimal(b)

print(math.floor(a*b))

Buggy python submission (verdict: Runtime Error):
import math
from decimal import decimal

a,b=map(input().split())

#パソコンは数値は2進数で表現しますが、2進数では小数点を正確に表現することができないため
#10進数表記に変える
#小数点を文字列型で定義する
a=decimal(a)
b=decimal(b)

print(math.floor(a*b))


Fixed submission:
import math
from decimal import Decimal

a,b=map(str,input().split())

#パソコンは数値は2進数で表現しますが、2進数では小数点を正確に表現することができないため
#10進数表記に変える
#小数点を文字列型で定義する
a=Decimal(a)
b=Decimal(b)

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


f= False
for d  in range (a,b+1):
    if d % k == 0:
        f=True
        break


if f :
    print('OK')
else :
    print('NG')


Fixed submission:
n,k = map(int,input().split())
a=[0 for i in range(n)]
for i in range(k):
    di = int(input())
    ai = list(map(int,input().split()))
    for j in range(len(ai)):
        a[ai[j]-1] = 1

print(a.count(0))
Buggy python submission (verdict: Runtime Error):
x=int(input())

a=int(100)
for i in range (3800)  :
    a=int(a*1.01)
    #a=round(a) roundは四捨五入、intは切り捨て
    if a < x:
        continue
    else:
        break

print(i+1)　
#range関数によるリストは1番目が0

Fixed submission:
x=int(input())

a=int(100)
for i in range (3800)  :
    a=int(a*1.01)
    #a=round(a) roundは四捨五入、intは切り捨て
    if a < x:
        continue
    else:
        break

print(i+1)
#range関数によるリストは1番目が0
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[0 for i in range(n)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))


Fixed submission:
n=int(input())
a=[0 for i in range(n+1)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[0 for i in range(n)]
for i in range(m): #0,1,
    if i%3!=0 and i%5!=0:
        a[i]=int(i+1)

print(sum(a))


Fixed submission:
n=int(input())
a=[0 for i in range(n+1)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
P = [int(input()) for i in range(N)]

L = sorted([abs(X-p) for p in P])
if 0 not in L :
    print(X)
    exit()

DL = list(set([x for x in L if L.count(x) > 1]))

ans_abs = 1
for i,x in enumerate(DL) :
    if x == i+1 :
        ans_abs += 1
    else :
        break

if X-ans_abs in P :
    print(X+ans_abs)
else :
    print(X-ans_abs)


Fixed submission:
import itertools
X,N = map(int,input().split())

if N == 0 :
    print(X)
    exit()

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

L = sorted([abs(X-p) for p in P])
if 0 not in L :
    print(X)
    exit()

DL = list(set([x for x in L if L.count(x) > 1]))

ans_abs = 1
for i,x in enumerate(DL) :
    if x == i+1 :
        ans_abs += 1
    else :
        break

if X-ans_abs in P :
    print(X+ans_abs)
else :
    print(X-ans_abs)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
inc = abs(N-K)

if N <= inc :
    print(N)
else :
    print(N%inc)

Fixed submission:
N,K = map(int,input().split())
inc = abs(N-K)

if N <= inc :
    print(N)
elif K/2 < N%K :
    print(K-N%K)
else :
    print(N%K)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
dict = {}
 
if M == 0 :
    if N == 1 :
        print(0)
    else :
        print(10**(N-1))
    exit()
 
for x in L :
    dict.setdefault(x[0],[])
    dict[x[0]].append(x[1])
dict.setdefault(1,[1])
 
for k,v in dict.items():
    dict[k] = set(v)
 
ansList = ["0"]*N
for i in range(N) :
    if i+1 in dict :
        ansList[i] = str(list(dict[i+1])[0])
 
isZeroHead = 2 <= N and ansList[0] == "0"
isOverlapping = any([ 2 <= len(v) for v in dict.values()])  
ans = -1 if isZeroHead or isOverlapping else int("".join(ansList))
 
# print(dict)
# print("isZeroHead :",isZeroHead)
# print("isOverlapping :",isOverlapping)
print(ans)

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

l = [ A[i+1]-A[i] for i in range(N-1)]
l.append( K-A[-1] + A[0] )

l.remove(max(l))
print(sum(l))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
count = 0

for i,p in enumerate(P) :
    pj_min = min(P[:i+1])
    if p <= pj_min :
        count += 1
    
print(count)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
count = 0
minlist = []

for i,p in enumerate(P) :
    if i == 0 :
        minlist.append(p)
        continue

    if p < minlist[i-1] :
        minlist.append(p)
    else:
        minlist.append(minlist[i-1])
    
for i,p in enumerate(P) :
    pj_min = minlist[i]
    if p <= pj_min :
        count += 1
    
print(count)
Buggy python submission (verdict: Runtime Error):
import string
l = string.ascii_uppercase

N = int(input())
S = input()

ans = []
plusNumber = N % 26
for c in S :
    ans.append(l[l.index(c) + plusNumber])
print("".join(ans))

Fixed submission:
import string
l = string.ascii_uppercase

N = int(input())
S = input()

ans = []
for c in S :
    plusNumber = (l.index(c) + N) % 26
    ans.append(l[plusNumber])
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
A=tuple(map(int,input().split()))
X=[None]*N
for i in range(N) :
    X[i]=str(A.index(i+1)+1)
print(" ".join(X))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
X=[None]*N
for i in range(N) :
    X[A[i]-1]=i+1
print(*X)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
X=[None]*N
for i in range(N) :
    X[i]=str(A.index(i+1)+1)
print(" ".join(X))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
X=[None]*N
for i in range(N) :
    X[A[i]-1]=i+1
print(*X)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
X=[]
for i in range(N) :
    X.append(str(A.index(i+1)+1))
print(" ".join(X))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
X=[None]*N
for i in range(N) :
    X[A[i]-1]=i+1
print(*X)
Buggy python submission (verdict: Runtime Error):
import sys
N,K,Q =map(int,input().split())
F = {}
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    F[str('A'+ str(i+1))] = K - (Q - cnt)
    if F[str('A'+ str(i+1))] >= 1 :
        print("Yes")
    else:
        print("No")


Fixed submission:
N=input()
if N == "Sunny" :
    print("Cloudy")
elif N == "Cloudy" :
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K,Q =map(int,input().split())
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    Point = K - (Q - cnt)
    if Point >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K,Q =map(int,input().split())
F = {}
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    Point = F[str('A'+ str(i+1))] = K - (Q - cnt)
    if Point >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K,Q =map(int,input().split())
F = {}
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    F[str('A'+ str(i+1))] = K - (Q - cnt)
    if F[str('A'+ str(i+1))] >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K,Q =map(int,input().split())
F = {}
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    F[str('A'+ str(i+1))] = K - (Q - cnt)
for i in range(N) :
    if F[str('A'+ str(i+1))] >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K,Q =map(int,input().split())
F = {}
a = []
for l in sys.stdin:
    a.append(int(l))

for i in range(N):
    F[str('A'+ str(i+1))] = K
for i in range(N):
    cnt = a.count(i+1)
    F[str('A'+ str(i+1))] = F[str('A'+str(i+1))] - (Q - cnt)
for i in range(N) :
    if F[str('A'+ str(i+1))] >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q =map(int,input().split())
FP = [K]*N
S = []
for i in range(Q):
    S.append(int(input()))
S.sort()
for i in range(N):
    FP[i] -= Q - S.count(i+1)
for i in FP :
    if i >= 1 :
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
L=[K]*N
for i in range(Q):
    A=int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0 :
        print("Yes")
    else :
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
M = [input() for i in range(N)]

M_sorted = [''.join(sorted(m)) for m in M]
M_setlist = list(set(M_sorted))
ans = 0

for m in M_setlist :
    c =M_sorted.count(m)
    if c == 2 :
        ans += 1
    elif 3 <= c :
        ans += (c**2 -c*3)/2 + c

print(int(ans))

Fixed submission:
N = int(input())
M = [input() for i in range(N)]
 
M_sorted = [''.join(sorted(m)) for m in M]
d = {}
ans = 0
 
for m in M_sorted :
    d.setdefault(m,0)
    ans += d[m]
    d[m] += 1
 
print(ans)
Buggy python submission (verdict: Runtime Error):
YM=0
MY=0
F=int(X[0] + X[1])
B=int(X[2] + X[3])
if 0<F<=12 :
    MY += 1
else:
    pass

if 0<B<=12 :
    YM += 1
else:
    pass

if YM == 1 and MY == 1 :
    print("AMBIGUOUS")
elif YM == 1 and MY == 0 :
    print("YYMM")
elif YM == 0 and MY == 1 :
    print("MMYY")
else :
    print("NA")

Fixed submission:
X=input()
YM=0
MY=0
F=int(X[0] + X[1])
B=int(X[2] + X[3])
if 0<F<=12 :
    MY += 1
else:
    pass

if 0<B<=12 :
    YM += 1
else:
    pass

if YM == 1 and MY == 1 :
    print("AMBIGUOUS")
elif YM == 1 and MY == 0 :
    print("YYMM")
elif YM == 0 and MY == 1 :
    print("MMYY")
else :
    print("NA")