#C6227. Count Pairs with Given Sum

    ID: 49964 Type: Default 1000ms 256MiB

Count Pairs with Given Sum

Count Pairs with Given Sum

Given an array of integers and a target integer x, your task is to determine the number of unique pairs (i, j) where i < j such that \( arr[i] + arr[j] = x \). Since the answer can be large, return it modulo \(10^9+7\).

Note: A pair \((i, j)\) is considered unique if \(i < j\) and indices are not reused in different order. The modulo operation is performed with \(10^9+7\).

inputFormat

The first line contains two integers n and x, where n is the number of elements in the array and x is the target sum. The second line contains n space separated integers representing the array elements.

outputFormat

Print a single integer—the count of unique pairs (i, j) with i < j for which arr[i] + arr[j] = x, taken modulo \(10^9+7\).

## sample
5 7
1 5 3 4 2
2