qyliang/CodeNanoFix huggingface dataset:
Buggy code:
A, B = input().split()
S = input().split("-")
print("Yes" if len(S) == 2 and len(S[0]) == A and len(S[1]) == B else "No")


Fixed code:
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")
Buggy code:
a, b = map(int, input().split())
s = list(input())
print(s)
print(len(s), a+b+1)
flag = True
if len(s) == a+b+1:
    if s[a] == "-":
        s.pop(a)
        for i in s:
            if i == "-":
                flag = False
    else:
        flag = False
else:
    flag = False
if flag:
    print("Yes")
else:
    print("No")


Fixed code:
a, b = map(int, input().split())
s = list(input())
flag = True
if len(s) == a+b+1:
    if s[a] == "-":
        s.pop(a)
        for i in s:
            if i == "-":
                flag = False
    else:
        flag = False
else:
    flag = False
if flag:
    print("Yes")
else:
    print("No")
Buggy code:
#ABC084-B
a,b = map(int,input().split())
s = input()

mae = s[:a]
usiro = s[a+1:a+b+1]
#print(mae)
#print(usiro)
if mae.isdecimal() and usiro.isdecimal():
    print('Yes')
else:
    print('No')

Fixed code:
#ABC084-B
a,b = map(int,input().split())
s = input()

mae = s[:a]
usiro = s[a+1:a+b+1]
#print(mae)
#print(usiro)
if mae.isdecimal() and usiro.isdecimal() and s[a] == '-':
    print('Yes')
else:
    print('No')
Buggy code:
a,b = map(int, input().split())
s = input()

if s[a] != "-":
    print ("No")
if s.count("-") != 1:
    print ("No")
else:
    print ("Yes")

Fixed code:
a,b = map(int, input().split())
s = input()

if s[a] != "-":
    print ("No")
elif s.count("-") != 1:
    print ("No")
else:
    print ("Yes")
Buggy code:
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and s.index("-")==a:
    print("Yes")
else:
    print("No")

Fixed code:
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a and s.count("-")==1:
    print("Yes")
else:
    print("No")
Buggy code:
a,b=map(int,input().split())
s=input()
try:
  if s[:a].isdecimal()==True and s[a+1:].dicimal()==True:
    print("Yes" if s[:a]+"-"+s[a+1:]==s else "No")
  else:
    print("No")
except:
  print("No")

Fixed code:
a,b=map(int,input().split())
s=input()
try:
  if s[:a].isdecimal()==True and s[a+1:].isdecimal()==True:
    print("Yes" if s[:a]+"-"+s[a+1:]==s else "No")
  else:
    print("No")
except:
  print("No")
Buggy code:
A, B = map(int, input().split())
S = list(input())
if len(S) == A+B+1 and S[A] == '-' and S.count('#') == 1:
    print(Yes)
else:
    print('No')

Fixed code:
A, B = map(int, input().split())
S = list(input())

if len(S) == A+B+1 and S[A] == '-' and S.count('-') == 1:
    print('Yes')

else:
    print('No')
Buggy code:
def issigit(s):
  return all(c in '0123456789' for c in s)

def check(s, a, b):
  if len(s) != a + b + 1:
    return False
  
  if not isdigit(s[:a]):
    return False
  
  if s[a] != '-':
    return False
  
  if not isdigit(s[-b:]):
    return False
  
  return True
  
a, b = map(int, input().split())
s = input()
if check(s, a, b):
  print('Yes')
else:
  print('No')


Fixed code:
def isdigit(s):
  return all(c in '0123456789' for c in s)

def check(s, a, b):
  if len(s) != a + b + 1:
    return False
  
  if not isdigit(s[:a]):
    return False
  
  if s[a] != '-':
    return False
  
  if not isdigit(s[-b:]):
    return False
  
  return True
  
a, b = map(int, input().split())
s = input()
if check(s, a, b):
  print('Yes')
else:
  print('No')
Buggy code:
a, b = list(map(int, input().split()))
s = input()
l = s.split("-")
if len(l) != 2:
  ans = "No"
elif len[0]==a and len[1] == b:
  ans = "Yes"
else:
  ans = "No"
print(ans)


Fixed code:
a, b = list(map(int, input().split()))
s = input()
l = s.split("-")
if len(l) != 2:
  ans = "No"
elif len(l[0])==a and len(l[1]) == b:
  ans = "Yes"
else:
  ans = "No"
print(ans)
Buggy code:
import re
a, b = map(int, input().split())
s = input()
if s[a] == '-':
  s = re.sub(r'-', '', s)
  print(s)
  if re.fullmatch(r'[0-9]+', s) and len(s) == a + b:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Fixed code:
import re
a, b = map(int, input().split())
s = input()
if s[a] == '-' and len(s) == a + b + 1:
  s = re.sub(r'-', '', s)
  if re.fullmatch(r'[0-9]+', s) and len(s) == a + b:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Buggy code:
a, b = map(int, input().split())
s = input('')
if len(s) == (a+b+1) and s[a]=='-':
    print('Yes')
else:
    print('No')

Fixed code:
a,b = map(int,input().split())
s = input()
if(len(s)==(a+b+1) and s[a]=="-" and s[:a].isdigit() and s[a+1:].isdigit()):
    print("Yes")
else:
    print("No")
Buggy code:
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s.split("-")
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")

Fixed code:
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s[:a], s[a+1:]
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")
Buggy code:
A,B = map(int,input().split())
S = input()

count = "No"

if S[:A+1].isnumeric():
    if S[A+1] == "-":
        if len(S[A+2:]) == B and S[A+2:].isnumeric():
            count = "Yes"

print(count)

Fixed code:
A,B = map(int,input().split())
S = input()

count = "No"

if S[:A].isnumeric():
    if S[A] == "-":
        if len(S[A+1:]) == B and S[A+1:].isnumeric():
            count = "Yes"

print(count)
Buggy code:
a,b = map(int,input().split())
s = input()
print("Yes" if s[:a].isdigit() and s[a+1:].isdigit() else "No")

Fixed code:
a,b = map(int,input().split())
s = input()
print("Yes" if s[:a].isdigit() and s[a+1:].isdigit() and s[a]=="-" else "No")
Buggy code:
import re

def validate(a, b, s):
    pattern = "\\d{%d}-\\d{%d}"%(a, b)
    print(pattern)
    m = re.match(pattern, s)
    return m is not None



if __name__ == "__main__":
    a, b = map(int, input().split())
    s = input()
    if validate(a, b, s):
        print("Yes")
    else:
        print("No")

Fixed code:
import re

def validate(a, b, s):
    pattern = "\\d{%d}-\\d{%d}"%(a, b)
    #print(pattern)
    m = re.match(pattern, s)
    return m is not None



if __name__ == "__main__":
    a, b = map(int, input().split())
    s = input()
    if validate(a, b, s):
        print("Yes")
    else:
        print("No")
Buggy code:
# 2020/06/03
# AtCoder Beginner Contest 084 - B

# Input
a, b = map(int,input().split())
s = input()

# Calc
is_a_dec = str.isdecimal(s[0:a])
is_b_dec = str.isdecimal(s[a+1:len(s)])

if is_a_dec and is_b_dec:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)


Fixed code:
# 2020/06/03
# AtCoder Beginner Contest 084 - B

# Input
a, b = map(int,input().split())
s = input()

# Calc
is_a_dec = str.isdecimal(s[0:a])
is_b_dec = str.isdecimal(s[a+1:len(s)])
is_hy = (s[a] == '-')

if is_a_dec and is_b_dec and is_hy:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)
Buggy code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    csf = [list(map(int, input().split())) for _ in range(n - 1)]

    for i in range(n):
        if i == n - 1:
            print(0)
        else:
            x = csf[i][1]
            for j in range(i + 1, n - 1):
                cj1, sj1, fj1 = csf[j - 1]
                cj, sj, fj = csf[j]
                if x + cj1 + (fj1 - x % fj1) <= sj:
                    x = sj
                else:
                    x += cj1 + x % fj1
            x += csf[-1][0] + (csf[-1][2] - x % csf[-1][2])
            print(x)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    csf = [list(map(int, input().split())) for _ in range(n - 1)]

    for i in range(n):
        if i == n - 1:
            print(0)
        else:
            x = csf[i][1]
            for j in range(i + 1, n - 1):
                cj1, sj1, fj1 = csf[j - 1]
                cj, sj, fj = csf[j]
                # print(i, j, x, csf[j - 1], csf[j])
                if x + cj1 + (fj1 - x % fj1) % fj1 <= sj:
                    x = sj
                else:
                    x += cj1 + (fj1 - x % fj1) % fj1
            x += csf[-1][0] + (csf[-1][2] - x % csf[-1][2]) % csf[-1][2]
            print(x)


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

def arrive(time,now):
  time=(time+a[now][2]-1)//a[now][2]*a[now][2]+a[now][0]
  if now==n-2:
    return time
  else:
    return arrive(time,now+1)

for i in range(n-1):
  print(arrive(a[i][1],i))
print(0)

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

def arrive(time,now):
  if time>a[now][1]:
    time=(time+a[now][2]-1)//a[now][2]*a[now][2]+a[now][0]
  else: time=a[now][1]+a[now][0]
  if now==n-2:
    return time
  else:
    return arrive(time,now+1)

for i in range(n-1):
  print(arrive(a[i][1],i))
print(0)
Buggy code:
n=int(input())
m=[]
for c,s,f in map(int,input().split()):
  m.append(0)
  for i in range(len(m)):
    if m[i]>s:
      m[i]=s+((m[i]-s)//f+((m[i]-s)%f>0))*f+c
    else:#m[i]<=s
      m[i]=s+c
m.append(0)
for i in m:
  print(i)

Fixed code:
n=int(input())
m=[]
for _ in range(n-1):
  c,s,f=map(int,input().split())
  m.append(0)
  for i in range(len(m)):
    if m[i]>s:
      m[i]=s+((m[i]-s)//f+((m[i]-s)%f>0))*f+c
    else:#m[i]<=s
      m[i]=s+c
m.append(0)
for i in m:
  print(i)
Buggy code:
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
  x,y,z=map(int,input().split())
  c.append(x)
  s.append(y)
  f.append(z)
def needtime(t,i):
  if s[i]>=t:
    T=s[i]
  else:
    T=t+f[i]-(t-s[i])%f[i]
  return T+c[i]
for i in range(n):
  t=0
  for j in range(i,n-1):
    t=needtime(t,j)
  print(t)

Fixed code:
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
  x,y,z=map(int,input().split())
  c.append(x)
  s.append(y)
  f.append(z)
def needtime(t,i):
  if s[i]>=t:
    T=s[i]
  else:
    if (t-s[i])%f[i]==0:
      T=t
    else:
      T=t+f[i]-(t-s[i])%f[i]
  return T+c[i]
for i in range(n):
  t=0
  for j in range(i,n-1):
    t=needtime(t,j)
  print(t)
Buggy code:
n = int(input())
csf = []
for i in range(n):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time < csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = (time-csf[j][1])%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')

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


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time <= csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = -time%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')
Buggy code:
N = int(input())
clis = [];slis =[];flis = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    clis.append(c);slis.append(s);flis.append(f)
for i in range(N):
    count=0
    for i2 in range(N-i-1):
        c=clis[i+i2];s=slis[i+i2];f=flis[i+i2]
        if count <= s:
            count=s+c
        elif (count-s)%f ==0:
            count = count+c
        else:
            count = count + c f-count%f
    print(count)


Fixed code:
N = int(input())
clis = [];slis =[];flis = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    clis.append(c);slis.append(s);flis.append(f)
for i in range(N):
    count=0
    for i2 in range(N-i-1):
        c=clis[i+i2];s=slis[i+i2];f=flis[i+i2]
        if count <= s:
            count=s+c
        elif (count-s)%f ==0:
            count = count+c
        else:
            count = count + c+f-count%f
    print(count)
Buggy code:
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        elif time % f[j] == 0:
            time = s[j]
        elif time >= s[j]:
            #while time < s[j]:
            time += f[j] - time % f[j]
            time += c[j]
        else:
            time += s[j] + c[j]
    print(time)
print(0)

Fixed code:
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time < s[j]:
            time = s[j] + c[j]
        elif time % f[j] != 0:
            time += f[j] - time % f[j] + c[j]
        else:
            time += c[j]
    print(time)
print(0)
Buggy code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    else:
      ans[j] += F - (ans[j]-S)%F
    ans[j] += C
    
for i in ans:
  print(i)



Fixed code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j]%F != 0:
      ans[j] += F - ans[j]%F
    ans[j] += C
    
for i in ans:
  print(i)
Buggy code:
N = int(input())

time_list = []

for i in range(N - 1):
    C, S, F = map(int, input().split())
    time_list.append(C + S)
    for j in range(0, i):
        t = time_list[j]
        if t < S:
            time_list[j] += S - t
        else:
            time_list[j] += t % F + C

time_list.append(0)

for time in time_list:
    print(time)


Fixed code:
N = int(input())

time_list = []

for i in range(N - 1):
    C, S, F = map(int, input().split())
    time_list.append(C + S)
    for j in range(0, i):
        t = time_list[j]
        if t < S:
            time_list[j] += S - t + C
        elif t % F != 0:
            time_list[j] += F - t % F + C
        else:
            time_list[j] += C

time_list.append(0)

for time in time_list:
    print(time)
Buggy code:
n = int(input())
station = [tuple(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s-res, (res+(f-1))//f - res) + c
    print(res)
else:
    print(0)


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

for i in range(n-1):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s-res, ((res+(f-1))//f)*f - res) + c
    print(res)
else:
    print(0)
Buggy code:
n =int(input())
csfs = []
for i in range(0,n-1):
    csfs.append(list(map(int,input().split())))

res = []
for i in range(0,n-1):
    c = csfs[i][0]
    s =csfs[i][1]
    f = csfs[i][2]
    syuppatu = s
    toutyaku = s+c
    for j in range(i+1,n-1):
        if toutyaku < csfs[j][1]:
            syuppatu = csfs[j][1]
            toutyaku = syuppatu+csfs[j][0]
        else:
            syuppatu = ((toutyaku + f-1) // f) * f
            toutyaku = syuppatu + csfs[j][0]
    res.append(toutyaku)
res.append(0)
for re in res:
    print(re)

Fixed code:
n =int(input())
csfs = []
for i in range(0,n-1):
    csfs.append(list(map(int,input().split())))

res = []
for i in range(0,n-1):
    c = csfs[i][0]
    s =csfs[i][1]
    f = csfs[i][2]
    syuppatu = s
    toutyaku = s+c
    for j in range(i+1,n-1):
        if toutyaku < csfs[j][1]:
            syuppatu = csfs[j][1]
            toutyaku = syuppatu+csfs[j][0]
        else:
            syuppatu = ((toutyaku+csfs[j][2]-1) // csfs[j][2]) * csfs[j][2]
            toutyaku = syuppatu + csfs[j][0]
    res.append(toutyaku)
res.append(0)
for re in res:
    print(re)
Buggy code:
n=int(input())
p=[list(map(int,input().split()))for i in range(n-1)]
for i in range(n):
    c=0
    d=p[i:]
    for j in range(n-i-1):
        if c<d[j][1]:
            c+=d[j][1]+d[j][0]
        else:
            c+=((c-1)//d[j][2]+1)*d[j][2]+d[j][0]-c
    else:
        print(c)

Fixed code:
n=int(input())
p=[list(map(int,input().split()))for i in range(n-1)]
for i in range(n):
    c=0
    d=p[i:]
    for j in range(n-i-1):
        if c<d[j][1]:
            c+=d[j][1]+d[j][0]-c
        else:
            c+=((c-1)//d[j][2]+1)*d[j][2]+d[j][0]-c
    else:
        print(c)
Buggy code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al):
	ret = 0
	for (c, s, f) in al:
		if ret <= s:
			ret = s+c
		else:
			st = ((ret + f-1)//f)*f
			ret = st + c
	print(ret)
		

def main():
	n = int(input())
	if n==4:
		return 1/0
	#b , c = tin()
	#s = input()
	al = [lin() for _ in range(n-1)]
	for i in range(n):
		cc(al[i:])
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(al):
	ret = 0
	for (c, s, f) in al:
		if ret <= s:
			ret = s+c
		else:
			st = ((ret + f-1)//f)*f
			ret = st + c
	print(ret)
		

def main():
	n = int(input())
	#if n==4:
	#	return 1/0
	#b , c = tin()
	#s = input()
	al = [lin() for _ in range(n-1)]
	for i in range(n):
		cc(al[i:])
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy code:
n = int(input())
csf=[]
for _ in range(n-1):
    csf.append(list(map(int,input().split())))
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<csf[j][1]:
            t += csf[j][1]
        elif t%csf[j][2]!=0:
            t = t+csf[j][2]-t%csf[j][2]
        t += csf[j][0]
    print(t)


Fixed code:
n = int(input())
csf=[]
for _ in range(n-1):
    csf.append(list(map(int,input().split())))
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<csf[j][1]:
            t = csf[j][1]
        elif t%csf[j][2]!=0:
            t = t+csf[j][2]-t%csf[j][2]
        t += csf[j][0]
    print(t)
Buggy code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    total_elapsed_times = list()

    # HACK: More smarter.
    for i in range(station_count):
        if i < station_count - 1:
            total_elapsed_times.append(s[i])
        else:
            total_elapsed_times.append(0)

    for j in range(station_count - 1):

        for k in range(j, station_count - 1):
            if total_elapsed_times[j] < s[k]:
                total_elapsed_times[j] = s[k]
            elif total_elapsed_times[j] % f[j] == 0:
                pass
            else:
                total_elapsed_times[j] += f[k] - (total_elapsed_times[j] % f[k])

            total_elapsed_times[j] += c[k]

    for total_elapsed_time in total_elapsed_times:
        print(total_elapsed_time)


Fixed code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    for i in range(station_count):
        elapsed_time = 0

        for j in range(i, station_count - 1):
            if elapsed_time < s[j]:
                elapsed_time = s[j]
            elif (elapsed_time % f[j]) == 0:
                pass
            else:
                elapsed_time = elapsed_time + f[j] - (elapsed_time % f[j])

            elapsed_time += c[j]

        print(elapsed_time)
Buggy code:
ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
    csf.append(tuple(ma()))
for i in range(n-1):
    ans = csf[i][1] + csf[i][0]
    for j in range(i+1,n-1):
        if ans<=csf[j][1]:
            ans =csf[j][1]+csf[j][0]
        else:
            ans = math.ceil(ans/csf[j][2]) +csf[j][0]
    print(ans)
print(0) 


Fixed code:
ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
    csf.append(tuple(ma()))
for i in range(n-1):
    ans = csf[i][1] + csf[i][0]
    for j in range(i+1,n-1):
        if ans<=csf[j][1]:
            ans =csf[j][1]+csf[j][0]
        else:
            ans = ceil(ans/csf[j][2])*csf[j][2] +csf[j][0]
    print(ans)
print(0)
Buggy code:
N = int(input())
L = [list(map(int, input().split())) for i in range(N-1)]
ans = []

for i in range(N-1):
    time = L[i][1]
    for j in range(i, N-1):
        c, s, f = L[j]
        if time >= s:
            time += f - (time % f) 
        else:
            time += s - time
        time += c
    ans.append(time)

ans.append(0)
print(*ans, sep="\n")

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

for i in range(N-1):
    time = L[i][1]
    for j in range(i, N-1):
        c, s, f = L[j]
        if time < s:
            time = s
        elif time % f == 0:
            pass
        else:
            time += f - time % f
        time += c
    ans.append(time)

ans.append(0)
print(*ans, sep="\n")
Buggy code:
N = int(input())
array = []

for i in range(N-1):
  _input = str(input()).split(' ')
  array.append((int(_input[0]), int(_input[1], int(_input[2]))))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

Fixed code:
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)
Buggy code:
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]

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

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

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