text: from tool.runners.python import SubmissionPy
  import collections
  
  
  class JonSubmission(SubmissionPy):
  
      def run(self, s):
          code = [int(v) for v in s.strip().split(",")]
  
          view = "".join(chr(v) for v in compute(code, []))
  
          l = view.strip().split("\n")
          h = len(l)
          w = len(l[0])
  
          # print(view)
  
          result = 0
          for y in range(1, h-1):
              for x in range(1, w-1):
                  if l[y][x] != "." and l[y-1][x] != "." and l[y+1][x] != "." and l[y][x-1] != "." and l[y][x+1] != ".":
                      result += x*y
  
          return result
  
  
  def compute(code, input_l):
      p = collections.defaultdict(int, enumerate(code))
      pc = 0
      relative_base = 0
  
      def index(pos):
          mode = (p[pc] // 10 ** (1 + pos)) % 10
          if mode == 0:
              return p[pc + pos]
          if mode == 1:
              return pc + pos
          if mode == 2:
              return relative_base + p[pc + pos]
          raise Exception("Bad param mode")
  
      while True:
          op = p[pc] % 100
  
          if op == 1:
              p[index(3)] = p[index(1)] + p[index(2)]
              pc += 4
          elif op == 2:
              p[index(3)] = p[index(1)] * p[index(2)]
              pc += 4
          elif op == 3:
              p[index(1)] = input_l[0]
              pc += 2
          elif op == 4:
              yield p[index(1)]
              pc += 2
          elif op == 5:
              pc = p[index(2)] if p[index(1)] != 0 else pc + 3
          elif op == 6:
              pc = p[index(2)] if p[index(1)] == 0 else pc + 3
          elif op == 7:
              p[index(3)] = 1 if p[index(1)] < p[index(2)] else 0
              pc += 4
          elif op == 8:
              p[index(3)] = 1 if p[index(1)] == p[index(2)] else 0
              pc += 4
          elif op == 9:
              relative_base += p[index(1)]
              pc += 2
          elif op == 99:
              break
          else:
              raise Exception("Unknown op code")
  