If you don't mind the asymmetry of solve reading the input itself but not printing the output itself, you could also make it a generator:
from itertools import accumulate
def input_ints():
return map(int, input().split())
def solve():
_, q = input_ints()
cumulative = [0, *accumulate(input_ints())]
for _ in range(q):
a, b = input_ints()
yield cumulative[b] - cumulative[a - 1]
print('\n'.join(map(str, solve())))
I do mind that asymmetry, though. Another symmetric way, instead of solve doing both input and output, would be to solve doing neither of them:
from itertools import accumulate
def input_ints():
return map(int, input().split())
def solve(x, queries):
cumulative = [0, *accumulate(x)]
for a, b in queries:
yield cumulative[b] - cumulative[a - 1]
_, q = input_ints()
x = input_ints()
queries = (input_ints() for _ in range(q))
results = solve(x, queries)
print('\n'.join(map(str, results)))
Granted, now the "main block" doesn't look nice. But solve is now very nice, and it can also be tested nicely by just calling it with data, for example:
>>> list(solve([3, 2, 4, 5, 1, 1, 5, 3],
[[2, 4], [5, 6], [1, 8], [3, 3]]))
[11, 2, 24, 4]