Buggy python submission (verdict: Runtime Error):
import itertools
h, w, k = map(int, input().split())
li_hw =  [list(f) for f in [input() for _ in range(h)]]
all_h = []
score = []
# for l in range(2**(h-1)):
#     ind = []
#     pre = 0
#     cut_list=[]
#     hline_num = 0
#     for n,yn in enumerate(reversed(list(bin(l))[2:])):
#         if yn == "1":
#             cut_list.append(li_hw[pre:n+1])
#             pre = n+1
#     cut_list.append(li_hw[pre:h])
for i in itertools.product([0, 1], repeat=h-1):
    cut_list=[]
    hline_num = 0
    pre = 0
    cut_list = []
    for n, i2 in enumerate(i):
        if i2 == 1:
            cut_list.append(li_hw[pre:n+1])
            pre = n+1
    cut_list.append(li_hw[pre:h])
    hline_num = i.count(1)
    pred = 0
    wline_num = 0
    #print("list is {}".format(cut_list))
    
    
    for y in range(w):
        wcounter_list = []
        for c in cut_list:
            wcounter = 0
            for c2 in c:
                wcounter += c2[pred:y+1].count("1")
            wcounter_list.append(wcounter)
        #print("wcounter{}".format(wcounter_list))
        if max(wcounter_list) > k:
            pred = y
            wline_num += 1
            #print("line between{}and{}".format(y-1, y))
    #print("wline{}, hline{}".format(wline_num, hline_num))
    score.append(wline_num+hline_num)
print(min(score))

Fixed submission:
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
collections.Counter(li)
m = 0
dic = collections.Counter(li)
for i in dic.values():
    m += int(i*(i-1)*0.5)
for k in range(n):
      print(m-dic[li[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
li = list(map(int, input().split()))
def calc(a):
    return int(a*(a-1)*0.5)
for k in range(n):
	dic = collections.Counter(li)
	dic[li[k]] -=1
	data2 = map(calc, list(dic.values()))
	print(sum(data2))

Fixed submission:
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
collections.Counter(li)
m = 0
dic = collections.Counter(li)
for i in dic.values():
    m += int(i*(i-1)*0.5)
for k in range(n):
      print(m-dic[li[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
li = list(map(int, input().split()))
for k in range(n):
    dic = collections.Counter(li)
    dic[li[k]] -=1
    x = 0
    for d in dic.values():
        x+= int(d*(d-1)*0.5)
    print(x)

Fixed submission:
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
collections.Counter(li)
m = 0
dic = collections.Counter(li)
for i in dic.values():
    m += int(i*(i-1)*0.5)
for k in range(n):
      print(m-dic[li[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
for k in range(n):
	dic = collections.Counter(li)
	dic[li[k]] -=1
	x = 0
	for d in dic.values():
		x+= int(d*(d-1)*0.5)
	print(x)

Fixed submission:
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
collections.Counter(li)
m = 0
dic = collections.Counter(li)
for i in dic.values():
    m += int(i*(i-1)*0.5)
for k in range(n):
      print(m-dic[li[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
king_li=[]
for k in range(n):
    cp_li = li.copy()
    del cp_li[k]
    k_li=[]
    for val in collections.Counter(cp_li).values():
        in_li=[]
        in_li.append(int(val*(val-1)*0.5))
        k_li.append(sum(in_li))
    king_li.append(sum(k_li))
for k in king_li:
  print(k)

Fixed submission:
import collections
n = int(input())
a = map(int, input().split())
li = []
for i in a:
    li.append(i)
collections.Counter(li)
m = 0
dic = collections.Counter(li)
for i in dic.values():
    m += int(i*(i-1)*0.5)
for k in range(n):
      print(m-dic[li[k]]+1)