Problem:
Problem A: Traffic Analysis There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure)   Monitoring systems are connected to the cameras respectively.
When a car passes through the monitoring line, the corresponding monitoring system records elapsed time (sec) from the start of monitoring. Your task is to write a program which reads records of the two monitoring systems and prints the maximum time interval where cars did not pass through the monitoring line. The two monitoring system start monitoring simultaneously. The end of monitoring is indicated by the latest time in the records. Input The input consists of multiple datasets. Each dataset consists of:  n m  tl 1  tl 2 ... tl n  tr 1  tr 2 ... tr m   n , m are integers which represent the number of cars passed through monitoring line on the up line and the down line respectively. tl i , tr i are integers which denote the elapsed time when i -th car passed through the monitoring line for the up line and the down line respectively. You can assume that tl 1 < tl 2 < ... < tl n 、 tr 1 < tr 2 < ... < tr m . You can also assume that n , m ≤ 10000, and 1 ≤ tl i , tr i ≤ 1,000,000. The end of input is indicated by a line including two zero. Output For each dataset, print the maximum value in a line. Sample Input 4 5
20 35 60 70
15 30 40 80 90
3 2
10 20 30
42 60
0 1
100
1 1
10
50
0 0 Output for the Sample Input 20
18
100
40

Solution (Python):



import sys
from sys import stdin
input = stdin.readline

while True:
	n, m = map(int, input().split())
	if n == 0 and m == 0: break
	if n > 0: a = list(map(int, input().split()))
	if m > 0: b = list(map(int, input().split()))
	ans = i = j = 0
	s, t = 0, -1
	while i < n or j < m:
		if i < n:
			if s == a[i]: i += 1
			if i < n: t = a[i]
		if j < m:
			if s == b[j]: j += 1
			if j < m and (t < 0 or b[j] < t): t = b[j]
		if t >= 0:
			if i < n and t == a[i]: i += 1
			if j < m and t == b[j]: j += 1
			ans = max(ans, t-s)
			s, t = t, -1
	if t >= 0: ans = max(ans, t-s)
	print(ans)

Solution (Python):
while True:
	n,m = map(int,raw_input().split())
	if n == 0 and m == 0 : break

	traffic = [0]
	if n != 0:
		traffic = map(int,raw_input().split())
	if m != 0:
		traffic += map(int,raw_input().split())
	
	traffic.sort()
	
	max = traffic[0]
	next = traffic[0]
	for var in traffic[1:]:
		if var - next > max:
			max = var - next
		next = var
		
	print max

Solution (Python):
while 1:
    t,(n,m)=[0],map(int,input().split())
    if n==m==0:break
    if n:t+=map(int,input().split())
    if m:t+=map(int,input().split())
    t.sort()
    print(max(t[i+1]-t[i] for i in range(n+m)))

Solution (Python):
while True:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    up=map(int,raw_input().split()) if n!=0 else []
    down=map(int,raw_input().split()) if m!=0 else []
    upDown=up+down
    upDown.sort()
    maxlen=upDown[0]
    for i in range(n+m-1):
        maxlen=max(maxlen,upDown[i+1]-upDown[i])
    print maxlen

Solution (Python):
get = lambda:map(int, raw_input().split())
while 1:
    n,m = get()
    if n==m==0: break
    t = [0]
    if n!=0: t += get()
    if m!=0: t += get()
    t.sort()
    print max(t[i+1]-t[i] for i in xrange(n+m)) if n+m>1 else t[1]

Solution (Python):
while 1:
	n,m = map(int,raw_input().split())
	if n == m == 0: break
	data = [0]
	if n > 0: data += map(int,raw_input().split())
	if m > 0: data += map(int,raw_input().split())
	data = sorted(data)
	print max(data[i+1]-data[i] for i in range(n+m))

Solution (Python):

while True :
    n, m = map(int, input().split())
    if n == 0  and m == 0 :
        break
    car_list = []
    if n != 0 :
        A = list(map(int, input().split()))
        for i in range(n) :
            car_list.append(A[i])
    if m != 0 :
        A = list(map(int, input().split()))
        for i in range(m) :
            car_list.append(A[i])
    car_list.sort()
    car_list.insert(0, 0)
    
    max_car = 0
    for i in range(n+m) :
        if car_list[i+1] - car_list[i] > max_car :
            max_car = car_list[i+1] - car_list[i]
    print(max_car)

Solution (Python):
if __name__ == '__main__':
    while True:
        L, R = list(map(int, input().strip().split()))
        if L == 0 and R == 0:
            break
            
        arr = set([ 0 ])
        if L > 0:
            arr.update( list(map(int, input().strip().split(' '))) )
        if R > 0:
            arr.update( list(map(int, input().strip().split(' '))) )
        arr = sorted(list(arr))

        maxi = -9999999999
        for i in range(len(arr) - 1):
            maxi = max(maxi, arr[i + 1] - arr[i])

        print(maxi)

Solution (Python):
while True:
  n, m = map(int, input().split())
  if n == 0 and m == 0:
    break
  if n != 0 and m != 0:
    t_all = [0] + sorted(list(map(int, input().split())) + list(map(int, input().split())))
  else:
    t_all = [0] + sorted(map(int, input().split()))
  ans = 0
  for i in range(1, n + m + 1):
    ans = max(ans, t_all[i] - t_all[i - 1])
  print(ans)