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):
moji = list(input())
listlist=[]
inlist=[]
result=0
if moji[0]=='>':
    inlist.append(2)
else:
    pass
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)):
            result += m
        for n in range(inlist.count(2)):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    pass
elif moji[i] == '<' and moji[i+1]=='<':

        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)):
            result += m
        for n in range(inlist.count(2)):
            result += n

elif moji[i] == '<' and moji[i+1]=='>':
    pass

print(result)

moji = list(input())
listlist=[]
inlist=[]
result=0
if moji[0]=='>':
    inlist.append(2)
else:
    pass
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
elif moji[i] == '<' and moji[i+1]=='<':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
elif moji[i] == '<' and moji[i+1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
result

moji = list(input())
listlist=[]
inlist=[]
result=0
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
elif moji[len(moji)-2] == '<' and moji[len(moji)-1]=='<':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
elif moji[len(moji)-2] == '<' and moji[len(moji)-1]=='>':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
print(result)

Verdicts: Wrong Answer

Wrong Answer

Accepted