int input for in range append list map int input split for in range fo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
n = int(input())
a = 0
A = []
B = [0]*n
for i in range(n):
A.append(list(map(int, input().split())))
for i in range(n):
a = 0
for j in range(n):
if A[i][j] + A[j][i] == 1:
B[i] += 1
a += 1
if A[i][j] + A[j][i] == 2:
B[i] += 2
a += 1
if a < 2:
B[i] = 0
print(sum(B))
print(*B)