output_description: For each k=1,2,...,N, print a line containing the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: def check_block(comb, K):
      block = 0
      pre = (comb & 1) > 0
      mapping = {0: 0}
      cut_num = 0
      for i in range(1, K):
          cur = ((1 << i) & comb) > 0
          if pre != cur:
              block += 1
              pre = cur
              cut_num += 1
          mapping[i] = block
      return mapping, cut_num
  
  
  H, W, K = map(int, input().split())
  graph = [input() for ele in range(H)]
  #
  ans = 1319203291031903
  for comb in range(1 << (H - 1)):
      mapping, cut_num = check_block(comb, K)
      pre = [0] * (cut_num + 1)
      gg = False
      # preprocess
      for j in range(H):
          pre[mapping[j]] += graph[j][0] == "1"
      for ele in pre:
          if ele > K:
              gg = True
              break
      if gg:
          continue
  
      for i in range(1, W):
          cum = pre[:]
          for j in range(H):
              cum[mapping[j]] += graph[j][i] == "1"
          for ii in range(len(cum)):
              if cum[ii] - pre[ii] > K:
                  gg = True
                  break
              if cum[ii] > K:
                  cut_num += 1
                  for idx in range(len(cum)):
                      cum[idx] -= pre[idx]
                  break
          pre = cum
          if gg:
              break
  
      if not gg:
          ans = min(ans, cut_num)
  print(ans)
  
problem_description: Statement
  
  We have N balls. The i-th ball has an integer A_i written on it.  
  For each k=1, 2, ..., N, solve the following problem and print the answer.
  
    * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
samples: [{"input": "5\n    1 1 2 1 2", "output": "2\n    2\n    3\n    2\n    3\n    \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2.  \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal.  \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n    1 2 3 4", "output": "0\n    0\n    0\n    0\n    \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n    3 3 3 3 3", "output": "6\n    6\n    6\n    6\n    6\n    \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n    1 2 1 4 2 1 4 1", "output": "5\n    7\n    5\n    7\n    7\n    5\n    7\n    5"}]