Use dynamic programming:
ans[i] = 0 # i < 4
ans[i] = ans[i - 1] + (i - 1) * (i - 1) // 4 - (i - (i // 2 + 1)) # i >= 4
With linear dynamic programming solution, we can't solve for very large N
.
Using matrix multiplication, we can reduce the complexity to logarithmic time.
Simple replace & eval.
Exploiting SQL injection in register
function to cheat points and format string vulnerability in reward
function to get shell.