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.

Solution in Haskell (GHC 8.8.3) (judge verdict: Accepted)

{-# LANGUAGE OverloadedStrings #-}
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Data.String
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BS
---------------------------------------------------------------------------------
main = do
  [a,b,x] <- map (read::String->Integer) .words <$> getLine
  print $ check a b x

check a b x
  | a==b = if mod a x==0 then 1 else 0
  | otherwise = if mod a x==0 then (div b x) - (div a x) + 1 else (div b x) - (div a x)
  
---------------------------------------------------------------------------------

{-ByteString関連-}
--IO
getLine' = BS.getLine
getContents' = BS.getContents
getInt' = fst . fromJust . BS.readInt <$> getLine'
getIntListw' = map (fst . fromJust. BS.readInt) .words' <$> getContents'
getIntListl' = map (fst . fromJust. BS.readInt) .lines' <$> getContents'
getInteger' = fst . fromJust. BS.readInteger <$> getLine'
putStr' = BS.putStr
putStrLn' = BS.putStrLn
--演算子
bs1 |++| bs2 = BS.append bs1 bs2
chr |:+| bs2 = BS.cons chr bs2
bs1 |+:| chr = BS.snoc bs1 chr
--部分文字列操作
head' bs = BS.head bs
last' bs = BS.last bs
init' bs = BS.init bs
tail' bs = BS.tail bs
take' n bs = BS.take n bs
drop' n bs = BS.drop n bs
takeWhile' f bs = BS.takeWhile f bs
dropWhile' f bs = BS.dropWhile f bs
--リスト操作
length' bs = BS.length bs
reverse' bs = BS.reverse bs
transpose' bs = BS.transpose bs
sort' bs = BS.sort bs
group' bs = BS.group bs
lines' bs = BS.lines bs
words' bs = BS.words bs
unlines' bs = BS.unlines bs
unwords' bs = BS.unwords bs
--要素の有無
elem' chr bs = BS.elem chr bs
notElem' chr bs = BS.notElem chr bs
elemIndex' chr bs = BS.elemIndex chr bs
elemIndices' chr bs = BS.elemIndices chr bs
count' chr bs = BS.count chr bs
--整形
--justifyRight'::Char -> ByteString -> ByteString
--justifyRight' chr bs = convertString $ T.justifyRight chr (convertString bs)

{-elem関連-}
--elemの第一引数をリストにしたもの。
--elemList "abc" "atcoder" -> [True,False,True]
elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

--elemIndexの第一引数をリストにしたもの。
elemIndexList [] list = []
elemIndexList (x:xs) list  = elemIndex x list : elemIndexList xs list

--elemIndicesの第一引数をリストにしたもの。
elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list