#K92142. Find Pairs with Given Sum

    ID: 38132 Type: Default 1000ms 256MiB

Find Pairs with Given Sum

Find Pairs with Given Sum

Given two integers n and k, your task is to find all pairs of integers \((i, j)\) that satisfy the following conditions:

  • \(1 \leq i < j \leq n\)
  • \(i + j = k\)

You should output the total number of such pairs on the first line, followed by each valid pair in a new line, with the two numbers separated by a space.

Make sure your program reads from standard input and writes to standard output.

inputFormat

The input consists of a single line containing two space-separated integers \(n\) and \(k\).

outputFormat

The output starts with a single integer representing the number of pairs found. Each subsequent line contains one pair \((i, j)\) with the two numbers separated by a space.

## sample
5 5
2

1 4 2 3

</p>