#C7459. Find Pairs with Given Sum
Find Pairs with Given Sum
Find Pairs with Given Sum
You are given an array of integers and a target integer. Your task is to find all pairs of distinct indices (i, j) such that the sum of the numbers at these indices equals the target, i.e., \(a_i + a_j = T\), where \(T\) is the target integer. Each valid pair must satisfy \(i < j\) and the pair itself should be output with the smaller index first. Moreover, the list of pairs should be sorted in lexicographical order.
If no valid pairs exist, the output should be empty.
inputFormat
The first line contains two integers n and target, where n is the number of elements in the array and target is the target sum.
The second line contains n space-separated integers representing the array.
outputFormat
For each valid pair (i, j), output a line with two integers separated by a space. The pairs should be listed in lexicographical order. If no pairs are found, output nothing.
## sample5 6
1 2 3 4 3
1 3
2 4
</p>