qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
res = [0] * n
for i in range(1, n):
  c, s, f = map(int, input().split())
  res[i-1] += s + c
  for j in range(i-1):
    if res[j] < s:
      res[j] = s + c
    elif res[j] == s:
      res[j] += c
    else:
      if (res[j] - s) % f == 0:
        res[j] += c
      else:
        res[j] += f + c
print(res)

Fixed code:
n = int(input())
res = [0] * n
for i in range(1, n):
  c, s, f = map(int, input().split())
  res[i-1] += s + c
  for j in range(i-1):
    if res[j] < s:
      res[j] = s + c
    elif res[j] == s:
      res[j] += c
    else:
      if (res[j] - s) % f == 0:
        res[j] += c
      else:
        res[j] = s + (((res[j] - s) // f) + 1) * f + c
for elem in res:
  print(elem)
Buggy code:
N = int(input())
stations = [ list(map(int, input().split())) for _ in range(N-1)]

time = [0] * N


for i, station in enumerate(stations):
    C, S, F = station
    for j in range(i + 1):
        if S > time[j]:
            time[j] = S + C
        else:
            time[j] += F - (time[j] % F) + C

[ print(t) for t in time ]


Fixed code:
N = int(input())
stations = [ list(map(int, input().split())) for _ in range(N-1)]

time = [0] * N


for i, station in enumerate(stations):
    C, S, F = station
    for j in range(i + 1):
        if S > time[j]:
            time[j] = S + C
        elif time[j] % F == 0:
            time[j] += C
        else:
            time[j] += F - (time[j] % F) + C

[ print(t) for t in time ]
Buggy code:
import math
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
  x,y,z = map(int, input().split())
  c += [x]
  s += [y]
  f += [z]
  
for i in range(n-1):
  ans = s[i]+c[i]
  for j in range(i+1, n):
    ans = (ans//f[j]) * math.ceil(ans/f[j]) + c[j]
  print(ans)
print(0)

Fixed code:
import math

n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    x, y, z = map(int, input().split())
    c += [x]
    s += [y]
    f += [z]

for i in range(n - 1):
    ans = s[i] + c[i]
    for j in range(i + 1, n-1):
        if ans < s[j]:
            ans = s[j] + c[j]
        else:
            ans = f[j] * math.ceil(ans / f[j]) + c[j]
    print(ans)
print(0)
Buggy code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        else:
            tmp += arr[start][2]-((tmp-arr[start][1]) % arr[start][2])
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Fixed code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        elif (tmp-arr[start][1]) % arr[start][2] == 0:
            pass
        else:
            tmp += arr[start][2]-((tmp-arr[start][1]) % arr[start][2])
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)
Buggy code:
N = int(input())
stations = [list(map(int, input().split())) for _ in range(N-1)]

for idx, station in enumerate(stations):
  time = station[1] + station[0]
  for next in range(idx+1, N-1):
    if time < stations[next][1]:
      time = stations[next][1] + stations[next][0]
    else:
      time += stations[next][2] - (time-stations[next][1])%stations[next][2] + stations[next][0]
  print(time)
print(0)
    

Fixed code:
N = int(input())
stations = [list(map(int, input().split())) for _ in range(N-1)]

for idx, station in enumerate(stations):
  time = station[1] + station[0]
  for next in range(idx+1, N-1):
    if time < stations[next][1]:
      time = stations[next][1] + stations[next][0]
    elif (time-stations[next][1])%stations[next][2] == 0:
      time += stations[next][0]
    else:
      time += stations[next][2] - (time-stations[next][1])%stations[next][2] + stations[next][0]
  print(time)
print(0)
Buggy code:
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

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


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

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

    print(time)
Buggy code:
n=int(input())-1
csf=[list(map(int,input().split())) for i in range(n)]
# print(csf)
for i in range(n):
    time=0
    for j in range(i,n):
        if time<csf[j][1]:
            time=csf[j][1]+csf[j][0]
        else:
            time+=csf[j][2]-(time%csf[j][2])+csf[j][0]
    print(time)
print(0)

Fixed code:
n=int(input())-1
csf=[list(map(int,input().split())) for i in range(n)]
# print(csf)
for i in range(n):
    time=0
    for j in range(i,n):
        if time<csf[j][1]:
            time=csf[j][1]+csf[j][0]
        elif time%csf[j][2]!=0:
            time+=csf[j][2]-(time%csf[j][2])+csf[j][0]
        else:
            time+=csf[j][0]
    print(time)
print(0)
Buggy code:
import sys,math
input = sys.stdin.readline

N = int(input())
CSF = [[0,0,0]]
for i in range(1,N):
    CSF.append(list(map(int,input().split())))
for i in range(1,N+1):
    nowtime = 0
    for j in range(i,N):
        if nowtime <=CSF[j][1]:
            depT =CSF[j][1]
        else:
            depT =CSF[j][1] + math.ceil((nowtime-CSF[j][1])/CSF[j][2])*CSF[j][2]

        nowtime = depT+CSF[j][0]
        print(nowtime,depT)
    print(nowtime)


Fixed code:
import sys,math
input = sys.stdin.readline

N = int(input())
CSF = [[0,0,0]]
for i in range(1,N):
    CSF.append(list(map(int,input().split())))
for i in range(1,N+1):
    nowtime = 0
    for j in range(i,N):
        if nowtime <=CSF[j][1]:
            depT =CSF[j][1]
        else:
            depT =CSF[j][1] + math.ceil((nowtime-CSF[j][1])/CSF[j][2])*CSF[j][2]

        nowtime = depT+CSF[j][0]
        #print(nowtime,depT)
    print(nowtime)
Buggy code:
N = int(input())

ans = [0]*N
for i in range(N-1):
    c,s,f = map(int,input().split())
    ans[i] += s+c
    for j in range(i):
        ans[j] = max((ans[j]+f-1), s)+c
for a in ans:
    print(a)


Fixed code:
N = int(input())

ans = [0]*N
for i in range(N-1):
    c,s,f = map(int,input().split())
    ans[i] += c+s
    for j in range(i):
        ans[j] = max((ans[j]+f-1)//f*f, s)+c
for a in ans:
    print(a)
Buggy code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f ** 2 + c
        print(cur)


if __name__ == "__main__":
    main()

Fixed code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c
        print(cur)


if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
t = [0 for i in range(n)]
for i in range(n-1):
    c,s,f = map(int,input().split())
    for j in range(i+1):
        if t[j] <= s:
            t[j] = c + s
        elif t[j] % f:
            t[j] += c
        else:
            t[j] += f - (t[j] % f)
for i in t:
    print(i)

Fixed code:
n = int(input())
t = [0 for i in range(n)]
for i in range(n-1):
    c,s,f = map(int,input().split())
    for j in range(i+1):
        if t[j] <= s:
            t[j] = c + s
        elif t[j] % f == 0:
            t[j] += c
        else:
            t[j] += f - (t[j] % f) + c
for i in t:
    print(i)
Buggy code:
n=int(input())
lst=[]
for i in range(n):
  c,s,f=map(int,input().split())
  lst.append([c,s,f])
for j in range(n-1):
  time=lst[j][0]+lst[j][1]
  for k in range(n-j-1):
    if time<=lst[j+1][1] :
      time=lst[j+1][0]+lst[j+1][1]
    elif (time-lst[j+1][1])%lst[j+1][2]==0:
      time+=lst[j+1][2]
    else:
      time+=lst[j+1][2]+lst[j+1][2]-(time-lst[j+1][1])%lst[j+1][2]
  print(time)
print(0)


Fixed code:
n=int(input())
lst=[]
for i in range(n-1):
  c,s,f=map(int,input().split())
  lst.append([c,s,f])
for j in range(n-1):
  time=lst[j][0]+lst[j][1]
  ind=j
  for k in range(n-j-2):
    if time<=lst[ind+1][1] :
      time=lst[ind+1][0]+lst[ind+1][1]
      ind+=1
    elif (time-lst[ind+1][1])%lst[ind+1][2]==0:
      time+=lst[ind+1][0]
      ind+=1
    else:
      time+=lst[ind+1][0]+lst[ind+1][2]-(time-lst[ind+1][1])%lst[ind+1][2]
      ind+=1
  print(time)
print(0)
Buggy code:
n = int(input())
pair = []
ns = []
for i in range(n-1):
    c,s,f = map(int, input().split())
    pair.append((c,s,f))

ans = []
for i in range(n-1):
    c,s,f = pair[i]
    cnt = s + c
    for j in range(i+1,n-1):
        c,s,f = pair[j]
        s_ = ((cnt - 1)//f+1 )*f
        cnt = s_ + c
    print(cnt)
print(0)

Fixed code:
n = int(input())
pair = []
ns = []
for i in range(n-1):
    c,s,f = map(int, input().split())
    pair.append((c,s,f))

ans = []
for i in range(n-1):
    c,s,f = pair[i]
    cnt = s + c
    for j in range(i+1,n-1):
        c,s,f = pair[j]
        s_ = max(s,((cnt - 1)//f+1)*f)
        cnt = s_ + c
    print(cnt)
print(0)
Buggy code:
def f():
  n=int(input())
  l=(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      now=a+s-(-max(0,now-s)//d)*d
    print(now)
if __name__=="__main__":
  f()

Fixed code:
def f():
  n=int(input())
  l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      now=a+s-(-max(0,now-s)//d)*d
    print(now)
if __name__=="__main__":
  f()
Buggy code:
N=int(input())

csflist=[]
for i in range(N-1):
    c,s,f=map(int,input().split())
    csflist.append((c,s,f))

for i in range(N):
    sec=0
    for j in range(i,N-1):
        c,s,f=csflist[j]
    if sec<s:
        sec=s
    elif sec%f>0:
        sec+=f-(sec%f)
    sec+=c
print(sec)

Fixed code:
N=int(input())

csflist=[]
for i in range(N-1):
  c,s,f=map(int,input().split())
  csflist.append((c,s,f))
#print(csflist)

for i in range(N):
  sec=0
  for j in range(i,N-1):
    c,s,f=csflist[j]
    if sec<s:
      sec=s
    elif sec%f>0:
      sec+=f-(sec%f)
    sec+=c
    #print(i,j,sec)
  print(sec)
Buggy code:
n = int(input())
CSF = [list(map(int, input().split())) for i in range(n - 1)]
CSF.append([0, 0, 0])
for i in range(n):
    c, s, f = CSF[i]
    t = s + c
    for j in range(i + 1, n):
        c, s, f = CSF[j]
        if f == 0:
            break
        if t > s:
            s = s + (t - s - f + 1) // f * f
        t = s + c
    print(t)

Fixed code:
n = int(input())
CSF = [list(map(int, input().split())) for i in range(n - 1)]
CSF.append([0, 0, 0])
for i in range(n):
    c, s, f = CSF[i]
    t = s + c
    for j in range(i + 1, n):
        c, s, f = CSF[j]
        if f == 0:
            break
        if t > s:
            s = s + (t - s + (f - 1)) // f * f
        t = s + c
    print(t)
Buggy code:
n = int(input())
csf = [[int(item) for item in input().split()] for _ in range(n-1)]

for i in range(n):
    total_time = 0
    for c, s, f in csf[i:]:
        time = 0
        # wait for start
        if total_time < s:
            time += s - total_time
        # wait for next train
        else:
            time += total_time % f
        # take train
        time += c
        total_time += time
    print(total_time

Fixed code:
n = int(input())
csf = [[int(item) for item in input().split()] for _ in range(n-1)]

for i in range(n):
    total_time = 0
    for c, s, f in csf[i:]:
        time = 0
        # wait for start
        if total_time < s:
            time += s - total_time
        # wait for next train
        else:
            time += (f - total_time % f) % f
        # take train
        time += c
        total_time += time
    print(total_time)
Buggy code:


class Diagram:
    def __init__(self, n, xs):
        self.n = n
        self.xs = xs + [[0, 0, 0]]

    def departure(self, i, t):
        if i == self.n - 1:
            return t
        s = self.xs[i][1]
        f = self.xs[i][2]
        c = s // f
        d, m = divmod(t, f)
        if m == 0:
            if d > c:
                return t
            else:
                return s
        else:
            return s + f*(d+1)

    def arrival(self, i, t):
        return self.departure(i, t) + self.xs[i][0]



if __name__ == "__main__":
    n = int(input())
    xs = [list(map(int, input().split())) for i in range(n-1)]
    d = Diagram(n, xs)

    ys = [0]*n
    for i in range(n):
        for j in range(i,n) :
            ys[i] = d.arrival(j, ys[i])
    for y in ys:
        print(y)

Fixed code:


class Diagram:
    def __init__(self, n, xs):
        self.n = n
        self.xs = xs + [[0, 0, 0]]

    def departure(self, i, t):
        if i == self.n - 1:
            return t
        s = self.xs[i][1]
        f = self.xs[i][2]
        c = s // f
        x = max(s, t)
        d, m = divmod(x, f)
        if m == 0:
            return x
        else:
            return f*(d+1)

    def arrival(self, i, t):
        return self.departure(i, t) + self.xs[i][0]



if __name__ == "__main__":
    n = int(input())
    xs = [list(map(int, input().split())) for i in range(n-1)]
    d = Diagram(n, xs)

    ys = [0]*n
    for i in range(n):
        for j in range(i,n) :
            ys[i] = d.arrival(j, ys[i])
    for y in ys:
        print(y)
Buggy code:
N = int(input())
CSFlist = [list(map(int, input().split())) for _ in range(N-1)]
def calc_time(start):
    now = 0
    for i in range(start, N-1):
        C, S, F = CSFlist[i]
        now = max(now, C)
        if now % F != 0:
            now += F - now % F
        now += C
    return now
for _ in range(N-1):
    print(calc_time(_))
print(0)

Fixed code:
N = int(input())
CSFlist = [list(map(int, input().split())) for _ in range(N-1)]
def calc_time(start):
    now = 0
    for i in range(start, N-1):
        C, S, F = CSFlist[i]
        if now < S:
            now = S
        if now % F != 0:
            now += F - now % F
        now += C
    return now
for _ in range(N-1):
    print(calc_time(_))
print(0)
Buggy code:
def main():
    N = int(input())
    time = [0]*N
    data = [list(map(int,input().split()))for _ in range(N-1)]
    for i in range(N-1):
        for j  in range(i,N-1):
            c,s,f = data[j]
            if time[i] > s:
                tmp = time[i]-s
                if tmp % f != 0:
                    tmp //= f
                    tmp += 1
                else:
                    tmp //= f
                time[i] = tmp*f+c
            else:
                time[i] = s+c
    for t in time:
        print(t)

if __name__ == "__main__":
    main()

Fixed code:
def main():
    N = int(input())
    time = [0]*N
    data = [list(map(int,input().split()))for _ in range(N-1)]
    for i in range(N-1):
        for j  in range(i,N-1):
            c,s,f = data[j]
            if time[i] > s:
                tmp = time[i]-s
                if tmp % f != 0:
                    tmp //= f
                    tmp += 1
                else:
                    tmp //= f
                time[i] = s+tmp*f+c
            else:
                time[i] = s+c
    for t in time:
        print(t)

if __name__ == "__main__":
    main()
Buggy code:
from math import ceil


def get_required_time(trains, station_num, station):
    arrival = [0] * station_num
    for i in range(station, station_num):
        if arrival[i - 1] < trains[i - 1][1]:
            arrival[i] = trains[i - 1][0] + trains[i - 1][1]
        else:
            arrival[i] = trains[i - 1][0] + trains[i - 1][2] * ceil(arrival[i - 1] / trains[i - 1][2])
    return arrival


def main():
    station_num = int(input())
    trains = [list(map(int, input().split())) for _ in range(station_num - 1)]
    for i in range(station_num):
        arrival = get_required_time(trains, station_num, i)
        if i == 0:
            answer = arrival[-1]
        elif i == station_num - 1:
            answer = 0
        else:
            answer = min(arrival[-1] - arrival[i] + trains[i][1], arrival[-1])
        print(answer)


if __name__ == '__main__':
    main()

Fixed code:
from math import ceil


def get_required_time(trains, station_num, station):
    arrival = [0] * station_num
    for i in range(station, station_num):
        if arrival[i - 1] < trains[i - 1][1]:
            arrival[i] = trains[i - 1][0] + trains[i - 1][1]
        else:
            arrival[i] = trains[i - 1][0] + trains[i - 1][2] * ceil(arrival[i - 1] / trains[i - 1][2])
    return arrival


def main():
    station_num = int(input())
    trains = [list(map(int, input().split())) for _ in range(station_num - 1)]
    for i in range(1, station_num):
        print(get_required_time(trains, station_num, i)[-1])
    print(0)


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]

ans = [0]*n
for i in range(n):
    time = 0
    for j in range(i, n-1):
        if l[j][1] - time > 0:
            time += l[j][1] - time
        time += time % l[j][2] + l[j][0]
    ans[i] += time

print(ans)


Fixed code:
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]

ans = [0]*n
for i in range(n):
    time = 0
    for j in range(i, n-1):
        if l[j][1] - time > 0:
            time += l[j][1] - time
        if time % l[j][2] != 0:
            time += l[j][2] - time % l[j][2]
        time += l[j][0]
    ans[i] += time

for i in ans:
    print(i)
Buggy code:
n = (input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    point = i
    ans = 0
    while point < n-1:
        c, s, f = csf[point][0], csf[point][1], csf[point][2]
        if ans < s:
            ans += s-ans+c
        else:
            if ans%f != 0:
                ans += f-(ans%f)
            ans += c
        point += 1
    print(ans)

Fixed code:
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    point = i
    ans = 0
    while point < n-1:
        c, s, f = csf[point][0], csf[point][1], csf[point][2]
        if ans < s:
            ans += s-ans+c
        else:
            if ans%f != 0:
                ans += f-(ans%f)
            ans += c
        point += 1
    print(ans)
Buggy code:
N = int(input())
CC = [0] * (N-1)
SS = [0] * (N-1)
FF = [0] * (N-1)

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

for i in range(N-1):
    T = 0
    Max = 0
    for k in range(i,N-1):
        Max = max(T, SS[k])
        U = Max % FF[k]
        T = Max - U + FF[k] + CC[k]
        #print(i,k,T)
    print(T)
print(0)

Fixed code:
N = int(input())
CC = [0] * (N-1)
SS = [0] * (N-1)
FF = [0] * (N-1)

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

for i in range(N-1):
    T = 0
    Max = 0
    for k in range(i,N-1):
        Max = max(T, SS[k])
        U = Max % FF[k]
        if U == 0:
            T = Max + CC[k]
        else:
            T = Max - U + FF[k] + CC[k]
        #print(i,k,T)
    print(T)
print(0)
Buggy code:
import sys
input = sys.stdin.readline
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]

print(CSF)
ans = [0 for _ in range(N)]

for i in range(N-1) :
    temp = CSF[i][1] + CSF[i][0]
    t = i + 1
    while t < N-1 :
        if temp < CSF[t][1] :
            temp = CSF[t][1] + CSF[t][0]
        else :
            temp = ((temp+CSF[t][2]-1)//CSF[t][2])*CSF[t][2] + CSF[t][0]
        t += 1
    ans[i] = temp

for answer in ans :
    print(answer)


Fixed code:
import sys
input = sys.stdin.readline
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]

ans = [0 for _ in range(N)]

for i in range(N-1) :
    temp = CSF[i][1] + CSF[i][0]
    t = i + 1
    while t < N-1 :
        if temp < CSF[t][1] :
            temp = CSF[t][1] + CSF[t][0]
        else :
            temp = ((temp+CSF[t][2]-1)//CSF[t][2])*CSF[t][2] + CSF[t][0]
        t += 1
    ans[i] = temp

for answer in ans :
    print(answer)
Buggy code:
N = int(input())
ans = []
for _ in range(N - 1):
    C, S, F = map(int, input().split())
    ans.append(S + C)
    for i in range(len(ans) - 1):
        if ans[i] <= S:
            ans[i] = S + C
        else:
            start = F * ((ans[i] - S) // F + 1)
            ans[i] += start + C

ans.append(0)
for a in ans:
    print(a)


Fixed code:
N = int(input())
ans = []
for _ in range(N - 1):
    C, S, F = map(int, input().split())
    ans.append(S + C)
    for i in range(len(ans) - 1):
        if ans[i] <= S:
            ans[i] = S + C
        else:
            if (ans[i] - S) % F == 0:
                ans[i] += C
            else:
                ans[i] = S + F * ((ans[i] - S) // F + 1) + C

ans.append(0)
for a in ans:
    print(a)
Buggy code:
import sys
input = sys.stdin.readline
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]

ans=[]
for i in range(n):
    time=0
    for j in range(i,n-1):
        c,s,f=csf[j][0],csf[j][1],csf[j][2]
        if time>s:
            time=s -(-(time-s)//f)*f
        else:
            time=s
        time+=c

        #print(i,j,c,s,f,time)
    ans.append(time)
print(ans)


Fixed code:
import sys
input = sys.stdin.readline
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]

ans=[]
for i in range(n):
    time=0
    for j in range(i,n-1):
        c,s,f=csf[j][0],csf[j][1],csf[j][2]
        if time>s:
            time=s -(-(time-s)//f)*f
        else:
            time=s
        time+=c

        #print(i,j,c,s,f,time)
    ans.append(time)
for i in ans:
    print(i)
Buggy code:
N = int(input())

min_time = [0 for _ in range(N)]
for i in range(N-1):
    speed, start, interval = map(int, input().split())
    min_time[i] += start + speed
    for j in range(i):
        if min_time[j] - start < 0:
            min_time[j] = start
        else:
            min_time[j] += interval - ((min_time[j] - start) % interval)
        min_time[j] += speed

for ans in min_time:
    print(ans)


Fixed code:
N = int(input())

min_time = [0 for _ in range(N)]
for i in range(N-1):
    speed, start, interval = map(int, input().split())
    min_time[i] += start + speed
    for j in range(i):
        if min_time[j] - start < 0:
            min_time[j] = start
        else:
            while (min_time[j] - start) % interval != 0:
                min_time[j] += 1
        min_time[j] += speed

for ans in min_time:
    print(ans)
Buggy code:
int(input())
yo=[]
for _ in range(n-1):
  a=list(map(int,input().split()))
  yo.append(a)
  
def ans(x):
  if x==n-1:
    return 0
  else:
    t=0
    for i in range(x,n-1):
      if t<=yo[i][1]:
        t=yo[i][1]+yo[i][0]
      else:
        s=t-yo[i][1]
        if s%yo[i][2]==0:
          t=t+yo[i][0]
        else:
          mo=s%yo[i][2]
          t=t+yo[i][2]-mo+yo[i][0]
    return t
    
for j in range(n):
  print(ans(j))
        
        

Fixed code:
n=int(input())
yo=[]
for _ in range(n-1):
  a=list(map(int,input().split()))
  yo.append(a)
  
def ans(x):
  if x==n-1:
    return 0
  else:
    t=0
    for i in range(x,n-1):
      if t<=yo[i][1]:
        t=yo[i][1]+yo[i][0]
      else:
        s=t-yo[i][1]
        if s%yo[i][2]==0:
          t=t+yo[i][0]
        else:
          mo=s%yo[i][2]
          t=t+yo[i][2]-mo+yo[i][0]
    return t
    
for j in range(n):
  print(ans(j))