Harryxun/stf_run huggingface dataset:
s=input()
S=""
for i in range(len(s)):
    if s[i]=="x":
        continue
    S=S+s[i]
rev=""
n=len(S)//2
for i in range(n):
    rev=rev+S[len(S)-1-i]
#print(S)
#print(rev)
flag=True
for i in range(n):
    if S[i]==rev[i]:
        pass
    else:
        flag=False
if flag:
    pass
else:
    print(-1)
    exit()

ky=S[n]
count=0
for i in range(n):
    if S[i]==ky:
        count+=1
count+=1
xcount=0
tmp=0
num=-1
for i in range(len(s)):
    if s[i]==ky:
        tmp+=1
        if tmp==count:
            num=i
            break
for i in range(len(s)):
    if s[i]=="x":
        xcount+=1

eat=0
noteat=0
for i in range(num):
    if (num-1-i)<0 or (num+1+i)>=(len(s)):
        break

    if s[num-1-i]=="x" or s[num+1+i]=="x":
        if s[num-1-i]==s[num+1+i]:
            eat+=1
        else:
            noteat+=1
ans=(xcount-eat)
ans=max(0,ans)
print(ans)

### FIXED CODE ###

s=input()
l=0
r=len(s)-1
cnt=0
while(l<r):
    if s[l]==s[r]:
        l+=1
        r-=1
    elif s[l]=="x":
        cnt+=1
        l+=1
    elif s[r]=="x":
        cnt+=1
        r-=1
    else:
        cnt=-1
        break
print(cnt)
n = input()
if n[0] = n[1] = n[2] or n[1] = n[2] = n[3]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
  print("Yes")
else:
  print("No")
n = int(input())

sum = 0
tmp = n

while tmp > 0:
    sum += sum % 10
    tmp //= 10

if n % sum == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

def digitsum(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n = n // 10
    return ans

N = int(input())
SumN = digitsum(N)
if N % SumN == 0:
    print("Yes")
else:
    print("No")
import math
H,M = map(int,input().split())
if H == 1 or M ==1 :
    print(1)
else :
    prnt(math.ceil((H*M)/2))

### FIXED CODE ###

import math
H,M = map(int,input().split())
if H == 1 or M ==1 :
    print(1)
else :
    print(math.ceil((H*M)/2))
a,b=map(int,input().split())
c=a//b;
d=a%b
e=(double)a/b
print(f'{c} {d} {e}')



### FIXED CODE ###

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

print("{0} {1} {2:.8f}".format(a//b,a%b,a/b))
N, M = map(int, input().split())

A = sorted(list(map(int, input().split())), reverse=True)

B = []
for i in range(M):
    b, c = map(int, input().split())
    B.append([b, c])

B.sort(key=lambda x:(-x[1]))

cnt = 0
ans = 0
a = 0
b = 0
while True:
    if b <= M-1 and A[a] <= B[b][1]:
        for k in range(B[b][0]):
            ans += B[b][1]
            cnt += 1
            if cnt == N:
                print(ans)
                break
        b += 1
    else a <= N-1:
        cnt += 1
        ans += A[a]
        if cnt == N:
            print(ans)
            break
        a += 1

### FIXED CODE ###

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

A = sorted(list(map(int, input().split())), reverse=True)

B = []
for i in range(M):
    b, c = map(int, input().split())
    B.append([b, c])

B.sort(key=lambda x:(-x[1]))

cnt = 0
ans = 0
a = 0
b = 0
while True:
    if b <= M-1 and A[a] <= B[b][1]:
        n = min(B[b][0], N-cnt)
        ans += B[b][1]*n
        cnt += n
        if cnt == N:
            print(ans)
            break
        b += 1
    elif a <= N-1:
        cnt += 1
        ans += A[a]
        if cnt == N:
            print(ans)
            break
        a += 1
n, k = map(int, raw_input().split())
if k % 2 == 1:
    print((n / k) ** 3)
else:
    print((n / k) ** 3 + ((n + k / 2) / k) ** 3)

### FIXED CODE ###

n, k = map(int, raw_input().split())
if k % 2 == 1:
    print((n / k) ** 3)
else:
    print((n / k) ** 3 + ((n + k / 2) / k) ** 3)
s,w = map(int, input().split())

print('unsafe' if s=<w else 'safe')

### FIXED CODE ###

s,w = map(int, input().split())
print('unsafe' if s<=w else 'safe')
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
import numpy
n = inN()

if n < 3:
    print(0)
    exit()
elif n < 6:
    print(1)
    exit()


m = n//3
n -= 5
l = [1]*n
ans = 1
for i in range(m-1):
    l = numpy.cumsum(l)
    l %= mod
    ans += l[n-1]%mod
    n -= 3

print(ans%mod)
    

### FIXED CODE ###

def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
import numpy
n = inN()

if n < 3:
    print(0)
    exit()
elif n < 6:
    print(1)
    exit()


m = n//3
n -= 5
l = [1]*n
ans = 1
for i in range(m-1):
    l = numpy.cumsum(l)
    l %= mod
    ans += l[n-1]%mod
    n -= 3

print(ans%mod)
N=input()
print(N*(N+1)/2)

### FIXED CODE ###

N=int(input())
print((N*(N+1))//2)
n = int(input())
num_list = list(map(int,input()))

sorted_num_list = sorted(num_list)
cnt = 0
for i in range(len(num_list)):
	if num_list[i] != sorted_num_list[i]:
		cnt += 1
if cnt < 3:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

n = int(input())
num_list = list(map(int,input().split()))
sorted_num_list = sorted(num_list)
cnt = 0
for i in range(len(num_list)):
	if num_list[i] != sorted_num_list[i]:
		cnt += 1
if cnt < 3:
	print("YES")
else:
	print("NO")
import copy

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

if n>2:
    memo = list([])

    for k in range(n):
        t = copy.copy(s_all)
        t.pop(k)

        c = gcd(t[0], t[1])

        for i in s:
            c = gcd(c,i)

        memo.append(c)

    print(max(memo))

if n==2:
    print(max(s_all))

### FIXED CODE ###

import numpy as np

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

l = [0]*n
r = [0]*n

for i in range(1,n):
    l[i]=gcd(l[i-1],s[i-1])

tmp = list(range(0,n-1))
tmp.reverse()
for i in tmp:
    r[i]=gcd(r[i+1],s[i+1])
    
m = list([])

for i in range(n):
    m.append(gcd(l[i],r[i]))

print(max(m))
a = int(input())

b = []

for i in a:
    b.append(input().split())

res = 0

num = a.pop(0) * 2

for i in range(b):
    if (b[i] == 'BTC'):
        c = int(a[i-1]) * 380000
        res += c
    elif (b[i] == 'JPY'):
        res += int(b[i-1])
    else:
        pass

print(res) 

### FIXED CODE ###

a = int(input())

b = []

for i in range(a):
    b.append(input().split())

res = 0

for i in b:
    if (i[1] == 'BTC'):
        res += float(i[0])*380000
    else:
        res += int(i[0])

print(res)
n = int(input())
a = list(map(int, input().split()))
max_a = 20 ** 2
MOD = 10 ** 9 + 7

ru = [0] * (n + 1)
for i in range(n):
    ru[i + 1] = ru[i] ^ a[i]

ptn = [0] * (max_a)
ptn[0] = 1
tot_ex0 = 0

if ru[-1] != 0:
    # 0, ru[-1], 0, ru[-1], 0, ..., ru[-1]
    for i in range(n):
        if i == n - 1:
            print(ptn[0])
            exit()
        if ru[i + 1] == 0:
            ptn[0] += tot_ex0
            ptn[0] %= MOD
        elif ru[i + 1] == ru[-1]:
            ptn[ru[i + 1]] += ptn[0]
            ptn[ru[i + 1]] %= MOD
            tot_ex0 += ptn[0]
            tot_ex0 %= MOD
print(re)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
max_a = 2 ** 20
MOD = 10 ** 9 + 7

ru = [0] * (n + 1)
for i in range(n):
    ru[i + 1] = ru[i] ^ a[i]


if ru[-1] != 0:
    # 0, ru[-1], 0, ru[-1], 0, ..., ru[-1]
    dp = [0] * (max_a)
    dp[0] = 1
    tot_ex0 = 0
    for i in range(n):
        if i == n - 1:
            print(dp[0])
            exit()
        if ru[i + 1] == 0:
            dp[0] += tot_ex0
            dp[0] %= MOD
        elif ru[i + 1] == ru[-1]:
            dp[ru[i + 1]] += dp[0]
            dp[ru[i + 1]] %= MOD
            tot_ex0 += dp[0]
            tot_ex0 %= MOD
else:
    # 0, x, 0, x, 0, x, ..., 0 (x != 0)
    dp = [0] * max_a
    dq = [1] * max_a
    set_evaled = [0] * max_a
    times = 0
    ans = 0
    for i in range(n):
        if i == n - 1:
            ans = sum(dp)
            break
        elif ru[i + 1] == 0:
            # これを遅延評価する
            # for j in range(max_a):
            #     dq[j] += dp[j]
            times += 1
        else:
            dq[ru[i + 1]] += (times - set_evaled[ru[i + 1]]) * dp[ru[i + 1]]
            dq[ru[i + 1]] %= MOD
            set_evaled[ru[i + 1]] = times
            dp[ru[i + 1]] += dq[ru[i + 1]]
            dp[ru[i + 1]] %= MOD
    # 0, 0, 0, 0, 0, 0, ..., 0
    cnt_0 = sum([1 for i in range(n) if ru[i + 1] == 0])
    ans = (ans + pow(2, cnt_0 - 1, MOD)) % MOD
    print(ans)
import math
import numpy as np

N = int(input())
S = list(input())

nW = [0 for i in range(N)]
nE = [0 for i in range(N)]

if S[0] == 'W':
    nW[0] = 1

if S[N-1] == 'E':
    nE[N-1] = 1

for i in range(1, N):
    if S[i] == 'W':
        nW[i] = nW[i-1] + 1
    else:
        nW[i] = nW[i-1]

for i in range(N-2,-1,-1):
    if S[i] == 'E':
        nE[i] = nE[i+1] + 1
    else:
        nE[i] = nE[i+1]

if nE[0] > nW[N-1]:
    count = nW[n-1]
else:
    count = nE[0]

for i in range(1,N-1):
    if nW[i-1] + nE[i+1] < count:
        count = nW[i-1] + nE[i+1]


print(count)

### FIXED CODE ###

import math
import numpy as np

N = int(input())
S = list(input())

nW = [0 for i in range(N)] #iまでのWの数
nE = [0 for i in range(N)] #iまでのEの数

if S[0] == 'W':
    nW[0] = 1
else:
    nE[0] = 1

for i in range(1, N):
    if S[i] == 'W':
        nW[i] = nW[i-1] + 1
        nE[i] = nE[i-1]
    else:
        nW[i] = nW[i-1]
        nE[i] = nE[i-1] + 1

if nE[N-1] - nE[0] < nW[N-1]:
    count = nE[N-1] - nE[0]
else:
    count = nW[N-1]

for i in range(1,N-1):
    if nW[i-1] + nE[N-1] - nE[i] < count:
        count = nW[i-1] + nE[N-1] - nE[i]

print(count)
import random
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
  s = list(map(int, input().split()))
  print(1+s.index(max(x)))

### FIXED CODE ###

import random
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
  s.append(list(map(int, input().split())))
for i in range(d):
  print(random.randrange(1,27))
a,b,c =map(int,input().split())
a,b,c =abc.split()

if c>=a and c<=b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

if c>=a and c<=b:
    print("Yes")
else:
    print("No")
A,B=map(int,input().split())
for i in range(B):
  if(i*A>=B):
    ans=i
    break
print(ans)

### FIXED CODE ###

A,B=map(int,input().split())
for i in range(B):
  if(i*A-i+1>=B):
    ans=i
    break
print(ans)
S = input()

s = S[0]
temp_T = 100000
for i in range(1, len(S)+1):
    if(S[i] != s):
        judge = max(i,len(S)-i)
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)


### FIXED CODE ###

S = input()

# s = S[0]
temp_T = len(S)
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)

print(temp_T)
N = int(input())
v = sorted(list(map(int, input().split())))
for i in range(N):
    a = (v[i]+v[i+1])/2
    v[i+1] = int(a)
    v[i] = 'A'
    a = 0
print(v[-1])

### FIXED CODE ###

a = int(input())
s = input()
print(s if a >= 3200 else 'red')
a,b,k = map(int, input().split())
nums = list(range(a,b+1))
ans = nums[:k] + list(reversed(nums))[:k]
print(ans)
for a in set(sorted(ans)):
    print(a)


### FIXED CODE ###

a,b,k = map(int, input().split())
tmp = []
for i in range(k):
    if a + i <= b:
        tmp.append(a+i)
    if b - i >= a:
        tmp.append(b-i)

for i in sorted(set(tmp)):
    print(i)
a , b = map(int , input().split)
c=str(a)+str(b)
c=int(c)
for i in range (100):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==100-1:
        print("No")
        break

        

### FIXED CODE ###

a , b = map(int , input().split())
c=str(a)+str(b)
c=int(c)
for i in range (1000):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==1000-1:
        print("No")
        break
import itertools


def solve(A1,A2,A3):
    
    vec = [A1,A2,A3]
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    
    return res

res = solve(A1,A2,A3)
print(res)


### FIXED CODE ###

import itertools

A1,A2,A3 = map(int,input().split())
    
vec = [A1,A2,A3]
com = list(itertools.permutations(vec))
    
all_cos = [0,0,0,0,0,0]
for i in range(6):
    tmp_com = com[i]
        
    tmp_A1 = tmp_com[0]
    tmp_A2 = tmp_com[1]
    tmp_A3 = tmp_com[2]
        
    cos1 = 0
    cos2 = abs(tmp_A1 - tmp_A2)
    cos3 = abs(tmp_A2 - tmp_A3)
        
    all_cos[i] = cos1 + cos2 + cos3
    
res = min(all_cos)
print(res)
def main08():
    data = input().split()
    nl = []
    for i in range(2):
        nl.append(int(data[i]))
    hantei = nl[0] + nl[1]
    result = 0
    if hantei <= nl[0] and 1 <= hantei:
        for i in range(nl[0]):
            result = result + nl[1] + i
    elif nl[1] > 0:
        for i in range(nl[0]-1):
            result = result + nl[1] + i + 1
    else:
        for i in range(nl[0]-1):
            result = result + nl[i] + i
    print(result)

if __name__ == "__main__":
    main08()

### FIXED CODE ###

def main08():
    data = input().split()
    nl = []
    for i in range(2):
        nl.append(int(data[i]))
    hantei = nl[0] + nl[1]
    result = 0
    if hantei <= nl[0] and 1 <= hantei:
        for i in range(nl[0]):
            result = result + nl[1] + i
    elif nl[1] > 0:
        for i in range(nl[0]-1):
            result = result + nl[1] + i + 1
    else:
        for i in range(nl[0]-1):
            result = result + nl[1] + i
    print(result)

if __name__ == "__main__":
    main08()
n = input()
m=input()
if int(n) == int(m):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

r = input()
k=r.split()
if k[0] == k[1]:
    print('Yes')
else:
    print('No')
a = list(str(int(input)))
print(a.count("1"))


### FIXED CODE ###

a = list(str(int(input())))
print(a.count("1"))
s = input()
n = int(input())
ans=[]
a = "ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnopqrstuwvxyz"
a_list=[]
for j in a:
	a_list.append(j)
for i in range (len(s)):
	ans.append(a_list[a_list.index(s[i])+n])
ans=ans.upper()
print("".join(ans))

### FIXED CODE ###


n = int(input())
s = input()
ans=[]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
a_list=[]
for j in a:
	a_list.append(j)
for i in range (len(s)):
	ans.append(a_list[a_list.index(s[i])+n].upper())
print("".join(ans))
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    answer = 0
    for i in range(N):
        temp_list = make_divisors(A[i])
        temp1 = temp_list[:-1]
        temp2 = temp_list[-1]
        if len(A[A == temp2]) > 1:
            answer += 1
        for t in temp1:
            if t in A:
                answer += 1
                break

    print(N - answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

### FIXED CODE ###

#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    from collections import Counter
    M = max(A) + 1
    B = [True] * (M+1)
    A = sorted(A)
    C = Counter(A)

    answer = 0
    for a in A:
        if B[a]:
            for j in range(a, M, a):
                B[j] = False
            if C[a] > 1:
                continue
            else:
                answer += 1

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()
n, a, b = map(int, input().split())

cnt=1
for i in range(1,n + 1):
    cnt*=i
    if i == a:
        af = cnt
    elif i == n-a:
        anf = cnt
    elif i == b:
        bf = cnt
    elif i == n-b:
        bnf = cnt
    elif i == n:
        nf=cnt
        break

ans = 2 ** n - (nf//af//anf) - (nf//bf//bnf)-1
print(int(ans % (10**9+7)))


### FIXED CODE ###


def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)
N,K = map(int,input().split())
a = list(map(int,input().split()))
c = 0
r = [0]*N
r[0] = a[0]
minus = 0
minusidx = 0
start = 0
if r[0] >= K:
    c+=N
    minus += r[0]
    minusidx += 1
    start = 1
for i in range(1,N):
    r[i] = r[i-1] + a[i]
    if r[i]-minus >= K:
        c+= N-i
        for j in range(i):
            minus = r[minusidx]
            minusidx += 1
            if r[i] - minus >= K:
                c += N - i
            else:
                break
print(c)

### FIXED CODE ###

X,Y = map(int,input().split())
if X < Y:
    print(0)
else:
    print(10)
n = int(input())
a = list(map(int, input().split()))

b = set(a)

c = {}

for i in a:
    c[i] = c.get(i, 0) + 1

d = {}

for k in a:
    if d.get(k, "hello") == "hello":
        ans = 0
        for i in b:
            if i != k:
                ans += c[i]*(c[i]-1)//2
            else:
                ans += (c[i]-1)*(c[i]-2)//2
        d[k] = ans
    else:
        ans = d[ans]
    print(ans)


### FIXED CODE ###

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

c = {}

for i in a:
    c[i] = c.get(i, 0) + 1

ways = 0
for i in c:
    ways += c[i]*(c[i]-1)//2

for k in a:
    ans = ways-c[k]+1
    print(ans)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

b_rest = [max(b[0]-a[0],0)]
a_rest = [max(a[0]-b[0],0)]

for i in range(1, n-1):
  b_rest.append( min(b[i], max( ((b[i]+b_rest[i-1])-a[i]), 0 ) ) )
  a_rest.append( max( a[i]-(b[i]+b_rest[i-1]), 0 ) ) 

a_rest.append(max(0, (a[n-1]-b_rest[-1]) ) )
ans = sum(a) - sum(a_rest)
                                
print(ans)

### FIXED CODE ###

"""
- https://atcoder.jp/contests/abc136/tasks/abc135_a
- |A−K|=|B−K| (others:IMPOSSIBLE)
- reg: 0≤A, B≤10^9
"""

a, b = map(int, input().split())
# 三項演算子
k = int ((a+b)/2) if (a+b) % 2 == 0 else 'IMPOSSIBLE'

print(k)
a, b = map(int, input().split())

if a*b % 2 == 0
print('Odd')
else:
  print('Even')

### FIXED CODE ###

a, b = map(int, input().split())
 
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd')
print('EOvdedn'[int(input())*int(input())%2::2])

### FIXED CODE ###

print('EOvdedn'[eval(input().replace(' ','*'))%2::2])
from collections import defaultdict
from operator import itemgetter

n, a, b = map(int, input().split())
ppp = list(map(int, input().split()))
qqq = list(map(itemgetter(0), sorted(enumerate(ppp, start=1), key=itemgetter(1))))

dp = {0: 0}
for i in qqq:
    ndp = defaultdict(lambda: 1000_000_000_000_000)
    tmp_min_cost = 1000_000_000_000_000
    for j, cost in sorted(dp.items()):
        if cost >= tmp_min_cost:
            continue
        tmp_min_cost = cost
        if j < i:
            ndp[i] = min(ndp[i], cost)
            ndp[j] = min(ndp[j], cost + b)
        else:
            ndp[j] = min(ndp[j], cost + a)
    dp = ndp

print(min(dp.values()))


### FIXED CODE ###

from bisect import bisect
from operator import itemgetter

n, a, b = map(int, input().split())
ppp = map(int, input().split())
qqq = [i for i, p in sorted(enumerate(ppp, start=1), key=itemgetter(1))]
INF = 10 ** 15

dp = [(0, 0)]
for i in qqq:
    ndp = []
    s = bisect(dp, (i,))
    tmp_min = INF
    for j, cost in dp[:s]:
        cost += b
        ndp.append((j, cost))
        tmp_min = cost
    stay_cost = dp[s - 1][1]
    if tmp_min > stay_cost:
        ndp.append((i, stay_cost))
        tmp_min = stay_cost
    for j, cost in dp[s:]:
        cost += a
        if tmp_min > cost:
            ndp.append((j, cost))
            tmp_min = cost
    dp = ndp

print(dp[-1][1])
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
x, y = 0, 0
perm = list(permutations(list(range(1, n+1))))
# print(perm)
for i in perm:
    if i == a:
        x = perm.index(i)
    if i == b:
        y = perm.index(i)
print(abs(x-y))


### FIXED CODE ###

from itertools import permutations

n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
x, y = 0, 0
perm = list(permutations(list(range(1, n+1))))
# print(perm)
for i in perm:
    if i == a:
        x = perm.index(i)
    if i == b:
        y = perm.index(i)
print(abs(x-y))
import re
S=str(input())
k=int(input())
x=re.search(r'[2-9]',S).start()

if S[0]=='1':
  if k<=x:
    print(1)
  else:
    print(S[x])     
  
else:
  print(S[0])


### FIXED CODE ###

import re
S=str(input())
k=int(input())

if set(S)=={'1'}:
  print(1)
  
else:
  x=re.search(r'[2-9]',S).start()
      
  if S[0]=='1':
    if k<=x:
      print(S[0])
    else:
      print(S[x])     
  else:
    print(S[0])
S = input()

i = 0
while i + 1 <= len(S):
    if S[i] == 'h' and S[i+1] == 'i':
        i += 2
    else:
        break

if i == len(S):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()

i = 0
if len(S) % 2 != 0:
    print('No')
    exit()

while i + 1 <= len(S):
    if S[i] == 'h' and S[i+1] == 'i':
        i += 2
    else:
        break

if i == len(S):
    print('Yes')
else:
    print('No')
import numpy as np
n = int(input())

res_v = np.zeros(n + 1, dtype='int64')
res_v_cumsum = np.zeros(n + 1, dtype='int64')
res_v[0] = 0
res_v[1] = 1
res_v[2] = 1
res_v_cumsum[0] = 0
res_v_cumsum[1] = 1
res_v_cumsum[2] = 2

M = 1000000007

for k in range(3, n):
    res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
    res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M

print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)

### FIXED CODE ###

n = int(input())

if n == 1:
    print(1)
else:
    res_v = [0]*(n + 1)
    res_v_cumsum = [0]*(n + 1)
    res_v[0] = 0
    res_v[1] = 1
    res_v[2] = 1
    res_v_cumsum[0] = 0
    res_v_cumsum[1] = 1
    res_v_cumsum[2] = 2

    M = 1000000007

    for k in range(3, n):
        res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
        res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M
    #print(res_v)
    print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)
n = input()
a = list(map(int, input().split()))
min = a[1]
ans = 0            
for i in a:
	if min > i:
		ans += (min - i)
	else:
		min = i

print(ans) 

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
max = 0
step = 0            
for i in a:
	if max > i:
		step += max - i
	else:
		max = i

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

### FIXED CODE ###

print(input().count("1"))