Problem:


Score : 200 points

Problem Statement

You are given nonnegative integers a and b (a ≤ b), and a positive integer x.
Among the integers between a and b, inclusive, how many are divisible by x?

Constraints

0 ≤ a ≤ b ≤ 10^{18}

1 ≤ x ≤ 10^{18}

Input

The input is given from Standard Input in the following format:

a b x

Output

Print the number of the integers between a and b, inclusive, that are divisible by x.

Sample Input 1

4 8 2

Sample Output 1

3

There are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.

Sample Input 2

0 5 1

Sample Output 2

6

There are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.

Sample Input 3

9 9 2

Sample Output 3

0

There are no integer between 9 and 9, inclusive, that is divisible by 2.

Sample Input 4

1 1000000000000000000 3

Sample Output 4

333333333333333333

Watch out for integer overflows.



Sample input:
4 8 2


Sample output:
3

Submission status: Accepted

Solution code:
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	carry = 0
	for j in range(len(b)):
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)


a, b, x = [n for n in input().split(" ")]
c1 = bigint_divide(b, x)

if int(a) == 0:
  c2 = 0
else:
  c2 = bigint_divide(bigint_minus(a, 1), x)

if int(a) == 0:
  print(bigint_plus(bigint_minus(c1, c2), 1))
else:
  print(bigint_minus(c1, c2))

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())

print(b//x - (a-1)//x)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    a, b, x = MAP()

    print(b//x - (a-1)//x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
def f(n):
    if n==-1:
        return 0
    else:
        return n//x+1
print(f(b)-f(a-1))

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())
b=b//x + 1
if a!=0:
  a=(a-1)//x + 1
print(b-a)

Submission status: Accepted

Solution code:
import math
from decimal import Decimal
a, b, x = list(map(int, input().split()))

print(math.floor(Decimal(b)/x) - math.ceil(Decimal(a)/x) + 1)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, X = il()
    print((B // X) - ((A - 1) // X))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
ans=b//x-a//x
if a%x==0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

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

# y = ((b/x) -((a-1)/x))
print(((b//x) -((a-1)//x)))

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, x = MAP()

ans = b // x - (a-1) // x
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, x = MAP()

c = b // x
d = (a - 1) // x
print(c - d)

Submission status: Accepted

Solution code:
def main():
    a, b, x = map(int, input().split())

    ans = b // x - (a - 1) // x

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    a, b, x = map(int, input().split())

    ans = b // x - a // x
    if a % x == 0:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
      
print(max(b//x-(a-1)//x,0))

Submission status: Accepted

Solution code:
#
# abc048 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 8 2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0 5 1"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """9 9 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 1000000000000000000 3"""
        output = """333333333333333333"""
        self.assertIO(input, output)


def resolve():
    a, b, x = map(int, input().split())

    print(b//x - (a-1)//x)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
#
# abc048 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 8 2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0 5 1"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """9 9 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 1000000000000000000 3"""
        output = """333333333333333333"""
        self.assertIO(input, output)


def resolve():
    a, b, x = map(int, input().split())

    if a % x == 0:
        print(b//x - a//x+1)
    else:
        print(b//x - a//x)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
a, b, x = map(int,input().split())
print(b//x - (a-1)//x)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
b1 = b//x
a1 = (a-1)//x
print(b1-a1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    a, b, x = [int(i) for i in input().strip().split()]
    b_x = b // x
    if a > 0:
        a_x = (a - 1) // x
    else:
        a_x = -1
    ans = b_x - a_x
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys  import stdin,stdout
 
import bisect
 
import math
 
from collections import deque
 
mod=10**9 +7 
 
def st():
    return list(stdin.readline().strip())
 
def inp():
    return int(stdin.readline())
 
def li():
    return list(map(int,stdin.readline().split()))
 
def mp():
    return map(int,stdin.readline().split())
 
def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)
 
 
def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)
 
                
 
 
def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime
 
def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a
 
def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

x=soe(10**6)
 
def prime(n):
    d={}
    i=0
    while x[i]*x[i]<=n:
        if n%x[i]==0:
            d[x[i]]=0
            while n%x[i]==0:
                n=n//x[i]
                d[x[i]]+=1
        i+=1
    if n>1:
        d[n]=1
        
    mi=-10
    ans=float('inf')
    
    for i in d:
        if d[i]>mi:
            ans=i
            mi=d[i]
        elif d[i]==mi:
            ans=min(ans,i)
    return ans
    
def solve():
    a,b,x=mp()
    z=b//x
    c=a//x
    if a%x==0:
        pr(z-c+1)
    else:
        pr(z-c)
 
 
 
for _ in range(1):
    solve()

Submission status: Accepted

Solution code:
def resolve():
  a, b, x = map(int, input().split(" "))

  diff = b - a
  result = diff // x
  if not x - a%x + b%x >= x or a%x == 0 or b%x == 0:
    result += 1

  print(result)

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
c=(b//x-a//x)
if a%x==0:
  print(c+1)
else:
  print(c)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())
c = (b // x) - ((a - 1) // x)
print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,x):
  def countDivisible(k,d):
    return k // d
  return countDivisible(b,x) - countDivisible(a-1,x)



def main():
  a,b,x = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(a,b,x))
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
def count_muls(num, x):
    if num < 0:
        return 0
    return num // x + 1

def resolve():
    a, b, x = map(int, input().split())
    print(count_muls(b, x) - count_muls(a-1, x))

resolve()

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())
if a%x == 0:
  print (b//x- a//x+ 1)
else:
  print (b//x- a//x)

Submission status: Accepted

Solution code:
# B - Between a and b ...
def main():
    a, b, x = map(int, input().split())

    if a == 0:
        print(b//x+1)
    else:
        print(b//x-((a-1)//x))
            

if __name__ ==  "__main__":
    main()

Submission status: Accepted

Solution code:
a, b, x = map(int,input().split())
 
if a % x == 0:
    print(b//x - a//x + 1)
    
else:
    print(b//x - a//x)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())

c = (b // x) - ((a - 1) // x)
d = c

print(d)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())

def count(n, x):
    if n < 0:
        return 0
    else:
        return n//x+1
ans = count(b, x)-count(a-1, x)
print(ans)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
ans = b//x -(a-1)//x
print(ans)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
#a<=y<=bでy%x=0を満たすyの個数を求める
#f(n)を0以上n以下で上記のyの個数を表す関数と定義する
#すると，問題の答えはf(b)-f(a-1)である
#f(b):0以上b以下のyの個数,f(a-1):0以上a-1以下のyの個数
#a=0のときf(-1)が呼ばれることに注意する
#f(b)=b//x+1
#a>0 f(a-1)=(a-1)//x+1
#a=0 f(a-1)=0
def between(a,b,x):
    if a==0:
        na=0
    else:
        na=(a-1)//x+1
    nb=b//x+1
    print(nb-na)
between(a,b,x)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
if a != 0:
    dum1 = ((a-1) // x) + 1
else:
    dum1 = 0
dum2 = (b//x)+1
print(dum2-dum1)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
dum1 = (a-1)//x
dum2 = b//x
print(dum2-dum1)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
if a % x == 0:
  b -= b % x
  print((b - a)//x + 1)
else:
  a -= a % x
  b -= b % x
  print((b - a)//x)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
ans = b // x - a // x
if a % x == 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
a += (x - a % x) if a % x != 0 else 0
answ = (b - a) // x if a % x != 0 else (b - a) // x + 1
print(answ)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,x = I()
ca = (a-1)//x
cb = b//x
ans += cb-ca
print(ans)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())

s=(b//x-(a-1)//x)
print(s)

Submission status: Accepted

Solution code:
import math
import sys
import numpy as np
from decimal import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# ----------------------------------------
a, b, x = map(int, readline().split())

ans = Decimal(b // x) - Decimal(a // x)
if (a % x == 0):
    ans += 1

print(int(ans))

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
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


inf = 10 ** 18
mod = 10 ** 9 + 7

a,b,x = lr()
inda = a//x
if a%x==0:
    inda-=1
indb = b//x
if a!=b:
    print(indb-inda)
else:
    if a%x==0:
        print(1)
    else:
        print(0)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
mx = b//x
mn = (a-1)//x
print(mx-mn)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
fb = b//x+1
if a!= 0 :
    fa = (a-1)//x+1
else :
    fa = 0
print(fb-fa)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())

if a%x==0:
    p=1
else:
    p=0

print(p+b//x-a//x)

Submission status: Accepted

Solution code:
import decimal
decimal.getcontext().prec=50
a,b,x=map(int,input().split())
a=decimal.Decimal(a)
b=decimal.Decimal(b)
print(int(b/x)-int((a+x-1)/x)+1)

Submission status: Accepted

Solution code:
def resolve():
    a, b, x = map(int, input().split())
    if a != 0:
        print(b//x-(a-1)//x)
    elif b != 0:
        print(b//x+1)
    else:
        print("1")
resolve()

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
ans = b//x - (a-1)//x
print(ans)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())

q1,r1=divmod(a,x)
q2,_=divmod(b,x)

print(q2-q1+(r1==0))

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
n=a//x
m=b//x
ans=m-n
if a%x==0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
if a%x==0:
  print(b//x-a//x+1)
else:
  print(b//x-a//x)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
ans = b // x - a // x
if a % x == 0:
  ans += 1
print(ans)

Submission status: Accepted

Solution code:
from decimal import *
a, b, x = map(int, input().split())
ax = int(Decimal(a) / Decimal(x))
bx = int(Decimal(b) / Decimal(x))
am = a % x
bm = b % x
if ax == bx and am != 0 and bm != 0:
  print(0)
elif am == 0:
  print(bx - ax + 1)
else:
  print(bx - ax)

Submission status: Accepted

Solution code:
a,b,x =map(int,input().split())
print((b//x)-((a-1)//x))

Submission status: Accepted

Solution code:
A,B,X=map(int,input().split())
print(abs((A-1)//X-B//X))

Submission status: Accepted

Solution code:
a,b,x = (int(T) for T in input().split())
print((b//x)-(a//x)+(a%x==0))

Submission status: Accepted

Solution code:
import math
a, b, x = map(int, input().split())
bwaru = b//x
awaru = (a-1)//x
ans = bwaru-awaru
print(ans)

Submission status: Accepted

Solution code:
a, b, x = [int(x) for x in input().split()]

first = (a // x) * x

if a % x != 0:
    first += x

result = len(range(first, b+1, x))
print(result)

Submission status: Accepted

Solution code:
a,b,x = map(int, open(0).read().split())
if a == 0:
    print((b//x)+1)
else:
    print((b//x)-((a-1)//x))

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())

na = (a - 1) // x
nb = b // x
print(nb - na)

Submission status: Accepted

Solution code:
A,B,X=map(int,input().split())
print(B//X-(A-1)//X)

Submission status: Accepted

Solution code:
a, b, x = [int(s) for s in input().split()]
q, m = divmod(a, x)
print(b // x - q + (1 if m == 0 else 0))

Submission status: Accepted

Solution code:
A, B, X = map(int, input().split())
print(B//X-(A-1)//X)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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


def function(n,x):
    if (n>=0):
        return n//x+1
    else:
        return 0

ans = function(b,x) - function(a-1,x)

print(ans)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
if a % x == 0:
    print(b // x - a // x + 1)
else:
    print(b // x - a // x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    a, b, x = MI()
    print(b // x - (a - 1) // x)


main()

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
k=a//x
l=a%x
p=b//x
q=b%x
if l==0:
    print(p-k+1)
else:
    print(p-k)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, b, x = LI()

    ans = b // x - (a - 1) // x
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())

if a%x == 0:
    ans = b//x - a//x + 1

else:
    ans = b//x - (a + x - a%x)//x + 1

print(ans)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
res = int(b//x - (a-1)//x)
print(res)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
t = b//x
if a == 0:
    print(t+1)
else:
    print(t-(a-1)//x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, x = map(int, input().split())
print(b//x - (a-1)//x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

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

def f(n):
    global x
    if n == -1: 
        return 0
    return n//x + 1 

ans = f(b)-f(a-1)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

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

if a == b:
    if a%x == 0:
        print(1)
    else:
        print(0)
    exit()
if a%x == 0 and b%x == 0:
    ans = b//x - a//x + 1 
    print(ans)
    exit()
if a%x != 0 and b%x != 0:
    ans = b//x - a//x
    print(ans)
    exit()
if a%x == 0 and b%x != 0:
    ans = b//x - a//x + 1 
    print(ans)
    exit()
ans = b//x - a//x 
print(ans)

Submission status: Accepted

Solution code:
a,b,x=list(map(int,input().split()))
print(b//x - (a-1)//x)

Submission status: Accepted

Solution code:
a,b,c = list(map(int,input().split()))
x = a//c 
y = b//c
if a%c:
    print(y-x)
else:
    print((y-x)+1)

Submission status: Accepted

Solution code:
a,b,x = list(map(int,input().split()))
a1 = a//x if a%x else a//x-1
a2 = b//x
print(a2-a1)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())

result = b//x-a//x
if a % x == 0:
    result +=1

print(result)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())

print(b//x - (a-1)//x)

Submission status: Accepted

Solution code:
def getDivCount( a, b, x ):
    count=0
    if a!=0 :
        count+=b//x-(a-1)//x
    else:
        count+=b//x+1
    return count

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

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())

count=0
if a==0 :
    count+=1

if a<=x :
    ai = x
else:
    ai = (a//x)*x
    if ai<a :
        ai +=x
if ai<=b :
    count+=1
    count+=(b-ai)//x

print(count)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())

s = b//x
t = (a-1)//x
print(s-t)

Submission status: Accepted

Solution code:
A,B,X = list(map(int,input().split()))
print(B//X-(A-1)//X)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
if a%x!=0:
  a+=x-a%x

if a==b and a==0:
  print(1)
elif a==b and a==x:
  print(1)
elif a>=b:
  print(0)
else:
  print(b//x-a//x+1)

Submission status: Accepted

Solution code:
import numpy as np
a, b, x = map(int, input().split())
print(b // x - (a-1) // x)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, x = map(int, readline().split())

    print(b // x - (a - 1) // x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())

r = b // x - a // x
if a % x == 0:
    r += 1

print(r)

Submission status: Accepted

Solution code:
def main():
    a, b, x = map(int, input().split())
    if a == 0:
        left = 0
    else:
        left = (a-1)//x + 1

    if b == 0:
        right = 1
    else:
        right = b//x + 1 

    print(right - left)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,x=map(int, input().split())
print(b//x-(a-1)//x)

Submission status: Accepted

Solution code:
a,b,x = map(int,input().split())
def f(n,x):
    if n == -1:
        return 0
    else:
        return n // x + 1
print(int(f(b,x)-f(a-1,x)))

Submission status: Accepted

Solution code:
a,b,x=list(map(int, input().split()))
if a==0:
    print(b//x+1)
else:
    print(b//x-(a-1)//x)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())

print(b//x + -a//x + 1)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
print(b // x - ~-a // x)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())
print(b//x-(a-1)//x if a!=0 else b//x+1)

Submission status: Accepted

Solution code:
a, b, x = list(map(int, input().split()))
print(b // x - (a - 1) // x)

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())


def n_div(a):
    # n of divisor <= a
    return a // x


answer = n_div(b) - n_div(a - 1)
print(answer)

Submission status: Accepted

Solution code:
a,b,x=[int(i) for i in input().split()]

def get_mod_num(limit,x):
    if limit==-1:
        return 0
    return limit//x+1

print(get_mod_num(b,x)-get_mod_num(a-1,x))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
n=a//c
m=b//c
o=0
if a%c==0:
    o=1
print(m-n+o)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():

    a, b, x = map(int, input().split())
    ans = 0

    ans = (b // x) - ((a-1) // x)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
a_p=a//x
b_p=b//x

if a%x==0:
    print(b_p-a_p+1)
else:
    print(b_p-a_p)

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
num_a=a//x
num_b=b//x
ans=num_b-num_a
if a%x==0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    a, b, x = list(map(int, input().split()))
    result = b // x - (a - 1) // x
    print(result)

resolve()

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
a_div = (a - 1) // x + 1
b_div = b // x + 1

print(b_div - a_div)