Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)
if len(c) <= k:
    print(0)
else:
    sum = 0
    for i in range(k, len(c)):
        sum += c.most_common()[i][1]
    print(sum)

Fixed submission:
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)
d = c.most_common()
if len(c) <= k:
    print(0)
else:
    sum = 0
    for i in range(k, len(c)):
        sum += d[i][1]
    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)
    

if len(c) <= k:
    print(0)
else:
    sum = 0
    for i in range(k, len(c)):
        sum += c.most_common()[i][1]
    print(sum)

Fixed submission:
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)
d = c.most_common()
if len(c) <= k:
    print(0)
else:
    sum = 0
    for i in range(k, len(c)):
        sum += d[i][1]
    print(sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
precount = 0
for i in range(1, n+1):
    tmp = i
    flag = 1
    count = 0
    while flag :
        flag = 0
        if i%2 == 0:
            i = i//2
            flag = 1
            count += 1
    if precount < count :
        precount = count
        ans = tmp
        
    
            

print(ans)

Fixed submission:
n = int(input())
precount = 0
if n==1:
    ans = 1
for i in range(1, n+1):
    tmp = i
    flag = 1
    count = 0
    while flag :
        flag = 0
        if i%2 == 0:
            i = i//2
            flag = 1
            count += 1
    if precount < count :
        precount = count
        ans = tmp
        
    
            

print(ans)
Buggy python submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
a = str(r) + str(g) + str(b)
if a%4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
r, g, b = map(int, input().split())
a = str(r) + str(g) + str(b)
if int(a)%4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if i+j+m == s:
                count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <=k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))

Fixed submission:
N, K = map(int, input().split()) 
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
A = list(map(int, input().split()))
print(sum(A.sort()[0:K]))

Fixed submission:
N, K = map(int, input().split()) 
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
ans = 1

for i in range(N):
    tmp = int(input())
    ans = lcm(ans, tmp)

print(ans)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
ans = 1

for i in range(N):
    tmp = int(input())
    ans = lcm(ans, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
a = input().strip()
if a <= z:
  print('a')
else:
  print('A')

Fixed submission:
a = input().strip()

if a.isupper():
    print('A')
else:
    print('a')
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
print(int(A) * int(float(B)*1000)//1000)

Fixed submission:
a,b=map(int,input().replace('.', '').split())
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a, b = input().split()
print(int(A) * int(float(B)*1000//1000))

Fixed submission:
a,b=map(int,input().replace('.', '').split())
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

print (int(a*b))

Fixed submission:
a,b=map(int,input().replace('.', '').split())
print(a*b//100)

Buggy python submission (verdict: Runtime Error):

n = int(input())
An = list(map(int, input().split()))

j = 100000000000000000

ans = 1


for i in range(n):
    ans = ans * An[i]

if ans <= j:
    print(ans)
    quit()
else :
    print('-1')
    quit()

Fixed submission:
a,b=map(int,input().replace('.', '').split())
print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
three = [0, 0, 0]

for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            g = i + j + k
            if g == s:
                ans += 1
                 
print(ans)

Fixed submission:
k, s = map(int, input().split())

ans = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k :
            ans += 1
                 
print(ans)
Buggy python submission (verdict: Runtime Error):
if α.isupper() = True :
  print("A")
else:
  print("B")

Fixed submission:
α = input()

if α.isupper() == True :
  print("A")
if α.islower() == True :
  print("a")

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
q = int(input())

total = sum(A)
dic = {}
for i in range(q):
  b, c = map(int, input().split())
  b_count = A.count(b)
  c_count = A.count(c)
  dic[c] = c_count + b_count
  if b in dic:
    b_count = dic[b]
  diff = c - b
  total += b_count*diff
  print(total)
  
  
    

Fixed submission:
alpha = str(input())

if  (alpha.islower() == True):
  print('a')
else:
  print('A')
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
x,N = map(int, input().split())

P = list(map(int, input().split()))

abs_list = []

for p in P:
  abs_list.append(np.abs(x-p))
  
if len(abs_list) == 0:
  print(x)
  sys.exit()
   
abs_max = max(abs_list)
for i in range(100):
  if abs_list.count(i) == 0:
    print(x-i)
    sys.exit()
  elif abs_list.count(i) == 1 and x+i in P and i !=0:
    print(x-i)
    sys.exit()
  elif abs_list.count(i) == 1 and x-i in P and i != 0:
    print(x+i)
    sys.exit()

Fixed submission:
X = list(map(int, input().split()))

for i, x in enumerate(X):
  if x == 0:
    print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

answer = 1
for a in A:
  answer = answer*a

if answer > 10**18:
  answer = -1
  
print(answer)

Fixed submission:
import sys

n = int(input())
A = list(map(int, input().split()))

answer = 1

for a in A:
  if a == 0:
    answer = 0
    print(answer)
    sys.exit()
    
for a in A:
  answer = answer*a
  if answer > 10**18:
    answer = -1
    print(answer)
    sys.exit()


print(answer)
Buggy python submission (verdict: Runtime Error):
x = int(input())

import math
def trial_division(n):
    #素因数を格納するリスト
    num_list = []
    factor = set(num_list)
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.add(num)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    else:
        factor.add(n)
        return factor


for number in trial_division(x):
  for a in range(round(x**(1/5))):
    b = a - number
    if a**5 - b**5 == x:
      print(a,b)
      break
    elif a**5 - (-b)**5==x:
      print(a,-b)
      break

Fixed submission:
s = str(input())

if s == 'ARC':
  print('ABC')
else:
  print('ARC')
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


for number in factorization(x):
  for a in range(number[0]**5):
    b = a - number[0]
    if a**5 - b**5 == x:
      print(a,b)
      break
    elif a**5 - (-b)**5==x:
      print(a,-b)
      break

Fixed submission:
import sys
x = int(input())

for a in range(120):
  for b in range(120):
    if a**5 - b**5 == x:
      print(a,b)
      sys.exit()
    elif a**5 - (-b)**5==x:
      print(a,-b)
      sys.exit()

Buggy python submission (verdict: Runtime Error):
x = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

for number in factorization(x):
  for a in range(x/number):
    b = a - number
    if a**5 - b**5 == x:
      print(a,b)
      break
    elif a**5 - (-b)**5==x:
      print(a,-b)
      break

Fixed submission:
import sys
x = int(input())

for a in range(120):
  for b in range(120):
    if a**5 - b**5 == x:
      print(a,b)
      sys.exit()
    elif a**5 - (-b)**5==x:
      print(a,-b)
      sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

for number in factorization(x):
  for a in range(x):
    b = a - number
    if a**5 - b**5 == x:
      print(a,b)
      break
    elif a**5 - (-b)**5==x:
      print(a,-b)
      break

Fixed submission:
import sys
x = int(input())

for a in range(120):
  for b in range(120):
    if a**5 - b**5 == x:
      print(a,b)
      sys.exit()
    elif a**5 - (-b)**5==x:
      print(a,-b)
      sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a = list(map(int, input().split()))

answer = []
for i in range(n):
  answer.append(a.count(i+1))


for j in range(n):
  print(answer[j])

Fixed submission:
import collections
import numpy as np

n = int(input())
l = list(map(int, input().split()))

answer = np.zeros(n ,dtype=int)
for number in l:
  answer[number-1] += 1


for j in range(n):
  c = round(answer[j])
  print(c)
Buggy python submission (verdict: Runtime Error):
from math import cos, sqrt, radians
A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)

Fixed submission:
N = str(input())
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
elif N[-1] == '3':
    print('bon')
Buggy python submission (verdict: Runtime Error):
S = input('Enter something: ')
if S[2] == S[3] and S[4] == s[5]:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
d n = map(int, input().split())
ans = 100**d * n
print(ans)

Fixed submission:
d, n = map(int, input().split())
if n<=99:
 ans = 100**d * n
else:
 ans = 100**d * (n+1)
print(ans)
Buggy python submission (verdict: Runtime Error):
num = int(input())
strng = ""
while num >= 1 :
    kalan = num % 26
    if(kalan==0):
      strng = "z" +strng
    else:
    	strng = chr(96+kalan)+strng
    num = num // 26
print(strng)

Fixed submission:
import re
txt=input()
x = re.search("[A-Z]", txt)
if(x):
  print("A")
else:
  print("a")

Buggy python submission (verdict: Runtime Error):
num = int(input())
strng = ""
while num >= 1 :
    kalan = num % 26
    strng = chr(97+kalan-1)+strng
    num = num // 26
print(strng)

Fixed submission:
import re
txt=input()
x = re.search("[A-Z]", txt)
if(x):
  print("A")
else:
  print("a")

Buggy python submission (verdict: Runtime Error):
N=0

N = int(input())
K = int(input())
p = [int(input()) for i in range(N)]

p.sort()
print(sum(p[0:K]))


Fixed submission:

S = input()
if(S.isupper()):
    print('A')
else:
    print('a')

Buggy python submission (verdict: Runtime Error):
S = input()
if(S.isupper()):
    printf('A')
else:
    printf('a')

Fixed submission:

S = input()
if(S.isupper()):
    print('A')
else:
    print('a')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=map(int,input().split())
x=10**18
ans=1
for i in a:
    ans=ans*i

if(ans>x):
  ans=-1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
if 0 in a:
  ans=0
else:
  for i in a:
    ans=ans*i
    if(ans>x):
      ans=-1
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if s=="ABC":
    ans=ARC
else:
    ans=ABC
print(ans)

Fixed submission:
S=input()
if S=="ABC":
    ans="ARC"
else:
    ans="ABC"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
ans=0
def gcd(a,b,c):
    a=math.gcd(a,b)
    return math.gcd(a,c)

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans+=gcd(i,j,k)
print(ans)

Fixed submission:
import math
#import time
def gcd(a,b,c):
    return math.gcd(a,math.gcd(b,c))
#time1=time.time()
K=int(input())
ans=0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i==j and j==k:
                ans+=gcd(i,j,k)
            elif i==j or i==k or j==k:
                ans+=3*gcd(i,j,k)
            else:
                ans+=6*gcd(i,j,k)
#time2=time.time()
print(ans)
#print(time2-time1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())
ans=0
for i in range(N):
    for j in range(i+1,N):
        if S[i]==S[j]:
            continue
        if j+(j-i)<N:
            s=S[j+(j-i)]
            S[j+(j-i)]="O"
        if i-(j-i)>=0:
            s1=S[i-(j-i)]
            S[i-(j-i)]="O"
        S2="".join(S)
        if (S[i]=="R" and S[j]=="G") or (S[i]=="G" and S[j]=="R"):
            ans+=S2.count("B",j+1,N)
        if (S[i]=="R" and S[j]=="B") or (S[i]=="B" and S[j]=="R"):
            ans+=S2.count("G",j+1,N)
        if (S[i]=="B" and S[j]=="G") or (S[i]=="G" and S[j]=="B"):
            ans+=S2.count("R",j+1,N)
        if j+(j-i)<N:
            S[j+(j-i)]=s
        if i-(j-i)>=0:
            S[i-(j-i)]=s1
print(ans)

Fixed submission:
N=int(input())
S=input()
totalPattern = S.count("R")*S.count("G")*S.count("B")
for i in range(N-1):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>N-1:
            continue
        if not S[i] == S[j] and not S[i] == S[k] and not S[j] == S[k]:
            totalPattern-=1
print(totalPattern)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())
ans=0
for i in range(N):
    for j in range(i+1,N):
        if S[i]==S[j]:
          continue
        for k in range(j+1,N):
            if k-j==j-i:
                continue
            if not (S[i]==S[j] or S[j]==S[k] or S[i]==S[k]):
                ans+=1
print(ans)

Fixed submission:
N=int(input())
S=input()
totalPattern = S.count("R")*S.count("G")*S.count("B")
for i in range(N-1):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>N-1:
            continue
        if not S[i] == S[j] and not S[i] == S[k] and not S[j] == S[k]:
            totalPattern-=1
print(totalPattern)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())
ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if k-j==j-i:
                continue
            if not (S[i]==S[j] or S[j]==S[k] or S[i]==S[k]):
                ans+=1
print(ans)

Fixed submission:
N=int(input())
S=input()
totalPattern = S.count("R")*S.count("G")*S.count("B")
for i in range(N-1):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>N-1:
            continue
        if not S[i] == S[j] and not S[i] == S[k] and not S[j] == S[k]:
            totalPattern-=1
print(totalPattern)
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
N,K=map(int,input().split())
gcd=[0]*(K+1)
ans=0
multipleNumber=0
for i in reversed(range(1,K+1)):
    multipleNumber=K//i
    totalNumber=multipleNumber**N%mod
    minus=range(2*i,K+1,i)
    for j in minus:
        totalNumber-=gcd[j]
        totalNumber%=mod
    gcd[i]=totalNumber
    ans+=i*gcd[i]
print(ans%mod)

Fixed submission:
mod=10**9+7
N,K=map(int,input().split())
d=[0]*(K+1)
ans=0
for i in range(1,K+1):
    d[i]=pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i]-=d[j]
        d[i]%=mod
    ans+=d[i]*i
    ans%=mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod=10**9+7
N,K=map(int,input().split())
gcd=[0]*(K+1)
ans=0
multipleNumber=0
for i in reversed(range(1,K+1)):
    multipleNumber=K//i
    totalNumber=multipleNumber**N%mod
    minus=range(2*i,K+1,i)
    for j in minus:
        totalNumber-=gcd[j]
        totalNumber%=mod
    gcd[i]=totalNumber
    ans+=i*gcd[i]
print(ans%a)

Fixed submission:
mod=10**9+7
N,K=map(int,input().split())
d=[0]*(K+1)
ans=0
for i in range(1,K+1):
    d[i]=pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i]-=d[j]
        d[i]%=mod
    ans+=d[i]*i
    ans%=mod
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a=10**9+7
N,K=map(int,input().split())
gcd=[0]*(K+1)
ans=0
multipleNumber
for i in reversed(range(1,K+1)):
    multipleNumber=math.floor(K/i)
    totalNumber=multipleNumber**N
    if 2*i<=K:
        minus=range(2*i,K+1,i)
        for j in minus:
            totalNumber-=gcd[j]
    gcd[i]=totalNumber
for i in range(1,len(gcd)):
    ans+=i*gcd[i]
print(ans)

Fixed submission:
mod=10**9+7
N,K=map(int,input().split())
d=[0]*(K+1)
ans=0
for i in range(1,K+1):
    d[i]=pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i]-=d[j]
        d[i]%=mod
    ans+=d[i]*i
    ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y,Z=map(int,input())
print(str(Z) + " " + str(X) + " " + str(Y))

Fixed submission:
X,Y,Z=map(int,input().split())
print(str(Z)+" "+str(X)+" " + str(Y))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=True
while a:
    if abs(N-K)<N:
        N=abs(N-K)
    else:
        a=False
print(N)

Fixed submission:
N,K=map(int,input().split())
N=N%K
ans=min(N,abs(N-K))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
input_lines=list(map(int,input().split()))
balls=[]
count=0
for i in range(10**100):
    for j in range(input_lines[1]):
        balls.append('b')
    for j in range(input_lines[2]):
        balls.append('r')
    if len(balls)>input_lines[0]:
        break
for i in range(input_lines[0]):
    if balls[i]=='b':
        count+=1
print(count)

Fixed submission:
n,a,b=map(int,input().split())
answer=n//(a+b)*a+min(n%(a+b),a)
print(answer)
Buggy python submission (verdict: Runtime Error):
#D
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BandC = [list(map(int, input().split())) for _ in range(Q)]

temp = [0] * 10 ** 5
for i in range(N):
    temp[A[i]] += 1
    
s = sum(A)

for i in range(Q):
    num = BandC[i][0]
    num_temp = temp[num]
    temp[num] = 0
    temp[BandC[i][1]] += num_temp
    s = s - BandC[i][0] * num_temp + BandC[i][1] * num_temp
    print(s)

Fixed submission:
#D
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BandC = [list(map(int, input().split())) for _ in range(Q)]

temp = [0] * (10 ** 5 + 1)
for i in range(N):
    temp[A[i]] += 1
    
s = sum(A)

for i in range(Q):
    num = BandC[i][0]
    num_temp = temp[BandC[i][0]]
    temp[BandC[i][0]] = 0
    temp[BandC[i][1]] += num_temp
    s = s - BandC[i][0] * num_temp + BandC[i][1] * num_temp
    print(s)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
if X <= 3 and Y <= 3:
    ans = (4-X) * 100000 + (4-Y) * 100000
    if X == 1 and Y == 1:
        ans += 400000
elif X <= 3:
    ans = (4-X) * 100000
elif Y <= 3:
    ans = (4-Y) * 100000
    
print(ans)

Fixed submission:
X, Y = map(int, input().split())
if X <= 3 and Y <= 3:
    ans = (4-X) * 100000 + (4-Y) * 100000
    if X == 1 and Y == 1:
        ans += 400000
elif X <= 3:
    ans = (4-X) * 100000
elif Y <= 3:
    ans = (4-Y) * 100000
else:
    ans = 0
    
print(ans)
Buggy python submission (verdict: Runtime Error):
S = str(input())
a = []
ans = 0

def sumn(x):
    y = x * (x+1)//2
    return y
    
cnt = 1

if len(S) == 1:
    ans = 1
    print(ans)
else:
    for i in range(len(S)-1):
        if S[i+1] == S[i]:
            cnt += 1
            if i+1 == len(S)-1:
                a.append(cnt)
        
        else:
            a.append(cnt)
            cnt = 1
            if i+1 == len(S)-1:
                a.append(cnt)
            
    if S[0] == '<':
        for i in range(len(a)):
            if i % 2 == 0:
                ans += sumn(a[i])
            else:
                if a[i] > a[i-1]:
                    ans += (sumn(a[i]) - a[i-1])
                else:
                    ans += sumn(a[i]-1)
    else:
        if i == 0:
            ans += sumn(a[i])
        elif i % 2 == 1:
            ans += sumn(a[i])
        else:
            if a[i] > a[i-1]:
                ans += (sumn(a[i]) - a[i-1])
            else:
                ans += sumn(a[i]-1)
    print(ans)

Fixed submission:
S = str(input())
a = []
ans = 0

def sumn(x):
    y = x * (x+1)//2
    return y
    
cnt = 1

if len(S) == 1:
    ans = 1
    print(ans)
else:
    for i in range(len(S)-1):
        if S[i+1] == S[i]:
            cnt += 1
            if i+1 == len(S)-1:
                a.append(cnt)
        
        else:
            a.append(cnt)
            cnt = 1
            if i+1 == len(S)-1:
                a.append(cnt)
            
    if S[0] == '<':
        for i in range(len(a)):
            if i % 2 == 0:
                ans += sumn(a[i])
            else:
                if a[i] > a[i-1]:
                    ans += (sumn(a[i]) - a[i-1])
                else:
                    ans += sumn(a[i]-1)
    else:
        for i in range(len(a)):
            if i == 0:
                ans += sumn(a[i])
            elif i % 2 == 1:
                ans += sumn(a[i])
            else:
                if a[i] > a[i-1]:
                    ans += (sumn(a[i]) - a[i-1])
                else:
                    ans += sumn(a[i]-1)
    print(ans)