Harryxun/stf_run huggingface dataset:
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    try:
        angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
        result = sorted(math.degrees(a) for a in angles)
        return angles if 0 in result else result
    except ValueError:
        return [0, 0, 0]

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])

### FIXED CODE ###

import math
a,b,x=map(int,input().split())

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))
import math

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

ans = 1

if N == 1 :
    ans = A[0]
else :
    for i in range(N) :
        B = A[:i-1] + A[i:] # i番目を除く
        stat = B[0]
        for b in B[1:] :
            stat = math.gcd(stat,b)
            if stat == 1:
                break
        else :
            ans = max(ans,stat)

print(ans)


### FIXED CODE ###

def gcd(a,b) :
    r = a % b
    if r == 0 :
        return b
    else :
        return gcd(b,r)

N = int(input())

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

L = [0] * N
R = [0] * N

for i in range(N) :  # iより左(右)
    if i == 0 :
        L[i] = A[i]
        R[-i-1] = A[-i-1]
    else :
        L[i] = gcd(L[i-1], A[i-1])
        R[-i-1] = gcd(R[-i],A[-i])

ans = 1

for i in range(N) :
    if i == 0 :
        new = R[i]
    elif i == N-1 :
        new = L[i]
    else :
        new = gcd(L[i],R[i])
    if ans < new :
        ans = new

print(ans)
i = eval(input("Enter your words: "))
if (i[2]==i[3]) and (i[4]==i[5]:
      print("Yes")
elif i=="coffee-like":
    print("Yes")
else:
      print("No")

### FIXED CODE ###

l = input()
print("Yes" if (l[2]==l[3] and l[4]==l[5]) else "No")
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a,b = map(int,input().split())
ans = (a+b)/2
 
if ans == int(ans):
  print(int(ans))
else:
  print('IMPOSSIBLE')
N = int(input())
ans = "No"

for i in range(1, 10):
    if N % i == 0:
        t =  N // A
        if 1 <= A <= 9:
            ans = "Yes"

print(ans)

### FIXED CODE ###

N = int(input())
ans = "No"

for i in range(1, 10):
    if N % i == 0:
        t =  N / i
        if 1 <= t <= 9:
            ans = "Yes"
            break

print(ans)
n = int(raw_input())
for l in range(n):
	x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) 
	if (x1-x2)/(y1-y2) == (x3-x4)/(y3-y4):
		print 'YES'
	else:
		print 'NO'

### FIXED CODE ###

n = int(raw_input())
for l in range(n):
	x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split())
	if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3))< 1e-10:
		print "YES"
	else:
		print "NO"
a,b,c = map(int, input())
if a==b:
  print(c)
elif a==c:
  print(b)
elif b==c:
  print(a)

### FIXED CODE ###

a,b,c = map(int, input().split())
if a==b:
  print(c)
elif a==c:
  print(b)
elif b==c:
  print(a)
N,K = map(int,input().split())
if K % 2 == 0:
    a = N // K 
    b = N // (k / 2) - a 
    print(a**3 + b ** 3)
else:
    a = N // K
    print(a**3)

### FIXED CODE ###

n,k = map(int,input().split())
if k % 2 ==1:
    a = n // k 
    print(a ** 3)
else:
    a = n // k
    if (a * k + k // 2) > n:
        print(2 * (a ** 3))
    else:
        print((a + 1) ** 3 + a ** 3)
xs = inpt().split()

print("A"+xs[2][0]+"B")

### FIXED CODE ###

xs = input().split()
 
print("A"+xs[1][0]+"C")
import math

a, b, c, d = map(int, input().split())


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


def cantdiv(x):
    return x - math.floor(x / c) - math.floor(x / d) + math.floor(x / lcm(c, d))


print(cantdiv(b) - cantdiv(a - 1))


### FIXED CODE ###

from fractions import gcd

a, b, c, d = map(int, input().split())


def lcm(x, y):
    if gcd(x, y) == 0:
        return x * y
    return x * y // gcd(x, y)


def cantdiv(x):
    return x - x // c - x // d + x // lcm(c, d)


print(cantdiv(b) - cantdiv(a - 1))
# _*_ coding: utf-8 _*_
while True:
    n, k = [int(e) for e in input().strip().split(' ')]
    s = input().strip()

    cnts = []
    ans = 0
    # denote whether the first block is 0 or 1
    tmp, cnt = s[0], 0
    flag = int(s[0])

    for i in range(n):
        if s[i] == tmp:
            cnt += 1
        else: # here tmp should be cleared
            cnts.append(cnt)
            cnt = 1
        tmp = s[i]
    cnts.append(cnt)

    n_zero = (len(cnts) + 1) // 2 if flag == 0 else len(cnts) // 2

    if n_zero <= k:
         ans = sum(cnts)
    else:
        ans = 0
        for inx in range(flag, len(cnts), 2):
            start = max(0, inx - 1)
            end = min(inx + 2 * k, len(cnts))
            tmp = sum(cnts[start: end])
            if tmp > ans:
                ans = tmp

    print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
s = [int(x) for x in list(input())]

state = 1
cnt = 0
l = []
for e in s:
    if e != state:
        l.append(cnt)
        cnt = 1
        state = e
    else:
        cnt += 1

if cnt != 0:
    l.append(cnt)


if len(l) % 2 == 1:
    l.append(0)

Add = 2 * k + 1
ruiseki = [0]

for i, e in enumerate(l):
    ruiseki.append(ruiseki[i] + l[i])

answer = 0
for i in range(0, len(l), 2):
    left = i
    right = min(i + Add, len(l))
    tmp = ruiseki[right] - ruiseki[left]
    answer = max(tmp, answer)

print(answer)
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])

def func(i):
    if i == N:
        return 0
    else:
        dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
        func(i+1)

func(2)
print(dp[N-1])

### FIXED CODE ###

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])
#!/usr/bin/env python3

s = str(int(input()))
k = int(input())

# if len(s) == 1:
#     print(s)
#     exit()


if s[0] == "1":
    print(s[1])
else:
    print(s[0])


### FIXED CODE ###

#!/usr/bin/env python3

s = str(int(input()))
k = int(input())


for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()

print(s[i])

# if s[0] == "1":
#     if k == 1:
#         print(1)
#     else:
#         print(s[1])
# else:
#     print(s[0])
from math import factorial
N=int(input())
print(factorial(N)%(7+1e9)

### FIXED CODE ###

import math
N=int(input())
print(math.factorial(N)%(7+10**9))
#!/usr/bin/env python3
# Daydream
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

tokens = ['dream', 'dreamer', 'erase', 'eraser']

def solve(S: str):
    print(YES if is_valid(S) else NO)
    return

def is_valid(S):
    if S in tokens:
        return True
    for token in tokens:
        sub = S[-len(token):]
        if sub == token:
            return is_valid(S[:-len(token)])
    return False


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# Daydream
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

tokens = ['dream', 'dreamer', 'erase', 'eraser']

def solve(S: str):
    print(YES if is_valid2(S) else NO)
    return

def is_valid(S):
    if S == '':
        return True
    for token in tokens:
        sub = S[-len(token):]
        if sub == token:
            return is_valid(S[:-len(token)])
    return False

def is_valid2(S):
    import re
    x = r"^(dream|dreamer|erase|eraser)*$"
    return True if re.match(x, S) else False

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
import sys
import os
f = open('/Users/murakiyusuke/coding/atcoder/input.txt','r')
sys.stdin = f

S=input()
T=input()

def match(S,T):
    for i in range(len(T)):
        if S[i]==T[i] or S[i]=='?':
            continue
        else:
            return False
    return True

if len(T)>len(S):
    print('UNRESTORABLE')
    exit()

S=S[::-1]
T=T[::-1]   
p=len(S)-len(T)+1
for i in range(p):
    sub = S[i:i+len(T)]
    if match(sub,T):
        S1=S.replace(sub,T,1).replace('?','a')
        print(S1[::-1])
        exit()
print('UNRESTORABLE')
        




### FIXED CODE ###



S=input()
T=input()

def match(S,T):
    for i in range(len(T)):
        if S[i]==T[i] or S[i]=='?':
            continue
        else:
            return False
    return True

if len(T)>len(S):
    print('UNRESTORABLE')
    exit()

S=S[::-1]
T=T[::-1]   
p=len(S)-len(T)+1
for i in range(p):
    sub = S[i:i+len(T)]
    if match(sub,T):
        S1=S.replace(sub,T,1).replace('?','a')
        print(S1[::-1])
        exit()
print('UNRESTORABLE')
n=int(input())
mod=10**9+7
a=[0]*(n)
a[0]=0
a[1]=0
a[2]=1
if n<3:
    print(0)
else:
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
print(a[n-1])

### FIXED CODE ###

n=int(input())
mod=10**9+7
if n<3:
    print(0)


else:
    a=[0]*(n)
    a[0]=0
    a[1]=0
    a[2]=1
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
    print(a[n-1])
N,M = map(int,input().split())

X = [0] * N
R = [0] *  N

ans = True
for i in range(M):
    s,c = map(int,input().split())
    if s > N:
        ans = False
        break
        
    if R[s-1] == 0:
        X[s-1] = c
        R[s-1] = "T"
        
    elif R[s-1] == "T" and X[s-1] != c or (s == 1 and c == 0):
        ans = False
        break
        
if ans:
    if i == 0 and X[0] == 0:
            cnt = 1
    else:
        cnt = X[0]
    for i in range(1,N):
        cnt = cnt * 10 + X[i]
        
    print(cnt)

else:
    print(-1)

### FIXED CODE ###

N,M = map(int,input().split())

X = [0] * N
R = [0] *  N

ans = True
for i in range(M):
    s,c = map(int,input().split())
    
        
    if R[s-1] == 0:
        X[s-1] = c
        R[s-1] = "T"
        
    elif R[s-1] == "T" and X[s-1] != c :
        ans = False
        break
        
if ans:
    if X[0] == 0 and R[0] == 0 and N != 1:
        cnt = "1"
    else:
        cnt = str(X[0])
    for i in range(1,N):
        cnt = cnt + str(X[i])
    
    if len(cnt) == len(str(int(cnt))):
        
        print(cnt)
    else:
        print(-1)
else:
    print(-1)
# coding: utf-8
# Your code here!

inp: str = input()

input_list = inp.split()

a = int(input_list[0])
b = int(input_list[1])

count = 0

for i in range(2):
    if a < b:
        count += b
        b -= 1
    else:
        count += a
        a -= 1

print(count)



### FIXED CODE ###

# coding: utf-8
# Your code here!

inp = input()

input_list = inp.split()

a = int(input_list[0])
b = int(input_list[1])

count = 0

for i in range(2):
    if a < b:
        count += b
        b -= 1
    else:
        count += a
        a -= 1

print(count)
from scipy import special
x,y=map(int,input().split())

a = special.comb(x, 2, True)
b = special.comb(y, 2, True)

print(a+b)

### FIXED CODE ###

from math import factorial

x,y=map(int,input().split())
if x>1:
    a = factorial(x) / factorial(2) / factorial(x - 2)
else: a=0
if y>1:
    b = factorial(y) / factorial(2) / factorial(y - 2)
else: b=0
print(int(a+b))
T = int(input().split(" ")[1])
t = [int(x) for x in input().split(" ")]
t.append(100000000000)

ret = 0

for i in range(len(t)-1):
	ret += min(T,t[i+1] - t[i])

print(ret)

### FIXED CODE ###

words = input().split(" ")

shiritori = "YES"

end = None

for word in words:
	if end is not None:
		if end != word[0]:
			shiritori = "NO"
			break
	end = word[-1]

print(shiritori)
#!/usr/bin/env python3

from atcoder.dsu import DSU
#import
import math
#import numpy as np
#= int(input())
#= input()
N, M = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
AB = [list(map(int, input().split())) for _ in range(M)]

g = DSU(N)

for a, b in AB:
    g.merge(a, b)

grp = g.groups()

print(len(grp) - 1)

### FIXED CODE ###

import types

_atcoder_code = """
# Python port of AtCoder Library.

__version__ = '0.0.1'
"""

atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)

_atcoder_dsu_code = """
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
"""

atcoder.dsu = types.ModuleType('atcoder.dsu')
exec(_atcoder_dsu_code, atcoder.dsu.__dict__)
DSU = atcoder.dsu.DSU

#!/usr/bin/env python3

# from atcoder.dsu import DSU
import math
N, M = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
AB = [list(map(int, input().split())) for _ in range(M)]

g = DSU(N)

for a, b in AB:
    g.merge(a-1, b-1)

grp = g.groups()

if grp == None:
    print(0)
else:
    print(len(grp) - 1)
N=int(input())
A=[]
for p in range(N):
	A+=[int(input())]
B=A.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in A:
		if i==C:
			print(D)
		else:
			print(C)

else:
	print(A[1])
	print(A[0])

### FIXED CODE ###

import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])
import sys
sys.setrecursionlimit(10**6)
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)


### FIXED CODE ###

from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    if i <= N-K:
        print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)
    else:
        print(0)
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
p, s = [list(i) for i in zip(*ps)]
p = list(map(int, p))

res = [0]*n
correct = 0
penalty = 0
for i in range(m):
    no = p[i] - 1
    if res[no] == 1:
        continue
    elif s[i] == 'WA':
        penalty += 1
    elif s[i] == 'AC':
        correct += 1
        res[no] = 1

print(correct, penalty)

### FIXED CODE ###

n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    p_i, s_i = input().split()
    p.append(int(p_i))
    s.append(s_i)

correct = [0]*n
penalty = [0]*n

for i in range(m):
    no = p[i]
    if correct[no-1] == 1:
        continue
    elif s[i] == 'WA':
        penalty[no-1] += 1
    elif s[i] == 'AC':
        correct[no-1] = 1

pen = 0
for i in range(n):
    if correct[i] == 1:
        pen += penalty[i]
print(sum(correct), pen)
import collections
N = int(input())
S = [input() for n in range(N)]

cnt = collections.Counter(S)
m = max(cnt.values())

for k, v in dict(sorted(cnt.items())):
    if v == m:
        print(k)

### FIXED CODE ###

import collections
N = int(input())
S = [input() for n in range(N)]

cnt = collections.Counter(S)
m = max(cnt.values())

ans = []
for k, v in cnt.items():
    if v == m:
        ans.append(k)
        
ans.sort()
for a in ans:
    print(a)
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import random
def resolve():
    
    S=input()
    A="dream dreamer erase eraser".split()
    #print(A)
    que=[S]
    while(que!=[]):
        t=len(que)
        print(t)
        vS=que.pop(random.randint(0,t-1))
        if vS=="":
            print("YES")
            return
        for w in A:
            r=len(w)
            if vS[:r]==w:
                que.append(vS[r:])
        print(que,"k")    

    print("NO")
#%%submit!
resolve()

### FIXED CODE ###

#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import random
def resolve():
    
    S=input()
    A="dream dreamer erase eraser".split()
    #print(A)
    que=[S]
    while(que!=[]):
        t=len(que)
        #print(t)
        vS=que.pop(random.randint(0,t-1))
        if vS=="":
            print("YES")
            return
        for w in A:
            r=len(w)
            if vS[:r]==w:
                que.append(vS[r:])
        #print(que,"k")    

    print("NO")
#%%submit!
resolve()
a, b, c = sort(map(int, input().split()))
print(a*b//2)


### FIXED CODE ###

a, b, c = sorted(map(int, input().split()))
print(a*b//2)
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

black = []
distance = [[-1 for _ in range(H)] for _ in range(W)]
for i in range(H):
  for j in range(W):
    if M[i][j] == '#':
      black.append((i, j))
      distance[i][j] = 0
      
while black:
  bi, bj = black.pop(0)
  for i, j in [(bi - 1, bj), (bi + 1, bj), (bi, bj - 1), (bi, bj + 1)]:
    if i >= 0 and i < H and j >= 0 and j < W:
      if M[i][j] == '.' and distance[i][j] == -1:
        M[i][j] = '#'
        black.append((i, j))
        distance[i][j] = distance[bi][bj] + 1
print(max([max(d) for d in distance]))

### FIXED CODE ###

from collections import deque
import copy
 
def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
 
 
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
 
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))
 
        if nque:
            que = copy.copy(nque)
        else:
            break
 
    print(count - 1)

if __name__ == "__main__":
    main()
import numpy as np
n,k = map(int,input().split())
a = np.array(input().split(),np.int)
F = np.array(input().split(),np.int)

A.sort()
F.sort()
F = F[::-1]

left = -1
right = (A * F).sum()

while (right - left) > 1:
    s = (left + right) // 2
    r = np.maximum(0, A - s // F).sum() <= k
    if r:
        right = s 
    else:
        left = s 

print(right)


### FIXED CODE ###

import numpy as np
n,k = map(int,input().split())

A = np.array(input().split(),np.int)

F = np.array(input().split(),np.int)


A.sort()
F.sort()

F_ = F[::-1]

left = -1
right = (A * F_).sum()

while (right - left) > 1:
    s = (left + right) // 2
    r = np.maximum(0, A - s // F_).sum() <= k
    if r:
        right = s 
    else:
        left = s 

print(right)
A,B = map(int, input().split(""))
print(A*B)

### FIXED CODE ###

A,B = map(int,input().split())
print(A*B)
N,K = map(int,input().split())
a = [int(x) for x in input().split()]

start = 0
end = 0
a_sum = a[0]

ans = 0
#右に進めるだけ進む ->  a_sum >= Kを満たすまで
#左を詰めていく -> a_sum >= K の間だけ

#右端までいったらbreak



while True:
    if a_sum < K:
        end += 1
        if end == N:
            break

        #新たに追加した最後の数字を追加
        a_sum += a[end]

    else:
        #もしK以上の場合、end以降の全ての要素が追加されても満たすため、その数を足す
        #その数はこの場合、N - end  ex:10個あってa[2]~a[5]個で満たしているとき、 2~a[6], a[7], a[8], a[9]とあって計 N - 5個
        ans += N - end

        #左を詰める
        a_sum -= a[start]
        start += 1

print(ans)


### FIXED CODE ###

#入力取得
W, H, x, y = map(int, input().split())


max_s = W * H /2

if W % 2 == 0 and H % 2 == 0 and W/2 == x and H/2 == y:
    ans = 1
else:
    ans = 0


print(str(max_s) + " " + str(ans))
N=int(input())


ans = 0
for i in range(1,int(n**0.5)):
    for j in range(i,int(n**0.5)):
        for k in range(j,int(n**0.5)):
            if i**2+j**2+k**2+i*j+j*k+k*i < n:
                if i == j and j == k:
                    ans += 1
                else:
                    ans += 3
                print(i,j,k,n)

    print(ans)


### FIXED CODE ###

N=int(input())
ans = [0]*10000000
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            ans[i**2+j**2+k**2+i*j+j*k+i*k] += 1
for i in range(1,N+1):
    print(ans[i])
N = int(input())
S = [input() for i in range(N)]

S_first = [S[i][0] for i in range(N)]
march = ['M','A','R','C','H']
march_number = [0]*5

for i in range(N):
    march_number[i] = S_first.count(march[i])

import itertools

ans=0
for v in itertools.combinations(march_number,3):
    ans += v[0]*v[1]*v[2]
print(ans)

### FIXED CODE ###

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

S_first = [S[i][0] for i in range(N)]
march = ['M','A','R','C','H']
march_number = [0]*5

for i in range(5):
    march_number[i] = S_first.count(march[i])

import itertools
ans = 0
for v in itertools.combinations(march_number,3):
    ans += v[0]*v[1]*v[2]
print(ans)
n = int(input())
lis = list(map(int,input().split()))
ans = lis[0] + lis[-1]
for i in range(n-1):
    ans += min(lis[i],lis[i+1])
print(ans)

### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = lis[0] + lis[-1]
for i in range(n-2):
    ans += min(lis[i],lis[i+1])
print(ans)
s = input()
start = len(s)
end = 0

for i in range(s):
    if s[i] == "A":
        start = min(start,i)
    if s[len(s)-1-i] == "Z":
        end = max(end,i)

print(len(s)-start-end)

### FIXED CODE ###

s = input()
start = len(s)
end = len(s)

for i in range(len(s)):
    if s[i] == "A":
        start = min(start,i)
    if s[len(s)-1-i] == "Z":
        end = min(end,i)

print(len(s)-start-end)