• + 0 comments

    Haskell. Didn't feel like a 50 point problem, but I'll take it /shrug

    module Main where
    
    import qualified Data.Set as S
    
    solve :: Int -> [Int] -> Int
    solve k ns =
        let
            s = S.fromList ns
            s' = S.map (+ k) s
         in
            S.size $ S.intersection s s'
    
    main :: IO ()
    main = do
        [_, k] <- fmap (map read . words) getLine :: IO [Int]
        ns <- fmap (map read . words) getLine :: IO [Int]
        print $ solve k ns