Problem p03438 (python)

Fixed submission:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####
def main():
	n = I()
	x = 0; y = 0
	
	for a,b in zip(LI(),LI()):
		if a > b:
			x += a-b
		else:
			y += (b-a)//2

	print('Yes' if y >= x else "No")

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def main():
	n = I()
	a = LI()
	b = LI()

	pos = 0
	neg = 0
	


	for i in range(n):
		diff = a[i]-b[i]

		if diff>0:
			pos += abs(diff)
		else:
			neg += abs(diff)

	g = gcd(pos,neg)
	if 2*(pos//g) == neg//g:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	n = I()
	a = LI()
	b = LI()

	for i in range(n-1):
		diff = a[i]-b[i]

		if diff == 0:
			pass

		elif diff>0:
			b[i] += diff
			a[i+1] += 2*diff

		elif diff<0:
			if diff%2:
				a[i] += abs(diff)+1
				b[i+1] += (abs(diff)+1)//2
				a[i+1] += 2
				b[i] += 1
			else:
				a[i] += abs(diff)
				b[i+1] += abs(diff)//2
		print(a)
		print(b)
		print("-"*10)

	print(a)
	print(b)
	print("-"*10)


	if a[-1]<=b[-1]:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
  main()