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

n = int(input())
lst = list(map(int, input().split()))

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)


Error: TLE

Fixed submission:

n = int(input())
lst = list(map(int, input().split()))

cnt = 0
tmp = []
for i in range(len(lst)):
    num = lst[i]
    tmp.append(num)
    if num == min(tmp):
        cnt += 1

print(cnt)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    n_min = 0
    for i in range(0, n):
        if i == 0:
            count += 1
            n_min = p[i]
            continue
        if p[i] <= n_min:
            count += 1
            n_min = p[i]
    print(count)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    for i in range(0, n):
        for j in range(0, i + 1):
            if p[i] > p[j]:
                break
            elif j == i:
                count += 1
    print(count)


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

N = int(input())
P = [int(x) for x in input().split()]
count = 0
check = 0
min = 10**9
for i in P:
    check = 0
    if min > i:
        min = i
    if i <= min:
        count += 1

print(count)


Error: TLE

Fixed submission:

N = int(input())
P = [int(x) for x in input().split()]
count = 0
check = 0
for i in range(N):
    check = 0
    for j in range(i):
        if P[i] > P[j]:
            check = 1
            break
    if check == 0:
        count += 1

print(count)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0
n_p = 0
for i in range(N):
    if i == 0:
        ans += 1
        n_p = P[0]
        continue

    if P[i] <= n_p:
        ans += 1

    if n_p > P[i]:
        n_p = P[i]


print(ans)


Error: TLE

Fixed submission:

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

ans = 0
for i in range(N):
    if i == 0:
        ans += 1
        continue

    if P[i] <= min(P[:i]):
        ans += 1

print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = list([int(x) for x in input().split()])
count = 0

min_a = N + 1

for a in A:
    if a == min(min_a, a):
        count += 1
        min_a = a

print(count)


Error: TLE

Fixed submission:

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
end_set = set()
count = 0

for a in A:
    if not end_set:
        count += 1
    elif a == min(min(end_set), a):
        count += 1
    end_set.add(a)

print(count)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
m = p_n[0]
for i in range(1, n):
    if m > p_n[i]:
        ans += 1
    m = min(m, p_n[i])
    p_i_1.append(p_n[i])
    if m == 1:
        break
print(ans)


Error: TLE

Fixed submission:

n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
for i in range(1, n):
    if min(p_i_1) > p_n[i]:
        ans += 1
    p_i_1.append(p_n[i])
print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
P = [int(x) for x in input().split()]
mins = [0] * N
mins[0] = P[0]
for n in range(1, N):
    mins[n] = min(P[n], mins[n - 1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)


Error: TLE

Fixed submission:

N = int(input())
P = [int(x) for x in input().split()]
ans = 0
m = 0
for i in range(N):
    for j in range(m, i):
        if P[i] > P[j]:
            m = j
            break
    else:
        ans += 1
print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    p = input_to_int_tuple()

    cnt = 0
    pre_min = 10**6
    for i in range(n):

        if i == 0 or p[i] <= pre_min:
            cnt += 1

        pre_min = min(pre_min, p[i])

        # temp = True
        # for j in range(i):
        #     if p[i] > p[j]:
        #         temp = False
        #         break
        # if temp:
        #     cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    p = input_to_int_tuple()

    cnt = 0
    for i in range(n):

        if i == 0 or p[i] <= min(p[:i]):
            cnt += 1

        # temp = True
        # for j in range(i):
        #     if p[i] > p[j]:
        #         temp = False
        #         break
        # if temp:
        #     cnt += 1

    print(cnt)


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

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

count = 1
mini = P[0]
for i in range(1, N):
    if mini >= P[i]:
        count += 1
        mini = P[i]

print(count)


Error: TLE

Fixed submission:

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

count = 1
for i in range(1, N):
    if P[i] <= min(P[:i]):
        count += 1
print(count)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
P = list(map(int, input().split()))
ans = 1
dp = [0 for i in range(N + 1)]
dp[0] = P[0]  # min
for i in range(N - 1):
    if P[i + 1] <= dp[i]:
        ans += 1
        dp[i + 1] = P[i + 1]
    else:
        dp[i + 1] = dp[i]

print(ans)


Error: TLE

Fixed submission:

N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(0, i):
        if P[j] < P[i]:
            break
    else:
        ans += 1
print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 1
base = p[0]

for i in range(1, n):
    if p[i] < base:
        ans += 1
        base = p[i]

print(ans)


Error: TLE

Fixed submission:

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

ans = 0

for i in range(n):
    baes = p[i]
    flag = True
    for j in range(i):
        if p[i] > p[j]:
            flag = False
            break

    if flag:
        ans += 1

print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

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

cnt = 1
p_min = P[0]

for i in range(1, N):
    if P[i] < p_min:
        cnt += 1
        p_min = P[i]

print(cnt)


Error: TLE

Fixed submission:

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

cnt = 1

for i in reversed(range(1, N)):
    if P[i] < min(P[:i]):
        cnt += 1

print(cnt)
Problem p02791 (Python) — buggy submission, verdict: Runtime Error

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

ret = 0
currmin = P[0]
for i in range(N):
    if P[i] <= currmin:
        currmin = P[i]
        ret += 1

print(ret)


Error: TypeError: 'map' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02791/Python/s629344950.py", line 5, in <module>
    currmin = P[0]
TypeError: 'map' object is not subscriptable


Fixed submission:

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

ret = 0
currmin = P[0]
for i in range(N):
    if P[i] <= currmin:
        currmin = P[i]
        ret += 1

print(ret)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
P = list(map(int, input().split()))
cnt = 0
res = float("Inf")
for n in range(N):
    if P[n] < res:
        res = P[n]
        cnt += 1
print(cnt)


Error: TLE

Fixed submission:

N = int(input())
P = list(map(int, input().split()))
cnt = 0
for n in range(N):
    if n == 0:
        cnt += 1
    else:
        L = P[:n]
        L.sort()
        if P[n] <= L[0]:
            cnt += 1
print(cnt)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
P = list(map(int, input().split()))
MIN = list()
count = 0
MIN.append(P[0])
for i in range(1, N):
    MIN.append(min(MIN[i - 1], P[i]))
for i in range(0, N):
    if P[i] <= MIN[i]:
        count += 1
print(count)


Error: TLE

Fixed submission:

N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N):
    for n in range(i + 1):
        if P[n] < P[i]:
            break
        if i == n:
            count += 1
print(count)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
p_list = list(map(int, input().split()))
min_num = p_list[0]
ans = 1

for i in range(1, n):
    if p_list[i] <= min_num:
        ans += 1
    min_num = min(min_num, p_list[i])

print(ans)


Error: TLE

Fixed submission:

n = int(input())
p_list = list(map(int, input().split()))
min_list = []
min_list.append(p_list[0])
ans = 1

for i in range(1, n):
    if p_list[i] <= min(min_list):
        ans += 1
    min_list.append(p_list[i])

print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
p_li = list(map(int, input().split()))

answer = 0
now_min = 999999
for i in range(len(p_li)):
    if now_min > p_li[i]:
        now_min = p_li[i]
        answer += 1

print(answer)


Error: TLE

Fixed submission:

n = int(input())
p_li = list(map(int, input().split()))

answer = 0
for i in range(len(p_li)):
    count_flag = True
    for j in range(i):
        if p_li[i] <= p_li[j]:
            continue
        else:
            count_flag = False
            break
    if count_flag:
        answer += 1

print(answer)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    tmp = P[0]
    for i in range(1, N):
        if P[i] == 1:
            print(ans + 1)
            return

        tmp = min(tmp, P[i])
        if P[i] <= tmp:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1

    for i in range(1, N):
        tmp = min(P[:i])
        if P[i] <= tmp:
            ans += 1

    print(ans)


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

n = int(input())
p = list(map(int, input().split()))

ans = 1
min = p[0]
for i in range(1, n):
    if min > p[i]:
        min = p[i]
    if p[i] <= min:
        ans += 1

print(ans)


Error: TLE

Fixed submission:

n = int(input())
p = list(map(int, input().split()))

ans = 1
for i in range(1, n):
    if p[i] <= min(p[:i]):
        ans += 1

print(ans)
Problem p02791 (Python) — buggy submission, verdict: Time Limit Exceeded

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

# N = 5
# P = [4, 2, 5, 1, 3]

ans = 0
min = 2 * 10**5
for i in range(0, N):
    # i = 1
    if min > P[i]:
        min = P[i]
    if P[i] <= min:
        ans += 1

print(ans)


Error: TLE

Fixed submission:

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

ans = 1
for i in range(1, N):
    if min(P[:i]) >= P[i]:
        ans += 1
print(ans)
Problem p02793 (Python) — buggy submission, verdict: Time Limit Exceeded

import fractions

N = int(input())
A = list(map(int, input().split()))
L = A[0]
for i in range(1, N):
    L = L * A[i] // fractions.gcd(L, A[i])

ans = 0
for i in range(N):
    ans = ans + L // A[i]  #% 1000000007

print(ans % 1000000007)


Error: TLE

Fixed submission:

import fractions

N = int(input())
A = list(map(int, input().split()))
L = A[0]
for i in range(1, N):
    L = L * A[i] // fractions.gcd(L, A[i])

ans = 0
for i in range(N):
    ans = (ans + L // A[i]) % 1000000007

print(ans)
Problem p02793 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import defaultdict


def factorize(n: int) -> dict:
    f = defaultdict(int)
    while n % 2 == 0:
        f[2] += 1
        n //= 2
    p = 3
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
            n //= p
        p += 2
    if n != 1:
        f[n] += 1
    return f


MOD = 10**9 + 7
n = int(input())
a = tuple(map(int, input().split()))

MAX_a = max(a)
iinv = [1] * (MAX_a + 1)
for i in range(2, MAX_a + 1):
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD

a_fac = []
lcm_fac = defaultdict(int)
for a_i in a:
    a_fac_i = factorize(a_i)
    a_fac.append(a_fac_i)
    for k, v in a_fac_i.items():
        lcm_fac[k] = max(lcm_fac[k], v)

lcm = 1
for k, v in lcm_fac.items():
    lcm *= pow(k, v, MOD)
    lcm %= MOD

ans = 0
for i in range(n):
    ans += lcm * iinv[a[i]]
    ans %= MOD

print(ans)


Error: TLE

Fixed submission:

from collections import defaultdict


def factorize(n: int) -> dict:
    f = defaultdict(int)
    while n % 2 == 0:
        f[2] += 1
        n //= 2
    p = 3
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
            n //= p
        p += 2
    if n != 1:
        f[n] += 1
    return f


def _pow(b, p, mod):
    ret = 1
    while p:
        if p % 2 == 1:
            ret *= b
            ret %= mod
        b **= 2
        p //= 2
    return ret


MOD = 10**9 + 7
n = int(input())
a = tuple(map(int, input().split()))

a_fac = []
lcm_fac = defaultdict(int)
for a_i in a:
    a_fac_i = factorize(a_i)
    a_fac.append(a_fac_i)
    for k, v in a_fac_i.items():
        lcm_fac[k] = max(lcm_fac[k], v)

# print(lcm_fac)
ans = 0
for a_fac_i in a_fac:
    b_i = 1
    for k, v in lcm_fac.items():
        b_i *= _pow(k, v - a_fac_i[k], MOD)
        b_i %= MOD
    # print(i, a[i], b_i)
    ans += b_i
    ans %= MOD

print(ans)
Problem p02793 (Python) — buggy submission, verdict: Time Limit Exceeded

import functools
import fractions

MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]

L = functools.reduce(lambda a, b: a // fractions.gcd(a, b) * b, A) % MOD
ans = 0

for a in A:
    ans += L * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)


Error: TLE

Fixed submission:

import fractions
import functools

MOD = 10**9 + 7

N = int(input())
A = [int(i) for i in input().split()]


def lcm(a, b):
    gcd = fractions.gcd(a, b)
    return (a * b) // gcd


LCM = functools.reduce(lcm, A)
ans = sum([(LCM // a) % MOD for a in A]) % MOD

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

def lcm(a, b):
    from fractions import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()


Error: 0

Fixed submission:

def lcm(a, b):
    from math import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()
Problem p02794 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import combinations
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(n - 1))
m = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(m))

graph = [[] for _ in range(n + 1)]
for i, (a, b) in enumerate(AB):
    graph[a].append((b, i))
    graph[b].append((a, i))


def dfs(s, g):
    kouho = 0
    par = [(0, 0)] * (n + 1)
    stack = []
    stack.append(s)
    while stack:
        v = stack.pop()
        if v == g:
            break
        for u, i in graph[v]:
            if u == par[v][0]:
                continue
            par[u] = (v, i)
            stack.append(u)
    # 経路復元
    p = g
    q, i = par[p]
    while q > 0:
        kouho |= 1 << i
        p = q
        q, i = par[q]
    return kouho


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c


sets = [0 for _ in range(m)]

for idx, (u, v) in enumerate(UV):
    sets[idx] = dfs(u, v)
ans = 0
for i in range(1, m + 1):
    kumiawase = list(combinations(range(m), i))
    for kumi in kumiawase:
        temp = 0
        for j in range(i):
            temp |= sets[kumi[j]]
        num = popcnt(temp)
        ans += (-1) ** (i + 1) * (pow(2, n - 1) - pow(2, n - 1 - num))

print(ans)


Error: TLE

Fixed submission:

from itertools import combinations
import sys

input = sys.stdin.buffer.readline

n = int(input())
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
# LCAが必要そう
# 慣れないけどdoublingしてみる？
# 実行時間に余裕があるし、毎回DFSしていい気がしてきた。
# 通った辺を(a,b)の形でsetに打ち込んで全部白になる場合の数を調べる方針


def dfs(s, g):
    kouho = set()
    par = [-1] * (n + 1)
    depth = [0] * (n + 1)
    stack = []
    stack.append(s)
    while stack:
        v = stack.pop()
        if v == g:
            break
        d = depth[v]
        for u in graph[v]:
            if u == par[v]:
                continue
            par[u] = v
            depth[u] = d + 1
            stack.append(u)
    # 経路復元
    p = g
    q = par[g]
    while q > 0:
        kouho.add((min(p, q), max(p, q)))
        p = q
        q = par[q]
    return kouho


m = int(input())
sets = [[] for _ in range(m)]
for i in range(m):
    u, v = map(int, input().split())
    sets[i] = dfs(u, v)
ans = 0
for i in range(1, m + 1):
    kumiawase = list(combinations(range(m), i))
    for kumi in kumiawase:
        temp = set()
        for j in range(i):
            temp |= sets[kumi[j]]
        num = len(list(temp))
        ans += (-1) ** (i + 1) * (pow(2, n - 1) - pow(2, n - 1 - num))

print(ans)
Problem p02796 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: lr[1])
count = 1
cur = LR[0][1]
for l, r in LR[1:]:
    if cur <= l:
        count += 1
        cur = r
print(count)


Error: TLE

Fixed submission:

import heapq

n = int(input())
XL = [tuple(map(int, input().split())) for _ in range(n)]

blocked = [0] * n
total = 0
for i in range(n):
    ax, al = XL[i]
    for j in range(i + 1, n):
        bx, bl = XL[j]
        if ax - al < bx - bl < ax + al or ax - al < bx + bl < ax + al:
            blocked[i] -= 1
            blocked[j] -= 1
            total += 1
count = 0
heapq.heapify(blocked)
while total > 0:
    total += heapq.heappop(blocked)
    count += 1

print(n - count)
Problem p02796 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0] - x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x: x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)


Error: TLE

Fixed submission:

N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)
Problem p02796 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort(reverse=True)
while len(T) - 1 > 0:
    t = T.pop()
    i = 1
    while len(T) and t[0] > T[-1][1]:
        N -= 1
        i += 1
        T.pop()
print(N)


Error: TLE

Fixed submission:

N = int(input())
R = [list(map(int, input().split())) for i in range(N)]
T = [[R[i][0] + R[i][1], R[i][0] - R[i][1]] for i in range(N)]
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)
Problem p02797 (Python) — buggy submission, verdict: Runtime Error

from sys import stdin

N, K, S = [int(x) for x in stdin.readline().rstrip().split()]

ans = [S] * K
if S == 10**9:
    ans.extend([1] * (N - K))
else:
    ans.extend([S + 1] * (N - K))

print(*ans)


Error: WA

Fixed submission:

from sys import stdin

N, K, S = [int(x) for x in stdin.readline().rstrip().split()]

ans = [S] * K
n = (N - K) // (S - 1)
ans.extend([S + 1] * (N - K))

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

n, k, s = map(int, input().split())
print(*[s] * k + [(s + 1) % 10**9] * (n - k))


Error: WA

Fixed submission:

from itertools import repeat

n, k, s = map(int, input().split())
print(*repeat(s, k), *repeat((s + 1) % 10**9, n - k))