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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, k = map(int, input().split())
    m = set(range(1, n + 1))
    for _ in range(k):
        d = int(input().strip())
        a_l = set(map(int, input().split()))
        m -= a_l
    print(len(m))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

count = 0
for i in temp:
    if i == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math

tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

#s = int(input())
#tmp = input().split()
#n,m,k = list(map(lambda a: int(a), tmp))

ans=[]
for i in range(n):
	ans.append(0)

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

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

Submission status: Accepted

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

f=[False]*n

for i in range(k):
  for x in a[i]:
    f[x-1]=True

print(n-sum(f))

Submission status: Accepted

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

dt = defaultdict(int)
for i in range(N):
    dt[i+1] = 0

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

    for j in A:
        dt[j] += 1

cnt = 0
for k, v in dt.items():
    if v == 0:
        cnt += 1

print(cnt)

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()))
d={}
for i in range(1,N+1):
    d[i]=0

for i in range(K):
    for a in A[i]:
        d[a]+=1

ans=0
for i in range(1,N+1):
    if d[i] == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

sunuke_list = [0] * (N + 1)
d_list = []
A_list = []

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

    for a in A:
        sunuke_list[a] += 1

print(sunuke_list.count(0) - 1)

Submission status: Accepted

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

d=[]
a=[]

for i in range(k):
    d1=int(input())
    d.append(d1)
    a1=map(int,input().split())
    a+=a1

b=set(a)
count=0
for i in range(1,n+1):
    if i in b:
        continue
    else:
        count+=1

print(count)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        if j in ans:
            del ans[(ans.index(j))]
print(len(ans))

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Having = [False] * n

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

        for j in having:
            Having[j - 1] = True

    print(Having.count(False))


resolve()

Submission status: Accepted

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

Submission status: Accepted

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

dk = [None] * k
ak = [None] * k
for i in range(k):
    dk[i] = int(input())
    ak[i] = list(map(int, input().split(' ')))

c = [False] * n

for i in range(k):
    for a in ak[i]:
        c[a - 1] = True

ans = c.count(False)

print(ans)

Submission status: Accepted

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

ans = []
for i in A[1::2]:
    ans += i

print(N - len(set(ans)))

Submission status: Accepted

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

res = 0

for i in range(1,K+1,1):
  d = int(input())
  A = [i for i in map(int,input().split())]
  for a in A:
    treats[i][a] = True
    
for j in range(1,N+1,1):
  flag = 1
  for i in range(1,K+1,1):
    if treats[i][j] == True:
      flag = 0
      
  if flag: res += 1
    
print(res)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
dak = []
for _ in range(k):
    temp = [int(input())]
    temp.append(list(map(int, input().split())))
    dak.append(temp)
snack = [0]*n
for da in dak:
    for i in da[1]:
        snack[i-1] = 1
print(snack.count(0))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
snuke = [False]*n
for i in range(k):
    d = int(input())
    a = [int(j) for j in input().split()]
    for j in a:
        snuke[j-1] = True
ans = 0
for i in snuke:
    if i == False:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

# s=str(input())

# if s =="ABC":
# 	print("ARC")
# else:
# 	print("ABC")
n,k=input2()
d=[]
A=[]
I=[]
for i in range(k):
	d.append(input1())
	A+=input_array()

print(n-len(Counter(A)))

Submission status: Accepted

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

lk = list()
lsuneke = list()
for i in range(K):
    lk.append(int(input()))
    lsuneke.extend(list(map(int, input().split())))

lnum = list(set(lsuneke))
print(N - len(lnum))

Submission status: Accepted

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

ans=[0 for i in range(N)]
l=[]

for i in range(K):
  d=int(input())
  A=[int(x) for x in input().rstrip().split()]
  for j in A:
    ans[j-1]+=1


cnt=0

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

Submission status: Accepted

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

sunuke = [0]*n;

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

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

print(ans);

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l = range(1,n+1)
for _ in range(k):
    _ = input()
    a = list(map(int, input().split()))
    l = list(filter(lambda x: not x in a, l))
print(len(l))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = [0]*k
a = [None]*k
okashi = {}

for i in range(k):
    dd = int(input())
    aa = [int(j) for j in input().split()]
    d[i] = dd
    a[i] = aa

for i in range(1, n+1):
    okashi[i] = 0

for i in range(k):
    for aaa in a[i]:
        okashi[aaa] += 1

ans = 0

for times in okashi.values():
    if times == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

point_list = [0]*N

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


print(N - len(set(hoge)))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
i = 0
d = []
As = []
while True:
  if i != K:
    d.append(int(input()))
    As.append(list(map(int,input().split())))
  else:
    break
  i += 1

r = [0]*N
for x in range(len(d)):
  for y in As[x]:
    r[y-1] += 1

print(r.count(0))

Submission status: Accepted

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

D = []
As = []
for _ in range(K):
    D.append(int(input()))
    As.append(map(int, input().split()))

d = {i: 0 for i in range(1, N + 1)}
for i in range(K):
    A = As[i]
    for j in A:
        d[j] += 1

ans = 0
for key, val in d.items():
    if val == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import collections as cc
I=lambda:list(map(int,input().split()))
n,k=I()
l=[[] for i in range(n)]
for j in range(k):
    nn,=I()
    m=I()
    for i in range(nn):
        l[m[i]-1].append(i)
ans=0
for i in l:
    if len(i)==0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N, K =  input().strip().split()
N = int(N)
K = int(K)
hasSnakes = set()
for _ in range(K):
    num_snukes = int(input())
    for snuke in input().split():
        hasSnakes.add(snuke)
print(N - len(hasSnakes))

Submission status: Accepted

Solution code:
n,k = input().split()
n = int(n)
k = int(k)
ans = [0]*n
count = 0
for i in range(k):
  a = int(input())
  str_list = list(input().split())
  for j in str_list:
    ans[int(j)-1] = ans[int(j)-1] + 1
for i in range(n):
  if ans[i] == 0:
    count = count + 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split(" "))
sunuke = [0 for num in range(N)]
for i in range(K):
    d = int(input())
    sweets = list(map(int,input().split(" ")))
    for sweet in sweets:
        if sunuke[sweet-1] == 0:
            sunuke[sweet-1] = 1
trick = sunuke.count(0)
print(trick)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst = [i for i in range(1, n+1)]
for j in range(k):
  kashi = int(input())
  s = input().rstrip().split(' ')
  for k in range(len(s)):
    if int(s[k]) in lst:
      lst.remove(int(s[k]))
print(len(lst))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke = list(range(n))
for _ in range(k):
    _ = input()
    aa = map(int, input().split())
    for a in aa:
        a -= 1
        if a in sunuke:
            sunuke.remove(a)
print(len(sunuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = [True]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        sunuke[a-1] = False

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
import numpy as np
nk = input()
[n, k] = [int(comp) for comp in nk.split()]
a = np.zeros(n, dtype=int)
for i in range(k):
    d = input()
    temp = input()
    for comp in temp.split():
        a[int(comp)-1] = 1
print(n-np.array(a).sum())

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    cnt = [0] * (N + 1)
    for i in range(K):
        input()
        a = list(map(int, input().split()))
        for x in a:
            cnt[x] += 1
        
    # print(cnt)
    print(sum([1 for n in cnt[1:] if n == 0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=set()
for i in range(b):
  p=int(input())
  l=list(map(int,input().split()))
  for j in l:
    s.add(j)
print(a-len(s))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
sunuke = [1 for _ in range(N)]
for k in range(K):
	d = int(input())
	A = [int(i) for i in input().split()]
	for i in range(d):
		sunuke[A[i]-1] = 0

print(sum(sunuke))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
s = [1 for j in range(N)]

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for l in range(d):
        s[A[l] -1] = 0

print(sum(s))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
v = []
for i in range(n):
  v.append(False)
for i in range(k):
  d = int(input())
  a = map(int, input().split())
  for j in a:
    v[j - 1] = True
ans = 0
for b in v:
  if not b:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(1000000)



def main():
    n, k = map(int, input().split())

    has_set = set()
    a_dic = {}
    for i in range(k):
        input()
        for z in list(map(int, input().split())):
            has_set.add(z)

    print(n-len(has_set))




main()

Submission status: Accepted

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

Submission status: Accepted

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

okashi_total = [0 for x in range(N)]

for k in range(K):
    d = int(input())
    okashi_d = list(map(int, input().split()))
    
    for i in okashi_d:
        okashi_total[i-1] += 1
        
print(okashi_total.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = [False] * (N+1)
for i in range(K):
    d = int(input())
    for j in map(int, input().split()):
        lst[j] = True
ans = -1
# print(lst)
for i in lst:
    if not i:
        ans += 1
print(ans)

Submission status: Accepted

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

A.sort()
A = set(A)
count = 0
for i in range(1,N+1):
    if i in A:
        pass
    else:
        count += 1
print(count)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

x = set()

for _ in range(k):
    input()

    temp1 = list(map(int,input().split()))

    for temp2 in temp1:
        x.add(temp2)

print(n - len(x))

Submission status: Accepted

Solution code:
import itertools

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

d = []
A = []

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

ans = 0
A = itertools.chain.from_iterable(A)
A = set(A)
for i in range(1,N+1):
    if i not in A:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_ans = [1 for i in range(N)]
for i in range(K):
    d = int(input())
    if d > 1 :
        A = list(map(int, input().split()))
        for j in range(len(A)):
            if A_ans[A[j]-1] == 1 :
                A_ans[A[j]-1] = 0
    else:
        A = int(input())
        if A_ans[A-1] == 1 :
            A_ans[A-1] = 0

print(sum(A_ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
num_arr = [0]*(N+1)
for _ in range(K):
  p = int(input())
  arr = list(map(int,input().split()))
  for i in arr:
    num_arr[i] += 1
    
print(num_arr.count(0)-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,k = MI()
li = []
for i in range(k):
    d = int(input())
    a = LI()
    li += a
a = set(li)
print(n-len(a))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
Okashi = [[] for _ in range(K + 1)]
for j in range(1, K + 1):
    D = int(input())
    A = [int(i) for i in input().split()]
    for a in A:
        Okashi[j].append(a)

tmp = [0] * (N+1)
for o in Okashi[1:]:
    for b in o:
        tmp[b] += 1

ans = sum([1 for a in tmp[1:] if a==0])
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
okashi = [0 for _ in range(N)]
for _ in range(K):
    input()
    alist = list(map(int, input().split()))
    for a in alist:
        okashi[a-1] += 1
ans = okashi.count(0)
print(ans)

Submission status: Accepted

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

ns = [False] * n

for _ in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))[:d]
    for i in a_list:
        ns[i-1] = True
    
print(len(ns) - sum(ns))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = []
for _ in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    A.append(a)
B = [0 for _ in range(N+1)]
for a in A:
    for j in range(len(a)):
        B[a[j]] = 1
print(N-sum(B))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
data = []
for _ in range(k):
  _ = input()
  tmp = [int(i) for i in input().split()]
  data += tmp
  
print(n - len(set(data)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = list(map(int, input().split(' ')))
    count = [0 for _ in range(N)]
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split(' ')))
        for a in A:
            count[a - 1] += 1
    answer = 0
    for c in count:
        if c == 0:
            answer += 1
    print(answer)


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()))
    L = [j for j in L if j not in a]

print(len(L))

Submission status: Accepted

Solution code:

# N人 K種類
N, K = map(int, input().split())

check = [0] * N

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

count = 0
for checkN in check:
    if checkN == 0:
        count += 1

print(count)

Submission status: Accepted

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

for _ in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  
  for a in A:
    c[a - 1] += 1
    
ans = c.count(0)

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = [int(x) for x in range(1, n+1)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        if j in ans:
            ans.remove(j)
print(len(ans))

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

d = defaultdict(int)
for i, da in enu(dA):
    if i%2 == 0:
        pass
    else:
        for a in da:
            d[a] = d[a]|1

print(N-sum(d.values()))

Submission status: Accepted

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

N,K = inpl()
people = []
for i in range(1,N+1):
  people.append(i)

for i in range(K):
  a = inp()
  num = inpl()
  for j in num:
    try:
    	people.remove(j)
    except:
      pass
    
print(len(people))

Submission status: Accepted

Solution code:
n, k = list(map(lambda x: int(x), input().split(' ')))
result = 0
data = set()

for i in range(k):
  d = int(input())
  a = list(map(lambda x: int(x), input().split(' ')))

  for s in a:
    data.add(s)

print(n - len(data))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
d = {}
for i in range(K):
    _ = int(input())
    tmp = [int(i) for i in input().split()]
    for j in tmp:
        d[j] = 1
ans = 0
for i in range(N):
    if not i + 1 in d:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
D = []
A = []
for i in range(K):
    d = INT()
    D.append(d)
    a = LIST()
    A.append(a)

B = []
for i in A:
    for j in i:
        B.append(j)

ans = 0
for i in range(N):
    if i+1 not in B:
        ans += 1
print(ans)

Submission status: Accepted

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

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

count = 0
for i in range(1, N+1):
    if i not in ans:
        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())
  for j in list(map(int,input().split())):
    l[j-1]+=1
from collections import Counter
c=Counter(l)
print(c[0])

Submission status: Accepted

Solution code:
from sys import stdin
N,K= list(map(int,stdin.readline().strip().split()))
sunuke=[0]*N
for i in range(K):
    input()
    kasi=list(map(int,stdin.readline().strip().split()))
    for i in kasi:
        sunuke[i-1]+=1
print(sunuke.count(0))

Submission status: Accepted

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

for i in range(K):
  input()
  A.extend(list(map(int, input().split())))
  
print(N - len(set(A)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = []
A = []
for _ in range(K):
    d.append(int(input()))
    A.append([int(e) for e in input().split()])
snukes = [0] * (N+1)
for a in A:
    for item in a:
        snukes[item] += 1
snukes = snukes[1:]
print(len([e for e in snukes if e == 0]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = (int(i) for i in input().split())
# B = [int(x) for x in stdin.readline().rstrip().split()]
# A = [[int(i) for i in input().split()] for i in range(N)]
sunuke = [0]*(N+1)
for j in range(K):
    d = int(input())
    l = [int(i) for i in input().split()]
    for i in l:
        sunuke[i] += 1

# print(sunuke)
print(sunuke.count(0)-1)

Submission status: Accepted

Solution code:
def abc166_b():
  n, k = map(int, input().split())
  snuke = []
  for _ in range(k):
    _ = int(input())
    snuke += list(map(int, input().split()))
  ans = n - len(set(snuke))
  print(ans)

abc166_b()

Submission status: Accepted

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

print(sum(a))

Submission status: Accepted

Solution code:
# print('input >>')
N, K = map(int,(input().split()))
As = []
okashi = [0] * N

for _ in range(K):
    d = input()
    As.append(list(map(int,(input().split()))))

for A in As:
    for a in A:
        okashi[a-1] += 1

ans = 0
for okashi_ in okashi:
    if okashi_ == 0:
        ans += 1

# print('-----output-----')
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = [1 for _ in range(n + 1)]
cnt[0] = 0
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for ai in a:
        cnt[ai] = 0
print(sum(cnt))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
ans=[]
for i in range(b):
    c=input()
    d=[int(x) for x in input().split()]
    ans+=d
    ans=set(ans)
    ans=list(ans)
print(a-len(ans))

Submission status: Accepted

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

for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for val in A:
    s[val - 1] += 1
    
ans = s.count(0)
print(ans)

Submission status: Accepted

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

l = [0 for i in range(N)]

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

print(l.count(0))

Submission status: Accepted

Solution code:
N,K=(int(i) for i in input().split())
poss = [0]*(N+1)
# ~ for i in range(N): poss.append([])
for _ in range(K):
	x = int(input())
	for y in (int(j) for j in input().split()):
		poss[y]+=1
ans = 0
for i in range(1, N+1):
	if poss[i]==0:
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split(' ')]
A = list(range(1,N+1))
for i in range(K):
	d = int(input())
	B = [int(j) for j in input().split(' ')]
	A = [x for x in A if not x in B]
print(len(A))

Submission status: Accepted

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

import itertools
a_flattened = list(itertools.chain.from_iterable(A))
se = set(a_flattened)
print(N - len(se))

Submission status: Accepted

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

l = [False for _ in range(n)]
for _ in range(k):
    input()
    a = list(map(int, input().split()))
    for ai in a:
        l[ai-1] = True

print(len(list(filter(lambda x: not x, l))))

Submission status: Accepted

Solution code:

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

d = [0] * k
ans = set([])

for i in range(k):
    d[i] = int(input())
    tmp = set(map(int,input().split()))
    ans = ans | tmp
print(n - len(ans))

Submission status: Accepted

Solution code:
NK = [int(i) for i in input().split(" ")]
info = []
for i in range(NK[1]):
    d = int(input())
    A = [int(i) for i in input().split(" ")]
    info.append(A)

have_okasi = [0]*NK[0]
for A in info:
    for a in A:
        have_okasi[a-1] += 1
print(have_okasi.count(0))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import time
import numpy as np

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

Sunuke = np.zeros(n)

for i in range(k):
    d = int(input())
    Okashi = np.zeros(n)
    for a in input().split():
        Okashi[int(a)-1] += 1
    Sunuke += Okashi


ans = n - np.count_nonzero(Sunuke)
print(ans)

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        sunuke[a-1] = 0
    
ans = sum(sunuke)
print(ans)