|
Download misc/misc-0363.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/misc/misc-0363.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@034ba678829a1c436b19d43dd3adab33b5170a80/misc/misc-0363.jsonl
-
curl -L -o misc-0363.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/misc/misc-0363.jsonl
2.3 kB
| {"type": "session", "harness": "opencode", "id": "misc-0363", "name": "Synthetic Competitive Programming"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert competitive programmer. You solve problems by analyzing requirements, designing algorithms, and writing clean, efficient code. When solving problems, explain your reasoning step by step before providing the final solution."}} | |
| {"type": "message", "message": {"role": "user", "content": "**Problem Description**:\nA baker has several trays of cookies, each with a certain number of cookies. Every minute, he can choose any two adjacent trays and transfer one cookie from the tray with more cookies to the tray with fewer cookies. The goal is to make all trays have the same number of cookies using the minimum number of transfers. If it is impossible to achieve equal number of cookies, return -1.\n\n**Input Format**:\n- The first line contains an integer \\( T \\) (1 ≤ \\( T \\) ≤ 100), the number of test cases.\n- For each test case:\n - The first line contains an integer \\( N \\) (1 ≤ \\( N \\) ≤ 100,000), the number of trays.\n - The second line contains \\( N \\) integers \\( c_1, c_2, \\ldots, c_N \\) (0 ≤ \\( c_i \\) ≤ 1,000,000,000), where \\( c_i \\) is the number of cookies in the \\( i \\)-th tray.\n\n**Output Format**:\n- For each test case, output a single line with the minimum number of transfers needed to make all trays have the same number of cookies, or -1 if it is impossible.\nExamples\n\n**Input**:\n```\n3\n3\n8 10 5\n4\n6 8 6 6\n2\n1 2\n```\n\n**Output**:\n```\n5\n4\n-1\n```"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "def main():\n import sys\n input = sys.stdin.read().split()\n ptr = 0\n T = int(input[ptr])\n ptr += 1\n for _ in range(T):\n N = int(input[ptr])\n ptr += 1\n c = list(map(int, input[ptr:ptr+N]))\n ptr += N\n S = sum(c)\n if S % N != 0:\n print(-1)\n continue\n avg = S // N\n running = 0\n transfers = 0\n for i in range(N):\n running += c[i] - avg\n if i != N - 1:\n transfers += abs(running)\n print(transfers)\n\nif __name__ == \"__main__\":\n main()"}} | |