output_description: Print the area of the triangle ABC.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      |AB| |BC| |CA|
attempt: # coding:utf-8
  import copy
  
  N, K = map(int, input().split())
  T = []
  D = []
  ls_td = []
  for n in range(N):
      t, d = map(int, input().split())
      ls_td.append([t, d])
  ls_td = sorted(ls_td, key=lambda x: x[1])[::-1]
  head = ls_td[:K]
  tail = ls_td[K:]
  
  
  def get_set(mat):
      st = set()
      for t, d in mat:
          st.add(t)
      return st
  
  
  def score(mat):
      r = 0
      ls_t = set()
      for t, d in mat:
          ls_t.add(t)
          r += d
      r += len(ls_t) ** 2
      return r
  
  
  def search_del(mat):
      idx = -1
      st = set()
      for i, (t, d) in enumerate(mat):
          if t in st:
              idx = i
          st.add(t)
      return idx
  
  
  st = get_set(head)
  current_score = score(head)
  idx = search_del(head)
  for t, d in tail:
      if idx == -1:
          break
  
      if t in st:
          pass
      else:
          new = copy.deepcopy(head)
          new[idx] = t, d
          candidate_score = score(new)
          if current_score < candidate_score:
              head = new
              st.add(t)
              current_score = candidate_score
              idx = search_del(head)
  print(current_score)
  
problem_description: Statement
  
  There is a right triangle ABC with ∠ABC=90°.
  
  Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the
  right triangle ABC.
  
  It is guaranteed that the area of the triangle ABC is an integer.
samples: [{"input": "3 4 5", "output": "6\n    \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n    \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n    \n\nThis triangle has an area of 630."}]