peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math
import collections
import itertools
import heapq
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    sA = sorted(A)
    sC = sorted(C)

    res = 0
    for b in B:
        a = bisect.bisect_left(sA, b)
        c = N - bisect.bisect_right(sC, b)
        res += a*c

    print(res)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
def c():
    for i in range(1,10):
        for s in range(1,11-i):
            if i*s==n:
                print("Yes")
                return
    print("No")
c()
# Judge status: Wrong Answer
import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 7 + 10**9

b = [tuple(map(int, format(i, "060b"))) for i in a]
bits1 = np.array(b)
bits0 = bits1 ^ 1

accum1 = np.add.accumulate(bits1)
accum0 = np.add.accumulate(bits0)

sum1 = bits1[-1:0:-1] * accum0[-2::-1]
sum0 = bits0[-1:0:-1] * accum1[-2::-1]

s1 = np.sum(sum1, axis=0)
s0 = np.sum(sum0, axis=0)

ans = (s1 + s0) * (2 ** np.array(tuple(range(59,-1,-1)), np.int64)) % p

print(np.sum(ans) % p)
# Judge status: Accepted
a,b = map(int,input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14

if a < b:
    print ("Bob")
elif a > b:
    print ("Alice")
else:
    print ("Draw")
# Judge status: Accepted
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
dekai = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == dekai]
M.sort()
A = '\n'.join(M)
print(A)
# Judge status: Accepted
N,M = map(int,input().split(" "))
List = [0]*M
for i in range(N):
    LIst = [int(i)-1 for i in input().split(" ")]
    for l in LIst[1:]:
        List[l]+=1
count = 0
for i in List:
    if i==N:
        count+=1
print(count)
# Judge status: Wrong Answer
n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a)
while(len(a)>1):
    d=(a[0]+a[1])/2
    a.append(d)
    a.pop(0)
    a.pop(0)
    if(len(a)==1):
        break
print(a[0])
# Judge status: Wrong Answer
# ABC_086_B_1_21.py

a,b=list(map(int, input().split()))
ab=str(a)+str(b)
ab=int(ab)
flag=False
for i in range (101):
	if i**2==ab:
		flag=True
		break
if flag==True:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
N, C, K = map(int, input().split())

T = [int(input()) for _ in range(N)]

T.sort()

res = 0
i = 0
while i < N:
	res += 1
	Left = i
	while (i < N and T[i] - T[Left] <= K and i - Left + 1 <= C):
		i += 1

print(res)
# Judge status: Accepted
n,m=map(int, input().split())
xy=[list(map(int, input().split())) for _ in range(m)]

ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
    x=xy[i][0]-1
    y=xy[i][1]-1
    if red[x]:
        red[y]=True
        if ball[x]==1:
            red[x]=False
    ball[y]+=1
    ball[x]-=1
print(red.count(True))
# Judge status: Wrong Answer
o=input()
e=input()
print("".join([o[i]+e[i] for i in range(len(e)-1)]),end="")
print(o[-1],end="")
if len(o) == len(e):
  print(e[-1])
# Judge status: Accepted
import sys
sample = sys.stdin.read().splitlines()
n, stones = int(sample[0]), list(map(int, sample[1].split()))
dp = [float('inf')] * n
jumps = (1, 2)
dp[0] = 0
for idx in range(len(dp)):
  for jump in jumps:
    if idx+jump < len(dp):
      dp[idx+jump] =  min(dp[idx]+abs(stones[idx+jump]-stones[idx]), dp[idx+jump])
print(dp[-1])
# Judge status: Wrong Answer
# N=1079
N=int(input())

ans=int(round((N*100/108)+0.01))

if (ans*1.08)//1 == N:
    print(ans)
else:
    print(":(")
# Judge status: Accepted
N = int(input())

print((N + 1) * N // 2)
# Judge status: Wrong Answer
N = int(input()) 
A = list(map(int, input().split())) 

M = 1000
X = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        X = int(M/A[i])
        M = M - X * A[i]
    
    elif A[i] > A[i+1]:
        M = M + A[i] * X
        X = 0
    
if X > 0:
    M = M + X * A[N-1]

print(int(M))
# Judge status: Accepted
N = int(input())
d = [int(x) for x in input().split()]

d.sort()
length = len(d)
left = d[length//2-1]
right = d[length//2]

if left==right:
    print(0)
else:
    print(right - left)
# Judge status: Wrong Answer
a, b = map(int, input().split())
t = input()
print(t.replace(t[b-1], t[b-1].lower()))
# Judge status: Wrong Answer
def f(n):
  if n==1:
    return 1
  else:
    return n*f(n//2)+1
a=int(input())
print(f(a))
# Judge status: Accepted
D,T,S = map(int,input().split())

if D/S >T :
    print("No")
else:
    print("Yes")
# Judge status: Accepted
i, j = map(int, input().split())
MOD = 2019
ans = float("inf")
for x in range(i, min(j+1, i+MOD)):
    for y in range(x+1, min(j+1, i+MOD)):
        ans = min(ans, x%MOD * y%MOD)
print(ans)
# Judge status: Wrong Answer
import math

x = int(input())
c = 100

for i in range(1, 3761):
    c += math.floor(c * 0.01)
    if c >= x:
        print(i)
        break
# Judge status: Wrong Answer
from collections import deque
import sys
input = sys.stdin.readline
N = int(input())
A = deque()
B = deque()
time = 0
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    time += a
    if time > B[i]:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Accepted
a,b,k=map(int,input().split())
count=0
s=[]
for i in range(1,101):
  if a%i==0 and b%i==0:
    s.append(i)
print(s[-k])
# Judge status: Wrong Answer
N=int(input())
A=[int(i) for i in input().split()]
X=0
cnt=0
for i in range(N-1):
  if A[i+1]-A[i]>0:
    if X!=1:cnt+=1
    X=1
  elif A[i+1]-A[i]<0:
    if X!=-1:cnt+=1
    X=-1
print(cnt)
# Judge status: Accepted
S = input()

D = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(D[S])
# Judge status: Accepted
import sys
from math import pi

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    cDiv = (B // C) - ((A - 1) // C)
    dDiv = (B // D) - ((A - 1) // D)
    cd = C * D // gcd(C, D)
    cdDiv = (B // cd) - ((A - 1) // cd)
    print((B - A + 1) - (cDiv + dDiv - cdDiv))
    

    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
def main():
    n,a,b=map(int,input().split())
    mod=10**9+7
    c,d=1,1
    for i in range(1,a+1):
        c=c*pow(i,mod-2,mod)%mod
        c=c*(i+n-a)%mod
    for i in range(1,b+1):
        d=d*pow(i,mod-2,mod)%mod
        d=d*(i+n-b)%mod
    print((pow(2,n,mod)-c-d-1)%mod)
main()
# Judge status: Accepted
W,H,N=map(int,input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int,input().split())
  if A==1:
    a=max(a,x)
  if A==2:
    b=min(b,x)
  if A==3:
    c=max(c,y)
  if A==4:
    d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))
# Judge status: Wrong Answer
num, k = map(int, input().split())

for i in range(1, 30):
    if k ** i > num:
        print(i)
        exit(0)
# Judge status: Accepted
def main():
  import sys
  n = int(input())
  a = tuple(map(int,sys.stdin.readline().split()))
  b = tuple(map(int,sys.stdin.readline().split()))
  
  count=0
  cNow=a[0]
  cNext=a[1]
  
  for i in range(n):
    cNext=a[i+1]
    h = b[i]
    count+=min(cNow,h)  
    if h>cNow:
        count+=min(h-cNow,cNext)
        cNow=max(0,cNext-(h-cNow))
        continue
    cNow=cNext
  print(count)
  
if __name__=="__main__":
  main()
# Judge status: Wrong Answer
from collections import Counter
S = Counter(input())
flag = False
for c in S.values():
  if c % 2 == 1:
    flag = True
if flag:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N,M,K = list(map(int,input().split()))
for i in range(0,N+1):
    for j in range(0,M+1):
        if (N-i)*j+(M-j)*i == K:
            print('Yes')
            exit()
print('No')
# Judge status: Wrong Answer
import heapq
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
logof2=[0]*N
mi=0
buf=0
#print(A)
for i in range(N):
    logof2[i]=-math.log2(A[i])
#print(logof2)
heapq.heapify(logof2)
for i in range(M):
    buf=heapq.heappop(logof2)
    buf=buf+1
    heapq.heappush(logof2,buf)
    #print(logof2)
for i in range(N):
    mi=mi+math.floor(pow(2,-logof2[i]))

print(mi)
# Judge status: Accepted
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
t = input()

for _ in range(len(s)):
    s = s[-1] + s[:len(s)-1]
    if s == t:
        print("Yes")
        exit()

print("No")
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
Ans = 0
c = 0
h = H[0]
for i in H[1:]:
    if h - i >= 0:
        c += 1
    else:
        if c > Ans :
            Ans = c
        c = 0
    h = i
if c > Ans :
    Ans = c
print(Ans)
# Judge status: Wrong Answer
s=input()

s_a=s.count("a")
s_b=s.count("b")
s_c=s.count("c")

if s_a==0 or s_b==0 or s_c==0:
    if max(s_a, s_b, s_c)>=2:
        print("NO")
    else:
        print("YES")
else:
    if max(s_a, s_b, s_c)-min(s_a, s_b, s_c)>2:
        print("NO")
    else:
        print("YES")
# Judge status: Accepted
n = int(input())

for i in range(1, 50001):
    if int(i*1.08) == n:
        print(i)
        exit()
print(":(")
# Judge status: Accepted
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

h, n = ril()
ls = rils(n)
dp = [float('inf')] * (h + 1)
dp[0] = 0
for i, (a, b) in enumerate(ls):
    for j in range(h + 1):
        dp[min(j + a, h)] = min(dp[min(j + a, h)], dp[j] + b)
print(dp[-1])
# Judge status: Wrong Answer
n,m = map(int,input().split())
h = list(map(int,input().split()))
root = set()
for _ in range(m):
    s,g = map(int,input().split())
    path = tuple(sorted([s,g]))
    root.add(path)
print(n-len(root)+1)
# Judge status: Wrong Answer
n = int(input())
for i in range(8):
  if 2**i <n and n <2**(i+1):
    print(2**i)
# Judge status: Wrong Answer
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 9
for i in range(N):
 if abs(X - x[i]) < ans:
   ans = abs(X- x[i])
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
f = lambda : map(int,input().split())

n, q = f()
s = input()

ln = [0]
for i in range(n):
  ln += [ln[i] + (s[i-1:i+1]=='AC')]

for _ in range(q):
  l, r = f()
  print(ln[r] - ln[l])
# Judge status: Accepted
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()

MOD = 10 ** 9 + 7


def modinv(x):
    return pow(x, MOD - 2, MOD)


def main():
    s = sum(A) % MOD
    ans = s * s % MOD
    for a in A:
        ans = (ans - a ** 2) % MOD
    ans = ans * modinv(2) % MOD
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
memo = {}
memo[0] = 2
memo[1] = 1

def lucas(num):
    if num in memo:
        return memo[num]
    value = lucas(num-1) + lucas(num-2)
    memo[num] = value
    return value   

print(lucas(N))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A,B,K = map(int, read().decode("utf-8").split())

if K > A:
  K = K - A
  A = 0
else:
  A = A - K 
  print(A, B)
  quit()

if K > B:
  K = K - B
  B = 0
else:
  B = B - K
  print(A, B)
  quit()

print(0, 0)
# Judge status: Accepted
a, b = map(int, input().split())
if a > 8 or b > 8:
	print(":(")
else:
	print("Yay!")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

cnt, ans, num = 0, 0, 10 ** 10
for ai in a:
    cnt += (ai < 0)
    ans += abs(ai)
    num = min(num, abs(ai))
print(ans if cnt % 2 == 0 else ans - 2 * num)
# Judge status: Accepted
import sys
def main():
    INF=sys.maxsize
    N,K=tuple(map(int,sys.stdin.readline().split()))
    h=tuple(map(int,sys.stdin.readline().split()))
    dp=[INF for _ in range(N)]
    dp[0]=0
    for i in range(1,N):
        for j in range(1,K+1):
            if i-j>=0:
                dij=dp[i-j]+abs(h[i]-h[i-j])
                if dij<dp[i]:dp[i] = dij
    print(dp[N-1])
if __name__=='__main__':main()
# Judge status: Accepted
print(min(set(map(chr,range(97,123)))-set(input())or["None"]))
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())

cost = a*x+b*y

for i in range(max(x,y)):
  if min(x, y)-i-1 >=0:
    if cost > a*(x-i-1)+b*(y-i-1)+c*(i+1)*2:
      cost = a*(x-i-1)+b*(y-i-1)+c*(i+1)*2
  elif x-i-1 < 0:
    if cost > b*(y-i-1)+c*(i+1)*2:
      cost = b*(y-i-1)+c*(i+1)*2
  else:
    if cost > a*(x-i-1)+c*(i+1)*2:
      cost = a*(x-i-1)+c*(i+1)*2

print(cost)
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
A.sort()

print(sum(A[n:3*n:2]))
# Judge status: Accepted
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ct = 0

for i in range(N-1):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        up_bound = bisect.bisect_left(L, a+b)
        ct += max(0, up_bound - (j+1))

print(ct)
# Judge status: Accepted
n, p = map(int, input().split())
a = list(map(int, input().split()))
odds = sum(i%2 for i in a)
if odds>0:
    print(2**(n-1))
elif p==0:
    print(2**(n))
else:
    print(0)
# Judge status: Accepted
N = int(input())
S = input()

ans = ''
for i in S:
    num = (ord(i) + N)
    if num > 90:
        num = 64 + num % 90
    ans += chr(num)

print(ans)
# Judge status: Accepted
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, y = map(int, input().split())
    count = 0
    tmp = x
    while tmp <= y:
        tmp *= 2
        count += 1
    print(count)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Accepted
s = list(input())
t = list(input())
S,T = set(s),set(t)
sl = []
tl = []
for i in S:
    sl.append([j for j, x in enumerate(s) if x == i])

for i in T:
    tl.append([j for j, x in enumerate(t) if x == i])

if sorted(sl)==sorted(tl):print('Yes')
else:print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
ans = [0] * (N+1)
for a in A:
  ans[a] += 1
print("\n".join(map(str, ans[1:])))
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    dp = []
    now = 1
    ans = 0
    for i in range(n+1):
        if a[i] > now:
            print(-1)
            return
        else:
            dp.append(now)
            now -= a[i]
            now *= 2
    now = 0
    for i in range(n, -1, -1):
        now += a[i]
        ans += min(now, dp[i])
    print(ans)


main()
# Judge status: Accepted
s=input()
t=input()

ans=len(s)
for i in range(len(s)-len(t)+1):
    res=len(t)
    s_slice=s[i:i+len(t)]
    for j in range(len(t)):
        if s_slice[j]==t[j]:
            res-=1
    ans=min(res,ans)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        if A[i] + A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] -= (B[i] - A[i])
        else:
            ans += (A[i] + A[i+1])
            A[i+1] = 0
print(ans)
# Judge status: Accepted
n=int(input())

if n==1:
  print(1)
elif n==2:
  print(3)
else:
  ans=0
  num_1=2
  num_2=1
  for i in range(n-1):
    ans = num_1+num_2
    num_1,num_2 = num_2, ans
  print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
q = int(input())

from  collections import Counter

dict_a = Counter(a)
s = sum(a)

for i in range(q):
  b, c = map(int, input().split())
  s -= b*dict_a[b]
  s += c*dict_a[c]
  dict_a[c] += dict_a[b]
  dict_a[b] = 0
  print(s)
# Judge status: Accepted
N = int(input())
ret = N
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))

for x in range(N):
    n = sum(lst1[: N - x]) + sum(lst2[N - x - 1 :])
    ret = max(ret, n)
print(ret)
# Judge status: Accepted
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j] == b[k]:
        a[i][j] = 0
ans = 'No'
for i in range(3):
  if a[i][0]+a[i][1]+a[i][2] == 0:
    ans = 'Yes'
  if a[0][i]+a[1][i]+a[2][i] == 0:
    ans = 'Yes'
if a[0][0]+a[1][1]+a[2][2] == 0 or a[2][0]+a[1][1]+a[0][2] == 0:
  ans = 'Yes'
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
ans=10000000
for i in range(-100, 101):
    sum=0
    for a in range(len(A)):
        sum+=(A[a]-i)**2
    ans=min(ans,sum)
print(ans)
# Judge status: Accepted
K = int(input())
A, B = map(int, input().split())

MaxKx = B//K*K

if MaxKx >= A :
    print('OK')
else :
    print('NG')
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
ans = 0
for i in range(n):
  if i > 0 and l[i] < l[i-1]:
    ans += l[i-1] - l[i]
    l[i] = l[i-1]
print(ans)
# Judge status: Accepted
n = int(input())

for i in range((n//4)+1):
  for j in range((n//7)+1):
    if (4*i)+(7*j) == n:
      print("Yes")
      exit()

print("No")
# Judge status: Wrong Answer
ls = list(map(int,input().split()))
for num in range(4):
    if ls[num] == 0:
        print(num+1)
# Judge status: Accepted
import math


N, D = map(int, input().split())
X = [None] * N

for i in range(N):
    X[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        total = 0
        for k in range(D):
            total += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        distance = math.sqrt(total)
        if distance.is_integer():
            ans += 1

print(ans)
# Judge status: Accepted
a, b, c = map(int,input().split())
list = [a, b, c]
list.sort(reverse = True)
print(list[0] * 10 + list[1] + list[2])
# Judge status: Wrong Answer
import sys
import numpy as np
input = sys.stdin.readline

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N  = int(input())
lst_A = np.array(list(map(int, input().split())))
inv_A = 1/lst_A
mod = 10**9+7
lcm_A = lcm(lst_A)
print(int(np.sum(inv_A*lcm_A)) % mod)
# Judge status: Accepted
N=int(input())
print(int((N*(N+1))/2))
# Judge status: Accepted
N,W=map(int,input().split(' '))
bag=[tuple(map(int,input().split(' '))) for _ in range(N)]
dp1,dp2=[0]*(W+1),[0]*(W+1)
for i in range(N):
    dp1=dp2
    dp2=[0]*(W+1)
    for j in range(1,W+1):
        if j<bag[i][0]:
            dp2[j]=dp1[j]
        else:
            dp2[j]=max(dp1[j],dp1[j-bag[i][0]]+bag[i][1])
print(dp2[-1])
# Judge status: Accepted
# coding: utf-8
s = input()
t = input()
ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
def has_duplicates(seq):
    return len(seq) != len(set(seq))


def main():
    n = int(input())
    if has_duplicates(list(map(int, input().split(' ')))):
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()
# Judge status: Accepted
N,M = list(map(int,input().split()))

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(N-2,M-2))
else:
    print((N-2)*(M-2))
# Judge status: Wrong Answer
n,k = map(int, input().split())

ans = 0
for i in range(k,n+2):
    if n != 1:
        if i > 2:
            ans += n*(n+1)//2 - (n-i)*(n-i+1)//2 - (i-1)*i//2 + 1
        elif i == 2:
            ans += n*(n+1)//2 - i + 1
        elif i == 1:
            ans += n+1
    else:
        if i == 2:
            ans += 2
        elif i == 1:
            ans += 1

print(ans%(10**9+7))
# Judge status: Accepted
x = int(input())

i = 0
sum = 0

while(1):
    i += 1
    sum += i
    if sum < x:
        continue
    else:
        break

print(i)
# Judge status: Wrong Answer
#解説見ながら

n = int(input())

ans = n

for i in range(n) :
    c = 0
    a = n-i
    while a>0 :
        c += a%6
        a = a//6
    a = i
    while a>0 :
        c += a%9
        a = a//9
    if c<ans :
        ans = c

print(ans)
# Judge status: Wrong Answer
s = input()
s=s.replace('0B', '')
s=s.replace('1B', '')
s=s.replace('B', '')
print(s)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

length = len(A)
find_next = 1

for i in range(N):
    if A[i] == find_next:
        find_next += 1

if find_next == 1:
    print(-1)
else:
    print(length - find_next + 1)
# Judge status: Accepted
def resolve():
	N = int(input())
	A = [int(i) for i in input().split()]
	if 0 in A:
		print(0); return
	A.sort()
	ans = 1
	for i in reversed(range(N)):
		ans *= A[i]
		if ans > 10**18:
			print(-1); return
	print(ans)

resolve()
# Judge status: Accepted
def generator(x, a): # xの倍数でaより大きいもののうちの最小値
    if x >= a:
        y = x
    else:
        tmp = a // x + 1
        if a % x == 0:
            tmp -= 1
        y = x * tmp

    return y


def main():
    a, b, x = map(int, input().split())
    minimum = generator(x, a)

    if minimum > b:
        count = 0
    else:
        count = (b - minimum) // x + 1

    if a == 0:
        count += 1

    print(count)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
B = list(map(int, input().split()))
A = [0] * n
A[0] = B[0]
A[-1] = B[-1]
for i in range(n-2,0,-1):
    A[i] = min(A[i+1], B[i-1])

print(sum(A))
# Judge status: Wrong Answer
n=int(input())
A=[]
for i in range(n):
  A.append(input())
from collections import Counter
C=Counter(A)
qq=max(C.values())
ans=[]
for word,times in C.items():
  if times==qq:
    ans.append(word)
print(sorted(ans))
# Judge status: Wrong Answer
import math
S=input()
Q=int(input())
Rev=1
front=""
back=""
for i in range(Q):
    a=input().split()
    if a[0]=="1":
        Rev=Rev*-1
        continue
    if (a[1]=="1"and Rev==1) or (a[1]=="2" and Rev==-1):
        front+=a[2]
    else:
        back+=a[2]
print(front)
if Rev==1:
    #str(front.reverse().extend(S).extend(back))
    print(front[::-1]+S+back)
    #str(front.reverse()+S+back)
else:
    print(back[::-1]+S[::-1]+front)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
 
a.sort()
for i in range(n-1):
    a[i+1] = (a[i] + a[i+1]) / 2
 
print(a[-1])
# Judge status: Wrong Answer
n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for num, i in enumerate(b[:]):
  if num == 0:
    a.append(i)
  elif num == n-2:
    a.append(i)
  elif i <= b[num + 1]:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
print(sum(a))
# Judge status: Wrong Answer
def resolve():
  base = 10**9+7
  S = int(input())
  dp = [0] * (S+1)
  dp[0] = 1

  for i in range(3, S+1):
    dp[i] = dp[i-1] + dp[i-3]
  # print(dp)
  print(dp[S]%base)
# Judge status: Accepted
import collections

N = int(input())
a = collections.deque()
while True:
	a.appendleft(N % 2)
	if N % -2 == -1:
		N -= 2
	N //= -2
	if not N:
		break
for i in a:
	print(i, end='')
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
x=[]
y=[]
for i in range(m):
    a,b=mp()
    if a==1:
        x.append(b)
    if b==n:
        y.append(a)
if len(list(set(x) & set(y)))>=1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
from fractions import gcd
n=int(input())
ans=int(input())
for i in range(1,n):
  t=int(input())
  ans=ans*t/gcd(ans,t)
print(int(ans))
# Judge status: Accepted
N = int(input())
L_li = list(map(int, input().split()))
L_li.sort(reverse=True)
if L_li[0] < sum(L_li[1:]) :
    print("Yes")
else :
    print("No")
# Judge status: Accepted
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()

x = 7 % K
i = 1
while True:
    if x == 0:
        print(i)
        exit()
    x = (x * 10 + 7) % K
    i += 1
    if i > 10**6:
        print(-1)
        exit()
# Judge status: Wrong Answer
n = int(input()) #10000以下

for i in range(11):
  if n >= 1000:
    n -= 1000
    
  if n < 1000:
    print(1000 - n)
    break