int input ans for in range ans append for in range list map int input

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
n = int(input())
ans = []
for i in range(n):
ans.append([])
for i in range(n):
a = list(map(int,input().split()))
ans[i].append(i)
for j in range(n):
if a[j] == 1:ans[i].append(j);ans[j].append(i)
summa = 0
for i in range(n):
c = []
for j in range(len(ans[i])):
if ans[i][j] not in c : c.append(ans[i][j])
if len(c) < 3: ans[i] = []
else: summa += len(ans[i])-1
print(summa)
for i in range(n):
if ans[i] == []:print(0,end = " ")
else: print(len(ans[i])-1,end = " ")