peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def solve():
    n,l = map(int,input().split())
    mn = 10**10
    s = 0
    for i in range(n):
        s+=l+i
        if abs(mn)>abs(l+i):
            mn = l+i
    print(s-mn)
if __name__=='__main__':
    solve()
# Judge status: Accepted
n, a, b = map(int, input().split())

temp = n // (a + b)
amari = n % (a + b)

if amari > a:
    print((temp + 1) * a)
else:
    print(temp * a + amari)
# Judge status: Accepted
def main():
    n=int(input())
    cnt=[50]*26
    tmp=[0]*26
    for i in range(n):
        s=input()
        for j in range(len(s)):
            tmp[ord(s[j])-97]+=1
        for j in range(26):
            cnt[j]=min(cnt[j],tmp[j])
            tmp[j]=0
    ans=""
    for i in range(26):
        if cnt[i]!=0:
            ans+=chr(97+i)*cnt[i]
    print(ans)
if __name__=="__main__":
    main()
# Judge status: Accepted
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**0.7)+3):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
        break
for i in ans:
    print(i)
# Judge status: Wrong Answer
n,m=map(int,input().split())
def perm(n):
    a=1
    for i in range(1,n+1):
        a*=i*i
        a%=10**9+7
    return a

if n==m:
    print((perm(n)*2)%(10**9+7))
elif abs(n-m)==1:
    print(perm(n)%(10**9+7))
else:
    print(0)
# Judge status: Wrong Answer
# Hello World program in Python
from collections import Counter 

d = int (input())
l = []
for k in range(d):
  r = input()
   
  l.append(Counter(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))

a = [0] * n
a[0] = b[0]
a[-1] = b[-1]

for i in range(1, n-1):
    a[i] = min(b[i], b[i - 1])

print(sum(a))
# Judge status: Wrong Answer
num=int(input())
ans_list=[]
ans=40000
for i in range(2,num-1): 
	max_list=list(map(int,str(num-i)))  
	min_list=list(map(int,str(i)))
	tot=sum(max_list)+sum(min_list)
	ans=min(tot,ans)
print(ans)
# Judge status: Accepted
N,*S,=open(0).read().split()
N=int(N)
C0=S.count('AC')
C1=S.count('WA')
C2=S.count('TLE')
C3=S.count('RE')
print('AC x '+str(C0))
print('WA x '+str(C1))
print('TLE x '+str(C2))
print('RE x '+str(C3))
# Judge status: Accepted
V = list(map(int, input().split()))
V = sorted(V, reverse=True)
ans = V[0] * 10 + V[1] + V[2]
print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
ans = 0
for i in range(n):
    count = 0
    j = i+1
    while j <  k:
        j = j << 1
        count += 1
    ans += 1/n * (1/2)**count

print(ans)
# Judge status: Accepted
X=int(input())
count=0
M=100
while M<X:
	M=int(M*1.01)
	count=count+1
print(count)
# Judge status: Accepted
#python3
from math import ceil
def main():
    n = int(input())
    a = ceil(n/2)
    print("{0:.10f}".format(a/n))
main()
# Judge status: Wrong Answer
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r-100*(10-n))
# Judge status: Accepted
def solve():
    S = input()
    a = S.find('A')
    z = S.rfind('Z')
    print(z - a + 1)

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
ave=sum(a)/N
if ave%1>=0.5:
    if ave>=0:
        ave=int(ave)+1
    else:
        ave=int(ave)-1
else:
    ave=int(ave)
ans=0
for i in a:
    ans+=(ave-i)**2
print(ans)
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
  s = list(map(int,list(str(i))))
  if a <= sum(s) <= b:
    ans += i
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
edge = []
for i in range(n+1):
    edge.append([])
for i in range(m):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
for i in edge[1]:
    if n in edge[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Accepted
n, x = map(int, input().split())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n-1):
  if a[i]+a[i+1] > x:
    k = min([a[i+1], a[i]+a[i+1]-x])
    a[i+1] -= k
    ans += k
    if a[i] > x:
      ans += a[i]-x
      a[i] = x

print(ans)
# Judge status: Accepted
N =input()
A = list(map(int,input().split()))
cnt =0
while all(a%2==0 for a in A):
    A = [a/2 for a in A]
    cnt+=1
print(cnt)
# Judge status: Accepted
n,k,q = map(int,input().split())
a = list(int(input()) for i in range(q))
z = [0] * n
for i in range(q):
    z[a[i]-1] += 1
for i in range(n):
    if z[i] >= q - k + 1:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
last = input()

if last == "ABC":
  print("ARC")
else:
  print("ARC")
# Judge status: Accepted
from sys import stdin

a = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
print(s if a >= 3200 else "red")
# Judge status: Accepted
n,m,*a=map(int,open(0).read().split())
c=[bin(i)[::-1].index("1") for i in a]
if sum(c)!=c[0]*n:
    print(0)
    exit()
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a=list(set(a))
b=a[0]
for i in a:
    b=lcm(i,b)
    if b>2*m:
        print(0)
        exit()
print((m-b//2)//b+1)
# Judge status: Wrong Answer
mod = 1000000007
n = int(input())
a = list(map(lambda x: format(int(x), 'b'), input().split()))

cnt = [0] * 65

for i in range(n):
  a_len = len(a[i])
  for j in range(a_len):
    if a[i][j]  == '1':
      cnt[a_len-j-1] += 1
      
ans = 0
for i in range(len(cnt)-1, -1, -1):
  ans *= 2
  ans %= mod
  ans += cnt[i] * (n-cnt[i])
  
print(ans)
# Judge status: Accepted
str = input()

str2 = str.split(" ")

res = 1
for str3 in str2:
    res *= int(str3)

print(res)
# Judge status: Accepted
h=int(input())
count=0
num=h
while num!=1:
    count+=1
    num=num//2
print(2**(count+1)-1)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from math import factorial
mod=10**9+7
n,m=map(int,input().split())
if n>m:
    n,m=m,n
if n+1==m:
    n=factorial(n)%mod
    m=factorial(m)%mod
    print(n*m%mod)
elif n==m:
    n=factorial(n)%mod
    m=factorial(m)%mod
    print(2*n*m%mod)
else:
    print(0)
# Judge status: Accepted
S = input()
K = int(input())

for s in S[:K]:
    if s != '1':
        print(s)
        break
else:
    print(1)
# Judge status: Wrong Answer
def solve(sequence, term):
    count = 0
    for t in term:
        count = 0
        for i, s in enumerate(sequence):
            if t == s or s == "?":
                count += 1
            else:
                count = 0
            if count == len(term):
                return (sequence[:i - count+1] + term + sequence[i +2:]).replace("?", "a")
            
    return "UNRESTORABLE"

S = input()
T = input()
print(solve(S, T))
# Judge status: Wrong Answer
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X, Y = input_number_list()
    if X > 51:
        print("No")
    elif Y < 2:
        print("No")
    else:
        print(['No', 'Yes'][2*X <= Y <= 4*X])


if __name__ == '__main__':
    main()
# Judge status: Accepted
a=input()
b=int(a[-3:])
if b==0:
  ans=0
else:
  ans=1000-b
print(ans)
# Judge status: Wrong Answer
week = {"SUN":7,"MON":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6}
print(week[input()])
# Judge status: Accepted
from collections import defaultdict
n = int(input())
bars = list(map(int, input().split()))
bars.sort(reverse=True)
sides = defaultdict(int)
decided = []
ans = 0

for b in bars:
    sides[b] += 1
    if sides[b] == 2:
        decided.append(b)
        sides[b] -= 2
    if len(decided) == 2:
        ans = decided[0] * decided[1]
        break

print(ans)
# Judge status: Accepted
N=int(input())
lst=list(map(int,input().split()))
lst.sort(reverse=True)

A=0
B=0
for i in range(N):
    if i==0 or i%2==0:
        A+=lst[i]
    else:
        B+=lst[i]

print(int(A)-int(B))
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
  print('A')
else:
  print('B')
# Judge status: Accepted

N = int(input())

t_prev=0
x_prev=0
y_prev=0

for i in range(N):
    t_i, x_i, y_i = map(int, input().split()) 

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif x_i-x_prev > t_i-t_prev or y_i-y_prev>t_i-t_prev:
        print('No')
        exit()

    t_prev=t_i
    x_prev=x_i
    y_prev=y_i

print("Yes")
# Judge status: Accepted
s = input()

L = ['R', 'U', 'D']
M = ['L', 'U', 'D']

lens = len(s)
cnt = 0

for i in range(lens):
    if (i+1)%2 == 1 and s[i] in L:
        cnt += 1
    elif (i+1)%2 == 0 and s[i] in M:
        cnt += 1

if cnt == lens:
    print('Yes')
else :
    print('No')
# Judge status: Accepted
a,b = map(int,input().split())

if a<=8 and b <= 8:
  print('Yay!')
else:
  print(':(')
# Judge status: Wrong Answer
a=int(input())
b=[input() for i in range(a)]
b.sort()
for i in range(a):
  print(b[i])
# Judge status: Accepted
n = int(input())
m = str(input())

red = m.count('R')

con = 0;

for i in range(red):
    if m[i] == 'W':
        con += 1
print(con);
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

import functools
import fractions
gcd=functools.reduce(fractions.gcd,A)
print(gcd)
# Judge status: Accepted
n, c, k, *T = map(int, open(0).read().split())
T.sort()
ans = s = 0
while s < n:
    t = T[s] + k
    X = [T[s]]
    for i in range(s+1, min(n, s+c)):
        if T[i] <= t:
            X.append(T[i])
        else:
            break
    s += len(X)
    ans += 1
print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
if y%2==0 and y<=4*x and y>=2*x:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
for i in range(9):
  if n<=i*111:
    print((i)*111)
    break
# Judge status: Accepted
s = list(input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

mae = a*10 + b 
ushiro = c*10 + d
if mae <= 12 and mae != 0:
    if ushiro <= 12 and ushiro != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if ushiro <= 12 and ushiro != 0:
        print("YYMM")
    else:
        print("NA")
# Judge status: Accepted
string = input()
result = string.count("R")
if(result == 2 and string[1] == "S"):
  print("1")
else:
  print(result)
# Judge status: Wrong Answer
N=int(input())
A=sorted(list(map(int,input().split(' '))))
l_tmp=A[1:]
tmp = A[0]
ans = A[0]
while True:
    l_tmp_tmp=[]
    for i in l_tmp:
        if i%tmp:
            l_tmp_tmp.append(i%tmp)
            ans = min(ans,i%tmp)
    if len(l_tmp_tmp):
        tmp = ans
        l_tmp=l_tmp_tmp
    else:
        break
print(ans)
# Judge status: Wrong Answer
PI = 3.1415
def circumference(r):
  return (2* PI * r)
print ('%.3f' % circumference(5))
# Judge status: Accepted
def rec(w, x, n):
    if len(w) == n:
        return print(w)
    else:
        for i in range(x + 1):
            rec(w + chr(ord('a') + i), x + 1 if i == x else x, n)


n = int(input())
rec("", 0, n)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-1):
    if(p[i] != i+1):
        count += 1
if(count <= 2):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
c=input()
A=['a','e','i','o','u']
if c in A:
    print("vowel")
else:
   print("consonant")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.append(-1)
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ret = 0
for i in range(N):
  ret += B[A[i]-1] + C[A[i]-1] if A[i+1] == A[i]+1 else B[A[i]-1]
print(ret)
# Judge status: Accepted
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
    exit()
else:
    for i in range(k):
        if int(b[i]) != 1:
            print(b[i])
            exit()
print(1)
# Judge status: Wrong Answer
N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]

final = 1000000000

for i in range(1, N ** 2):
    ans = 0
    rikai = [0]*M
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(1, M+1):
                rikai[k-1] += A[j][k]
            ans += A[j][0]
    if all(el >= X for el in rikai):
        final = min(final, ans)

if final == 1000000000:
    print(-1)
else:
    print(final)
# Judge status: Accepted
K=int(input())

X=[0]*K
m=0
p=7
for i in range(K):
  m=(m+p)%K
  if m==0:
    print(i+1)
    break
  elif X[m]==1:
    print(-1)
    break
  else:
    X[m]=1
  p=(p*10)%K
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1,-1,-1):
  b[i]=(a[i]+sum(b[i::i+1]))%2
l=[x+1 for x,y in enumerate(b) if y==1]
print(len(l))
print(*l)
# Judge status: Accepted
s = input()

#sが2文字以下の場合は要素数
if len(s)<=2:
    print(len(set(list(s))));exit()

#dp[i]はsをi-1文字目まで見た時の分割の最大数
dp=[0]*(len(s)+1)

dp[0]=0
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

#4文字目からスタート
for i in range(3,1+len(s)):
    if s[i-1]!=s[i-2]:
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-3]+2
print(dp[-1])
# Judge status: Accepted
n, m = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
div = make_divisors(m)
for i in div[::-1]:
    if i <= m / n:
        print(i)
        break
# Judge status: Accepted
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

ato = H.pop()

if N == 1:
    print('Yes')
    exit()

for i in range(N-1, 0, -1):
    mae = H.pop()
    if ato - mae < -1:
        print('No')
        exit()
    elif ato - mae == -1:
        ato = mae - 1
    else:
        ato = mae

print('Yes')
# Judge status: Accepted
N = int(input())
S = input()
n = S.count('.')
ans = min(n, N-n)
lsc = 0
rsc = N-n
for i, c in enumerate(S):
    if c == '#':
        lsc += 1
        rsc -= 1
    a = lsc + ((N-i-1) - rsc)
    ans = min(ans, a)

print(ans)
# Judge status: Accepted
# A - Circle Pond
import math
import sys


def main():
    R = int(input())
    print(2 * math.pi * R)
    sys.stderr.write("debug")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N, x = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])

ans = 0

if sum(a) <= x:
  	ans = N - 1
elif sum(a) == x:
    ans = N
else:
    for i in range(N):
        if x >= a[i]:
            x -= a[i]
            ans += 1

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
if n == m == 1:
  print(1)
elif n == 1:
  print(m-2)
elif m == 1:
  print(n-2)
elif n == 2 or m == 2:
  print(0)
else:
  print(n*m -(n+m-2)*2)
# Judge status: Wrong Answer
info=[]
for _ in range(6):
  info.append(int(input()))
ans=5+info[0]//min(info[1:])
print(ans)
# Judge status: Accepted
import sys
a1=[int(i) for i in input().split()]
a2=[int(i) for i in input().split()]
a3=[int(i) for i in input().split()]
for l in sys.stdin:
  if int(l) in a1:
    a1[a1.index(int(l))]=0
  elif int(l) in a2:
    a2[a2.index(int(l))]=0
  elif int(l) in a3:
    a3[a3.index(int(l))]=0
m=sum(a1)*sum(a2)*sum(a3)
for i in range(3):
  m*=a1[i]+a2[i]+a3[i]
  m*=a1[i]+a2[1]+a3[2-i]
print('Yes' if m==0 else 'No')
# Judge status: Accepted
a, b, c, x, y = map(int,input().split())

min_xy = min(x, y) 
max_xy = max(x, y)

min_xy_cost = min(a + b, c * 2) * min_xy

if x >= y:
  rest = x - y
  rest_cost = rest * min(a, c * 2)
else:
  rest = y - x
  rest_cost = rest * min(b, c * 2)
  
total = min_xy_cost + rest_cost

print(total)
# Judge status: Accepted
N = int(input())

ans = 0
for n in range(N+1):
    if n*n <= N: ans = n*n
    else: break
print(ans)
# Judge status: Accepted
s=input()
k=int(input())
ans=""
for i in s[:-1]:
    if i=="a":
        ans+=i
        continue
    if k>=123-ord(i):
        k-=123-ord(i)
        ans+="a"
    else:
        ans+=i
i=s[-1]
ans+=chr((ord(i)+k-97)%26+97)
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
if np.count_nonzero(A) != len(A):
    answer = np.abs(A).sum()
else:
    negative = np.count_nonzero(A < 0)
    if negative%2 == 0:
        answer = np.abs(A).sum()
    else:
        answer = np.abs(A).sum()
        answer -= 2 * min(np.abs(A[0]), np.abs(A[-1]))

print(answer)
# 37
# Judge status: Accepted
n,m=map(int,input().split())
if n==m:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def solve():
    N = int(input())
    L = list(map(int, input().split()))

    count = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if(L[i] != L[j] and L[j] != L[k] and L[k] != L[i]):
                    if(L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]):
                        count += 1

    print(count)
# Judge status: Accepted
N = int(input())
l, r = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(N):
    l[i], r[i] = map(int, input().split())


if N%2 == 1:
    lm = sorted(l)[(N+1)//2-1]
    rm = sorted(r)[(N+1)//2-1]
    print(rm - lm + 1)
else:
    lm = sum(sorted(l)[N//2-1:N//2+1])/2
    rm = sum(sorted(r)[N//2-1:N//2+1])/2
    # 0.5 刻みで増えることに注意
    print(int((rm-lm+0.5)*2))
# Judge status: Accepted
s=input()
t=input()

slen=len(s)
tlen = len(t)
min = tlen

for i in range(slen - tlen + 1):
    count = 0
    for j in range(tlen):
        if s[i + j] != t[j]:
            count += 1
    if count < min:
        min = count

print(min)
# Judge status: Accepted
import itertools
n,m,q = map(int,input().split())
a = [];b = []; c = []; d = []
for i in range(q):
    u,x,y,z = map(int,input().split())
    a.append(u)
    b.append(x)
    c.append(y)
    d.append(z)

ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    score = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            score += d[i]
    ans = max(score,ans)
print(ans)
# Judge status: Accepted
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(4+math.ceil(n/min(l)))
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    S = readline().rstrip()
    e_right = S.count('E')
    w_left = 0
    res = N
    
    for i in range(N):
        if S[i] == 'E':
            e_right -= 1
            res = min(res, e_right + w_left)
        else:
            res = min(res, e_right + w_left)
            w_left += 1
    
    print(res)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c,d,e=map(int,input().split())
n=(c-a)*60+(d-b)
print(n-e)
# Judge status: Wrong Answer
x,y = map(int,input().split())
ans = 0
if x*y < 0:
    ans += 1
elif y < x:
    ans += 2
ans += abs(abs(x)-abs(y))
if x<y:
    ans = min(y-x,ans)
print(ans)
# Judge status: Accepted
s = input()
if s == 'ABC':
  print('ARC')
if s == 'ARC':
  print('ABC')
# Judge status: Accepted
N,K=map(int,input().split())
C=[0]*(10**5+1)
for i in range(N):
    a,b=map(int,input().split())
    C[a]+=b
cnt=0
l=0
while cnt<K:
    l+=1
    cnt+=C[l]
print(l)
# Judge status: Accepted
import sys
a, b = map(int, sys.stdin.readline().split())
print(-((a-b) // (a-1)) + 1)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = []
for i in range(len(s)):
    t += chr(((ord(s[i])-65+n)%26)+65)
''.join(t)
print(t)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(k*x+y*(n-k))
else:
    print(n*x)
# Judge status: Accepted
P = 10**9 + 7
S = int(input())

ans = [0]*(S + 1)
for i in range(3, S + 1):
    ans[i] = 1
for i in range(6, S + 1):
    for j in range(3, i - 2):
        ans[i] = (ans[i] + ans[j]) % P

print(ans[S])
# Judge status: Wrong Answer
s = int(input())

n = 2
ss = set()
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in ss:
        break
    ss.add(s)
    n += 1
print(n)
# Judge status: Accepted
N = int(input())
S = list(input())
 
we = []
west = 0
east = 0
for i in range(N):
    if S[i] == "W":
        west += 1
    elif S[i] == "E":
        east += 1
    we.append([west,east])
 
ans = 1e9
for i in range(N):
    if i == 0:
        left = 0
    else:
        left = we[i][0]
    right = we[N-1][1] - we[i][1]
    ans = min(ans,left+right)
 
print(ans)
# Judge status: Accepted
input()
c = [0]
for i, pi in enumerate(map(int, input().split())):
    if i + 1 == pi:
        c[-1] += 1
    else:
        c.append(0)
print(sum((i + 1) // 2 for i in c))
# Judge status: Wrong Answer
from collections import deque
n=int(input())
q=deque([[1,1],[6,1],[9,1]])
b=set()
while q:
    a=q.popleft()
    if a[0] in b:
        continue
    b.add(a[0])
    if a[0]==n:
        print(a[1])
        break
    if a[0]>n:
        continue
    q.append([a[0]+1,a[1]+1])
    for i in range(10):
        q.append([a[0]+6**i,a[1]+1])
        q.append([a[0]+9**i,a[1]+1])
# Judge status: Accepted
import sys


def resolve():
    readline = sys.stdin.readline    # 1行だけ文字列にする

    X, Y = map(int, readline().split())

    # Ai+1 = 2Aiとすればおｋ？
    A = X
    cnt = 1
    while 1:
        A = 2 * A
        if A <= Y:
            cnt += 1
        else:
            print(cnt)
            break


resolve()
# Judge status: Wrong Answer
N = int(input())
for x in range(1,10000):
  if int(x*1.08)==N:
    print(x)
    break
if x==9999:
  print(":(")
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))

p_sort = sorted(p)

ans = 0

for i in range(len(p)):
  if p[i] != p_sort[i]:
    ans += 1

if ans <= 2:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
import sys

h,w = map(int, input().split())

all = h*w

if h == 1 or w == 1:
    print(1)
    sys.exit()


if all % 2 == 0:
    ans = all//2
else:
    ans = all//2+1

print(ans)
# Judge status: Wrong Answer
N = int(input())
a=2
while a < N:
	a*=2
print(int(a/2))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = sum(a)
sum_b = sum(b)
if sum_a <= sum_b:
    cnt = 0
    for i in range(n):
        if a[i] > b[i]:
            cnt += a[i] - b[i]
        elif a[i] < b[i]:
            cnt -= (b[i] - a[i]) // 2
    if cnt <= 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Wrong Answer
K = int(input())
a,b = map(int,input().split())
c = 'NG'
for i in range(a,b+1):
  if i % K == 0:
    c = 'OK'
  break
print(c)
# Judge status: Wrong Answer
import itertools

N, K = list(map(int, input().split()))
D = set(input().split())
diff = set([str(n) for n in range(10)]) - D
lenN = len(str(N)) + 1

lists = list(itertools.product(list(diff), repeat=lenN))
lists = sorted([int("".join(l)) for l in lists])

for l in lists:
  if l >= N:
    print(l)
    break
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

fcount=0
tcount=0

for i in range(n):
    if a[i]%4==0:
        fcount+=1
    elif a[i]%2==0:
        tcount+=1

ocount=n-(fcount+tcount)

if fcount+tcount>=n:
    print("Yes")
elif ocount<=n//2 and ocount<=fcount:
    print("Yes")
elif n%2!=0 and fcount>=n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
numsA = [int(e) for e in input().split()]
numsB = [int(e) for e in input().split()]
T = int(input())
if abs(numsA[0]-numsB[0])<=(numsA[1]-numsB[1])*T:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N,M=map(int,input().split())
X=sorted(list(map(int,input().split())))
print(sum(sorted([X[i+1]-X[i] for i in range(M-1)])[::-1][N-1:]))
# Judge status: Accepted
A,B=map(int,input().split())
S=input()
print('Yes' if S[A]=='-' and S[:A].isdecimal() and S[A+1:].isdecimal() else 'No' )
# Judge status: Wrong Answer
x, y = map(int, input().split())
mod = 10 ** 9 + 7
dif = abs(x - y)
num = min([x, y]) - dif
if num % 3 != 0:
    print(0)
    exit()
num = num / 3 * 2 + dif
ans = 1
for i in range(int(num)):
    ans = ans * (i + 1) % mod
print(ans % mod)