import strutils, sequtils, tables, algorithm let tmp, arr = map(split readLine stdin, parseInt) (N, X) = (tmp[0], tmp[1]) var a = initCountTable[int]() i, ans = 0 for i, ai in arr: inc a, ai var b = newSeq[int](len a) for k, v in a: b[i] = k i += 1 sort(b, cmp) for i, v in b[0 .. b.len div 2]: if X - v in b: ans += a[v] * a[X - v] * (2 - int(v == X - v)) echo ans