Here is the contest link. All problems are from Codeforces' Problemset.
A. New Year String
Solution
The key observation for solving this problem is that any occurrence of 2025 can be converted into 2026 using a single operation. Therefore, if the given string does not already satisfy any of the conditions stated in the problem, only one operation is needed to create an occurrence of 2026 (since the string contains 2025 when it is not already a New Year string).
As a result, the answer is always either 0 or 1. To determine whether the answer is 0, simply check if the string satisfies at least one of the required conditions. This can be done using the in operator method in Python.
Code
n = int(input())
nums = list(map(int, input().split()))
answer = []
for i in range(n):
if i == n-1:
answer.append(nums[i])
else:
answer.append(nums[i] + nums[i + 1])
print(*answer)



