alexjercan/bugnet huggingface dataset:
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            primes.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        primes.append(n)
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    while n % 2 == 0:
        n //= 2
        primes.append(2)
    for i in range(3, n + 1, 2):
        while n % i == 0:
            n //= i
            primes.append(i)
        if n == 1:
            break
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd


def prime_factors(n):
    i = 2

    factors = []

    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)

    return factors


A, B = [int(x) for x in input().split()]

print(len(set(prime_factors(gcd(A, B)))) + 1)


Error: TLE

Fixed submission:

import numpy as np


def is_prime(n):
    return n != 1 and not np.any(n % np.arange(2, n) == 0)


A, B = [int(x) for x in input().split()]

N = np.arange(1, min(A, B) + 1)

cd = np.argwhere((A % N == 0) & (B % N == 0)).ravel() + 1
primes = [n for n in cd if is_prime(n)]

print(len(primes) + 1)
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

# D - Disjoint Set of Common Divisors

import fractions

A, B = map(int, input().split())
C = fractions.gcd(A, B)

primes = []
i = 2
while i * i <= C:
    while C % i == 0:
        C //= i
        primes.append(i)
    i += 1
if C > 1:
    primes.append(C)

print(len(set(primes)) + 1)


Error: 0

Fixed submission:

# D - Disjoint Set of Common Divisors

import math

A, B = map(int, input().split())
C = math.gcd(A, B)

primes = []
i = 2
while i * i <= C:
    while C % i == 0:
        C //= i
        primes.append(i)
    i += 1
if C > 1:
    primes.append(C)

print(len(set(primes)) + 1)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
lim = a**0.5 + 10
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)


Error: TLE

Fixed submission:

from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
lim = a // 2
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]
gcd = fractions.gcd(A, B)
C = []
y = 1
while y**2 <= gcd:
    if gcd % y == 0:
        if y >= 2:
            C.append(y)
        if y**2 != gcd:
            C.append(gcd // y)
    y += 1

ans = 1
g = 1
C.sort()
for c in C:
    while gcd % c == 0:
        gcd //= c
        if g != c:
            ans += 1
        g = c

print(ans)


Error: TLE

Fixed submission:

from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]
gcd = fractions.gcd(A, B)

x = 2
ans = 1
g = 1

while gcd > 1:
    if gcd % x == 0:
        gcd //= x
        if g != x:
            ans += 1
        g = x
    else:
        x += 1

print(ans)
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

from collections import defaultdict

A, B = map(int, input().split())


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


d = gcd(A, B)
# print(d)


def f(v):
    dic = defaultdict(int)
    if v == 1:
        dic[1] = 1
        return dic
    for i in range(2, v):
        if i * i > v:
            break
        while v % i == 0:
            v //= i
            dic[i] += 1
    if v != 1:
        dic[v] += 1
    dic[1] = 1
    return dic


divisor = f(d)
# print(divisor)
print(len(divisor))


Error: 0

Fixed submission:

def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def furui(data):
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


a, b = map(int, input().split())
# a, b = 100000000000000, 1000000000000000
a = make_divisors(a)
a = furui(a)
b = make_divisors(b)
b = furui(b)
print(len(set(a) & set(b)) + 1)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

from fractions import gcd

A, B = map(int, input().split())

d = gcd(A, B)
d_ori = d
ans = 1
k = 2
while d > 2:
    plus = 0
    while d % k == 0:
        d //= k
        plus = 1
    ans += plus
    k += 1
    if k > d_ori ** (1 / 2):
        ans += 1
        break
print(ans)


Error: TLE

Fixed submission:

from fractions import gcd

A, B = map(int, input().split())

d = gcd(A, B)
ans = 1
k = 2
while d > 2:
    plus = 0
    while d % k == 0:
        d //= k
        plus = 1
    ans += plus
    k += 1
print(ans)
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

import math

A, B = map(int, input().split())

while B > 0:
    A, B = B, A % B
N = A

ans = 1
for i in [2] + list(range(3, int(math.sqrt(N)) + 2, 2)):
    if N % i == 0:
        while N % i == 0:
            N //= i
        ans += 1
if N > 1:
    ans += 1
print(ans)


Error: 0

Fixed submission:

import math

A, B = map(int, input().split())

N = math.gcd(A, B)
primes = []
if N % 2 == 0:
    primes.append(2)
for i in range(3, int(math.sqrt(N)) + 2, 2):
    if N % i == 0:
        for p in primes:
            if i % p == 0:
                break
        else:
            primes.append(i)
print(len(primes) + 1)
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


A, B = tuple(map(int, input().split(" ")))

print(len(set(prime_factorize(gcd(A, B)))) + 1)


Error: 0

Fixed submission:

from math import gcd


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


A, B = tuple(map(int, input().split(" ")))

print(len(set(prime_factorize(gcd(A, B)))) + 1)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


def prime_factorize(n):
    p = []
    while n % 2 == 0:
        if 2 not in p:
            p.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in p:
                p.append(f)
            n //= f
        else:
            f += 2
    if n != 1 and n not in p:
        p.append(n)
    return p


a, b = map(int, input().split())
q = prime_factorize(gcd(a, b))
# print(q)
print(len(q) + 1)


Error: TLE

Fixed submission:

def gcd(g1, g2):
    x = min(g1, g2)
    y = max(g1, g2)

    if y % x == 0:
        return x
    else:
        return gcd(x, y % x)


def prime_factorize(n):
    p = []
    while n % 2 == 0:
        if 2 not in p:
            p.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in p:
                p.append(f)
                n //= f
        else:
            f += 2
    if n != 1 and n not in p:
        p.append(n)
    return p


a, b = map(int, input().split())
q = prime_factorize(gcd(a, b))
# print(q)
print(len(q) + 1)
Problem p02900 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
    i += 1
print(r + (d > 1))


Error: 0

Fixed submission:

import math

d = math.gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
    i += 1
print(r + (d > 1))
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

import fractions

A, B = map(int, input().split())

G = fractions.gcd(A, B)

res = 1

for i in [2] + list(range(3, int(G**0.5) + 1, 2)):
    if G % i == 0:
        res += 1
        while G % i == 0:
            G //= i

if G > 2:
    res += 1

print(res)


Error: TLE

Fixed submission:

import fractions

primes = [2]


def is_prime(n):
    for p in primes:
        if p * p > n:
            break
        if n % p == 0:
            return False

    return True


A, B = map(int, input().split())

G = int(fractions.gcd(A, B))

res = 1

if G % 2 == 0:
    res += 1
    G //= 2

for i in range(3, G, 2):
    if i > G:
        break
    if not is_prime(i):
        continue
    primes.append(i)
    if G % i == 0:
        res += 1
        G //= i

if G > 1 and is_prime(G) and G not in primes:
    res += 1

print(res)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

import fractions
import math

a, b = map(int, input().split())
greatest = fractions.gcd(a, b)

factor = [1]
max_iter = int(math.sqrt(greatest)) + 1
for i in range(2, max_iter):
    while greatest % i == 0:
        greatest //= i
        factor.append(i)
if greatest != 1:
    factor.append(greatest)
factor = set(factor)
print(len(factor))


Error: TLE

Fixed submission:

a, b = map(int, input().split())
i = 1
common = []
while True:
    if a % i == 0 and b % i == 0:
        a //= i
        b //= i
        common.append(i)
    if min(a, b) < i:
        break
    i += 1

count = 1
for i in range(1, len(common)):
    for j in range(1, i):
        if common[i] % common[j] == 0:
            break
    else:
        count += 1
print(count)
Problem p02900 (Python) — buggy submission, verdict: Time Limit Exceeded

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


A, B = map(int, input().split())
C = gcd(A, B)

ans = []
while C % 2 == 0:
    ans.append(2)
    C //= 2
i = 3
while C >= i * i:
    if C % i == 0:
        ans.append(i)
        C //= i
    else:
        i += 2
if C != 1:
    ans.append(C)
print(len(set(ans)) + 1)


Error: TLE

Fixed submission:

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


A, B = map(int, input().split())
C = gcd(A, B)

ans = []
i = 2
while True:
    if C == 1:
        break
    if C % i != 0:
        i += 1
        continue
    ans.append(i)
    C //= i
print(len(set(ans)) + 1)
Problem p02903 (Python) — buggy submission, verdict: Runtime Error

H, W, A, B = map(int, input().split())
for _ in range(B):
    print("0" * A + "1" * (W - A))
for _ in range(H - B):
    print("1" * A + "0" * (W - A))


Error: 0

Fixed submission:

from math import gcd


H, W, A, B = map(int, input().split())
gcd_hw = gcd(H, W)
gcd_ab = gcd(A, B)
if H == 1:
    print("1" * A + "0" * (W - A))
    exit()
if W == 1:
    print(*("1" * B + "0" * (H - B)), sep="\\n")
    exit()

if H // gcd_hw == B // gcd_ab and W // gcd_hw == A // gcd_ab:
    ans = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(A):
            ans[i][(j + B * i) % W] = 1
    [print("".join(map(str, row))) for row in ans]
else:
    print("No")
Problem p02905 (Python) — buggy submission, verdict: Runtime Error

import sys


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    solo_invs = [0] + [f * i % MOD for f, i in zip(factorials, invs[1:])]

    return factorials, invs, solo_invs


def decompose_inverses(solo_invs, MOD):
    # 各整数 g に対して、g の約数である各 i について dcm[i] を全て足すと 1/g になるような数列を作成
    n = len(solo_invs)
    dcm = solo_invs[:]
    for i in range(1, n):
        d = dcm[i]
        for j in range(2 * i, n, i):
            dcm[j] -= d
    for i in range(1, n):
        dcm[i] %= MOD
    return dcm


n, *aaa = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
LIMIT = max(aaa)
count = [0] * (LIMIT + 1)
double = [0] * (LIMIT + 1)
for a in aaa:
    count[a] += a
    double[a] += a * a
_, _, solo_invs = prepare(LIMIT, MOD)
dcm = decompose_inverses(solo_invs, MOD)

ans = 0
inv2 = solo_invs[2]
for d in range(1, LIMIT + 1):
    ans = (ans + dcm[d] * (sum(count[d::d]) ** 2 - sum(double[d::d])) * inv2) % MOD
print(ans)


Error: 0

Fixed submission:

import sys


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    solo_invs = [0] + [f * i % MOD for f, i in zip(factorials, invs[1:])]

    return factorials, invs, solo_invs


def decompose_inverses(solo_invs, MOD):
    # 各整数 g に対して、g の約数である各 i について dcm[i] を全て足すと 1/g になるような数列を作成
    n = len(solo_invs)
    dcm = solo_invs.copy()
    for i in range(1, n):
        d = dcm[i]
        for j in range(2 * i, n, i):
            dcm[j] -= d
    for i in range(1, n):
        dcm[i] %= MOD
    return dcm


n, *aaa = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
LIMIT = max(aaa)
count = [0] * (LIMIT + 1)
double = [0] * (LIMIT + 1)
for a in aaa:
    count[a] += a
    double[a] += a * a
_, _, solo_invs = prepare(LIMIT, MOD)
dcm = decompose_inverses(solo_invs, MOD)

ans = 0
inv2 = solo_invs[2]
for d in range(1, LIMIT + 1):
    ans = (ans + dcm[d] * (sum(count[d::d]) ** 2 - sum(double[d::d])) * inv2) % MOD
print(ans)
Problem p02909 (Python) — buggy submission, verdict: Runtime Error

S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx >= len(weather):
    print(weather[0])
else:
    print(weather[idx])


Error: 0

Fixed submission:

S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx > len(weather):
    print(weather[0])
else:
    print(weather[idx])
Problem p02909 (Python) — buggy submission, verdict: Runtime Error

import sys

S = sys.stdin.readline().rstrip()

WS = ["Sunny", "Cloudy", "Rainy"]

i = WS.index(S)
i += 1
if i == 3:
    i = 0

print(WS[i])


Error: 0

Fixed submission:

import sys

S = sys.stdin.readline().rstrip()

WS = ["Sunny", "Cloudy", "Rainy"]

i = WS.index(S)
i += 1
if i == 2:
    i = 0

print(WS[i])
Problem p02909 (Python) — buggy submission, verdict: Runtime Error

w = input()
weather = ["Sunny", "Cloudy", "Rainy"]

index = weather.index(w)
index += 1
if index == 3:
    index = 0

print(weather[index])


Error: 0

Fixed submission:

w = input()
weather = ["Sunny", "Cloudy", "Rainy"]

index = weather.index(w)
index += 1
if index == 2:
    index = 0

print(weather[index])
Problem p02909 (Python) — buggy submission, verdict: Runtime Error

s = input()

weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[(weather.index(s) + 1) % 3])


Error: 0

Fixed submission:

s = input()

weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[weather.index(s) + 1])
Problem p02910 (Python) — buggy submission, verdict: Runtime Error

li = list(input())

for i in range(len(li)):
    if i % 2 == 1:
        if li[i] == "R":
            print("No")
            quit()
        else:
            continue
    else:
        if li[i] == "L":
            print("No")
            quit()
        else:
            continue
print("Yes")


Error: TypeError: 'builtin_function_or_method' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02910/Python/s460535863.py", line 5, in <module>
    if len[i] == "R":
TypeError: 'builtin_function_or_method' object is not subscriptable


Fixed submission:

li = list(input())

for i in range(len(li)):
    if i % 2 == 0:
        if len[i] == "R":
            print("No")
            quit()
    else:
        if len[i] == "L":
            print("No")
            quit()
print("Yes")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

n, k, q = map(int, input().split())
arr = [k - q] * n

for _ in range(q):
    winner_id = int(input()) - 1
    arr[winner_id] += 1

for ele in arr:
    if ele > 0:
        print("Yes")
    else:
        print("No")


Error: TLE

Fixed submission:

n, k, q = map(int, input().split())
arr = [k for _ in range(n)]

for _ in range(q):
    winner_id = int(input()) - 1
    arr = [ele - 1 for ele in arr]
    arr[winner_id] += 1

for ele in arr:
    if ele > 0:
        print("Yes")
    else:
        print("No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N, K, Q, *A = map(int, open(0).read().split())
    ans = [0] * N
    for a in A:
        ans[a - 1] += 1
    print("\\n".join(["Yes" if Q < K + a else "No" for a in ans]))
    return


main()


Error: TLE

Fixed submission:

def main():
    N, K, Q, *A = map(int, open(0).read().split())
    A = [K + A.count(i) for i in range(1, N + 1)]
    print("\\n".join(["Yes" if Q < a else "No" for a in A]))
    return


main()
Problem p02911 (Python) — buggy submission, verdict: Runtime Error

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
p = k - q
s = [p] * n
for i in a:
    s[i - 1] += 1

for i in s:
    if i < 1:
        print("No")
    else:
        print("Yes")


Error: WA

Fixed submission:

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
p = k - q
s = [[i, p] for i in range(n)]
for i in a:
    s[i][1] += 1

for i in s:
    if i[1] < 1:
        print("No")
    else:
        print("Yes")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

n, k, q = map(int, input().split())
nList = [0] * n
for _ in range(q):
    nList[int(input()) - 1] += 1
for j in range(n):
    print("Yes" if k + nList[j] - q > 0 else "No")


Error: TLE

Fixed submission:

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
for i in range(n):
    print("Yes" if k + a.count(i + 1) - q > 0 else "No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

nkq = list(map(int, input().split()))
n, k, q = nkq[0], nkq[1], nkq[2]
attendees = dict()
for i in range(n):
    attendees[i] = 0

respondents = [int(input()) for i in range(q)]

for r in respondents:
    r_index = r - 1
    attendees[r_index] += 1

for i, p in attendees.items():
    point = p + k - q
    if point > 0:
        print("Yes")
    else:
        print("No")


Error: TLE

Fixed submission:

nkq = list(map(int, input().split()))
n, k, q = nkq[0], nkq[1], nkq[2]
attendees = dict()
for i in range(n):
    attendees[i] = k

attendees = [(i, k) for i in range(n)]

respondents = [int(input()) for i in range(q)]

for r in respondents:
    r_index = r - 1
    for a in attendees:
        i, p = a
        if i != r_index:
            attendees[i] = (i, p - 1)

for a in attendees:
    i, p = a
    if p > 0:
        print("Yes")
    else:
        print("No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")


Error: TLE

Fixed submission:

import numpy as np

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K] * N
np = np.array(N_array)
for x in A:
    np -= 1
    np[x - 1] += 1
for z in np:
    if z > 0:
        print("Yes")
    else:
        print("No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K, Q = [int(i) for i in input().split()]
points = [(K - Q)] * N
for _ in range(Q):
    answer = int(input())
    points[answer - 1] += 1
for p in points:
    print("Yes" if p > 0 else "No")


Error: TLE

Fixed submission:

def update_points(points, current_ansewr):
    return list(
        map(
            lambda x: x[1] if (x[0] + 1) == current_ansewr else x[1] - 1,
            enumerate(points),
        )
    )


N, K, Q = [int(i) for i in input().split()]
points = [K] * N
for _ in range(Q):
    answer = int(input())
    points = update_points(points, answer)
for p in points:
    print("Yes" if p > 0 else "No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    points = [K for _ in range(N)]
    points = list(map(lambda x: x - Q, points))

    for i in A:
        points[i - 1] += 1

    for i in points:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    points = [K for _ in range(N)]

    for i in A:
        points = list(map(lambda x: x - 1, points))
        points[i - 1] += 1

    for i in points:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

points = [K for _ in range(N)]

for i in range(Q):
    points[A[i] - 1] += 1

for j in range(N):
    points[j] -= Q

for j in range(N):
    if points[j] >= 1:
        print("Yes")
    else:
        print("No")


Error: TLE

Fixed submission:

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

points = [K for _ in range(N)]

for i in range(Q):
    points[A[i] - 1] += 1
    for j in range(N):
        points[j] -= 1

for j in range(N):
    if points[j] >= 1:
        print("Yes")
    else:
        print("No")
Problem p02911 (Python) — buggy submission, verdict: Runtime Error

n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()) - 1)
score = [0 for _ in range(n)]

for a_i in a:
    score[a_i] += 1

for i in range(n):
    result = k - q + score[i]
    print("Yes" if result > 0 else "No")


Error: IndexError: list assignment index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02911/Python/s560201752.py", line 4, in <module>
    a[i] = int(input()) - 1
IndexError: list assignment index out of range


Fixed submission:

n, k, q = map(int, input().split())
a = []
for i in range(q):
    a[i] = int(input()) - 1
score = [0 for _ in range(n)]

for a_i in a:
    score[a_i] += 1

for i in range(n):
    result = k - q + score[i]
    print("Yes" if result > 0 else "No")
Problem p02911 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K, Q = map(int, input().split())
ans_r = [K - Q] * N
cor = list(map(int, [input() for i in range(Q)]))
for i in cor:
    ans_r[i - 1] += 1
for i in ans_r:
    if i <= 0:
        print("No")
    else:
        print("Yes")


Error: TLE

Fixed submission:

N, K, Q = map(int, input().split())
ans_r = [K] * N
cor = list(map(int, [input() for i in range(Q)]))
for i in cor:
    ans_r[i - 1] += 1
    ans_r = list(map(lambda x: x - 1, ans_r))
ans_r = list(map(lambda x: "No" if x <= 0 else "Yes", ans_r))
for i in ans_r:
    print(i)