Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,k= map(int, io().split())
	s=[int(i) for i in io()[:n]]
	init=s[0]
	ll=[]
	m=0
	pre=init
	for c in s:
		if c == pre:
			m+=1
		else:
			ll.append(m)
			m=1
			pre=c
	ll.append(m)
	
	#print(ll)
	off= 1 if init==1 else 0
	if len(ll)<=2*k + off:
		return n
	pre=sum(ll[:2*k+off])
	rr_max=pre
	for i in range(len(ll)//2 - k):
		cc=pre - ll[2*i] - ll[2*i+1] + ll[2*(k+i)+off]+ll[2*(k+i)+1+off]
		rr_max = max(rr_max, cc)
		pre=cc
	return rr_max


#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Fixed submission:
import sys
bbn=1000000007
	
#+++++
		
def main2():
	n, k = map(int, input().split())
	sl = input()
	dd=[]
	ddv=[]
	left= sl[0]
	count=0
	pre=left
	for c in sl:
		if c == pre:
			count+=1
		else:
			dd.append(count)
			ddv.append(pre)
			pre=c
			count=1
	dd.append(count)
	ddv.append(pre)
	
	pa(ddv)
	if k == 0:
		return max([v for v,c in zip(dd,ddv) if c == '1'])
	
	ll=[]
	for i,c in zip(dd,ddv):
		if c == '0':
			pass
			
def main():
	n, k = map(int, input().split())
	sl = input()
	al=[]
	if sl[0]=='0':
		al.append(0)
	p=sl[0]
	count=1
	for c in sl[1:]:
		if c == p:
			count+=1
		else:
			al.append(count)
			count=1
			p=c
	else:
		al.append(count)
		if sl[-1]=='0':
			al.append(0)
			
	#pa(al)
	
	if 2*k+1 >= len(al):
		print(n)
		return 
	
	ret = al[0]
	for i in range(k):
		ret += al[2*i+1]
		ret += al[2*i+2]
	#pa(ret)
	rs=ret
	for i in range(k, (len(al)//2)):
		rs += al[2*i+1]
		rs += al[2*i+2]
		rs -= al[2*(i-k)+1]
		rs -= al[2*(i-k)]
		ret = max(rs, ret)
		#pa(rs)
	print(ret)
		
			
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

#+++++


def aaa(ll,a,b,c):
	ret=a+b+c
	for i,v1 in enumerate(ll):
		if v1==0:
			continue
		t1=abs(a-v1)
		if ret < t1:
			continue
		for j,v2 in enumerate(ll):
			if v2==0:
				continue
			if i==j:
				continue
			t2=t1 + abs(b-v2)
			if ret < t2:
				continue
			for k,v3 in enumerate(ll):
				if v3==0:
					continue
				if i==k or j==k:
					continue
				t3 = t2 + abs(c-v3)
				ret=min(ret, t3)
	return ret		
		
def main():
	n , a, b, c = map(int, input().split())
	bb=[]
	for i in range(n):
		bb.append(int(input()))
	ans=a+b+c
	for i in range(4**n-1):
		la=[]
		lb=[]
		lc=[]
		l=[]
		for j in range(n):
			sd=(i%(4 ** (j+1)))//(4**j)
			kk=bb[j]
			pp=0
			if sd == 0:
				la.append(kk)
			elif sd==1:
				lb.append(kk)
			elif sd==2:
				lc.append(kk)
			else:
				l.append(kk)
		pp=max(0,len(la)-1)+max(len(lb)-1,0)+max(0,len(lc)-1)
		l=l+[sum(la),sum(lb),sum(lc)]
		#print(l)
		ans=min(ans,aaa(l,a,b,c)+pp*10)
				
	
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys
import queue

#+++++


def aaa(ll,a,b,c):
	ret=a+b+c
	for i,v1 in enumerate(ll):
		if v1==0:
			continue
		t1=abs(a-v1)
		if ret < t1:
			continue
		for j,v2 in enumerate(ll):
			if v2==0:
				continue
			if i==j:
				continue
			t2=t1 + abs(b-v2)
			if ret < t2:
				continue
			for k,v3 in enumerate(ll):
				if v3==0:
					continue
				if i==k or j==k:
					continue
				t3 = t2 + abs(c-v3)
				ret=min(ret, t3)
	return ret		

def mk_str(ll):
	ll.sort()
	return '_'.join([str(v) for v in ll])


def main():
	n , a, b, c = map(int, input().split())
	est=lambda ll:aaa(ll,a,b,c)
	
	bb=[]
	for i in range(n):
		bb.append(int(input()))
	
	cl=set()
	ol=queue.PriorityQueue()
	

	
	st=bb
	ee=est(st)
	cc=0
	cl.add(mk_str(bb))
	ol.put((ee+cc, (cc, bb)))	
	while True:
		if ee == 0:
			return cc
		
		#to goal no join
		rr=cc+ee
		ol.put((rr, (rr, [a,b,c])))
		
		
		
		#join 1
		if len(st) > 3:
			cc+=10
			for i, v in enumerate(st):
				kk=st[:]
				m=kk.pop(i)
				for j, _ in enumerate(kk):
					kkk=kk[:]
					kkk[j]+=m
					stk=mk_str(kkk)
					if stk not in cl:
						cl.add(stk)
						ol.put((cc, (cc, kkk)))
		v,(cc, st) = ol.get()
		ee = est(st)
				
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#n = int(input())
	n, k = IN()
	#s = input()
	al = LIN()
	cl=[mod]*n
	cl[0]=0
	for i, c in enumerate(al):
		#pa(cl)
		for j, nv in enumerate(al[i:i+k+1]):
			cl[i+j]=min(cl[i+j], cl[i]+abs(nv-c))
	
	print(cl[-1])
	
#+++++
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 submission:
import sys

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

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#n = int(input())
	n, k = IN()
	#s = input()
	al = LIN()
	cl=[mod]*n
	cl[0]=0
	for i, c in enumerate(al):
		#pa(cl)
		for j, nv in enumerate(al[i:i+k+1]):
			cl[i+j]=min(cl[i+j], cl[i]+abs(nv-c))
	
	print(cl[-1])
	
#+++++
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 python submission (verdict: Runtime Error):
import sys

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

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007
inf = 10**12
#+++++

def main():
	#a = int(input())
	n, max_w = IN()
	#s = input()
	dp_v = [inf] * (10**5)
	dp_v[0] = 0
	for _ in range(n):
		add_v = []
		w, v = IN()
		for i, cv in enumerate(dp_v):
			if dp_v[i] == inf:
				continue
			if dp_v[i] + w < dp_v[i+v]:
				add_v.append((i+v, dp_v[i] + w))
		for i, nv in add_v:
			dp_v[i] = nv
	for i, min_w in enumerate(dp_v[::-1]):
		if min_w <= max_w:
			v=len(dp_v)-i-1
			return v
		
	
	
	
#+++++
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 submission:
import sys

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

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007
inf = 10**12
#+++++

def main():
	#a = int(input())
	n, max_w = IN()
	#s = input()
	dp_v = [inf] * (10**5 + 100)
	dp_v[0] = 0
	for _ in range(n):
		add_v = []
		w, v = IN()
		for i, cv in enumerate(dp_v):
			if dp_v[i] == inf:
				continue
			if dp_v[i] + w < dp_v[i+v]:
				add_v.append((i+v, dp_v[i] + w))
		for i, nv in add_v:
			dp_v[i] = nv
			
	for i, min_w in enumerate(dp_v[::-1]):
		if min_w <= max_w:
			v=len(dp_v)-i-1
			return v
		
	
	
	
#+++++
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 python submission (verdict: Runtime Error):
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	pl=101
	
	ff=[0]*pl
	for i  in range(pl):
		ff[i]=[0]*pl
	
	v=[]
	for i in range(n):
		x, y, h = map(int, input().split())
		v.append([x,y,h])
	
	tt=0
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v[i+1:]:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp==jhp:
						ff[px][py]+=1
	
	for i, vl in enumerate(ff):
		for j, va in enumerate(vl):
			if va == tt:
				[x,y,h]=v[0]
				rh=h+abs(x-i)+abs(y-j)
				print(i,j,rh)
				return
				
	raise NameError('HiThere')
	print(0,0,1)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	pl=101
	
	ff=[0]*pl
	for i in range(pl):
		ff[i]=[0]*pl
	
	v=[]
	v0=[]
	for i in range(n):
		x, y, h = map(int, input().split())
		if h > 0:
			v.append([x,y,h])
		else:
			v0.append([x,y,h])
		
	
	tt=0
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v[i+1:]:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp==jhp:
						ff[px][py]+=1
	
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v0:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp<=jhp:
						ff[px][py]+=1
								
	for i, vl in enumerate(ff):
		for j, va in enumerate(vl):
			if va == tt:
				[x,y,h]=v[0]
				rh=h+abs(x-i)+abs(y-j)
				print(i,j,rh)
				return
	if len(v)	== 0:		
		raise NameError('HiThere')
	print(0,0,1)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

#+++++
		
def main():
	n,m = map(int, input().split())
	if n == 1:
		return m
	
	ret = 0
	for i in range(1,m):
		a = m // i
		b = m % i
		if b == 0 and n*i <= m:
			ret = i
			
		if n*i > m:
			return ret
			
		if ret == 1 and i*i > m:
			return 1
			
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys
import math

#+++++


		
def main():
	n,m = map(int, input().split())
	if m % n ==0:
		return m // n
		
	ll=1
	for i in range(1, int(math.sqrt(m))+1):
		#pa((i,ll))
		if m % i == 0:
			if i >= n:
				ll=max(ll, m // i)
			if m // i >= n:
				ll=max(ll, i)
	return ll
				

#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

#+++++
		
def main():
	n,m = map(int, input().split())
	if n == 1:
		return m
	
	ret = 0
	for i in range(1, m):
		a = m // i
		b = m % i
		if b == 0 and n*i <= m:
			ret = i
			
		if n*i > m:
			return ret
			
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys
import math

#+++++


		
def main():
	n,m = map(int, input().split())
	if m % n ==0:
		return m // n
		
	ll=1
	for i in range(1, int(math.sqrt(m))+1):
		#pa((i,ll))
		if m % i == 0:
			if i >= n:
				ll=max(ll, m // i)
			if m // i >= n:
				ll=max(ll, i)
	return ll
				

#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict

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

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	al = list(IN())
	odd_dd=defaultdict(lambda : 0)
	even_dd=defaultdict(lambda :0)
	for i, v in enumerate(al):
		if i%2==0:
			odd_dd[v] += 1
		else:
			even_dd[v] += 1
	
	odd_ll=[(odd_dd[key], key) for key in odd_dd.keys()]
	even_ll=[(even_dd[key], key) for key in even_dd.keys()]
	
	odd_ll.sort(reverse=True)
	even_ll.sort(reverse=True)
	kk=n//2
	pa(odd_ll)
	pa(even_ll)
	#全部同じ
	if len(odd_ll)==1 and len(even_ll)==1:
		a=4/0
		if odd_ll[0][1]==even_ll[0][1]:
			return kk
		else:
			return 0
	
	if odd_ll[0][1] == even_ll[0][1]:
		if odd_ll[0][0] >= even_ll[0][0]:
			return (kk-odd_ll[0][0])+(kk-even_ll[1][0])
		else:
			return (kk-odd_ll[1][0])+(kk-even_ll[0][0])
	else:
		return (kk-odd_ll[0][0])+(kk-even_ll[0][0])
	
	#pa(odd_ll)
	#print(str(a+b+c)+s)
	
	
#+++++
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 submission:
import sys
from collections import defaultdict

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

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	al = list(IN())
	odd_dd=defaultdict(lambda : 0)
	odd_dd[-1]=0
	even_dd=defaultdict(lambda :0)
	even_dd[-1]=0
	
	for i, v in enumerate(al):
		if i%2==0:
			odd_dd[v] += 1
		else:
			even_dd[v] += 1
	
	odd_ll=[(odd_dd[key], key) for key in odd_dd.keys()]
	even_ll=[(even_dd[key], key) for key in even_dd.keys()]
	
	odd_ll.sort(reverse=True)
	even_ll.sort(reverse=True)
	kk=n//2
	pa(odd_ll)
	pa(even_ll)
	
	#先頭が同じ
	if odd_ll[0][1] == even_ll[0][1]:
		ra=(kk-odd_ll[0][0])+(kk-even_ll[1][0])
		rb=(kk-odd_ll[1][0])+(kk-even_ll[0][0])
		return min(ra, rb)
	else:
		ret= (kk-odd_ll[0][0])+(kk-even_ll[0][0])
		return ret
	
#+++++
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 python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N,C = map(int, raw_input().split())
da=[]
db=[]
dc=[]

colorGrid = [map(int, raw_input().split()) for _ in range(C)]

dataGrid = [map(int, raw_input().split()) for _ in range(N)]

for i in range(N):
	for j in range(N):
		d=i+j+2
		inn=dataGrid[i][j]
		if d%3==0:
			da.append(inn)
		elif d%3==1:
			db.append(inn)
		else:
			dc.append(inn)

ka=range(C)
kb=range(C)
kc=range(C)
du = lambda oc, tc : colorGrid[oc][dc]
for i in range(C):
	ka[i]=sum([du(oc, i) for oc in da])
	kb[i]=sum([du(oc, i) for oc in db])
	kc[i]=sum([du(oc, i) for oc in dc])	


ra=ka.sort()[0:3]
rb=kb.sort()[0:3]
rc=kc.sort()[0:3]

mm=-1
for i in range(3):
	for j in range(3):
		for k in range(3):
			d=ra[i]+rb[j]+rc[k]
			if mm == -1 or d< mm:
				mm=d

print mm

Fixed submission:
import sys

#+++++

def naiseki(va,vb):
	return sum([a*b for a,b in zip(va,vb)])

def main():
	n , c = map(int, input().split())
		
	ccc=[0]*c
	for i in range(c):
		ccc[i]=[0]*c
	for i in range(c):
		temp=list(map(int,input().split()))
		#ccc[i]=temp
		for j,v in enumerate(temp):
			ccc[j][i]=v
		
	pa(ccc)
		
	ddl=[0,0,0]
	for i in range(3):
		ddl[i]=[0]*c
		
	for i in range(1,n+1):
		ll=list(map(int, input().split()))
		for j, color_v in enumerate(ll,start=1):
			group=(i+j)%3
			ddl[group][color_v-1]+=1
			
	pa('_____ddl_____')
	for i in range(3):
		pa(ddl[i])
		
	rrb=[0]*3
	for i in range(3):
		rrb[i]=[0]*c	
		for j in range(c):
			rrb[i][j]=(naiseki(ddl[i], ccc[j]),j)
			
	pa('____rrb_____')
	for i in range(3):
		pa(rrb[i])
	
	c=[0]	* 3
	for i in range(3):
		rrb[i].sort()
		aa=rrb[i][:3]
		c[i]=aa
		
	pa('____ c _____')
	for i in range(3):
		pa(c[i])
		
	mm=None
	for i in range(3):
		for j in range(3):
			for k in range(3):
				ii=c[0][i][1]
				ji=c[1][j][1]
				ki=c[2][k][1]
				if ii !=ji and ji!=ki and ki!=ii:
					temp=c[0][i][0]+c[1][j][0]+c[2][k][0]
					#pa(temp)
					mm = temp if mm is None else min(mm,temp)
					
	return mm
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Runtime Error):
a=input()

al=[int(c) for c in list(str(a))]

sal=sum(al)
return sal if sal > 1 else 10

Fixed submission:
a=input()

al=[int(c) for c in list(str(a))]

sal=sum(al)
ret= sal if sal > 1 else 10
print(ret)
Buggy python submission (verdict: Runtime Error):
import sys

#+++++


def main():
	s = input()
	a = ''.join(sorted(s)) == 'abc'
	if a:
		print('Yes')
	else:
		print('No')
	#print(' '.join([str(v) for v in l]))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		#input = sys.stdin.readline
        pass
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys

#+++++


def main():
	s = input()
	#a ='Yes' if ''.join(sorted(s)) == 'abc' else 'No'
	for c in 'abc':
		if c not in s:
			print('No')
			return 
	print('Yes')
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Buggy python submission (verdict: Runtime Error):
import sys

#+++++


def main():
	s = input()
	a = ''.join(sorted(s)) == 'abc'
	if a:
		print('Yes')
	else:
		print('No')
	#print(' '.join([str(v) for v in l]))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		#input = sys.stdin.readline
        pass
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys

#+++++


def main():
	s = input()
	#a ='Yes' if ''.join(sorted(s)) == 'abc' else 'No'
	for c in 'abc':
		if c not in s:
			print('No')
			return 
	print('Yes')
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Buggy python submission (verdict: Runtime Error):
import sys

#+++++


def main():
	s = input()
	a = ''.join(sorted(s)) == 'abc'
	if a:
		print('Yes')
	else:
		print('No')
	#print(' '.join([str(v) for v in l]))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed submission:
import sys

#+++++


def main():
	s = input()
	#a ='Yes' if ''.join(sorted(s)) == 'abc' else 'No'
	for c in 'abc':
		if c not in s:
			print('No')
			return 
	print('Yes')
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy python submission (verdict: Runtime Error):
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 submission:
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)