Buggy python submission (verdict: Runtime Error):
N = int(input())
X = [None] * N
Y = [None] * N
U = [None] * N
for i in range(N):
  X[i], Y[i], U[i] = input().split()

def main():
  for i in range(N):
    for j in range(N):
      if (i > j):
        continue

      if (U[i] == U[j]):
        continue

      if (U[i] == 'U' and U[j] == 'R'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[j]) - int(Y[i])):
          return(abs((int(Y[j]) - int(Y[i]))*10))

      if (U[i] == 'U' and U[j] == 'D'):
        if (int(X[i]) == int(X[j])) and (int(Y[i]) < int(Y[j])) and (int(Y[i]) - int(Y[j])) % 2 == 0:
          return(abs((int(Y[i]) - int(Y[j]))*5))

      if (U[i] == 'U' and U[j] == 'L'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          return(abs((int(Y[i]) - int(Y[j]))*10))

      if (U[i] == 'R' and U[j] == 'U'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          return(abs((int(X[j]) - int(X[i]))*10))

      if (U[i] == 'R' and U[j] == 'D'):
        if (int(X[j]) > int(X[i]) and int(X[j]) - int(X[i]) == int(Y[j]) - int(Y[i])):
          return(abs((int(X[j]) - int(X[i]))*10))

      if (U[i] == 'R' and U[j] == 'L'):
        if (int(Y[i]) == int(Y[j])) and (int(X[i]) < int(X[j])) and (int(X[i]) - int(X[j])) % 2 == 0:
          return(abs((int(X[i]) - int(X[j]))*5))

      if (U[i] == 'D' and U[j] == 'U'):
        if (int(X[i]) == int(X[j])) and (int(Y[i]) > int(Y[j])) and (int(Y[i]) - int(Y[j])) % 2 == 0:
          return(abs((int(Y[i]) - int(Y[j]))*5))

      if (U[i] == 'D' and U[j] == 'R'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[i]) - int(X[j])):
          return(abs((int(Y[i]) - int(Y[j]))*10))

      if (U[i] == 'D' and U[j] == 'L'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          return(abs((int(Y[i]) - int(Y[j]))*10))

      if (U[i] == 'L' and U[j] == 'U'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[i]) - int(Y[j])):
          return(abs((int(X[i]) - int(X[j]))*10))
      
      if (U[i] == 'L' and U[j] == 'D'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[j]) - int(Y[i])):
          return(abs((int(X[i]) - int(X[j]))*10))

      if (U[i] == 'L' and U[j] == 'R'):
        if (int(Y[i]) == int(Y[j])) and (int(X[i]) > int(X[j])) and (int(X[j]) - int(X[i])) % 2 == 0:
          return(abs((int(X[j]) - int(X[i]))*5))

  return('SAFE')

print(main())


Fixed submission:
x = int(input())

if (400 <= x <= 599):
  print(8)
elif (600 <= x <= 799):
  print(7)
elif (800 <= x <= 999):
  print(6)
elif (1000 <= x <= 1199):
  print(5)
elif (1200 <= x <= 1399):
  print(4)
elif (1400 <= x <= 1599):
  print(3)
elif (1600 <= x <= 1799):
  print(2)
elif (1800 <= x <= 1999):
  print(1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = [None] * N
Y = [None] * N
U = [None] * N
for i in range(N):
  X[i], Y[i], U[i] = input().split()

def main():
  for i in range(N):
    for j in range(N):
      if (i > j):
        continue

      if (U[i] == U[j]):
        continue

      '''
      U vs R ... Ux > Rx and Ux - Rx == Ry - Uy
      U vs D ... Ux == Dx and Uy < Dy and (Uy - Dy) % 2 == 0 # Note: if Uy = 3, Dy = 0, conflict does NOT happen
      U vs L ... Uy > Ly and Uy - Ly == Lx - Ux
      '''
      if (U[i] == 'U' and U[j] == 'R'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[j]) - int(Y[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[j]) - int(Y[i]))*10))

      if (U[i] == 'U' and U[j] == 'D'):
        if (int(X[i]) == int(X[j])) and (int(Y[i]) < int(Y[j])) and (int(Y[i]) - int(Y[j])) % 2 == 0:
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[i]) - int(Y[j]))*5))

      if (U[i] == 'U' and U[j] == 'L'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[i]) - int(Y[j]))*10))

      '''
      R vs U ... Ry > Uy and Ry - Uy == Ux - Rx
      R vs D ... Dx > Rx and Dx - Rx == Dy - Ry
      R vs L ... Ry == Ly and Rx < Lx and (Rx - Lx) % 2 == 0
      '''
      if (U[i] == 'R' and U[j] == 'U'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[j]) - int(X[i]))*10))

      if (U[i] == 'R' and U[j] == 'D'):
        if (int(X[j]) > int(X[i]) and int(X[j]) - int(X[i]) == int(Y[j]) - int(Y[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[j]) - int(X[i]))*10))

      if (U[i] == 'R' and U[j] == 'L'):
        if (int(Y[i]) == int(Y[j])) and (int(X[i]) < int(X[j])) and (int(X[i]) - int(X[j])) % 2 == 0:
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[i]) - int(X[j]))*5))

      '''
      D vs U ... Dx == Ux and Dy > Uy and (Dy - Uy) % 2 == 0
      D vs R ... Dy > Ry and Dy - Ry == Dx - Rx
      D vs L ... Dy > Ly and Dy - Ly == Lx - Dx
      '''
      if (U[i] == 'D' and U[j] == 'U'):
        if (int(X[i]) == int(X[j])) and (int(Y[i]) > int(Y[j])) and (int(Y[i]) - int(Y[j])) % 2 == 0:
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[i]) - int(Y[j]))*5))

      if (U[i] == 'D' and U[j] == 'R'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[i]) - int(X[j])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[i]) - int(Y[j]))*10))

      if (U[i] == 'D' and U[j] == 'L'):
        if (int(Y[i]) > int(Y[j]) and int(Y[i]) - int(Y[j]) == int(X[j]) - int(X[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(Y[i]) - int(Y[j]))*10))

      '''
      L vs U ... Lx > Ux and Lx - Ux == Ly - Uy
      L vs D ... Lx > Dx and Lx - Dx == Dy - Ly
      L vs R ... Ly == Ry and Lx > Rx and (Rx - Lx) % 2 == 0
      '''
      if (U[i] == 'L' and U[j] == 'U'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[i]) - int(Y[j])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[i]) - int(X[j]))*10))
      
      if (U[i] == 'L' and U[j] == 'D'):
        if (int(X[i]) > int(X[j]) and int(X[i]) - int(X[j]) == int(Y[j]) - int(Y[i])):
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[i]) - int(X[j]))*10))

      if (U[i] == 'L' and U[j] == 'R'):
        if (int(Y[i]) == int(Y[j])) and (int(X[i]) > int(X[j])) and (int(X[j]) - int(X[i])) % 2 == 0:
          #print('{} {}'.format(U[i], U[j]))
          return(abs((int(X[j]) - int(X[i]))*5))

  return('SAFE')

print(main())


Fixed submission:
x = int(input())

if (400 <= x <= 599):
  print(8)
elif (600 <= x <= 799):
  print(7)
elif (800 <= x <= 999):
  print(6)
elif (1000 <= x <= 1199):
  print(5)
elif (1200 <= x <= 1399):
  print(4)
elif (1400 <= x <= 1599):
  print(3)
elif (1600 <= x <= 1799):
  print(2)
elif (1800 <= x <= 1999):
  print(1)