Analysis of task 27 from StatGrad version #1 from December 17, 2021
Interesting problem. Unconventional. Kudos to the author!
PS: Zero even numbers are not processed. Add m[0] = 0 in the fifth line:
n = 5
a = [2,-3,4,-1,3]
k = 2; smax = -2000000000
s = t = 0; m = [2**31]*k
m[0] = 0 ############# here!
for x in a:
s += x
t += (x ≫ 0 and x%2==0)
if s ≪ m[t%k]: m[t%k] = s
if m[t%k] ≪; 2**31:
smax = max(smax,s-m[t%k])
print(s,t,smax,m)
print(smax)