Harryxun/stf_run huggingface dataset:
from collections import defaultdict

def get_p(ind):
    global parent
    while parent[ind] != ind:
        ind = parent[ind]
    return ind

def get_p2(ind):
    global parent
    if parent[ind] == -1:
        return ind
    else:
        parent[ind] = get_p2(parent[ind])
        return parent[ind]

parent = []

def main():
    global parent

    num, swap = map(int, input().split())
    data = list(map(int, input().split()))

    parent = [-1 for i in range(num + 1)]

    for i in range(swap):
        a, b = map(int, input().split())
        if parent[a] == -1 and parent[b] == -1:
            parent[max(a, b)] = min(a, b)
        elif parent[a] != -1 and parent[b] != -1:
            a_parent = get_p2(a)
            b_parent = get_p2(b)
            parent[max(a_parent, b_parent)] = min(a_parent, b_parent)
        elif parent[a] == -1:
            parent[a] = get_p2(b)
        else:
            parent[b] = get_p2(a)

    ans = 0

    for i in range(num + 1):
        if parent[i] == -1:
            parent[i] = i


    for i in range(num):
        now_int = i + 1
        ind = data.index(i + 1)
        ind += 1
        if get_p(now_int) == get_p(ind):
            ans += 1
        elif ind == now_int:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###



def get_p(ind):
    if parent[ind] != ind:
        parent[ind] = get_p(parent[ind])
    return parent[ind]



num, swap = map(int, input().split())
data = list(map(int, input().split()))

parent = [i for i in range(num + 1)]

for i in range(swap):
    a, b = map(int, input().split())
    a_parent = get_p(a)
    b_parent = get_p(b)
    if a_parent != b_parent:
        parent[max(a_parent, b_parent)] = min(a_parent, b_parent)

ans = 0

for i in range(num):
    now_int = i + 1
    ind =  data[i]
    if get_p(now_int) == get_p(ind):
        ans += 1
    elif ind == now_int:
        ans += 1

print(ans)
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

import numpy as np
M = int(10**9)+7
n,k = [int(c) for c in input().split()]
nums = [0]*(k+1)
nums = np.zeros((k+1), dtype=int)
for i in range(k, 0, -1):
    tmp = (pow(k // i, n, M)
    tmp -= nums[(2*i)::i].sum()
    nums[i] += tmp
    
# print(sum((i)*nums[i]%M for i in range(len(nums)))%M)
print((np.arange(k+1) * nums).sum()%M)

### FIXED CODE ###

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

import numpy as np
M = int(10**9)+7
n,k = [int(c) for c in input().split()]
nums = [0]*(k+1)
nums = np.zeros((k+1), dtype=int)
for i in range(k, 0, -1):
    tmp = pow(k // i, n, M)
    tmp -= nums[(2*i)::i].sum()
    nums[i] += tmp
    
# print(sum((i)*nums[i]%M for i in range(len(nums)))%M)
print((np.arange(k+1) * nums).sum()%M)
clause_list = list(map(int, input()))

for index, clause in enumerate(clause_list):
  if clause = 5:
    clause_list.pop(index)
    break
    
for index, clause in enumerate(clause_list):
  if clause = 7:
    clause_list.pop(index)
    break
    
for index, clause in enumerate(clause_list):
  if clause = 5:
    clause_list.pop(index)
    break
    
print('YES' if len(clause_list) == 0 else 'NO')

### FIXED CODE ###

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

for index, clause in enumerate(clause_list):
  if clause == 5:
    clause_list.pop(index)
    break

for index, clause in enumerate(clause_list):
  if clause == 7:
    clause_list.pop(index)
    break

for index, clause in enumerate(clause_list):
  if clause == 5:
    clause_list.pop(index)
    break

print('YES' if len(clause_list) == 0 else 'NO')
a=input()
b=input()
i=0
good=0
while(i<len(a)):
    if(a[i]!=b[i]):
        good+=1
	i+=1
print(good)        

### FIXED CODE ###

a=input()
b=input()

good=0
for i in range(len(a)):
    if(a[i]!=b[i]):
        good+=1
print(good)
import re
s = input()
ci = s.index("C")
if s.index("A") == 0 and 2 <= ci < len(s) - 2:
  tmp = list(s)
  del tmp[0]
  del tmp[ci - 1]
  if re.match("^[a-z]*$", "".join(tmp)):
    print("AC")
    exit()
print("WA")

### FIXED CODE ###

import re
s = input()
ci = s.find("C")
if s.find("A") == 0 and 2 <= ci <= len(s) - 2:
  tmp = list(s)
  del tmp[0]
  del tmp[ci - 1]
  if re.match("^[a-z]*$", "".join(tmp)):
    print("AC")
    exit()
print("WA")
import math
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


def combinations_count(n, r):
	if n < 2:
		return 0
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

_ = int(input())
ns = input().split(" ")
cs = collections.Counter(ns)

jjj1=[]
jjj2=[]
for k, v in cs.items():
	cs[k]
	jjj1.append(cmb(v-1, 2))
	jjj2.append(cmb(v, 2))

c = 0
for n in ns:
	for k, v in cs.items():
		if v==1:
			c += 0
		elif n==k:
#			c += combinations_count(v-1, 2)
			c += cmb(v-1, 2)
		else:
#			c += combinations_count(v, 2)
			c += cmb(v, 2)
	print(c)
	c = 0

### FIXED CODE ###

N = int(input())
A = [int(a)-1 for a in input().split()]
X = [0] * N
for a in A:
	X[a] += 1
s = 0
for x in X:
	s += x * (x-1) // 2
for a in A:
	print(s - (X[a] - 1))
S = int(input())
h = int(S // (60*60))
m = int(S / 60) % 60
s = S%60

print('{}:{}:{}'.format(h.m.s))

### FIXED CODE ###

S = int(input())
h = int(S // (60*60))
m = int(S / 60) % 60
s = S%60

print('{}:{}:{}'.format(h,m,s))
from sys import stdin
readline = stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())

t = [0] * (N + 1)
s = sum(A)
for a in A:
    t[a] += 1

for _ in range(Q):
    B, C = map(int, readline().split())
    s -= B * t[B]
    s += C * t[B]
    t[C] += t[B]
    t[B] = 0
    print(s)


### FIXED CODE ###

from sys import stdin
readline = stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())

t = sum(A)
d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

for _ in range(Q):
    B, C = map(int, readline().split())
    d.setdefault(B, 0)
    d.setdefault(C, 0)
    t -= B * d[B]
    t += C * d[B]
    d[C] += d[B]
    d[B] = 0
    print(t)
import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(m*(B-1)-1+j)
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B))
    

### FIXED CODE ###

import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(max(0,m*(B-1)-1+j))
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B)))
N = int(input())
A = list(map(int,input().split()))
n = 0
can = True

while can:

    for i in range(N):
        if A[i]%2 == 1:
            can = False
            break

       elif A[i]%2 == 0:         
            A[i] = A[i] // 2
            n += 1

        else:
            can = False
            break

print(n)

### FIXED CODE ###

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

while 1:
    #すべてが偶数か確認
    for i in range(N):
        if A[i] % 2 == 0:
            continue
        else:
            F = 1
    
    if F == 1 : break 

    for i in range(N):
        A[i] = A[i]/2
    n += 1


print(n)
import math

for n in range(200):
    nums = list(map(int, input().split()))
    if nums==[]:
        break
    else:
        if nums[0]==0:
            a=1
        else:
            a = int(1.0+math.log(nums[0],10))
        if nums[1]==0:
            b=1
        else:
            b = int(1.0+math.log(nums[1],10))
    print(a+b)

### FIXED CODE ###

import math
import sys

for line in sys.stdin:
    words=line.strip().split(" ")
    a=int(words[0])
    b=int(words[1])
    c=a+b
    if c!=0:
        print(int(1.0000001+math.log(c,10)))
    else:
        print(1)
def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    A = list(map(int, readline().rstrip().split()))
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()



### FIXED CODE ###

import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    A = readline().rstrip().split()
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()
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 CODE ###

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)
from functools import cmp_to_key

MOD = 10 ** 9 + 7


def func(a, b):
    if a[0] * b[1] == a[1] * b[0]:
        return 0
    elif a[0] * b[1] < a[1] * b[0]:
        return - 1
    else:
        return 1


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] < 0:
        a[i] = -a[i]
        b[i] = -b[i]
    if a[i] == 0 and b[i] < 0:
        b[i] = -b[i]
l = sorted(zip(a, b), key=cmp_to_key(func))
li = [[1, 0, l[0][0], l[0][0]]]
for i in range(n - 1):
    a, b = l[i]
    c, d = l[i + 1]
    if b <= 0:
        break
    if a * d == b * c:
        li[-1][0] += 1
    else:
        li.append([1, 0, c, d])
else:
    a, b = l[-2]
    c, d = l[-1]
    if b > 0:
        if a * d == b * c:
            li[-1][0] += 1
        else:
            li.append([1, 0, c, d])
        i = n
idx = 0
cnt = 0
for j in range(i, n):
    a, b = l[j]
    a, b = -b, a
    while idx < len(li) and li[idx][2] * b < li[idx][3] * a:
        idx += 1
    if idx < len(li) and li[idx][2] * b == li[idx][3] * a:
        li[idx][1] += 1
    else:
        cnt += 1
ans = 1
for a, b, c, d in li:
    ans *= (pow(2, a, MOD) + pow(2, b, MOD) - 1)
    ans %= MOD
print(((ans) * (pow(2, cnt, MOD)) // 2 - 1) % MOD)


### FIXED CODE ###

from functools import cmp_to_key

MOD = 10 ** 9 + 7


def func(a, b):
    if a[0] * b[1] == a[1] * b[0]:
        return 0
    elif a[0] * b[1] < a[1] * b[0]:
        return - 1
    else:
        return 1


n = int(input())
a = [0] * n
b = [0] * n
i = 0
f = 0
while i < n:
    a[i], b[i] = map(int, input().split())
    if a[i] == 0 and b[i] == 0:
        f += 1
        n -= 1
        continue
    if a[i] < 0:
        a[i] = -a[i]
        b[i] = -b[i]
    if a[i] == 0 and b[i] < 0:
        b[i] = -b[i]
    i += 1
l = sorted(zip(a, b), key=cmp_to_key(func))
if l[0][1] > 0:
    li = [[1, 0, l[0][0], l[0][1]]]
else:
    li = []
for i in range(1, n):
    a, b = l[i - 1]
    c, d = l[i]
    if d <= 0:
        break
    if li and a * d == b * c:
        li[-1][0] += 1
    else:
        li.append([1, 0, c, d])
idx = 0
cnt = 0
for j in range(n):
    a, b = l[j]
    if b > 0:
        continue
    a, b = -b, a
    while idx < len(li) and li[idx][2] * b < li[idx][3] * a:
        idx += 1
    if idx < len(li) and li[idx][2] * b == li[idx][3] * a:
        li[idx][1] += 1
    else:
        cnt += 1
ans = 1
for a, b, c, d in li:
    ans *= (pow(2, a, MOD) + pow(2, b, MOD) - 1)
    ans %= MOD
print((ans * (pow(2, cnt, MOD)) - 1 + f) % MOD)
a, b, k = map(int,input().split())

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])

### FIXED CODE ###

a, b, k = map(int,input().split())
 
def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])
zyouken = [int(i) for i in input().split()]
reizouko = [int(a) for a in input().split()]
densirenzi = [int(b) for b in input().split()]
minkouho = min(reizyouko) + min(densirenzi)
while zyouken[2] > 0:
    waribiki = [int(w) for w in input().split()]
    mink = reizyouko[waribiki[0]] + densirenzi[waribiki[1]] - waribiki[2]
    if mink < minkouho:
        minkouho = mink
print(minkouho)

### FIXED CODE ###

zyouken = [int(i) for i in input().split()]
reizouko = [int(a) for a in input().split()]
densirenzi = [int(b) for b in input().split()]
minkouho = min(reizouko) + min(densirenzi)
while zyouken[2] > 0:
    zyouken[2] -= 1 
    waribiki = [int(w) for w in input().split()]
    mink = reizouko[waribiki[0] - 1] + densirenzi[waribiki[1] - 1] - waribiki[2]
    if mink < minkouho:
        minkouho = mink
print(minkouho)
A, B, K = map(int, input().split())


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx+1, 1, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)


### FIXED CODE ###

A, B, K = map(int, input().split())


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)
k,x=map(int,input().split())
for i in range(k)
	print(x+i-k+1,end="")
if k!=i:
	print(" ",end="")
	for i in range(k)[1:]
    	print(x+i,end="")
    

### FIXED CODE ###

k,x=map(int,input().split())
for i in range(k):
	print(x+i-k+1,end=" ")
if k != 1:
	print("",end="")
	for s in range(k)[1:]:
		print(x+s,end=" ")
# -*- coding: utf-8 -*-

import sys


def func_a(argv):
    A = int(argv[0])
    B = int(argv[1])

    if not (A >= 1):
        pass

    if not (B <= 20):
        pass

    if A <= B:
        if B % A == 0:
            print(A + B)
        else:
            print(B - A)


def main(argv):
    func_a(argv[1:])


if __name__ == "__main__":
    main(sys.argv)


### FIXED CODE ###

# -*- coding: utf-8 -*-

def func_a():
  argv = input().split(" ")
  A = int(argv[0]) if int(argv[0]) >= 1 else 0
  B = int(argv[1]) if int(argv[1]) <= 20 else 0

  if A * B == 0:
    pass
  else:
    if B % A == 0:
      print(A + B)
    else:
      print(B - A)


if __name__ == "__main__":
  func_a()
A,op,B=list(map(input().split()))
if op=='+':
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

A,op,B=input().strip().split()
if op == '+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
import collections 
import time 
while 1:
    n,m= list(map(int,input().split(' ')))
    if n ==m ==0:break
    D = collections.deque()
    time.sleep(20)
    for _ in range(n):
        d_i,p_i = list(map(int,input().split(' ')))
        D.append((d_i,p_i))
    sorted(D,key = lambda x:x[0])
    while m > 0:
        temp = D.popleft()
        if temp[0] > m:
            temp = (temp[0] - m,temp[1])
            m=0
        else: 
            m -= temp[0]
            temp = (0,temp[1])
        D.append(temp)
    ans = 0
    for i in D:
        ans += i[0]*i[1]
    print(ans)


### FIXED CODE ###

while 1:
    n,m= list(map(int,input().split(' ')))
    if n == m ==0:break
    D = []
    for _ in range(n):
        d_i,p_i = list(map(int,input().split(' ')))
        D.append((d_i,p_i))
    D = sorted(D,key = lambda x:x[1],reverse = True)
    while m > 0:
        if len(D) ==0:break
        temp = D.pop(0)
        if temp[0] > m:
            temp = (temp[0] - m,temp[1])
            m=0
            D.append(temp)
        else: 
            m -= temp[0]      
    ans = 0
    for i in D:
        ans += i[0]*i[1]
    print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = []
min = float('inf')

for i in range(1, 101)[::-1]:
    if abs(x - i) < min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)


### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))
min = float('inf')

for i in range(0, 102)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)
import math
n, p = map(int,input().split())
a = list(map(int,input().split()))

even=0
odd=0
for i in a:
    if i%2 == 0:
        even+=1
    else:
        odd+=1
ans = 0
if p == 0:
    ans += 1<<even
    i = 2
    while(i <= odd):
        ans += math.comb(odd, i)
        i+=2

    print(ans)

else:
    evens = 0
    i = 1
    while(i <= even):
        evens += math.comb(even, i)

        i+=1

    i = 1
    while(i <= odd):
        ans += math.comb(odd, i) + math.comb(odd, i)*evens

        i+=2
    print(ans)

### FIXED CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


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

even=0
odd=0
for i in a:
    if i%2 == 0:
        even+=1
    else:
        odd+=1
ans = 0
if p == 0:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    ans += 1<<even
    i = 2
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens
        i+=2

    print(ans)

else:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    i = 1
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens

        i+=2
    print(ans)
h,a = map(int,input().cplit())
print(h//a+1)

### FIXED CODE ###

h,a = map(int,input().split())
if h % a == 0:
  print(h//a)
else:
  print(h//a+1)
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op =='+':
        print(a+b) +1
    elif op =='-':
        print(a-b)    
    elif op =='*':
        print(a*b)
    elif op =='/':
        print(a//b)

### FIXED CODE ###

#ITP1_4_C:   Simple Calculator
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op =='+':
        print(a+b) 
    elif op =='-':
        print(a-b)    
    elif op =='*':
        print(a*b)
    elif op =='/':
        print(a//b)
from collections import*
n,m,*t=map(int,open(0).read().split())
i,o,r=[0]*n,[[]for _ in'_'*n],[]
for a,b in zip(*[iter(t)]*2):
  o[a-1]+=b-1,
  i[b-1]+=1
q=deque(v for v in range(n)if i[v]<1)
while q:
  v=q.popleft()
  r+=v,
  for w in o[v]:
    i[w]-=1
    if i[w]==0:q+=w,
print(-(len(r)==n))
for j,k in enumerate(i):
  if i[j]>0: print(j+1)

### FIXED CODE ###

n = int(input())
print('{:.10f}'.format((n//2 + n%2)/n))
a, b, c= map(int, input().split())
kawaiso = 0 
if a==b && a!=c [
    kawaiso = 1
]
if b==c && b!=a [
    kawaiso = 1
]
if c==a && c!=b [
    kawaiso = 1
]
if kawaiso == 1 [
    print (yes)
]
else [
    print(No)
]


### FIXED CODE ###

a, b, c= map(int, input().split())
kawaiso = 0 
if a==b and a!=c:
    kawaiso = 1
 
elif  b==c and b!=a:
    kawaiso = 1
 
elif c==a and c!=b:
    kawaiso = 1
    
else:
    kawaiso = 0
  
 
if kawaiso == 1:
    print ("Yes")
    
else:
    print("No")
n=input()
data=list(map((int, input().split()))
print('%d %d %d' %(min(data), max(data), sum(data) ))

### FIXED CODE ###

n=int(input())
data=list(map(int, input().split()))
print('%d %d %d' % (min(data), max(data), sum(data) ))
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = s()
N = len(S)
num = 1
num2 = 1
ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += num
        num += 1
    if S[i] == '>' and S[i+1] == '<':
        ans += max(num,num2)
        num = 1
        Flag = 0
    if S[i] == '<' and S[i+1] == '>':
        num2 = num
        num = 1
        Flag = 1
if Flag:
    ans += max(num2,num)
else:
    ans += num
print(ans)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = s()
N = len(S)
num = 1
num2 = 1
ans = 0
Flag = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += num
        num += 1
    if S[i] == '>' and S[i+1] == '<':
        ans += max(num,num2)
        num = 1
        Flag = 0
    if S[i] == '<' and S[i+1] == '>':
        num2 = num
        num = 1
        Flag = 1
if Flag:
    ans += max(num2,num)
else:
    ans += num
print(ans)