Problem B

Statement
Copy Copied
Description:
You have n friends and you want to take m pictures of them. Exactly two of your friends should appear in each picture and no two pictures should contain the same pair of your friends. So if you have n = 3 friends you can take 3 different pictures, each containing a pair of your friends.

Each of your friends has an attractiveness level which is specified by the integer number ai for the i-th friend. You know that the attractiveness of a picture containing the i-th and the j-th friends is equal to the exclusive-or (xor operation) of integers ai and aj.

You want to take pictures in a way that the total sum of attractiveness of your pictures is maximized. You have to calculate this value. Since the result may not fit in a 32-bit integer number, print it modulo 1000000007 (109 + 7).

Input Format:
The first line of input contains two integers n and m $$( 1 \leq n \leq 5 \cdot 1 0 ^ { 4 } ; \; 0 \leq m \leq \frac { n \cdot ( n - 1 ) } { 2 } )$$ — the number of friends and the number of pictures that you want to take.

Next line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the values of attractiveness of the friends.

Output Format:
The only line of output should contain an integer — the optimal total sum of attractiveness of your pictures.

Note:
None

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
5000 cpp 0 2026-03-07T11:57:09.241043Z View View View Retry
4999 cpp 1 2026-03-07T11:55:45.132117Z View View View Retry
4998 cpp 1 2026-03-07T11:49:58.134998Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
3088 20260319-220008 openai gpt-5.4 go true 2026-03-20T00:25:28.016252Z View View View View Retry
2842 20260318-000008 openai gpt-5.4 go true 2026-03-18T01:05:07.74313Z View View View View Retry
1901 20260309-071525 gemini gemini-3-pro-preview go true 2026-03-09T08:11:27.20608Z View View View View Retry
1729 20260307-080843 openai gpt-5 go false 2026-03-07T11:40:51.763496Z View View View View Retry