Run time error(NZEC) in Python

import collections
t = int(raw_input())
list1 = []
i = 0
if t<=10:
while i<t:
a = int(raw_input())
i+=1

	if a <= 1000:
		for _ in xrange(t):
			test_cases = map(int, raw_input().split())
			list1.append(test_cases)

	for x in list1:
		counter = collections.Counter(x)
		j = counter.values()
		print (len(x) - max(j))
this code is giving me a Runtime error (NZEC) Please help!!!!!