Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
mat=[]
dx=[0,0,-1,1]
dy=[1,-1,0,0]
for i in range(n):
    mat.append(list(input().strip()))
f=0 
for i in range(n):
    if f:
        break 
    for j in range(m):
        if mat[i][j]=='#':
            q=[[i,j]]
            f=1 
            vis=[[0 for x1 in range(m)]for y1 in range(n)]
            vis[i][j]=1 
            while q:
                t=q.pop(0)
                #print(t)
                x,y=t[0],t[1] 
                for k in range(4): 
                    if 0<=x+dx[k]<n and 0<=y+dy[k]<m and vis[x+dx[k]][y+dy[k]]==0 and mat[x+dx[k]][y+dy[k]]=='#': 
                        vis[x+dx[k]][y+dy[k]]=1 
                        q.append([x+dx[k],y+dy[k]])
            break 
for i in range(n):
    for j in range(m): 
        if vis[i][j]==0 and mat[i][j]=='#':
           # print(i,j)
            print('No')
            exit()
print('Yes')

### FIXED CODE ###

n,m=map(int,input().split())
mat=[]
dx=[0,0,-1,1]
dy=[1,-1,0,0]
for i in range(n):
    mat.append(list(input().strip()))
f=0 
for i in range(n):
    for j in range(m):
        if mat[i][j]=='#':
            f=0 
            for k in range(4): 
                if 0<=i+dx[k]<n and 0<=j+dy[k]<m and mat[i+dx[k]][j+dy[k]]=='#': 
                    f=1  
            if not f:
                print('No')
                exit()
print('Yes')
N=input()
M=len(str(N))
K=int(N[0])
ans=0
for i in range (M):
	ans+=N[i]
print(max(9*(M-1)+(K-1),ans))

### FIXED CODE ###

N=input()
M=int(N[0:2])
L=len(N[2:])*9
K=0
sum=0
for i in range(len(N)):
	sum+=int(N[i])
K=0
if L>0:
	D=M
else:
	D=M+1
for i in range(D):
	j=str(i)
	if len(j)==1:
		K=max(K,(int(j)))
	else:
		K=max(K,(int(j[0])+int(j[1])))
print(max(sum,K+L))
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
mods=[0]*m
mods[0]=1
for i in range(1,len(a)):
  a[i]=a[i-1]+a[i]%m
  mods[a[i]%m]+=1
ans=0
for i in range(len(mods)):
  p=mods[i]
  if p>1:
    ans+=p*(p-1)//2
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
from collections import defaultdict
mods=defaultdict(int)
mods[0]=1
for i in range(1,len(a)):
  a[i]=a[i-1]+a[i]%m
  mods[a[i]%m]+=1
ans=0
for v in mods.values():
  if v>1:
    ans+=v*(v-1)//2
print(ans)
n = list(map(int, input().split()))
distance = n[1]
points = [list(map(int, input().split())) for i in range(n[0])]
ans = 0
for i in points:
    x = i[0]
    y = i[1]
    d = math.sqrt(x**2 + y**2)
    if d <= distance:
        ans += 1
print(ans)

### FIXED CODE ###

import math
n = list(map(int, input().split()))
distance = n[1]
points = [list(map(int, input().split())) for i in range(n[0])]
ans = 0
for i in points:
    x = i[0]
    y = i[1]
    d = math.sqrt(x**2 + y**2)
    if d <= distance:
        ans += 1
print(ans)
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])
import pandas as pd

n, k = map(int, input().split())
p_n = [int(i) for i in input().split()]

def expected(x):
    return (x+1)/2*k

s = pd.Series(list(map(expected, p_n)))

print(s.rolling(window=k).mean().max())

### FIXED CODE ###

n, k = map(int, input().split())
p_n = [int(i) for i in input().split()]

def expected(x):
    return (x+1)/2

def test3():
    e_n = list(map(expected, p_n))
    s_n = []
    for i, e in enumerate(e_n):
        if i == 0:
            s_n.append(e)
            continue
        s_n.append(s_n[i-1] + e)
    result = []
    result.append(s_n[k-1])
    for i in range(len(s_n)):
        if i+k >= n:
            continue
        result.append(s_n[i+k]-s_n[i])
    print(max(result))      
test3()
from collections import deque
n, m = map(int, input().split())
e = [[] for _ in range(n+1)]
lndmrk = [-1] * (n + 1)
for i in range(n):
	a, b = map(int, input().split())
	e[a].append(b)
	e[b].append(a)

q = deque()
lndmrk[1] = 0
q.append(1)
while(len(q) != 0):
	v = q.popleft()
	for i in e[v]:
		if lndmrk[i] != -1:
			continue
		lndmrk[i] = v
		q.append(i)
f = 1
for i in range(2, n+1):
	if lndmrk[i] == -1:
		f = 0
if f:
	print("Yes")
	for i in range(2, n+1):
		print(lndmrk[i])
else:
	print("No")

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
e = [[] for _ in range(n+1)]
lndmrk = [-1] * (n + 1)
for i in range(m):
	a, b = map(int, input().split())
	e[a].append(b)
	e[b].append(a)

q = deque()
lndmrk[1] = 0
q.append(1)
while(len(q) != 0):
	v = q.popleft()
	for i in e[v]:
		if lndmrk[i] != -1:
			continue
		lndmrk[i] = v
		q.append(i)
f = 1
for i in range(2, n+1):
	if lndmrk[i] == -1:
		f = 0
if f:
	print("Yes")
	for i in range(2, n+1):
		print(lndmrk[i])
else:
	print("No")
N = int(input())
nums = list(map(int, input().split()))

cumul = 1
for i in range(N):
    cumul *= nums[i]

if cumul > 10 ** 18: print(-1)
elif:print(cumul)


### FIXED CODE ###

N = int(input())
nums = list(map(int, input().split()))

cumul = 1
if 0 in nums:
    print(0)
else:
    for i in range(N):
        cumul *= nums[i]
        if cumul > 10 ** 18:
            print(-1)
            break
    if cumul <= 10 ** 18: print(cumul)
n = int(input())

hats = [0, 0, 0]
count = 1
mod = 1000000007

for a in map(int, input().split()):
  count *= hats.count(a)
  count %= mod
  count[count.index(a)] += 1
  
print(count)

### FIXED CODE ###

n = int(input())

hats = [0, 0, 0]
count = 1
mod = 1000000007

for a in map(int, input().split()):
  count *= hats.count(a)
  count %= mod
  try:
    hats[hats.index(a)] += 1
  except ValueError:
    count = 0
    break
  
print(count)
N, M = map(int, input().split())
A = []
for i in range(M):
    a = int(input())
    A.append(a)
def step(n):
    steps = [0 for i in range(n + 1)]
    ind = 0
    steps[0] = 1
    steps[1] = 1
    if 1 == A[ind]:
        steps[1] = 0
        ind += 1
    for i in range(2, n + 1):
        steps[i] = steps[i - 1] + steps[i - 2]
        if i == A[ind]:
            steps[i] = 0
            if ind < M-1:
                ind += 1
    return steps[n] % 1000000007
print(step(N))

### FIXED CODE ###

N, M = map(int, input().split())
A = []
for i in range(M):
    a = int(input())
    A.append(a)
def step(n):
    steps = [0 for i in range(n + 1)]
    ind = 0
    steps[0] = 1
    steps[1] = 1
    if M != 0:
        if 1 == A[ind]:
            steps[1] = 0
            if ind < M-1:
                ind += 1
    for i in range(2, n + 1):
        steps[i] = steps[i - 1] + steps[i - 2]
        if M != 0:
            if i == A[ind]:
                steps[i] = 0
                if ind < M-1:
                    ind += 1
    return steps[n] % 1000000007
print(step(N))
N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

A_sort = sorted(A_list)
C_sort = sorted(C_list)
# print(A_sort)
# print(C_sort)

# kよりも小さい値の位置を探す
def search_lower_num(a_list, k):
    low = 0
    high = len(a_list) - 1
    mid = (low + high)//2

    if a_list[high] < k:
        return a_list[:high+1]
    elif a_list[low] > k:
        return None

    while low <= high:
        mid = (low + high)//2

        if mid-1 >= 0:
            if a_list[mid-1] < k \
                and a_list[mid] >= k:
                return a_list[:mid]

        # 2分探索する。
        if a_list[mid] <= k:
            low = mid + 1
        elif a_list[mid] > k:
            high = mid - 1

    return None

# kよりも大きい値の位置を探す
def search_upper_num(a_list, k):
    low = 0
    high = len(a_list) - 1
    mid = (low + high)//2

    if a_list[low] > k:
        return a_list[low:]
    elif a_list[high] < k:
        return None

    while low <= high:
        mid = (low + high)//2

        if mid+1 < len(a_list):
            if a_list[mid] <= k \
                and a_list[mid+1] > k:
                return a_list[mid+1:]

        # 2分探索する。
        if a_list[mid] < k:
            low = mid + 1
        elif a_list[mid] >= k:
            high = mid - 1

    return None

sum_conbi = 0
for B in B_list:
    a_result = search_lower_num(A_sort, B)
    c_result = search_upper_num(C_sort, B)

    # print(a_result)
    # print(c_result)

    sum_conbi += len(a_result) * len(c_result)

print(sum_conbi)


### FIXED CODE ###

N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

A_sort = sorted(A_list)
C_sort = sorted(C_list)

# print("A:", A_sort)
# print("C:", C_sort)

def is_ok_lower(list_data, index: int, key: int):
    if (list_data[index] >= key):
        return True
    else:
        return False

def is_ok_upper(list_data, index: int, key: int):
    if (list_data[index] > key):
        return True
    else:
        return False


def binary_search(list_data, key: int, is_ok_func):
    ng = -1  #「index = 0」が条件を満たすこともあるので、初期値は -1
    ok = len(list_data) # 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    # どんな二分探索でもここの書き方を変えずにできる！
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2

        if (is_ok_func(list_data, mid, key)):
            ok = mid
        else:
            ng = mid

    # left は条件を満たさない最大の値、ok は条件を満たす最小の値になっている
    return ok

sum_conbi = 0
for B in B_list:
    a_key = binary_search(A_sort, B, is_ok_lower)
    c_key = binary_search(C_sort, B, is_ok_upper)

    # print(a_key, N-c_key)
    # print(B,">", A_sort[:a_key])
    # print(B,"<", C_sort[c_key:])

    sum_conbi += (a_key) * (N-c_key)

print(sum_conbi)
n,m,k = map(int, input().split())

g = [[] for i in range(n+1)]
f = [0]*(n+1)
b = []
for i in range(m):
  u, v = map(int, input().split())
  g[u].append(v)
  g[v].append(u)
  f[u] += 1
  f[v] += 1
for i in range(k):
  b.append(map(int, input().split()))

count = 0
renketu_list = [-1]*(n+1)
renketu_size = [0]
stack = []
for i in range(1, n+1):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    renketu_size.append(1)
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      u,v=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        renketu_size[count] += 1
        while len(g[v])>0:
          stack.append(g[v].pop())

s = [0] * (n+1)
for i in range(1, n):
  s[i] += renketu_size[renketu_list[i]] + f[i]
  
for i in range(k):
  u, v = b[i]
  if renketu_list[u] == renketu_list[v]:
    s[u] -= 1
    s[v] -= 1

print(" ".join(list(map(str, s))))
  

### FIXED CODE ###

n,m,k = map(int, input().split())

g = [[] for i in range(n+1)]
f = [0]*(n+1)
b = []
for i in range(m):
  u, v = map(int, input().split())
  g[u].append(v)
  g[v].append(u)
  f[u] += 1
  f[v] += 1
for i in range(k):
  b.append(map(int, input().split()))
count = 0
renketu_list = [-1]*(n+1)
renketu_size = [0]
stack = []
for i in range(1, n+1):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    renketu_size.append(1)
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      v=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        renketu_size[count] += 1
        while len(g[v])>0:
          stack.append(g[v].pop())

s = [0] * (n+1)
for i in range(1, n+1):
  s[i] += renketu_size[renketu_list[i]] - f[i] - 1
  
for i in range(k):
  u, v = b[i]
  if renketu_list[u] == renketu_list[v]:
    s[u] -= 1
    s[v] -= 1

print(" ".join(list(map(str, s[1:]))))
N = int(input())

def f(x):
  i = 1
  count = 0
  while i**2 < x:
    if x % i == 0: count += 2
    i += 1
  if i**2 == x: count += 1
  return count
  

dp = [0]*N
for i in range(1,N):
  dp[i] = dp[i-1] + f[i+1]

print(dp[N-1])
  

### FIXED CODE ###

N = int(input())

ans = 0
for i in range(1,N):
	ans += (N-1)//i
print(ans)
from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        d[i].append((x, y))


ans = 0
for l in c:
    o = [None]*N
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if (o[x-1]!=None and o[x-1]!=y) or l[x-1]!=y:
                is_conflict = True
                break
            o[x-1] = y
        if is_conflict == True:
            break
    else:
        ans = mas(ans, sum(l))

print(ans)

### FIXED CODE ###

from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        d[i].append((x, y))


ans = 0
for l in c:
    o = [None]*N
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if (o[x-1]!=None and o[x-1]!=y) or l[x-1]!=y:
                is_conflict = True
                break
            o[x-1] = y
        if is_conflict == True:
            break
    else:
        ans = max(ans, sum(l))

print(ans)
from decimal import Decimal
N = int(input())
A = list(map(str, input().split()))
res = 1
for i in range(N):
    res = Decimal(str(res)) * Decimal(A[i])
if res > (10 ** 18):
    print(-1)
    exit()
print(res)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
res = 1
A.sort()
for i in range(N):
    res *= A[i]
    if res > (10 ** 18):
        print(-1)
        exit()
    elif res == 0:
        print(0)
        exit()
print(res)
n = int(input())
a = int(input())
b = int(input())

if n==1:
  print('Hello World')
elif n[0]==2:
  print(a+b)

### FIXED CODE ###

n = int(input())
 
if n==1:
  print('Hello World')
elif n==2:
  a = int(input())
  b = int(input())
  print(int(a+b))
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    if len(set(s))!=len(set(c)) or N>max(set(s)):
        print(-1)
        exit()
    a=[0]*N
    for i in range(len(s)):
        a[s[i]-1]=c[i]
    if a[0]==0:
        print(-1)
        exit()
    print("".join(map(str,a)))
    #print(s,c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    sc=[]
    for i in range(M):
        sc.append([s[i],c[i]])
    sc=list(map(list,set(map(tuple,sc))))
    sc.sort()
    for i in range(len(sc)):
        if sc[i][0]==1 and sc[i][1]==0 and not N==1:
            print(-1)
            exit()
    if M==0 and N==1:
        print(0)
        exit()
    if M==0 or len(sc)==1 and c[0]==0 and not s[0]==1:
        q=[1]
        for i in range(N-1):
            q.append(0)
        print("".join(map(str,q)))
        exit()
    for i in range(len(sc)-1):
        if sc[i][0]==sc[i+1][0]:
            print(-1)
            exit()
    #if N>max(set(s)):
    #    print(-1)
    #    exit()
    a=[0]*N
    for i in range(len(s)):
        a[s[i]-1]=c[i]
    if a[0]==0 and not N==1:
        a[0]=1
    print("".join(map(str,a)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()
N = int(input())
data = list(map(int(input().split()))
            
print ("11"+"\n")

### FIXED CODE ###

import math

N = int(input())
data = list(map(int,input().split()))


BIG = pow(10,9)+7

dp = [BIG]*(N+1)

dp[0] = 0

for i in range(N):
    for j in range(i+1,i+3):
        if j<N:
            dp[j] = min(dp[j], dp[i] + abs(data[i]-data[j]))
            
print(dp[N-1])
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
s = input()

if s == ABC:
    print("ARC")
else :
    print("ABC")


### FIXED CODE ###

#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
s = input()

if s == "ABC":
    print("ARC")
else :
    print("ABC")
import fractions 
from functools import reduce

n = int(input())
a = [int(i) for i in input().split()]

def gcd(nums):
    return reduce(fractions.gcd, nums)

ans = 0
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    if ans < gcd(aa):
        ans = gcd(aa)
print(ans)

### FIXED CODE ###

a, b, t = map(int, input().split())
ans = t // a * b
print(ans)
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[tuple(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

### FIXED CODE ###

n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)
h,w=map(int,input().split())
ll=[list(map(int,input().split())) for i in range(10)]

for i in range(10**3-1):
    for i in range(10):
        for j in range(10):
            if i!=j:
                ll[i][j]=min(ll[i][j],min(ll[i][o]+tra[o][j] for o in range(10) if o!=i and o!=j))
ans=0
for i in range(h):
    for j in map(int,input().split()):
        if j==-1 or j==1:continue
        ans+=ll[j][1]
print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
tra=[list(map(int,input().split())) for i in range(10)]
ll=[[tra[i][j] for j in range(10)] for i in range(10)]
for i in range(10**3-1):
    for i in range(10):
        for j in range(10):
            if i!=j:
                ll[i][j]=min(ll[i][j],min(ll[i][o]+tra[o][j] for o in range(10) if o!=i and o!=j))
ans=0
for i in range(h):
    for j in map(int,input().split()):
        if j==-1 or j==1:continue
        ans+=ll[j][1]
print(ans)
print(input()[:3]+'8'+input()[5:])

### FIXED CODE ###

s=input()
print(s[:3]+'8'+s[4:])
import sys
from datetime import datetime

def main():
    line_num = 0
    for line in sys.stdin.readlines():
        today = datetime.strptime(line, "%Y/%m/%d")
        TBD = datetime(2019, 5, 1)
        if today < TBD:
            print("HEISEI")
        else:
            print("TBD")
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from datetime import datetime

def main():
    line = sys.stdin.readline().strip()
    today = datetime.strptime(line, "%Y/%m/%d")
    TBD = datetime(2019, 5, 1)
    if today < TBD:
        print("Heisei")
    else:
        print("TBD")

if __name__ == "__main__":
    main()
S = input()
slst = [[] for _ in range(len(S))]
tmp = '<'
cnt = 0
index = 0
for i in range(len(S)):
    if tmp == S[i]:
        cnt += 1
    else:
        slst[index].append(tmp)
        slst[index].append(cnt)
        index += 1
        tmp = S[i]
        cnt = 1

slst[index].append(tmp)
slst[index].append(cnt)

ans = 0
for i in range(0, len(S), 2):
    if slst[i] == []:
        break
    elif slst[i + 1] == []:
        ans += ((slst[i][1] + 1) * ((slst[i][1]))) // 2
        break
    tmp = ((slst[i + 1][1]) * ((slst[i + 1][1] - 1))) // 2
    ans += tmp
    if slst[i + 1][1] >= slst[i][1]:
        ans += slst[i + 1][1]
    else:
        ans += ((slst[i][1] + 1) * ((slst[i][1]))) // 2

print(ans)

### FIXED CODE ###

S = input()
slst = [[] for _ in range(len(S) + 1)]
tmp = S[0]
cnt = 0
index = 0
for i in range(len(S)):
    if tmp == S[i]:
        cnt += 1
    else:
        slst[index].append(tmp)
        slst[index].append(cnt)
        index += 1
        tmp = S[i]
        cnt = 1

slst[index].append(tmp)
slst[index].append(cnt)

dp = [0] * (len(S) + 1)
if slst[0][0] == '<':
    dp[0] = 0
else:
    dp[0] = slst[0][1]

index = 1
for i in range(len(S)):
    if slst[i] == []:
        break

    if slst[i][0] == '>':
        dp[index] = dp[index - 1] + ((slst[i][1]) * ((slst[i][1] - 1))) // 2
        index += 1
    else:
        if slst[i + 1] == []:
            dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
            index += 1
        else:
            if slst[i][1] < slst[i + 1][1]:
                tdp = slst[i + 1][1]
                for k in range(1, slst[i][1]):
                    tdp += k
                dp[index] = dp[index - 1] + tdp
                index += 1

            else:
                dp[index] = dp[index - 1] + ((slst[i][1] + 1) * ((slst[i][1]))) // 2
                index += 1


print(dp[index - 1])
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
preans = 0
pew = 0
bflag = 0
b2w = 0
for i, word in enumerate(s):
    if bflag == 0:
        if word == '#':
            bflag = 1
    else:
        if word == '.':
            b2w = 1
    if b2w == 1:
        if word == '.':
            preans += 1
skip = 1
ans2 = 0
for i, word in enumerate(s):
    if b2w > skip:
        ans = min(preans, preans + bcount - wcount)
        preans = preans + bcount - wcount
        skip += 1
        wcount = 0
        bcount = 0

    if word == '#':
        bcount += 1

    if bflag == 0:
        if word == '#':
            bflag = 1
        else:
    else:
        if word == '#':
        else:
            b2w += 1
            bflag = 0

    if b2w == skip and word == '.':
        wcount += 1
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
bcount = 0
wcount = 0
for word in s:
    if word == '.':
        wcount += 1
ans = wcount
preans = ans
for word in s:
    if word == '#':
        preans += 1
    else:
        preans -= 1
    ans = min(ans, preans)
print(ans)
n = input()
k = input()

n = int(n)
k = int(k)

ans = n - k + 1
print (ans)


### FIXED CODE ###

n,k=input().split()

n = int(n)
k = int(k)

ans = n - k + 1
print (ans)
a, b, c, d, e, f = map(int, input().split)

flag = 0

if((e-d)>f or (d-c)>f or (c-b)>f or (b-a)>f):
  print(':(')
else:
  print('Yay!')

### FIXED CODE ###

import sys

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

flag = 0

if((b-a)>k or (c-a)>k or (d-a)>k or (e-a)>k or (c-b)>k or (d-b)>k or (e-b)>k or (d-c)>k or (e-c)>k or (e-d)>k):
  print(":(")
else:
  print("Yay!")