Problem:


Score : 200 points

Problem Statement

N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.

There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

Input

Input is given from Standard Input in the following format:

N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
n, k = map(int,input().split())

l = [list(map(int,input().split())) for i in range(k*2)]
a=[]
for i in range(1,k+1):
    a.append(l[2*i-1])
b = []
for j in a :
    for item in j :
        b.append(item)

ans = 0
for k in range(1,n+1):
    if b.count(k) == 0 :
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    li.extend(a)

counter = 0
for j in range(n):
    if j+1 not in li:
        counter += 1

print(counter)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
N, K = map(int, readline().split())
table = [0]*N
for _ in range(K):
    d = int(readline())
    for a in list(map(int, readline().split())):
        table[a-1] += 1

print(table.count(0))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
D = list()
Snuke = {x for x in range(1,N+1)}

for i in range(K):
    d = int(input())
    j = list(map(int,input().split()))
    D.append(j)    
    
for i in D:
    Snuke = Snuke.difference(set(i))


print(len(Snuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

result = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        result[a-1] = 1
cnt = 0
for val in result:
    if val == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import itertools
N1, K1 = map(int, input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
N = len(listA)
#print(N)
listB = []
for n in range(0,N):
  if n%2==1:
    listB.append(listA[n])
#    print(listB)
listC = list(itertools.chain.from_iterable(listB))
#print(listB)
print(N1 - len(list(set(listC))))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = [0] * K
A = [0] * K
for i in range (K):
	d[i] = map ( int, input() .split())
	A[i] = list(map(int, input().strip().split())) 

S = [False] * N

for i in range (K):
	for j in A[i]:
		S[j-1] = True

print (S.count(False))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
res = []
for _ in range(M):
    d = int(input())
    A = list(map(int, input().split()))
    for i in A:
        res.append(i)
ans = set(res)
print(N-len(ans))

Submission status: Accepted

Solution code:
from sys import stdin
import re
import bisect
import numpy as np

N, K = map(int, stdin.readline().rstrip().split())
frag = np.zeros((K,N), dtype=bool)
for i in range(K):
    _ = stdin.readline()
    line = map(int, stdin.readline().rstrip().split())
    for j in line:
        j -= 1
        frag[i][j] = True
        
count = int(0)
frag = frag.T
for i in range(N):
    if np.count_nonzero(frag[i] == 1) == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(0, k*2)]
a = query[1::2]
sunuke = [0] * n

for a in query[1::2]:
    for s in a:
        sunuke[s-1] += 1
print(sunuke.count(0))

Submission status: Accepted

Solution code:
N,K=input().split()
N=int(N)
K=int(K)
List = [[int(j) for j in input().split()] for i in range(2*K)]

A=[0]*N

for i in range(K):

  for j in range(0,List[i*2][0]):
    A[List[1+i*2][j]-1]+=1
print(A.count(0))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a = [[0]*N]*K
a = [[0 for n in range(N)] for k in range(K)]

for k in range(K):
    d=int(input())
    have_k=map(int,input().split())
    for h in have_k:
        a[k][h-1]=1

an=[0]*N
for k in range(K):
  for n in range(N):
    an[n] = an[n]+a[k][n]

result=0
for i in an:
  if i == 0:
    result+=1

print(result)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
listX=list()

while K>0:
    dk=int(input())
    listk=input().split()
    listX.extend(listk)
    K=K-1

listX=[int(s) for s in listX]
listN=list(range(N))
listN.append(N)
listN.remove(0)
listZ=list(set(listN)-set(listX))

L=str(len(listZ))
print(L)

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
A = []

for v in range(0,K):
    instanceA = []
    d = int(input())
    instanceA = list((map(int, input().split())))
    for i in instanceA:
        A.append(i)

A = set(A)

print(N-len(A))

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
using = { x:0 for x in range(1, n + 1)}
for _ in range(k):
    nbs = int(input())
    users = [int(x) for x in input().split()]
    for use in users:
        using[use] += 1
    victims = 0
#print(using)
for i, v in using.items():
    #print(v)
    if v == 0:
        victims += 1
print(victims)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
D=[]
A=[]
flg = 0
counta = 0
for i in range(k):
    D.append(int(input()))
    A.append(list(map(int, input().split())))
#print(A)
for i in range(n):
    flg = 1
    for j in A:
        if j.count(i+1) == 1:
            flg=0
    if flg==1:
        counta+=1
print(counta)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
sunuke_dict = dict()

for _ in range(K):
    d = input()
    s_list = input().split()

    for s_id in s_list:
        if s_id not in sunuke_dict:
            sunuke_dict[s_id] = [d]
        else:
            sunuke_dict[s_id].append(d)

print(N - len(sunuke_dict))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    ans = [0 for _ in range(n)]
    for i in range(k):
        d = ri()
        la = rli()
        for a in la:
            ans[a-1] += 1
    print(sum(1 for a in ans if a == 0))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split())
n,k=f()
s=set()
for _ in range(k): input(); s|=set(f())
print(n-len(s))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Aall = set(list(range(1, N+1)))
A = []
for i in range(N*2):
  try: 
    if i % 2 != 0:
      a = list(map(int, input().split()))
      A.extend(a)
    else:
      d = list(map(int, input().split()))
  except EOFError:
    d = 1
print(len(Aall-set(A)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())


d = [0]*K
a = [0]*K

for i in range(K):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))

n = list(range(1,N+1))

for i in range(K):
    for j in range(d[i]):
        for k in range(len(n)):
            if n[k] == a[i][j]:
                n[k] = 0

ans = 0
for i in range(len(n)):
    if n[i] != 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
l  = []

n, k = map(int, input().split())
for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for i in range(1, n+1):
        for j in A:
            if i == j:
                break
        else:
            l.append(i)

import collections
d = collections.Counter(l)
l2 = []
for u, v in d.items():
    if v == k:
        l2.append(u) 

print(len(l2))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
s=[0]*n
count=0
for i in range(k*2):
  if i%2==0:
    d=int(input())
  else:
    *a,=map(int,input().split())
    for j in range(d):
      tmp=a[j]
      s[tmp-1]+=1
for i in range(n):
  if s[i]==0:
    count+=1
print(count)

Submission status: Accepted

Solution code:

import sys
import itertools
 
 
N, K = map(int, input().split())

nums = [ ]
for _ in range(K):
    _ =  int(input())
    nums.extend([int(x.strip()) for x in input().split(' ') ])

print(N - len(set(nums)))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
List = []
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  List.extend(A)
List = list(set(List))
print(str(N - len(List)))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())

n = [0 for _ in range(N)]
for i in range(K):
  d = int(input())
  D = list(map(int,input().split()))
  for j in range(d):
    n[D[j]-1] += 1

ans = 0
for i in n:
  if i == 0:
    ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
 
p = [1]*a
 
while True:
  try:
    input()
  except EOFError:
    break
  c = input().split()
  for d in c:
    p[int(d)-1]=0
 
print(sum(p))

Submission status: Accepted

Solution code:
import itertools
a,b=map(int,input().split())
c=[]
for i in range(1,b*2+1):
    c.append(list(map(int,input().split())))
n=c[1::2]
n=list(itertools.chain.from_iterable(n))
print(a-len(set(n)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

d = [0] * k
a = [0] * k

for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))

funuke_list = []
for j in a:
    funuke_list += j

ans = n - len(set(funuke_list))

print(ans)

Submission status: Accepted

Solution code:
# cook your dish here
n,k = map(int,input().split())
d = []
visited = [0]*n
for j in range(k):
    d.append(int(input()))
    jk= [int(i) for i in input().split()]
    for jj in jk:
        visited[jj-1] = 1
print(n-sum(visited))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
mylist=[]
for _ in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for _ in range(d):
    mylist=list(set(mylist+(A)))
print(N-len(mylist))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, k = map(int, sys.stdin.readline().split())
	have = [0]*n
	for i in range(k):
		di = int(sys.stdin.readline())
		a = list(map(int, sys.stdin.readline().split()))
		for i in range(di):
			have[a[i]-1] += 1
	cnt = 0
	for i in range(n):
		if have[i] == 0:
			cnt += 1
	print(cnt)


main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
import itertools
A=[]
B=[]
i=0
m=0
for _ in range(2*K):
    a = [int(x) for x in input().split()]
    if i%2!=0:
        A.append(a)
    i=i+1
#A = list(map(list, set(map(tuple, A))))
B=(list(itertools.chain.from_iterable(A)))
print(N-len(set(B)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = 0

people_dic = []
have_dic = []
temp_min = []
min_people = []
min_num = 0


for all in range(1, n+1):
    people_dic.append(all)

for cnt in range(k):
    d = int(input())
    have_dic.append(list(map(int, input().split())))

for comparison in range(k):
    temp_min.append((list(set(people_dic) - set(have_dic[comparison]))))

min_people = temp_min[0]
for duplication in range(k):
    min_people = list(set(min_people) & set(temp_min[duplication]))

min_num = len(min_people)

print(min_num)

Submission status: Accepted

Solution code:
from collections import defaultdict
di = defaultdict(int)
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

for i in range(N):
    di[i + 1] = 0

for i in A:
    for j in i:
        di[j] += 1

count = 0
for i, k in di.items():
    if (k == 0):
        count += 1

print(count)

Submission status: Accepted

Solution code:
"""
ある街にN人のすぬけ君(すぬけ君1、すぬけ君2、 ...、 すぬけ君N)が住んでいます。

"""
n, k = map(int, input().split())
n_list = list(range(1, n+1))
input_map = {}
for i in range(k):
    d = int(input())
    d_list = [ int(ai) for ai in input().split()]
    for h in d_list:
        if n_list.count(h) == 1:
            n_list.remove(h)

print(len(n_list))

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
 
lis = []
 
for i in range(K):
  
  d = int(input())
  lis.extend(list(map(int,input().split())))
lis = set(lis)
 
print(N-len(lis))

Submission status: Accepted

Solution code:
import itertools
N, K = map(int, input().split())
snack = [list(map(int, input().split())) for i in range(2*K)]
answer = [int(i) for i in range(1, N+1)]

for i in snack[1::2]:
  for j in i:
    try:
      answer.remove(j)
    except:
      continue
print(len(answer))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())

Sunuke=[1]*N
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for ii in range(d):
        Sunuke[A[ii]-1]=0

print(sum(Sunuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
List = []
void = 0
cnt = 0
for i in range(int(K)):
    void = int(input())
    List.append(list(map(int, input().split())))

arr = [int(x) for y in List for x in y]

for k in range(1,N+1):
    if k in arr:
        pass
    else:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
n,k=map(int,input().split())
dlist = []
lists = []
x=np.zeros(n,int)
for i in range(k):
    dlist=input()
    lists.append(input().split())
for list in lists:
  l=len(list)
  for j in range(l):
    index=list[j]
    x[int(index)-1]=1
count = 0
for l in range(n):
  if x[l]==0:
    count+=1
print(count)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())

l=[0]*n

for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        l[j-1]+=1

print(l.count(0))

Submission status: Accepted

Solution code:


s = input().split();
n = int(s[0])
k = int(s[1])

A= [0 for i in range(n)]
ans = n
for i in range(k):
	d = input() 
	d = int(d)
	a =  list(map(int, input().split()))
	
	for j in range(d):
		if A[a[j]-1]== 0:
			A[a[j]-1]=1
			ans = ans -1
		else:
			continue

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
ans =[1]*N
d = [1]*K
A =[1]*K
count = 0
for i in range(K):
  d[i] = int(input())
  A[i] = input().split()
for i in range(K):
  for j in range(d[i]):
      ans[int(A[i][j])-1] = 0
for i in range(N):
  if ans[i] == 1:
    count += 1
print (count)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
o = 0
g = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        g.append(a[j])
g.sort()
for i in range(len(g)-1):
    if g[i] == g[i+1]:
        o += 1
print(n-len(g)+o)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

d = [0]*k
a = [0]*k

for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))

k = 0

b = sum(a, [])
    
for i in range(n):
    if i+1 not in b:
        k = k + 1

print(k)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
l=list(range(1,N+1))
for i in range(K):
  d=int(input())
  s = input().split()
  for j in range(d):
    l[int(s[j])-1]=0
num=0
for i in range(N):
  if l[i]!=0:
    num=num+1
print(num)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
d = []
n = []
for k in range(K):
    d.append(input())
    n.append(input().split())
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]
nfu = set(flatten(n))
print(N - len(nfu))

Submission status: Accepted

Solution code:
import collections
N,K = map(int,input().split())
s = []
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in range(d):
        s.append(A[j])
c = collections.Counter(s)
print(N-len(c))

Submission status: Accepted

Solution code:
import numpy as np

n, k = map(int, input().split())
List = [list(map(int, input().split())) for i in range(2*k)]

ans=np.zeros(n)
n=np.array(List[1])

for i in range(1,2*k,2):
  for j in List[i]:
    ans[j-1]=ans[j-1]+1

print(np.count_nonzero(ans==0))

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
A = []
for i in range(K):
    d = int(input())
    temp = list(map(int, input().split()))
    A = A + temp
hito = np.ones(N)
for i in range(len(A)):
    hito[A[i]-1] = 0
print(int(np.sum(hito)))

Submission status: Accepted

Solution code:
n,k = [int(s) for s in input().split()]
freq = [0]*(n+1)
for i in range(k):
    d = int(input())
    arr = [int(s) for s in input().split()]
    for j in arr:
        freq[j]+=1
c = 0
for i in range(1,n+1):
    if  freq[i] == 0:
        c+=1
print(c)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d = [0]*k
A = [[0]*n]*k
l = set()
for i in range(k):
	d[i] = int(input())
	A[i] = list(map(int,input().split()))
for i in range(k):
	l = l.union(A[i])
if set(range(1,n+1)) == l:
	print(0)
else:
	print(len(set(range(1,n+1))-l))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
P =[]
for i in range(K):
    d = int(input())
    e = input().split()
    P.append(e)

Q = []
for j in range(len(P)):
    for k in range(N):
        if str(k+1) in P[j]:
            if str(k+1) not in Q:
                Q.append(str(k+1)) 

print(N-len(Q))

Submission status: Accepted

Solution code:
# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement
# import queue
# import heapq


def main():
    N, K = map(int, input().split())

    sunuke = [True for _ in range(N)]

    for i in range(K):
        d = input()
        ds = list(map(int, input().split()))

        for s in ds:
            sunuke[s-1] = False

    print(sum(sunuke))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

check = [1]*N

for p in range(0,M):
	d = int(input())
	k = list(map(int,input().split()))
	for i in range (0, len(k)):
		check[k[i]-1]=0

print(sum(check))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
D = [None] * K
A = []
for i in range(K):
    D[i] = int(input())
    A.append(list(map(int, input().split())))

s = set()
for i in range(K):
    for d in range(D[i]):
        s.add(A[i][d])
ans = N - len(s)
print(ans)

Submission status: Accepted

Solution code:
num= map(int, input().split())
A=list(num)
B=[]
for i in range(A[1]):
    snake=int(input())
    S= map(int, input().split())
    for n in S:
        B.append(n)
D=0
for x in range(1,A[0]+1):
    if x not in B:
        D =D+1
print(D)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
D=[]
A=[]
for i in range(1,k+1):
    d = set(map(int, input().split())) 
    a = set(map(int, input().split())) 
    D.extend(d)
    A.extend(a)
l = set(A)
print(n-len(l))

Submission status: Accepted

Solution code:
import itertools
N,K = map(int, input().split())
c = []
for i in range(K):
	a = int(input())
	b=list(map(int,input().split()))
	c.append(b)
f = list(itertools.chain.from_iterable(c))
d = []
for i in range(1,N+1):
	e =  i in f
	if e  == False:
		d.append(i)
length = len(d)
print(length)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
lis = []
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    lis = lis + A

print(N - len(set(lis)))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
d = []
A= []
c = []
 
for i in range(k):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
 
for j in range(k):
    for m in range(d[j]):
        c.append(A[j][m])
 
print(n-len(set(c)))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
list_b = []

for i in range(K):
    d = 0
    d = int(input())
    list_a = input().split()
    for i in range(len(list_a)):
        list_b.append(int(list_a[i]))
    list_a = []

a = set(list_b)
ans = N - len(a)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = [[] for i in range(N)]

for i in range(K):
    d = int(input())
    data = [int(i) for i in input().split()]
    for j in data:
        J = j -1
        lst[J].append(d)

print(lst.count([]))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
result = set([i for i in range(1, N+1)])
s = set([])
for i in range(M):
  d = int(input())
  s |= set(map(int, input().split()))
print(len(result-s))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = []
a = []
ans = [1]*n
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))
    for su in a[i]:
        if ans[su-1] == 1:
            ans[su-1] = 0
answer = sum(ans)
print(answer)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = []
A = []
ari = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

for a in A:
  for k in range(1, N+1):
    if k in a:
      ari.append(k)


print(N-len(set(ari)))

Submission status: Accepted

Solution code:
def inputlist():
    return [int(i) for i in input().split()]


def main():
    N, K = inputlist()
    aryNum = [0] * N

    aryInput = []
    for i in range(K):
        intNumType = int(input())
        aryInput = inputlist()
        for j in range(len(aryInput)):
            aryNum[aryInput[j] - 1] += 1

    sum = 0
    for i in range(N):
        if aryNum[i] == 0:
            sum += 1

    print(sum)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lists = []
res = []

for i in range(1, N + 1):
    lists.append(int(i))

for _ in range(K):
    d = int(input())
    A = input().split()
    for p in range(len(A)):
        res.append(int(A[p]))

res_l = set(lists)
res_s = set(res)
result = res_l - res_s

li = list(result)
cnt = len(li)
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np

hairetsu = input().split(' ')
sunuke = int(hairetsu[0])
okashi = int(hairetsu[1])
books = [[0]*sunuke]*okashi

for i in range(0, okashi):
  kaisu = int(input())
  whohas = list(map(int, input().split(' ')))
  for j in range(0, kaisu):
    k = int(whohas[j])-1
    books[i][k] = 1


result = np.sum(books,axis=0)
a = np.count_nonzero(result)
print(sunuke - a)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = []

for i in range(N):
    sunuke.append(0)

for j in range(K):
    
    d = int(input())
    numberL = input().split()
    numberI = []
    
    for l in range(len(numberL)):
        numberI.append(int(numberL[l]))
    
    for m in range(len(numberI)):
        sunuke[numberI[m]-1] = sunuke[numberI[m]-1] + 1   
       

count = 0        
for i in range(len(sunuke)):
    if sunuke[i] == 0:
        count = count + 1
        
print(count)

Submission status: Accepted

Solution code:
import numpy as np

n, k = map( int, input().split() )
#print( n, k )

snk = range( n )
snk = list( snk )
snk = [ snki + 1 for snki in snk ]
#print( snk )

for i in range( k ):
    di = int( input() )
    ai = input().split()
    ai = [ int( aix ) for aix in ai ]
#    print( ai )

    for aij in ai:
        if any( si == aij for si in snk ):
            snk.remove( aij )
            
#    print( snk )




print( len( snk ) )

Submission status: Accepted

Solution code:
n,k=(int(x) for x in input().split())
ii=[]
for i in range(k):
    d=int(input())
    ad=[int(x) for x in input().split()]
    for j in ad:
        if j not in ii:
            ii.append(j)

print(n-len(ii))

Submission status: Accepted

Solution code:
import itertools

n,k = map(int,input().split())
ans =0
a = []
for i in range(k):
    d=int(input())
    a.append(list(map(int,input().split())))

a = [ flatten for inner in a for flatten in inner ]

for j in range(n):
   if a.count(j+1)==0:
       ans +=1

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
kashi = [0] * N
cnt = 0

for i in range(K):
    d = int(input())
    A = [0] * d
    A = list(map(int,input().split()))
    for j in range(d):
        kashi[A[j]-1] += 1

for k in range(N):
    if kashi[k] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set(range(1, n + 1))
for d in range(k):
    snack = int(input())
    aa = map(int, input().split())
    for a in aa:
        if a in s:
            s.remove(a)

print(len(s))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ns = []
ans =0
for i in range(k):
    p = int(input())
    s = str(input())
    for i in list(s.split()):
        ns.append(int(i))
for i in range(1,n+1):
    if( i not in ns):
        ans+= 1
print(ans)

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
dA = [list(map(int,input().split()))for k in range(2*K)]

L = list(sum(dA[1::2],[]))
print(N-len(set(L)))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
who_have=[]
while(K!=0):
    k=int(input())
    someone_have=list(map(int,input().split()))
    if(len(someone_have)!=0):
        for i in someone_have:
            if(i in range(1,N+1)):
                who_have.append(i)
    K-=1
print(N-len(set(who_have)))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())

klist =[0]*k

for i in range(0,k):
    a = int(input())
    if a ==1:
        temp = int(input())
        klist[i] = [temp]
    else:
      	tlist= list(map(int, input().split())) 
      	klist[i]=tlist


unil = set(sum(klist,[]))
treat =  len(set(unil))
res = n - treat
print(res)

Submission status: Accepted

Solution code:
N,K=list(map(int,input().split()))
h=[]
for k in range(K):
    d_i=int(input())
    a=list(map(int,input().split()))
    for i in range(d_i):
        h.append(a[i])
h2=set(h)
ans=N-len(h2)
print(ans)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
d = []
li = []
for i in range(l[1]):
    d += [int(input())]
    li += list(map(int, input().split()))
len_ = len(set(li))
result = l[0] - len_
print(result)

Submission status: Accepted

Solution code:
import numpy as np
N,K=map(int, input().split())
D = np.zeros((K, N))
for i in range(K):
    d=int(input())
    A=np.array(list(map(int, input().split())))
    for j in range(len(A)):
        D[i][A[j]-1] = 1
ans = D.sum(axis=0)
print(sum(ans == 0))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [list(map(int,input().split()))for i in range(2*k)]

t = a[1::2]

ans = [0]*n
count = 0

for i in t:
    for j in i:
        ans[j-1] += 1

print(ans.count(0))

Submission status: Accepted

Solution code:
N,K = input().split()
N = int(N)
K = int(K)

have = []
result = 0

for i in range(N):
    have.append([1]*K)


for i in range(K):
    d = int(input())
    
    A = input().split()
    A = map(int,A)

    for a in A:
        have[a-1][i-1] = 0

        
for j in have:
    if j == [1]*K:
        result += 1

print(result)

Submission status: Accepted

Solution code:
n,k  = map(int, input().split())
d=[]
a=[]
for i in range(0,k):
    do=int(input())
    d.append(do)
    a.extend(list(map(int, input().split())))
    a=list(set(a))
#print(n,k,d,a)
#print(a)

a_list=[]
for i in range(1,n+1):
    a_list.append(i)
#print(a_list)
a=a+a_list
a = [x for x in set(a) if a.count(x) == 1]
print(len(a))

Submission status: Accepted

Solution code:
snukes, kinds = map(int, input().split())
d = []
snacks = []
for x in range(kinds):
    d.append(int(input()))
    snacks  += ([int(x) for x in input().split()])

print(snukes - len(set(snacks)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())


t = []
for i in range(n+1):
    t += [i]
t = set(t)
s = set()
for j in range(k):
    di = int(input())
    s.update(map(int,input().split()))
t = t-s-{0}
print(len(t))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
d = []
A = []
B = set()
for i in range(K):
    _d = int(input())
    _A = list(map(int, input().split()))
    d.append(_d)
    A.append(_A)
    _B = set(_A)
    B = B | _B
print(N - len(B))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(2*k)]
ans = [0]*n
for i in range(k):
    for j in range(a[i*2][0]):
        s = a[i*2+1][j]
        ans[s-1] = 1
S = n - sum(ans)
print(S)

Submission status: Accepted

Solution code:
from itertools import chain

n,k=map(int,input().split())
A=[]

for _ in range(k):
    d=int(input())
    num=list(map(int,input().split()))
    A.append(num)

A=sum(A,[])

print(n-len(set(A)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
D = [0] * k
A = [0] * k
for i in range(k):
    D[i] = int(input())
    Atemp = [0] * D[i]
    Atemp = list(map(int, input().split()))
    A[i] = Atemp
    # print()
    # print(D)
    # print(A)
AA = []
for elem in range(k):
    AA += A[elem]
# print(AA)

AA = set(AA)
# print(AA)

# AA = []
# for i in range(k):
#     for j in range(k):
#         if j + 1 not in A[i]:
#             AA.append(j + 1)
#             print(AA)

print(n - len(AA))

Submission status: Accepted

Solution code:

N, K = map(int, input().split())

A = list(range(1, N+1))
d = []
B = []
c = []
for i in range(K):
    tmp = int(input())
    d.append(tmp)
    a = list(map(int, input().split()))
    
    B.append(a)
    c = list(set(A) & set(a))
    for j in range(len(c)):
        A.remove(c[j])

print(len(A))

Submission status: Accepted

Solution code:
def main():
  s = list(map(int,input().split()))
  n = [0]*s[0]
  for k in range(0,s[1],1):
    d = int(input())
    a = list(map(int,input().split()))
    #print(a)
    for i in range(0,d,1):
      #print(a[i])
      n[a[i]-1] = 1
      #print(n)
      
  sum=0
  #print(n)
  
  for k in range(0,s[0],1):  
    if(n[k]==0): sum = sum+1
 
  print(sum)
  
main()

Submission status: Accepted

Solution code:

import itertools

N , K = map(int, input().split())
A = [] * 100
d = [] * 100
count=0
for i in range(K):    
    d.append(int(input()))
    A.append(list(map(int , input().split())))
A = list(itertools.chain.from_iterable(A))

for k in range(1,N+1):
    if A.count(k) == 0:
        count+=1
print(count)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
list_a=[]
list_b=[]
for _ in range(k):
    if int(input())==1:
        list_b.append(int(input()))
    else:
        list_b+=list(map(int,input().split()))
print(n-len(set(list_b)))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().strip().split())
    d = []
    a = []

    for i in range(k):
        tmp_d = int(input())
        tmp_a = list(map(int, input().strip().split()))
        d.append(tmp_d)
        a.append(tmp_a)

    flg = [False] * n

    for i in range(k):
        for j in range(d[i]):
            flg[a[i][j]-1] = True

    print(flg.count(False))

main()