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=list(map(int,input().split()))
s = []
for i in range(N):
  s.append(1)
a=[]
for k in range(K):
  o = int(input())
  if 1<o:
    p = list(map(int,input().split()))
    for g in p:
      a.append(g)
  else:
    p = int(input())
    a.append(p)
for i in a:
  s[i-1] = 0
ans = 0
for w in s:
  if w==1:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
nk = list(map(int,input().split()))

A = [0]*nk[0]

for i in range(nk[1]):
  d = int(input())
  #print(d)
  add_A = list(map(int,input().split()))
  #print(add_A)
  
  for j in range(d):
    A[ add_A[j]-1 ] += 1

#print(A)

ans = 0
for i in range(nk[0]):
  if( A[i]==0 ):
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
nk = input().split()
n = int(nk[0])
k = int(nk[1])
t = [0]*n

for i in range(k):
    d = int(input())
    a = input().split()
    a = [int(x) for x in a]
    for j in range(d):
        t[a[j]-1] +=1
    
res= 0
for i in range(n):
    if t[i] == 0:
        res += 1
    
print(res)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
i=0
d=list()
A=list()
while i<K:
    d.append(int(input()))
    A+=list(map(int,input().split()))
    i+=1
B=set(A)
print(N-len(B))

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()))
ans = [0] * n
for i in range(k):
    for j in range(n):
        ans[j] += a[i].count(j+1)
print(ans.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
x = set()
for i in range(k):
    d = int(input())
    for j in input().split():
        x.add(j)

print(n - len(x))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(range(n))
for i in range(k):
    d= int(input())
    a = list(map(int, input().split()))
    for j in a:
        if j-1 in l:
            l.remove(j-1)
print(len(l))

Submission status: Accepted

Solution code:
list1=list(map(int,input().strip().split()))[:2]
n,k=list1[0],list1[1]
dict1={}
for i in range(k):
	d=int(input())
	have=list(map(int,input().strip().split()))
	for i in have:
		if i in dict1:
			dict1[i]+=1
		else:
			dict1[i]=1
print(n-len(dict1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
set_mentioned = set()
for k in range(K):
  _ = input()
  new_row = list(map(int, input().split()))
  [set_mentioned.add(value) for value in new_row]
print(N-len(set_mentioned))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[1]*n
for _ in range(0,k):
    d=int(input())
    b=list(map(int,input().split()))
    for x in b:
        a[x-1]=0
print(sum(a))

Submission status: Accepted

Solution code:
import collections
n,k = list(map(int,input().split()))
d_list = []
a_list = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    d_list.append(d)
    a_list.extend(a)
cnt = 0
cnt_dict = collections.Counter(a_list)
for i in range(1,n+1):
    if cnt_dict[i] == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

a = [0] * k

all_n = [0] * n


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


for i in range(len(a)):
  for j in range(len(a[i])):
    all_n[a[i][j] - 1] += 1

print(all_n.count(0))

Submission status: Accepted

Solution code:
import itertools


N, K = map(int, input().split())
d = []
A = []
ls = [i for i in range(1,N+1)]

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

A = list(itertools.chain.from_iterable(A))

#print(A, ls)
print(len(set(A)^set(ls)))

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)

def solve(n, k, d, A):
    s = set()
    for aa in A:
        for a in aa:
            s.add(a)
    ret = 0
    for i in range(1, n + 1):
        if not i in s:
            ret += 1
    print(ret)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush


# T = int(stdin.readline())
# for i in range(T):
    #N=int(stdin.readline())
N,K=list(map(int,stdin.readline().split()))
vis=set()
for k in range(K):
    dk=int(stdin.readline())
    ar=list(map(int,stdin.readline().split()))    
    for sn in ar:
        vis.add(sn)

print(N-len(vis))

Submission status: Accepted

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

trick=[True]*n

for i in range(k):
    input()
    a_lis=list(map(int,input().split()))
    for a in a_lis:
        trick[a-1]=False


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

print(ans)

Submission status: Accepted

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

for _ in range(K):
    d=input()
    A=A|set(map(int,input().split()))
    
print(N-len(A))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = []
a = set()
for _ in range(k):
    d.append(int(input()))
    for p in list(map(int, input().split())):
        a.add(p)

a_all = set(i+1 for i in range(n))

print(len(set(a_all)-set(a)))

Submission status: Accepted

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

ans = 0
for j in range(N):
    if j+1 in check:
        continue
    else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
sunuke = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    sunuke.append(a)
count_lst=[]
for j in sunuke:
    for a in range(1,n+1):
        if a in j:
            count_lst.append(a)
count=0
for z in range(1, n+1):
    if z not in count_lst:
        count+=1

print(count)

Submission status: Accepted

Solution code:
n,k = list(map(int,input().split()))
d_ = []
a_ = []
for i in range(k):
    d_.append(int(input()))
    a_.append(list(map(int,input().split())))

sum = []
for i in range(n):
    sum.append(i+1)

res = []
for l in range(k):
    for k in range(d_[l]):
        if( a_[l][k] in res):
            continue
        else:
            res.append(a_[l][k])

resList = set(sum) ^ set(res)
print(len(resList))

Submission status: Accepted

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

A = []
d = []
for _ in range(K):
  _ = int(input())
  tmp = list(map(int, input().split()))
  for i in tmp:
    A.append(int(i))
A = list(set(A))
print(N-len(A))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()

	ans = [False for i in range(N)]
	for i in range(K):
		d = inputInt()
		A = inputList()
		for jj in A:
			j = jj-1
			if ans[j] == False:
				ans[j] = True

	tmp = 0
	for i in ans:
		if i == False:
			tmp += 1

	print(tmp)







#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Accepted

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

have_list=[0]*N
for i in range(K):
  input()
  haves=input().split(' ')
  for n in haves:
    have_list[int(n)-1]+=1
print(have_list.count(0))

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split(" ")))
A = [0 for u in range(N)]
okasi = []
for i in range(K):
  d = int(input())
  okasi.append(list(map(int,input().split(" "))))
for a in okasi:
  for m in a:
    A[m-1] += 1
print(A.count(0))

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
d_list = []
A_list = []
for k1 in range(K):
    d_list+=[int(input())]
    A_list+=[[a_i for a_i in map(int,input().split())]]

S=[0 for i in range(N)]
for k2 in range(K):
    for i in A_list[k2]:
        S[i-1]+=1

counter = 0
for i in range(N):
    if S[i]==0:
        counter+=1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = [0] * n

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

# print(ans)
print(ans.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d={}
for _ in range(k):
  a=int(input())
  l=list(map(int,input().split()))
  for i in range(len(l)):
    if l[i] not in d:
      d[l[i]]=1
      n=n-1

print(n)

Submission status: Accepted

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

akun = [0]*N
count = N

for i in range(K):
    di = int(input())
    tmp = list(map(int,input().split()))
    for j in tmp:
        if akun[j-1] == 0:
            akun[j-1] +=1
            count -=1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
s = set(range(1, N+1))

for idx in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for person in a:
        s.discard(person)

print(len(s))

Submission status: Accepted

Solution code:
import itertools

n,k=map(int,input().split())
s=[input().split() for i in range(2*k)]
t=[]
for i in range(len(s)//2):
  t.append(s[2*i+1])
res = [ flatten for inner in t for flatten in inner ]

res = [int(i) for i in res]
res=list(set(res))

print(n-len(res))

Submission status: Accepted

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

A = [0]*N

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = []
for i in range(k):
    x = int(input())
    x = list(map(int, input().split()))
    for j in x:
        ans.append(j)
ans = set(ans)
cnt = 0
for i in range(1, n+1):
    if not i in ans:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

res = []
for i in range(k):
    kashi = int(input())
    res += [int(i) for i in input().split()]

print(n - len(set(res)))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
sunuke_set = set([i for i in range(1, N + 1)])

for i in range(K):
    d = int(input())
    d_set = set(list(map(int, input().split())))
    sunuke_set = sunuke_set - d_set

ans = len(sunuke_set)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

sunukes = [0] * N
for A in As:
    for a in A:
        sunukes[a-1] += 1

#print("sunuke")
ans = 0
for sunuke in sunukes:
    if(sunuke == 0):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=[]
for _ in range(k):
    d=int(input())
    as_=list(map(int,input().split()))
    for a in as_:
        h.append(a)
ans=0
for m in range(1, n+1):
    if not m in h:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import collections
def main():
  N,K = map(int, input().split())
  lists=[0]*N
  num_list = [list(map(int, input().split())) for _ in range(2*K)]
  num_list2=[list(num_list[i]) for i in range(1,2*K,2)]
  for i in range(K):
    tgtlist=num_list2[i]
    for j in range(len(tgtlist)):
      lists[tgtlist[j]-1]=lists[tgtlist[j]-1]+1
  print(len([i for i, x in enumerate(lists) if x == 0]))
  
    
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
import numpy as np

n, k = map(int, input().split())
sunukes = list(np.zeros(n))
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(n):
        if j+1 in a:
            sunukes[j] = 1
            
print(sunukes.count(0))

Submission status: Accepted

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

sunuke = {i + 1 for i in range(n)}
hav = set()

for _ in range(k):
    d = int(input())
    a_l = list(map(int, input().split()))
    for a in a_l:
        hav.add(a)

print(len(sunuke - hav))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
count = 0
A = list()
for _ in range(K):
  d = int(input())
  a = list(map(int,input().split()))
  A.append(a)
sum_A = sum(A,[])
for i in range(1,N+1):
  if (i in sum_A) == False:
    count = count + 1
print(count)

Submission status: Accepted

Solution code:
#coding:utf-8

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

sunuke = ["{}".format(i) for i in range(1,n+1)]

for i in range(k):
    d = int(input())
    a = input().split()
    for i in a:
        if i in sunuke:
            sunuke.remove(i)

ans = len(sunuke)

print("{}".format(ans))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
s=[]
for d in range(1,k+1):
    d=int(input())
    List=list(map(int,input().split()))
    for a in List:
        s.append(a)

t=set(s)

print(n-len(t))

Submission status: Accepted

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

hito = [i for i in range(1, N+1)]


for i in range(N):
    name = hito[i]
    for j in range(K):
        if name in A[j]:
            hito[i] = -1
            break

ans = set(hito)
print(len(ans)-1)

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
b=[]
for i in range(k):
  b += a[2*i-1]
print(n-len(set(b)))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

kodomo = [i for i in range(1,n+1)]

DS = []
okashi = []

for i in range(k):
    DS.append(int(input()))
    okashi.append(list(map(int,input().split())))

for i in range(k):
    for j in range(DS[i]):
        try:
            kodomo.remove(okashi[i][j])
        except ValueError:
            continue

print(len(kodomo))

Submission status: Accepted

Solution code:
N, K = [int(n) for n in input().split()]

d = []
A = []

S = dict([(i + 1, True) for i in range(N)])

for i in range(K):
    d.append(int(input()))
    # A.append([int(n) for n in input().split()])
    for a in input().split():
        if int(a) in S:
            del S[int(a)]

print(len(S))

Submission status: Accepted

Solution code:
[n,k] = [int(x) for x in input().split()]

temp = []
for _ in range(k):
    n_okashi_people_num = int(input())
    temp = temp + [int(x) for x in input().split()]

ans = n - len(list(set(temp)))

print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
lis=[i for i in range(1,N+1)]
for i in range(K):
  d=int(input())
  tmp=[int(_) for _ in input().split()]
  for j in range(d):
    if tmp[j] in lis:
      lis.remove(tmp[j])
print(len(lis))

Submission status: Accepted

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

counter = 0
for s in l:
    if s == 0:
        counter+=1

print(counter)

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
S = []
for i in range(k):
    d1 = int(input())
    
    S.append(list(map(int, input().split())))

ans = [0]*n

for i,s in enumerate(S):
    for d in s:
        ans[int(d)-1]+=1


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

n_count = np.zeros(n, dtype = np.int)
# print(n_count)

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

# print(n_count)
print(np.count_nonzero(n_count == 0))

Submission status: Accepted

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

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

print(int(n-len(set(a))))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d = [0] * k
a = [0] * k
arr = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]
    arr = arr + a[i]

ans = 0
for i in range(n):
    if i+1 in arr:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
okashi = [0 for i in range(n+1)]

for i in range(k):
    d = int(input())
    if(d==1):
        oka = int(input())
        okashi[oka] += 1
    else:
        oka = list(map(int,input().split()))
        
        for j in oka:
            okashi[j] += 1
c = 0
for i in okashi:
    if(i==0):
        c+=1
print(c-1)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
n = a[0]
k = a[1]


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

for i in range(k):
  num = int(input())
  c = list(map(int,input().split()))
  for j in c:
    if j in member:
      member.remove(j)
print(len(member))

Submission status: Accepted

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

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

for c in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for co in range(d):
        try:
            sunuke.remove(A[co])
        except ValueError:
            pass

print(len(sunuke))

Submission status: Accepted

Solution code:
import itertools
N,K = input().split()
N,K = int(N),int(K)
Alist = []

for i in range(0,K*2):
    Alist.append(input().split())

intAlist = [[int(item) for item in row] for row in Alist]

#菓子iを持ったすぬけくんはdi人いる、菓子はK種類、
#1の菓子を持ったすぬけが2人いる
count = 0
oklist = []
nowD = 0
for j in range(0,K*2):

    if j % 2 == 0:
        # nowD = intAlist[j]
        pass
    else:
        oklist.append(intAlist[j])
oklist = list(set(list(itertools.chain.from_iterable(oklist))))
print(N - len(oklist))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = list(list(map(int, input().split())) for _ in range(2*k))

a = []
for i in range(1, k+1):
    a += s[2*i-1]
    
lis = [None]*n
for i in range(n):
    lis[i] = i+1

cnt = 0
for i in lis:
    if i not in a:
        cnt += 1
        
print(cnt)

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 range(d):
        l[a[j] - 1] = 1
ans = 0
for i in range(n):
    if l[i] == 0:
        ans += 1
print (ans)

Submission status: Accepted

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

l = [0] * (n + 1) 

for i in range(k):
  d = int(input())
  a = input().split()
  #print(l[int(a[0])])
  for j in a:
    l[ int(j) ] = 1
    

print(n - sum(l))

Submission status: Accepted

Solution code:
import numpy as np
N,K=list(map(int, input().split()))
AA=np.zeros(N)
for i in range(K):
  d,=list(map(int, input().split()))
  A=[]
  A=np.array(list(map(int, input().split())))-1  
  AA[A]+=1  
print(N-np.count_nonzero(AA))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
d = []
a = []
ans = 0

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

for m in range(n):
    for array in a:
        if m+1 in array:
            ans -= 1
            break
    ans += 1

print(ans)

Submission status: Accepted

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

p = [x for x in range(1, n+1)]

for i in range(k*2):
    nums = list(map(int, input().split()))
    if i%2==0:
        pass
    else:
        for num in nums:
            if p.count(num) > 0:
                p.remove(num)

print(len(p))

Submission status: Accepted

Solution code:
from collections import defaultdict

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

b = defaultdict(int)
for i in range(K):
    d = int(input())
    M = input().split()
    for z in M:
        b[str(z)] = i
print(N - len(b))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunukes = list(range(1, n+1))
for _ in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  
  for i in a:
    if i in sunukes:
      sunukes.remove(i)
    
print(len(sunukes))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
(N,K)=input().split()
(N,K)=(int(N),int(K))
d=[0 for i in range(K)]
A=[0 for i in range(K)]
M=[]
for i in range(1,N+1):
  M.append(i)
for i in range(K):
  d[i]=int(input())
  A[i]=input().split()
  for j in range(len(A[i])):
    A[i][j]=int(A[i][j])
    if A[i][j] in M:
      M.remove(A[i][j])
print(len(M))

Submission status: Accepted

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

Submission status: Accepted

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

z = []
for j in a:
    for i in range(len(j)):
        z.append(j[i])

z = len(set(z))


print(n-z)

Submission status: Accepted

Solution code:
import numpy as np
import sys
from typing import Callable, NoReturn


def main() -> NoReturn:
    scan: Callable[[], str] = sys.stdin.readline

    n, k = map(int, scan().rstrip().split())  #type: int, int

    counter: np.ndarray = np.zeros((n, k))

    for i in range(k):
        input()
        for a in map(int, scan().rstrip().split()):
            counter[a - 1][i] += 1

    print(np.sum(counter @ np.ones((k,1)) == 0))


if __name__ == '__main__':
    main()

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())
  A = list(map(int,input().split()))
  for a in A:
    try:
      L.remove(a)
    except ValueError:
      pass
print(len(L))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[]
d={}
for i in range(k):
    x=int(input())
    a=input().split()
    for j in range(x):
        try:
            d[a[j]]+=1
        except:
            d[a[j]]=1
            l.append(a[j])
print(n-len(l))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = []
A = [A for A in range(1, n+1)]
ans = []
for i in range(k):
  d.append(int(input()))
  al = list(map(int, input().split()))
  for j in range(len(al)):
    if not(al[j] in ans):
      ans.append(al[j])
print(len(list(set(A)-set(ans))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = map(int, input().split())
check = defaultdict(lambda : False)
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        check[a] = True
ans = 0
for i in range(1, N+1):
    if not check[i]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
check = [int(i) for i in range(1,n + 1)]

num = []
for i in range(k):
  x = input()
  test = list(map(int, input().split()))
  for j in test:
    num.append(j)

num = set(check) ^ set(num)

print(len(num))

Submission status: Accepted

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

Submission status: Accepted

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

okashi = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    for j in list(map(int,input().split())):
        okashi[j-1] = 1

cnt = 0
for i in okashi:
    if i == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def main():
	n,k = map(int,input().split())
	da = []
	for i in range(k*2):
		da.append(list(map(int,input().split())))
	okashi = []
	for i in range(1,k*2,2):
		if len(da[i]) > 1:
			for s in range(len(da[i])):
				okashi.append(da[i][s])
		else:
			okashi.append(da[i][0])
	print(n - len(set(okashi)))




if __name__ == '__main__':
	main()

Submission status: Accepted

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


List=[]
for i in range(N):
    for j in range(K):
        check = 0
        for k in range(len(A[1+2*j])):
            if A[1+2*j][k] == i+1:
                check = check + 1
        if check ==0:
            List.append(i+1)


ans = 0
for i in range(1,N+1):
    p = 0
    for j in range(len(List)):
        if List[j] == i:
            p = p+1
    if p == K:
        ans = ans +1
        
        
    
            
print(ans)

Submission status: Accepted

Solution code:
def solve(n, k, d_arr, arr):
    ans = []
    for _ in range(n):
        ans.append(0)

    for i in range(k):
        ele = arr[i]
        for j in arr[i]:
            ans[j-1] += 1
    return ans.count(0)

if __name__ == "__main__":
    n, k = map(int, input().split(' '))
    d_arr = []
    arr = []
    for _ in range(k):
        d_arr.append(int(input()))
        arr.append([int(s) for s in list(input().split())])
    print(solve(n, k, d_arr, arr))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = set()
for i in range(k):
    d = int(input())
    tmp = set(list(map(int, input().split())))
    a = a.union(tmp)
print(n - len(a))

Submission status: Accepted

Solution code:
#-*- using:utf-8 -*-

N, K = map(int, input().split())
S = [False] * N
cnt=0
while cnt < K:
    d = int(input())
    A = list(map(int, input().split()))
    i=0
    while i < d:
        S[A[i] - 1] = True
        i += 1
    cnt += 1
n = sum(x==False for x in S)

print(n)

Submission status: Accepted

Solution code:

if __name__ == "__main__":
    N, K = map(int, input().split())
    A = []
    for i in range(K):
        X = int(input())
        A += list(map(int, input().split()))
    cnt = N - len(set(A))
    print(cnt)