#C4913. Three Items Selection

    ID: 48504 Type: Default 1000ms 256MiB

Three Items Selection

Three Items Selection

You are given an integer \(n\) representing the number of items, an integer \(k\) and a list of \(n\) integers representing the costs of the items. Your task is to determine if it is possible to choose exactly three distinct items such that the sum of their costs is divisible by \(k\). In other words, find three different costs \(a, b, c\) (from the list) such that:

[ a + b + c \equiv 0 \pmod{k} ]

If such a triplet exists, output YES. Otherwise, output NO.

Note: You are required to solve this problem by reading input from stdin and outputting the result to stdout.

inputFormat

The input consists of two lines:

  • The first line contains two integers \(n\) and \(k\), where \(n\) is the number of items and \(k\) is the divisor.
  • The second line contains \(n\) integers, representing the costs of the items.

outputFormat

Output a single line with YES if there exists a combination of exactly three distinct items such that the sum of their costs is divisible by \(k\), otherwise output NO.

## sample
5 6
1 5 3 2 4
YES

</p>