#C3955. Find Pair with Given Sum

    ID: 47439 Type: Default 1000ms 256MiB

Find Pair with Given Sum

Find Pair with Given Sum

You are given an array of integers and an integer \(K\). Your task is to determine whether there exist two distinct indices \(i\) and \(j\) (with \(i < j\)) such that:

[ a_i + a_j = K ]

This problem requires you to implement an efficient solution to check for such a pair. The input is provided via stdin and the answer must be printed to stdout as either True or False. Use appropriate algorithms to ensure the solution works for both small and large inputs.

inputFormat

The first line of input contains two integers \(n\) and \(K\), where \(n\) is the number of elements in the array and \(K\) is the target sum. The second line contains \(n\) space-separated integers representing the array.

Input Format:

n K
a1 a2 a3 ... an

outputFormat

Print True if there exists a pair of indices \(i < j\) such that \(a_i + a_j = K\), otherwise print False.

## sample
5 8
1 2 3 4 5
True