Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the…
- User
Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000.
a + b + c + d = n
Create a program that outputs the number of combinations that satisfy the conditions. Input
Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input.
The number of datasets does not exceed 50.
Output
For each data set, output the number of combinations of a, b, c, and d on one line.
Example
Input
2 3 35
Output
10 20 8436
Assistant
pythondef comb3(x): if x < 3: return 0 return x * (x - 1) * (x - 2) // 6 import sys for line in sys.stdin: n = int(line.strip()) if n < 0 or n > 4000: print(0) continue total = comb3(n + 3) if n >= 1001: total -= 4 * comb3(n - 1001 + 3) if n >= 2002: total += 6 * comb3(n - 2002 + 3) if n >= 3003: total -= 4 * comb3(n - 3003 + 3) # n >=4004 would make n>4000, which is already handled print(total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →
DeepSeek-R1Compare side by side →