





"""simple docstring"""




class  __A   :

			'''simple docstring'''







			def __init__(   self	,  __lowerCAmelCase							):



				'''simple docstring'''







				lowerCamelCase__        =		data
				lowerCamelCase__        =		4_2
				lowerCamelCase__        =		4_2





def lowerCAmelCase__(__snake_case							)    ->				None:







	'''simple docstring'''







	lowerCamelCase__        =		0
	lowerCamelCase__        =		x





def lowerCAmelCase__(__snake_case	,__snake_case							)    ->				None:







	'''simple docstring'''







	lowerCamelCase__    ,     lowerCamelCase__        =		find_set(__snake_case							), find_set(__snake_case							)
	if x == y:
		return

	elif x.rank > y.rank:
		lowerCamelCase__        =		x
	else:
		lowerCamelCase__        =		y
		if x.rank == y.rank:
			y.rank += 1





def lowerCAmelCase__(__snake_case							)    ->				Node:







	'''simple docstring'''







	if x != x.parent:
		lowerCamelCase__        =		find_set(x.parent							)
	return x.parent





def lowerCAmelCase__(__snake_case							)    ->				set:







	'''simple docstring'''







	lowerCamelCase__        =		({0, 1, 2}, {3, 4, 5})
	for s in sets:
		if node.data in s:
			return s
	lowerCamelCase__        =		F'{node.data} is not in {sets}'
	raise ValueError(__snake_case							)





def lowerCAmelCase__()    ->				None:







	'''simple docstring'''







	lowerCamelCase__        =		[Node(__snake_case							) for i in range(6							)]
	for v in vertex:
		make_set(__snake_case							)

	union_set(vertex[0]	,vertex[1]							)
	union_set(vertex[1]	,vertex[2]							)
	union_set(vertex[3]	,vertex[4]							)
	union_set(vertex[3]	,vertex[5]							)

	for nodea in vertex:
		for nodea in vertex:
			if find_python_set(__snake_case							).isdisjoint(find_python_set(__snake_case							)							):
				assert find_set(__snake_case							) != find_set(__snake_case							)
			else:
				assert find_set(__snake_case							) == find_set(__snake_case							)


if __name__ == "__main__":
			test_disjoint_set()










import os





def lowerCAmelCase__()    ->				Optional[Any]:







	'''simple docstring'''







	lowerCamelCase__        =		os.path.dirname(os.path.realpath(__snake_case							)							)
	lowerCamelCase__        =		os.path.join(__snake_case	,'''triangle.txt'''							)

	with open(__snake_case							) as f:
		lowerCamelCase__        =		f.readlines()

	lowerCamelCase__        =		[[int(__snake_case							) for y in x.rstrip('''\r\n'''							).split(''' '''							)] for x in triangle]

	for i in range(1	,len(__snake_case							)							):
		for j in range(len(a[i]							)							):
			lowerCamelCase__        =		a[i - 1][j] if j != len(a[i - 1]							) else 0
			lowerCamelCase__        =		a[i - 1][j - 1] if j > 0 else 0
			a[i][j] += max(__snake_case	,__snake_case							)
	return max(a[-1]							)


if __name__ == "__main__":
			print(solution())



