Problem p03004 (python)

Fixed submission:
# coding: utf-8
# Your code here!

import copy

N = int(input())

U = []
D = []
R = []
L = []

for _ in range(N):
    x, y, ori = input().rstrip().split(' ')
    x = int(x)
    y = int(y)
    if ori == 'U':
        U.append([x, y])
    elif ori == 'D':
        D.append([x, y])
    elif ori == 'R':
        R.append([x, y])
    else:
        L.append([x, y])
      

def calc(inc_points, dec_points, other_points, index):
    inc = []
    dec = []
    other = [] 
    if len(inc_points) > 0:
        inc_min = min([x[index] for x in inc_points])
        inc_max = max([x[index] for x in inc_points])
        inc = [inc_min, inc_max]
    if len(dec_points) > 0:
        dec_min = min([x[index] for x in dec_points])
        dec_max = max([x[index] for x in dec_points])
        dec = [dec_min, dec_max]
    if len(other_points) > 0:
        other_min = min([x[index] for x in other_points])
        other_max = max([x[index] for x in other_points])
        other = [other_min, other_max]
       
    cross_time = [0]
    if len(inc_points) > 0 and len(dec_points) > 0:
        for u in [inc_min, inc_max]:
            for d in [dec_min, dec_max]:
                if u < d: # collision
                    cross_time.append((d - u) / 2)
                    
    if len(dec_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for d in [dec_min, dec_max]:
                if rl < d: # collision
                    cross_time.append(d - rl)
                    
    if len(inc_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for u in [inc_min, inc_max]:
                if u < rl: # collision
                    cross_time.append(rl - u)
                   
    return inc, dec, other, cross_time
    
def calc_size(inc, dec, other, times):
    sizes = []
    for time in times:
        values = copy.copy(other)
        if len(inc) > 0:
            values.extend([x + time for x in inc])
        if len(dec) > 0:
            values.extend([x - time for x in dec])
        sizes.append(max(values) - min(values))
    return sizes
   
inc_x, dec_x, other_x, cross_time_x = calc(R, L, U+D, 0)         
inc_y, dec_y, other_y, cross_time_y = calc(U, D, R+L, 1)

times = list(set(cross_time_x + cross_time_y))
sizes_x = calc_size(inc_x, dec_x, other_x, times)
sizes_y = calc_size(inc_y, dec_y, other_y, times)

print(min([x*y for x, y in zip(sizes_x, sizes_y)]))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N = int(input())

U = []
D = []
R = []
L = []

for _ in range(N):
    x, y, ori = input().rstrip().split(' ')
    x = int(x)
    y = int(y)
    if ori == 'U':
        U.append([x, y])
    elif ori == 'D':
        D.append([x, y])
    elif ori == 'R':
        R.append([x, y])
    else:
        L.append([x, y])
      

def calc(inc_points, dec_points, other_points, index):
    inc = []
    dec = []
    other = [] 
    if len(inc_points) > 0:
        inc_min = min([x[index] for x in inc_points])
        inc_max = max([x[index] for x in inc_points])
        inc = [inc_min, inc_max]
    if len(dec_points) > 0:
        dec_min = min([x[index] for x in dec_points])
        dec_max = max([x[index] for x in dec_points])
        dec = [dec_min, dec_max]
    if len(other_points) > 0:
        other_min = min([x[index] for x in other_points])
        other_max = max([x[index] for x in other_points])
        other = [other_min, other_max]
       
    cross_time = [0]
    if len(inc_points) > 0 and len(dec_points) > 0:
        for u in [inc_min, inc_max]:
            for d in [dec_min, dec_max]:
                if u < d: # collision
                    cross_time.append((d - u) / 2)
                    
    if len(dec_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for d in [dec_min, dec_max]:
                if rl < d: # collision
                    cross_time.append(d - rl)
                    
    if len(inc_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for u in [inc_min, inc_max]:
                if u < rl: # collision
                    cross_time.append(rl - u)
                   
    return inc, dec, other, cross_time
    
def calc_size(inc, dec, other, times):
    sizes = []
    for time in times:
        values = other.copy()
        if len(inc) > 0:
            values.extend([x + time for x in inc])
        if len(dec) > 0:
            values.extend([x - time for x in dec])
        sizes.append(max(values) - min(values))
    return sizes
   
inc_x, dec_x, other_x, cross_time_x = calc(R, L, U+D, 0)         
inc_y, dec_y, other_y, cross_time_y = calc(U, D, R+L, 1)

times = list(set(cross_time_x + cross_time_y))
sizes_x = calc_size(inc_x, dec_x, other_x, times)
sizes_y = calc_size(inc_y, dec_y, other_y, times)

print(min([x*y for x, y in zip(sizes_x, sizes_y)]))