Problem: Given is a string S of length N-1. Each character in S is `<` or `>`.  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be _good_ when the following condition is satisfied for all i (1 \leq i \leq N-1):    * If S_i= `<`: a_i<a_{i+1}   * If S_i= `>`: a_i>a_{i+1}  Find the minimum possible sum of the elements of a good sequence of N non- negative integers.

Submission attempts (in order):
slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0
if nagasa==1:
	kotae=kosu[0]*(kosu[0]+1)/2
else:
	if slist=="<":
		if nagasa%2==0:
			for i in range(0,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		else:
			for i in range(0,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[-1]*(kosu[-1]+1)/2
	else:
		if nagasa%2!=0:
			for i in range(1,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
		else:
			for i in range(1,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
			kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae)
	

slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0

if slist=="<":
	if nagasa%2==0:
		for i in range(0,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
	else:
		for i in range(0,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[-1]*(kosu[-1]+1)/2
else:
	if nagasa%2!=0:
		for i in range(1,nagasa,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
	else:
		for i in range(1,nagasa-1,2):
			kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		kotae+=kosu[0]*(kosu[0]+1)/2
		kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae)
	

slist=list(input())
kosu=[]
n=len(slist)
counter=1
for i in range(n-1):
	if slist[i]==slist[i+1]:
		counter+=1
	else:
		kosu.append(counter)
		counter=1
kosu.append(counter)

nagasa=len(kosu)
kotae=0
if nagasa==1:
	kotae=kosu[0]*(kosu[0]+1)/2
else:
	if slist[0]=="<":
		if nagasa%2==0:
			for i in range(0,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
		else:
			for i in range(0,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[-1]*(kosu[-1]+1)/2
	else:
		if nagasa%2!=0:
			for i in range(1,nagasa,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
		else:
			for i in range(1,nagasa-1,2):
				kotae+=(kosu[i]*(kosu[i]+1)+kosu[i+1]*(kosu[i+1]+1))/2-min(kosu[i],kosu[i+1])
			kotae+=kosu[0]*(kosu[0]+1)/2
			kotae+=kosu[-1]*(kosu[-1]+1)/2
kotae=int(kotae)
print(kotae)
	

Verdicts: Wrong Answer

Wrong Answer

Accepted