alexjercan/bugnet huggingface dataset:
Problem p03469 (Python) — buggy submission, verdict: Runtime Error

S = input()
print(S.replace("2017", "2018"))


Error: TypeError: replace() argument 1 must be str, not int
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s380335764.py", line 3, in <module>
    print(S.replace(2017, 2018))
TypeError: replace() argument 1 must be str, not int


Fixed submission:

S = input()

print(S.replace(2017, 2018))
Problem p03469 (Python) — buggy submission, verdict: Runtime Error

S = list(input())
S[3] = "8"
a = "".join(S)
print(a)


Error: TypeError: sequence item 3: expected str instance, int found
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s280675216.py", line 3, in <module>
    print("".join(S))
TypeError: sequence item 3: expected str instance, int found


Fixed submission:

S = list(input())
S[3] = 8
print("".join(S))
Problem p03469 (Python) — buggy submission, verdict: Runtime Error

print(input().replace("2017", "2018"))


Error: ValueError: invalid literal for int() with base 10: '2017/01/07'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s711679119.py", line 1, in <module>
    n, y = map(int, input().split())
ValueError: invalid literal for int() with base 10: '2017/01/07'


Fixed submission:

n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)
Problem p03469 (Python) — buggy submission, verdict: Runtime Error

s = input().rstrip()

s1 = "2018" + s[4:] if s.startswith("2017") else s
print(s1)


Error: AttributeError: 'str' object has no attribute 'startwith'. Did you mean: 'startswith'?
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s739767122.py", line 3, in <module>
    s1 = "2018" + s[4:] if s.startwith("2017") else s
AttributeError: 'str' object has no attribute 'startwith'. Did you mean: 'startswith'?


Fixed submission:

s = input().rstrip()

s1 = "2018" + s[4:] if s.startwith("2017") else s
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
ls = [int(input()) for i in range(n)]
ls = set(ls)
print(len(ls))


Error: TypeError: 'str' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s164646605.py", line 2, in <module>
    ls = [int(input()) for i in range(n)]
TypeError: 'str' object cannot be interpreted as an integer


Fixed submission:

n = input()
ls = [int(input()) for i in range(n)]
ls = list(set(ls))
print(len(ls))
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List))


Error: TypeError: 'list' object is not callable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s093646747.py", line 5, in <module>
    print(len(List()))
TypeError: 'list' object is not callable


Fixed submission:

N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List()))
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
d = [int(input()) for i in range(N)]

# print(list(set(d)))
e = list(set(d))
print(len(e))


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s146380919.py", line 7, in <module>
    N = int(input())
EOFError: EOF when reading a line


Fixed submission:

N = int(input())
d = [int(input()) for i in range(N)]

print(list(set(d)))
e = list(set(d))
print(len(e))
N = int(input())
d = [int(input()) for i in range(N)]

# print(list(set(d)))
e = list(set(d))
print(len(e))
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sort(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)


Error: AttributeError: 'list' object has no attribute 'sorted'. Did you mean: 'sort'?
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066996346.py", line 6, in <module>
    list.sorted(reverse=True)
AttributeError: 'list' object has no attribute 'sorted'. Did you mean: 'sort'?


Fixed submission:

n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sorted(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066397851.py", line 2, in <module>
    nums = [int(input()) for _ in range(int(input()))]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066397851.py", line 2, in <listcomp>
    nums = [int(input()) for _ in range(int(input()))]
EOFError: EOF when reading a line


Fixed submission:

n = int(input())
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))
Problem p03470 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(d[1:], d):
    if a > b:
        cnt += 1
print(cnt)


Error: TypeError: 'int' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s632286045.py", line 4, in <module>
    for a, b in zip(cnt[1:], cnt):
TypeError: 'int' object is not subscriptable


Fixed submission:

n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(cnt[1:], cnt):
    if a > b:
        cnt += 1
print(cnt)
Problem p03471 (Python) — buggy submission, verdict: Time Limit Exceeded

n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - (i + j)
        if 10000 * i + 5000 * j + 1000 * k == y:
            a, b, c = (i, j, k)
            break
print(a, b, c)


Error: TLE

Fixed submission:

n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)
Problem p03471 (Python) — buggy submission, verdict: Time Limit Exceeded

N, Y = map(int, input().split())
for y in range(9):
    for x in range(N + 1):
        if Y == (10000 * x) + (5000 * y) + (1000 * (N - x - y)) and N >= x + y:
            print(x, y, N - x - y)
            break
        else:
            continue
        break
    else:
        if y == 8:
            print(-1, -1, -1)
        continue
    break


Error: TLE

Fixed submission:

N, Y = map(int, input().split())
for y in range(9):
    for x in range(N + 1):
        for z in range(N + 1):
            if Y == (10000 * x) + (5000 * y) + (1000 * z) and x + y + z == N:
                print(x, y, z)
                break
        else:
            continue
        break
    else:
        if y == 8:
            print(-1, -1, -1)
        continue
    break
Problem p03471 (Python) — buggy submission, verdict: Time Limit Exceeded

N, Y = list(map(int, input().split()))
ans = [-1, -1, -1]
flag = False
for x in range(N, -1, -1):
    for y in range(N - x, -1, -1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            ans = [x, y, N - x - y]
            flag = True
            break
        if flag == True:
            break
    if flag == True:
        break
print(ans[0], ans[1], ans[2])


Error: TLE

Fixed submission:

n, y = map(int, input().split())
max_x = y // 10000
max_y = y // 5000
max_z = y // 1000

for i in range(max_x + 1):
    for j in range(max_y + 1):
        remain = y - 10000 * i - 5000 * j
        if remain < 0:
            continue
        if remain // 1000 == n - (i + j):
            print(i, j, (n - i - j))
            exit()
print(-1, -1, -1)
Problem p03471 (Python) — buggy submission, verdict: Runtime Error

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

flag = False

for z in range(N + 1)[::-1]:
    rem1 = N - z + 1
    for y in range(rem1)[::-1]:
        x = N - z - y
        val = 10000 * x + 5000 * y + 1000 * z
        if val == Y:
            flag = True
            break
    if flag:
        break

if not flag:
    x = -1
    y = -1
    z = -1

print(x, y, z)


Error: TypeError: cannot unpack non-iterable int object
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s426671470.py", line 17, in <module>
    x, y, z = -1
TypeError: cannot unpack non-iterable int object


Fixed submission:

n, y = map(int, input().split())

flag = False

for z in range(n + 1)[::-1]:
    rem1 = n - z + 1
    for y in range(rem1)[::-1]:
        x = n - z - y
        val = 10000 * x + 5000 * y + 1000 * z
        if val == y:
            flag = True
            break
    if flag:
        break

if not flag:
    x, y, z = -1

print(x, y, z)
Problem p03471 (Python) — buggy submission, verdict: Runtime Error

def pay(i: int, remain: int, z: int):
    for i in range(0, (n - z) + 1):
        if 10 * i + 5 * (remain - i) + z == m:
            print(i, remain - i, z)
            exit()

    return


n, M = list(map(int, input().split(" ")))
m = int(M / 1000)

for z in range(n, -1, -1):
    pay(0, n - z, z)

print(-1, -1, -1)


Error: 0

Fixed submission:

def judge(z):
    if z >= 0:
        remain = n - z
        pay = [[i, remain - i] for i in range(remain + 1)]

        for i in range(remain + 1):
            if 10 * pay[i][0] + 5 * pay[i][1] + z == m:
                print(pay[i][0], pay[i][1], z)
                exit()

        judge(z - 1)

    else:
        print(-1, -1, -1)


n, M = list(map(int, input().split(" ")))
m = int(M / 1000)

judge(n)
Problem p03471 (Python) — buggy submission, verdict: Runtime Error

N, Y = map(int, input().split())
ans = 0
found = False

Y //= 1000

T = 0
for i in range(Y // 10 + 1):
    for j in range((Y - i * 10) // 5 + 1):
        T += 1
        x = Y - i * 10 - j * 5
        if x < 0:
            break
        if i + j + x == N:
            print(i, j, x)
            found = True
            break
    if found:
        break
if not found:
    print("-1 -1 -1")


Error: WA

Fixed submission:

N, Y = map(int, input().split())
ans = 0
found = False
for i in range(N + 1):
    for j in range(0, N - i + 1):
        k = N - i - j
        is_sum = i * 10_000 + j * 5_000 + k * 1_000 == Y
        if is_sum:
            print(i, j, k)
            found = True
            break
    if found:
        break
        # for k in range(N):
        #     if i * 10_000 + j * 5_000 + k * 1_000 == Y and i + j + k == N:
        #         print(i, j, k)
        #         found = True
if not found:
    print("-1 -1 -1")
Problem p03471 (Python) — buggy submission, verdict: Runtime Error

N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N + 1):
        if (N - x - y >= 0) and (10000 * x + 5000 * y + 1000 * (N - x - y) == Y):
            print(x, y, N - x - y)
            break
    else:
        if x == N and y == N:
            print(-1, -1, -1)
        continue
    break


Error: TypeError: 'str' object cannot be interpreted as an integer
/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s576925636.py:5: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
  if (N - x - y < 0) and (10000 * x + 5000 * y + 1000(N - x - y)) == Y:
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s576925636.py", line 3, in <module>
    for x in range(1, N):
TypeError: 'str' object cannot be interpreted as an integer


Fixed submission:

N, Y = input().split()

for x in range(1, N):
    for y in range(1, N):
        if (N - x - y < 0) and (10000 * x + 5000 * y + 1000(N - x - y)) == Y:
            print(x, y, N - x - y)
Problem p03471 (Python) — buggy submission, verdict: Runtime Error

N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[2])
else:
    print("-1 -1 -1")


Error: WA

Fixed submission:

N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[3])
else:
    print("-1 -1 -1")
Problem p03471 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3


def main():
    args = input().split()
    N = int(args[0])
    Y = int(args[1])

    for num10000 in range(0, N + 1):
        for num5000 in range(0, N + 1 - num10000):
            num1000 = N - num10000 - num5000
            value = 10000 * num10000 + 5000 * num5000 + 1000 * num1000
            if value == Y:
                print(num10000, num5000, num1000)
                return

    print(-1, -1, -1)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3


def main():
    args = input().split()
    N = int(args[0])
    Y = int(args[1])

    for num10000 in range(0, N + 1):
        for num5000 in range(0, N + 1 - num10000):
            for num1000 in range(0, N + 1 - num10000 - num5000):
                if num10000 + num5000 + num1000 != N:
                    continue
                value = 10000 * num10000 + 5000 * num5000 + 1000 * num1000
                if value == Y:
                    print(num10000, num5000, num1000)
                    return

    print(-1, -1, -1)


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

N, H = map(int, input().split())
a, b = [0] * N, [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
ma = max(a)
b.sort(reverse=True)
ans = 0
index = 0
while H > 0 and len(b) > index and b[index] > ma:
    H -= b[index]
    index += 1
    ans += 1
if H > 0:
    ans += (H + ma - 1) // ma
print(ans)


Error: TLE

Fixed submission:

N, H = map(int, input().split())
a, b = [0] * N, [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while len(b) > 0 and b[0] > a[0]:
    H -= b[0]
    b = b[1:]
    ans += 1
ans += (H + a[0] - 1) // a[0]
print(ans)
Problem p03472 (Python) — buggy submission, verdict: Time Limit Exceeded

def answer():
    import sys

    input = sys.stdin.readline
    wield = 0
    l = []
    N, H = map(int, input().split())
    for i in range(N):
        a, b = map(int, input().split())
        l.append(b)
        wield = max(a, wield)
    l.sort(reverse=True)
    ret = 0
    for a in l:
        if H <= 0:
            break
        if a > wield:
            ret += 1
            H -= a
        else:
            break
    if H > 0:
        ret += (H + wield - 1) // wield
    print(ret)


answer()


Error: TLE

Fixed submission:

def main():
    N, Y = [int(i) for i in input().split()]

    A = []
    B = []

    for i in range(N):
        a, b = [int(i) for i in input().split()]
        A.append(a)
        B.append(b)

    B.sort()
    B.reverse()
    A.sort()
    A.reverse()

    for i in range(1000000000):
        if Y <= 0:
            print(i)
            return

        b_m = max(B, default=0)
        a_m = max(A)
        if b_m > a_m:
            Y = Y - b_m
            B.remove(b_m)
        else:
            Y = Y - a_m


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

n, h = [int(t) for t in input().split()]
aa = []
bb = []
for _ in range(n):
    a, b = [int(t) for t in input().split()]
    aa.append(a)
    if b > a:
        bb.append(b)
aa.sort()
bb.sort()

cnt = 0
while h > 0:
    if not bb or aa[-1] >= bb[-1]:
        cnt += (h - 1) // aa[-1] + 1
        break
    else:
        h -= bb.pop()
    cnt += 1
print(cnt)


Error: TLE

Fixed submission:

n, h = [int(t) for t in input().split()]
aa = []
bb = []
for _ in range(n):
    a, b = [int(t) for t in input().split()]
    aa.append(a)
    if b > a:
        bb.append(b)
aa.sort()
bb.sort()

cnt = 0
while h > 0:
    if not bb:
        cnt += (h - 1) // aa[-1] + 1
        break
    elif bb[-1] > aa[-1]:
        h -= bb.pop()
    else:
        h -= aa[-1]
    cnt += 1
print(cnt)
Problem p03472 (Python) — buggy submission, verdict: Runtime Error

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
mod = (h + amax - 1) // amax
print(ans + mod if h > 0 else ans)


Error: NameError: name 'mod' is not defined
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03472/Python/s359965169.py", line 15, in <module>
    print(ans + mod if h > 0 else ans)
NameError: name 'mod' is not defined


Fixed submission:

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        mod = (h + amax - 1) // amax
        break
    h -= bi
    ans += 1
print(ans + mod if h > 0 else ans)
Problem p03473 (Python) — buggy submission, verdict: Runtime Error

m = int(input())
n = 48 - m
print(n)


Error: TypeError: unsupported operand type(s) for -: 'int' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03473/Python/s581215127.py", line 2, in <module>
    n = 48 - m
TypeError: unsupported operand type(s) for -: 'int' and 'str'


Fixed submission:

m = input()
n = 48 - m
print(n)
Problem p03474 (Python) — buggy submission, verdict: Runtime Error

A, B = map(int, input().split())
S = input().split("-")
print("Yes" if len(S) == 2 and len(S[0]) == A and len(S[1]) == B else "No")


Error: WA

Fixed submission:

A, B = input().split()
S1, S2 = input().split("-")
print("Yes" if len(S1) == A and len(S2) == B else "No")
Problem p03474 (Python) — buggy submission, verdict: Runtime Error

a, b = map(int, input().split())
s = input()
try:
    first, second = s.split("-")
    if len(first) == a and len(second) == b:
        print("Yes")
    else:
        print("No")
except:
    print("No")


Error: 0

Fixed submission:

a, b = map(int, input().split())
s = input()
first, second = s.split("-")
if len(first) == a and len(second) == b:
    print("Yes")
else:
    print("No")
Problem p03475 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        else:
            t += F[j] - t % F[j]
        t += C[j]
    print(t)


Error: TLE

Fixed submission:

N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())


def get_t(x, i):
    t = S[i]
    while x > t:
        t += F[i]
    return t


for i in range(N - 1):
    x = S[i] + C[i]
    for j in range(i + 1, N - 1):
        t = get_t(x, j)
        x = t + C[j]
    print(x)
print(0)
Problem p03475 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            # print("t = {}".format(t))
            C_j, S_j, F_j = train_info[j - 1]
            if t <= S_j:
                t = S_j + C_j
            elif t % F_j == 0:
                t += C_j
            else:
                t += F_j - t % F_j
                t += C_j

        print(t)


Error: TLE

Fixed submission:

n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            C_j, S_j, F_j = train_info[j - 1]
            while True:
                if (t >= S_j) & (t % F_j == 0):
                    t += C_j
                    break
                else:
                    t += 1

        print(t)
Problem p03475 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())

_list = []
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    _list.append([a, b, c])


for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time

            if wait >= 0:
                time += wait + c
                break

            test = (wait * -1) // f
            s += int(f * test)

            if s - time < 0:
                s += f

        num += 1

    print(time)


print(0)


Error: TLE

Fixed submission:

n = int(input())

_list = []
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    _list.append([a, b, c])

for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time
            if wait >= 0:
                time += wait + c
                break

            s += f

        num += 1

    print(time)


print(0)
Problem p03475 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def next_time(i, t):
    a = S[i]
    if t - a < 0:
        return a
    if t % F[i] == 0:
        return t
    b = (t - a + F[i] - 1) // F[i]
    # print(i, t, a, b, t + b * F[i])
    assert (a + b * F[i]) % F[i] == 0
    return a + b * F[i]


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)


Error: TLE

Fixed submission:

N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def next_time(i, t):
    a = S[i]
    while a < t:
        a += F[i]
    return a


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)