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:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)

a,b,x=l()
b=b//x
a=a//x-(a%x==0)
print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC048 B Between a and b...

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

_a = a//x
m_a = a%x
_b = b//x

if m_a == 0:
    print(_b - _a + 1)
else:
    print(_b - _a)

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:
import sys
readline = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:

def ans() : 
  a, b, x = tuple(map(int, input().split()))
  c1 = b // x
  c2 = (a - 1) // x
  print(c1 - c2)
  
  
ans()

Submission status: Accepted

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

print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,x=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())

def f_mod(a,x):
  return a//x+1

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

Submission status: Accepted

Solution code:
#ABC048-B
a,b,x = 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-1)//x )

Submission status: Accepted

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b, x = ns()
    tmp = 0
    if a % x == 0:
        tmp = 1
    ans = b // x - a // x + tmp
    if x == 0:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Vicfred
# https://atcoder.jp/contests/abc048/tasks/abc048_b
# math
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())

B = b//x
A = (a-1)//x
print(B-A)

Submission status: Accepted

Solution code:
import sys
def main():
    a,b,x=tuple(map(int,sys.stdin.readline().split()))
    res=b//x-a//x if a%x!=0 else b//x-a//x+1
    print(res)
if __name__=='__main__':main()

Submission status: Accepted

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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

first = x*(a//x + bool(a%x))
end = x*(b//x)
if first==end:
    print(1)
elif first>end:
    print(0)
else:
    print((end-first)//x+1)

Submission status: Accepted

Solution code:

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


def func(num1, num2, divide_num):
    ans = num2 // divide_num - (num1 - 1) // divide_num

    print(ans)


func(num1=a, num2=b, divide_num=x)

Submission status: Accepted

Solution code:

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


def func(num1, num2, divide_num):
    ans = num2 // divide_num - (num1 - 1) // divide_num
    # if num1 % divide_num == 0:
    #     ans += 1

    print(ans)


func(num1=a, num2=b, divide_num=x)

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

if a%x==0:
  a-=x
elif b%x==0:
  b+=x
elif b%x<a%x:
  b+=x
count=(b-a)//x
if count<0:
  count=0
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b_ = b // x

a_ = (a-1) // x

print(b_ - a_)

Submission status: Accepted

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

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

# ans = 0
bx = b//x + 1
ax = (a-1)//x + 1
ans = bx - ax
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from decimal import Decimal
a, b, c = map(int, input().split())
print(b//c - a//c if a%c != 0 else b//c - a//c +1)

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

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())
l = (a - 1) // x
r = b // x
print(r - l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, x = map(int, input().split())
if a==0:
    print((b//x)+1)
else:
    a = a - 1
    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 = map(int, input().split())
bx = B // X
ax = A // X

if A % X == 0:
    print(bx - ax + 1)
else:
    print(bx - ax)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May 30 16:32:18 2020

@author: NEC-PCuser
"""

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

a_shou = a // x
b_shou = b // x

ans = b_shou - a_shou

if (a % x == 0):
    ans += 1

print(int(ans))

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:
a, b, x = map(int, input().split())

a = -(-a // x) * x
b = (b // x) * x
print(max(0, (b - a) // x + 1))

Submission status: Accepted

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

if(a%x == 0):
    A = a//x
else:
    A = a//x + 1

B = b//x
print(B-A+1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May 30 12:02:39 2020

@author: naoki
"""

a,b,x = map(int,input().split()) # 整数a,b及び割る数xを入力
if a!=0:
    print((b//x+1) - ((a-1)//x+1))
else:
    print(b//x + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""解説から
1. n以下の整数からxで割り切れる数の数を求めるにはn//xすると良い f(n)
2. b以下の整数からxで割り切れる数の数を求める f(b)
3. a"未満"の整数は除外する必要があるのでf(a-1)を求める
4. f(b)-f(a-1)がa以上b以下の整数からxで割り切れる数の個数となる
5. a==0の時、f(a-1) == -1 となる。f(b) - -1 == f(b) + 1となるので、
    0以上b以下の数のxを求めるときにもきちんと求めることができる
"""
a, b, x = map(int, input().split())
b //= x
a = (a - 1) // x
print(b - a)

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
a = N[0]
b = N[1]
x = N[2]
if a % x == 0:
    a_min = a // x - 1
else:
    a_min = a // x
b_max = b // x
print(b_max - a_min)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
#メモ
#3-25 5 5個
#5-25 5 5個
#6-25 5 4個

b1=b//x
if a%x==0:
  b1+=1
a1=a//x

print(b1-a1)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,x=mp()
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 + 1 - ((a - 1) // x + 1))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
A, B, X = map(int, input().split())

def f(N):
    return N // X

print(f(B) - f(A - 1))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,x=map(int,readline().split())

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

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

ans = b//x - a//x

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res_a = (a - 1) // x
    res_b = b // x
    print(res_b - res_a)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

ap=a//x
bp=b//x

ans=bp-ap
if a%x==0:
  ans+=1

print(ans)

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

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

Submission status: Accepted

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

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 = map(int, input().split())

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

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

i = a// x
j = b// x
p = i* x
q = j* x
while i* x < a:
  i+= 1
  p = i* x
while j* x < b:
  j+= 1
  q = (j- 1)* x

ans = int((q- p)// x)+ 1

if(ans<= 0):
  print(0)
else:
  print(ans)

Submission status: Accepted

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

ans = b//x - a//x + (a%x==0)
print(max(0,ans))

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 = [int(_) for _ in input().split()]

count = b//x - a//x

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

print(count)

Submission status: Accepted

Solution code:
import sys


numbers = sys.stdin.readline().split(' ')

a = int(numbers[0])
b = int(numbers[1])
c = int(numbers[2])


if a > 0:
    print(b//c - (a-1)//c)
else:
    print(b//c+1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product


def solve():
    a, b, x = MI()

    def f(n, x):
        return n // x

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


if __name__ == '__main__':
    solve()

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:
a,b,x = map(int, input().split())
right = b // x + 1
if a == 0:
  left = 0
else:
  left = (a - 1) // x + 1
print(right - left)

Submission status: Accepted

Solution code:
start, end, div = list(map(int, input().strip().split()))

count = end // div - start //div

if start % div == 0:
  count += 1
print(count)

Submission status: Accepted

Solution code:
a, b, x = 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())

bans = b//x
aans = a//x

if a%x == 0:
    aans -= 1

print(bans - aans)

Submission status: Accepted

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

# a,b,x = map(int, "9 9 2".split())
cnt=0

alfa = b//x + 1
beta = (a-1)//x + 1

print(alfa - beta)

Submission status: Accepted

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

Submission status: Accepted

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


def f(n):
    return n//x


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

Submission status: Accepted

Solution code:
a,b,x=map(int,input().split())
#a以上b以下でxで割り切れる個数
a_ans=(a-1)//x
b_ans=b//x
print(b_ans-a_ans)

Submission status: Accepted

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

num_b = b // x
num_a = a // x
res = num_b - num_a
if a % x == 0:
    res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    a, b, x = map(int, input().split())
    print(b//x-((a-1)//x))
 
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())

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())
print(b//x-((a-1)//x))

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    a, b, x = [int(item) for item in input().split()]
    _a = a // x
    _b = b // x

    if a % x == 0:
        res = _b - _a + 1
    else:
        res = _b - _a
    
    print(res)



if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, x = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if a % x == 0:
        nmin = int(a / x)
    else:
        nmin = (a // x) + 1

    nmax = b // x

    print(nmax - nmin +1)


resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

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

Submission status: Accepted

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


def solve(a: int, b: int, x: int):
    if a % x == 0:
        print(int((b - a) // x + 1))
        return
    next = (x - a % x) + a
    if next > b:
        print(0)
        return
    v = (b - next) // x
    print(v + 1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  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

#####MakeDivisors######
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)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

a,b,x = IL()

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

Submission status: Accepted

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

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

count = 0
n = a % x
if (n == 0):
    c = a
else:
    c = a + (x - n)   # 最初の割れる数

if (c <= b):
    count += ((b - c) // x) + 1

print(count)

Submission status: Accepted

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

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

b_r = b // x

if a != 0:
    a_r = (a - 1) // x
    print(b_r - a_r)
else:
    print(b_r + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

low = (a-1) // x
up = b // x

print(up-low)

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, x = mi()
    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())

# 解けなかった
# ans = 0
# temp_A = 0
# temp_B = 0
# for i in range(B, A-1, -1):
#     if i % X == 0:
#         temp_B = i
#         break

# for i in range(A-1, 0, -1):
#     if i % X == 0:
#         temp_A = i
#         break

# if temp_A != 0:
#     ans_a = temp_A / X
# else:
#     ans_a = 0

# if temp_B != 0:
#     ans_b = temp_B / X
# else:
#     ans_b = 0

# ans = ans_b - ans_a

# if X == 1:
#     ans = B+1

# 切り捨て除算を使えば上手くいく
# 割り算をして、小数点以下を捨てる方法
print((B//X) - ((A-1)//X))

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



## ことごとくTLEする件
# forを回すからだめなのかも→回さないですませるには？
# bまでに約数いくつあるか出す → a-1 までに約数いくつあるか出す→引き算



## まず、aが割り切れるかどうか判定
## aが割り切れるなら、最小値はa
## 割り切れないなら、a+（除数 - あまり ) が最小値

#### divmodを使ってみよう！！


result = 0

a_x = divmod(a,x)  ## a/x の商と余り
## a = x * a_x[0] + a_x[1]
if a_x[1]==0:  ## 割り切れるとき
    first = a
else:  ## 割り切れないとき
    first = x * (a_x[0]+1)
    first2 = a + (x - a_x[1])  ## 検算用


b_x = divmod(b-first, x)

result = b_x[0]+1

print(result)






"""
名答だと思ったがだめだった

count = 0
first = 0
for i in range(a, b+1):
#    print(i)
    if i%x == 0:
        first = i
        count = 1
        break
    
if count != 0:
    result  = (b-first) // x +1

else :
    result = 0


print(result)



"""

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())
start=((a-1)//x+1)*x
if start>b:
    print(0)
else:
    print((b-start)//x+1)

Submission status: Accepted

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

ans = b_n - a_n
if a_p == 0:
  print(ans+1)
else:
  print(ans)

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())
if a%x == 0:
    print((b//x+1) - (a//x))
else:
    print((b//x+1) - (a//x+1))