Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    l = [s[0]]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] = l[-1] + s[i]
        else:
            lap(s[i])
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if l[0][0] == "<":
        dap(0)
    for i in l:
        if i[0] == "<":
            pap(len(i))
        else:
            dap(len(i))
    if l[-1][0] == ">":
        pap(0)
    dm = max(dlist)
    pm = max(plist)
    sm = [i for i in range(0,max(dm,pm)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    l = [s[0]]
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] = l[-1] + s[i]
        else:
            lap(s[i])
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if l[0][0] == "<":
        dap(0)
    for i in l:
        if i[0] == "<":
            pap(len(i))
        else:
            dap(len(i))
    if l[-1][0] == ">":
        pap(0)
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    flag = True
    l = [""]
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(len(s)):
        if flag:
            l[-1] = l[-1] + s[i]
        else:
            lap(s[i])
        if i < len(s)-1:
            if s[i] == "<" and s[i+1] == ">":
                flag = False
            else:
                flag = True
    xlist = []
    ylist = []
    xap = xlist.append
    yap = ylist.append
    for i in l:
        x = 0
        y = 0
        for j in list(i):
            if j == ">":
                x += 1
            else:
                y += 1
        xap(x)
        yap(y)
    for i in range(1,len(l)):
        x = xlist[i]
        y = ylist[i-1]
        if y <= x:
            xlist[i] = sm[x]
            ylist[i-1] = sm[max([0,y-1])]
        else:
          xlist[i] = sm[max([0,x-1])]
          ylist[i-1] = sm[y]
    xlist[0] = sm[xlist[0]]
    ylist[-1] = sm[ylist[-1]]
    print(sum(xlist)+sum(ylist))
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    flag = True
    l = [""]
    ans = 0
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    for i in range(len(s)):
        if flag:
            l[-1] = l[-1] + s[i]
        else:
            l.append(s[i])
        if i < len(s)-1:
            if s[i] == "<" and s[i+1] == ">":
                flag = False
            else:
                flag = True
    xlist = []
    ylist = []
    for i in l:
        x = 0
        y = 0
        for j in list(i):
            if j == ">":
                x += 1
            else:
                y += 1
        xlist.append(x)
        ylist.append(y)
    for i in range(1,len(l)):
        if ylist[i-1] <= xlist[i]:
            ylist[i-1] = max([0,ylist[i-1]-1])
        else:
          xlist[i] = max([0,xlist[i]-1])
    for i in xlist:
        ans += sm[i]
    for i in ylist:
        ans += sm[i]
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    flag = True
    l = [""]
    ans = 0
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    for i in range(len(s)):
        if flag:
            l[-1] = l[-1] + s[i]
        else:
            l.append(s[i])
        if i < len(s)-1:
            if s[i] == "<" and s[i+1] == ">":
                flag = False
            else:
                flag = True
    xlist = []
    ylist = []
    for i in l:
        x = 0
        y = 0
        for j in list(i):
            if j == ">":
                x += 1
            else:
                y += 1
        xlist.append(x)
        ylist.append(y)
    for i in range(1,len(l)):
        if ylist[i-1] <= xlist[i]:
            ylist[i-1] = max([0,ylist[i-1]-1])
        else:
          xlist[i] = max([0,xlist[i]-1])
    for i in xlist:
        ans += sm[i]
    for i in ylist:
        ans += sm[i]
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = input()
    f1 = False
    f2 = False
    l = [1]
    if s[0] == "<":
        f1 = True
        l.insert(0,0)
    if s[-1] == ">":
        f2 = True
    sm = [i for i in range(0,len(s)+1)]
    for i in range(1,len(sm)):
        sm[i] = sm[i-1]+sm[i]
    lap = l.append
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            l[-1] += 1
        else:
            lap(1)
    dlist = []
    plist = []
    dap = dlist.append
    pap = plist.append
    if f2:
        l.append(0)
    for i in range(len(l)//2):
        dap(l[2*i])
        pap(l[2*i+1])   
    for i in range(1,len(dlist)):
        x = dlist[i]
        y = plist[i-1]
        if y <= x:
            dlist[i] = sm[x]
            plist[i-1] = sm[max([0,y-1])]
        else:
          dlist[i] = sm[max([0,x-1])]
          plist[i-1] = sm[y]
    dlist[0] = sm[dlist[0]]
    plist[-1] = sm[plist[-1]]
    print(sum(dlist)+sum(plist))
    
if __name__ == '__main__':
    main()