open System open System.Text type IO() = let size = 1 <<< 12 let stream = Console.OpenStandardInput() let buffer = Array.zeroCreate size let ``!`` = byte '!' let ``~`` = byte '~' let mutable bufferPtr = 0 let hasNextByte = let mutable bufferLen = 0 fun () -> if bufferPtr < bufferLen then true else bufferPtr <- 0 bufferLen <- stream.Read(buffer, 0, size) bufferLen > 0 let readByte() = if hasNextByte() then let r = buffer.[bufferPtr] bufferPtr <- bufferPtr + 1 r else failwith "error" let isAscii c = ``!`` <= c && c <= ``~`` let nextCharByte() = let rec f() = let b = readByte() if isAscii b then b else f() f() let next() = let rec f (sb: StringBuilder) = let c = match sb.Length with | 0 -> nextCharByte() | _ -> readByte() if isAscii c then c |> char |> sb.Append |> f else sb f <| new StringBuilder() |> fun x -> x.ToString() member __.string() = next() member __.char() = nextCharByte() |> char member __.int() = next() |> int member __.int64() = next() |> int64 member __.float() = next() |> float let solve a x = let count = a |> Array.countBy id let countKey = count |> Array.map fst let countMap = count |> Map.ofArray let pairNum key1 = let val1 = countMap.[key1] |> int64 let key2 = x - key1 Map.tryFind key2 countMap |> function | Some val2 -> val1 * (int64 val2) | None -> 0L countKey |> Array.map pairNum |> Array.sum let io = new IO() let N, X = let a = io.int() let b = io.int() a, b let a = let t = Array.zeroCreate N for i in 0 .. (N - 1) do t.[i] <- io.int() t solve a X |> Console.WriteLine