#C2393. Three Sum Problem

    ID: 45704 Type: Default 1000ms 256MiB

Three Sum Problem

Three Sum Problem

You are given a list of integers and a target integer \(k\). Your task is to determine whether there exist three distinct elements \(a_i, a_j, a_k\) in the list such that

[ a_i + a_j + a_k = k ]

If such a triplet exists, print True; otherwise, print False. The input is provided in standard input and the output should be printed to standard output.

Note: The same element cannot be used more than once in forming the triplet (i.e. use three different indices even if their values are equal).

inputFormat

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

Example:
5 8
1 2 3 4 5

outputFormat

Output a single line with either True or False, indicating whether a triplet exists that sums up to \(k\) or not.

## sample
5 8
1 2 3 4 5
True