Linear Kingdom has exactly one tram line. It has `n` stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop.

## Your task

Calculate the tram's minimum capacity such that the number of people inside the tram never exceeds this capacity at any time. Note that at each stop all exiting passengers exit before any entering passenger enters the tram.

## Example

```c++
tram(4, {0, 2, 4, 4}, {3, 5, 2, 0}) ==> 6
```
  
Explaination:
* The number of passengers inside the tram before arriving is 0.
* At the first stop 3 passengers enter the tram, and the number of passengers inside the tram becomes 3.
* At the second stop 2 passengers exit the tram (1 passenger remains inside). Then 5 passengers enter the tram. There are 6 passengers inside the tram now.
* At the third stop 4 passengers exit the tram (2 passengers remain inside). Then 2 passengers enter the tram. There are 4 passengers inside the tram now.
* Finally, all the remaining passengers inside the tram exit the tram at the last stop. There are no passenger inside the tram now, which is in line with the constraints.

Since the number of passengers inside the tram never exceeds 6, a capacity of 6 is sufficient. Furthermore it is not possible for the tram to have a capacity less than 6. Hence, 6 is the correct answer.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def tram(stops, descending, onboarding):
	

Solutions:
from itertools import accumulate

def tram(stops, descending, onboarding):
	return max(accumulate((o - d for (d, o) in zip(descending[:stops], onboarding))))


def tram(stops, descending, onboarding):
	return max((sum(onboarding[:i]) - sum(descending[:i]) for i in range(stops + 1)))


def tram(stops, descending, onboarding):
	(n, m) = (0, 0)
	for (d, u) in zip(descending[:stops], onboarding):
		n += u - d
		m = max(m, n)
	return m


def tram(stops, descending, onboarding):
	(min_capacity, passengers) = (0, 0)
	for (off, on) in zip(descending[:stops], onboarding[:stops]):
		passengers += on - off
		min_capacity = max(min_capacity, passengers)
	return min_capacity


from itertools import accumulate as acc

def tram(stops, down, up):
	return max(acc((u - d for (d, u) in zip(down[:stops], up))))


def tram(stops, off, on):
	total = 0
	passengers = []
	for i in range(stops):
		total += on[i] - off[i]
		passengers.append(total)
	return max(passengers)


tram = lambda s, d, o, c=0, m=0: (lambda c: tram(s - 1, d[1:], o[1:], c, m=max(c, m)))(c + o[0] - d[0]) if s else max(c, m)


tram = lambda s, d, o, a=__import__('itertools').accumulate: max(a(map(int.__sub__, o[:s], d[:s])))


from itertools import accumulate

def tram(stops, descending, onboarding):
	return max(accumulate((b - a for (_, a, b) in zip(range(stops), descending, onboarding))))


from itertools import accumulate
from operator import add

def tram(stops, off, on):
	return max(accumulate((b - a for (a, b) in zip(off, on[:stops])), add))