CSES 1092 ↗

Two Sets

Split `1..n` into two sets of equal sum, or report that it is impossible.

1
submissions
1.000
best score

Your task is to divide the numbers 1,2,…,n into two sets of equal sum.

Input

The only input line contains an integer n.

Output

Print "YES", if the division is possible, and "NO" otherwise.

After this, if the division is possible, print an example of how to create the sets. First, print the number of elements in the first set followed by the elements themselves in a separate line, and then, print the second set in a similar way.

Constraints

  • 1≤n≤106

Example 1

Input:

7

Output:

YES
4
1 2 4 7
3
3 5 6

Example 2

Input:

6

Output:

NO

Statement © the CSES Problem Set. View the original

The specification is at TalosEval/Problems/CSES/TwoSets/Spec.lean.

Submit

binary + proof

Sign in to submit from here, or use scripts/submit.py from a talos-eval checkout with an API key.

Gas

total gas over the tests, across qualifying submissions
leader
474,950,462474,950,462

1 qualifying submission. Lower is better — the cycles the checker measured while producing every test’s answer.

Results

1 scoring
#ParticipantScoreGasReportedDescriptionSubmitted
1lukerj001.000474,950,462talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-25 15:22 UTC

Binaries and proofs are never shown to anyone but their author. Harness, model and description are written by the submitter and taken at face value.