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:

MOD = 10 ** 9 + 7
RLIMIT = 1000
DEBUG = 1

def main():
    for _ in inputt(1):
        n, k = inputi()
        l = [0] * (n + 1)
        for _ in range(k):
            d, = inputi()
            for c in inputi():
                l[c] = 1
        debug(l)
        print(n - sum(l))


# region M


# region import

from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(RLIMIT)

# endregion

# region fastio

BUFSIZE = 8192
class FastIO(io.IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = io.BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(io.IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    if args:
        sys.stdout.write(str(args[0]))
        split = kwargs.pop("split", " ")
        for arg in args[1:]:
            sys.stdout.write(split)
            sys.stdout.write(str(arg))
    sys.stdout.write(kwargs.pop("end", "\n"))
def debug(*args, **kwargs):
    if DEBUG and not __debug__:
        print("debug", *args, **kwargs)
        sys.stdout.flush()
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip()
inputt = lambda t = 0: range(t) if t else range(int(input()))
inputs = lambda: input().split()
inputi = lambda k = int: map(k, inputs())
inputl = lambda t = 0, k = lambda: list(inputi()): [k() for _ in range(t)] if t else list(k())

# endregion

# region bisect

def len(a):
    if isinstance(a, range):
        return -((a.start - a.stop) // a.step)
    return builtins.len(a)
def bisect_left(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if key(a[mid]) < x: lo = mid + 1
        else: hi = mid
    return lo
def bisect_right(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if x < key(a[mid]): hi = mid
        else: lo = mid + 1
    return lo
def insort_left(a, x, key = None, lo = 0, hi = None):
    lo = bisect_left(a, x, key, lo, hi)
    a.insert(lo, x)
def insort_right(a, x, key = None, lo = 0, hi = None):
    lo = bisect_right(a, x, key, lo, hi)
    a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right
def index(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi and key(a[i]) == x: return a[i]
    if default != None: return default
    raise ValueError
def find_lt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_le(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_gt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError
def find_ge(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError

# endregion

# region csgraph
# TODO

class Tree:
    def __init__(n):
        self._n = n
        self._conn = [[] for _ in range(n)]
        self._list = [0] * n
    def connect(a, b):
        pass

# endregion

# region ntheory

class Sieve:
    def __init__(self):
        self._n = 6
        self._list = [2, 3, 5, 7, 11, 13]
    def extend(self, n):
        if n <= self._list[-1]: return
        maxbase = int(n ** 0.5) + 1
        self.extend(maxbase)
        begin = self._list[-1] + 1
        newsieve = [i for i in range(begin, n + 1)]
        for p in self.primerange(2, maxbase):
            for i in range(-begin % p, len(newsieve), p):
                newsieve[i] = 0
        self._list.extend([x for x in newsieve if x])
    def extend_to_no(self, i):
        while len(self._list) < i: 
            self.extend(int(self._list[-1] * 1.5))
    def primerange(self, a, b):
        a = max(2, a)
        if a >= b: return
        self.extend(b)
        i = self.search(a)[1]
        maxi = len(self._list) + 1
        while i < maxi:
            p = self._list[i - 1]
            if p < b:
                yield p
                i += 1
            else: return
    def search(self, n):
        if n < 2: raise ValueError
        if n > self._list[-1]: self.extend(n)
        b = bisect(self._list, n)
        if self._list[b - 1] == n: return b, b
        else: return b, b + 1
    def __contains__(self, n):
        if n < 2: raise ValueError
        if not n % 2: return n == 2
        a, b = self.search(n)
        return a == b
    def __getitem__(self, n):
        if isinstance(n, slice):
            self.extend_to_no(n.stop + 1)
            return self._list[n.start: n.stop: n.step]
        else:
            self.extend_to_no(n + 1)
            return self._list[n]
sieve = Sieve()
def isprime(n):
    if n <= sieve._list[-1]:
        return n in sieve
    for i in sieve:
        if not n % i: return False
        if n < i * i: return True
prime = sieve.__getitem__
primerange = lambda a, b = 0: sieve.primerange(a, b) if b else sieve.primerange(2, a)
def factorint(n):
    factors = []
    for i in sieve:
        if n < i * i: break
        while not n % i:
            factors.append(i)
            n //= i
    if n != 1: factors.append(n)
    return factors
factordict = lambda n: Counter(factorint(n))

# endregion

# region main

if __name__ == "__main__":
    main()

# endregion


# endregion

Submission status: Accepted

Solution code:
[N,K] = [int(s) for s in input().rstrip().split(' ')]
L = [0]*N
for i in range(K):
    d_i = int(input())
    A_i = [int(s) for s in input().rstrip().split(' ')]
    for a_i in A_i:
        L[a_i-1] += 1
print(L.count(0))

Submission status: Accepted

Solution code:
def resolve():
    N,K = map(int,input().split())
    children=[False for i in range(N)]
    for i in range(K):
        d= int(input())      
        for i in map(int,input().split()):
            children[i-1]=True
    
    ans = 0
    for i in children:
        if not i:
            ans +=1
    
    print(ans)

        

    


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

having = set()
for k in range(K):
    _ = input()
    As = list(map(lambda x: int(x), input().split(" ")))
    having |= set(As)

result = N - len(having)
print(result)

Submission status: Accepted

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

L = set(sum(A,[]))
print(N - len(L))

Submission status: Accepted

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

Submission status: Accepted

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

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

oks = [False] * n
for xs in arr:
    for x in xs:
        oks[x - 1] = True

ans = 0
for x in oks:
    if x == False:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# B

inp = input().split(' ')
N, K = int(inp[0]), int(inp[1])

sunuke = [1 for i in range(N)]

for i in range(K):
    di = int(input())
    tmp = [int(t)-1 for t in input().split(' ')]
    for t in tmp:
        sunuke[t] = 0
print(sum(sunuke))

Submission status: Accepted

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


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

print(N-len(have))

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


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

    l = [1 for _ in range(N)]
    for _ in range(K):
        d = INT()
        A = LIST()

        for a in A:
            l[a-1] = 0

    print(sum(l))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(N-len(set(S)))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
senku = [0 for _ in range(n)]
while k:
    d = int(input())
    a = list(map(int, input().split()))
    a = [i-1 for i in a]
    for i in a:
        if not senku[i]:
            senku[i] = 1
    k-=1
print(n - sum(senku))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

N, K = map(int, input().split())
people = [0] * N

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

print(people.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, K = mapint_inp()

sunuke_set = set()

for _ in range(K):
    d = intinp()
    A = list(mapint_inp())
    for A_i in A:
        sunuke_set.add(A_i)

print(N - len(sunuke_set))

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())))

S = [1 for _ in range(N)]
for i in range(K):
    for j in range(len(A[i])):
        S[A[i][j]-1] = 0

print(sum(S))

Submission status: Accepted

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

data = [list(map(int,input().split())) for i in range(2*K)]

S = []
S = set(S)
for i in range(K):
    for j in range(data[2*i][0]):
        S.add(data[2*i+1][j])

print(N-len(S))

Submission status: Accepted

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

a_ls = [0] * n
for i in range(k):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        if a_ls[j-1] == 0:
            a_ls[j-1] = 1
print(n - sum(a_ls))

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

N,K = MI()
llist = [0]*N
for i in range(K):
    d = I()
    l = LI()
    for man in l:
        llist[man-1] += 1
print(llist.count(0))

Submission status: Accepted

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

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:
N,K =map(int,input().split())
ln =[0]*N
for i in range(K):
    d = int(input())
    l = list(map(int,input().split()))
    for j in range(d):
        ln[l[j]-1] += 1
print(ln.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
arr=[0 for i in range(n)]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for b in a:
        arr[b-1]+=1
cnt=0
for i in range(n):
    if arr[i]==0:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    sunuke = [0] * n
    for _ in range(k):
        d = int(input())
        A = list(map(int, input().split()))
        for i in range(d):
            sunuke[A[i] - 1] += 1

    res = 0
    for i in sunuke:
        if i == 0:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
lst = list(range(1,N+1))
st =set()
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    st |= set(A)

num=0

for s in lst:
    if not s in st:
        num+=1

print(num)

Submission status: Accepted

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

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

Pocession = [False for _ in range(N)]
for i, poc in enumerate(A):
    if i %2 == 1:
        for po in poc:
            Pocession[po-1] = True

print(Pocession.count(False))

Submission status: Accepted

Solution code:
a=input().split()
N=int(a[0])
K=int(a[1])
list1=[]
for i in range(K) :
  c=int(input())
  d=input().split()
  for item in d :
    list1.append(int(item))

m=len(list(set(list1)))
print(N-m)

Submission status: Accepted

Solution code:
import math
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    d=[]
    a=set([])
    for i in range(k):
        d.append(INT())
        a=a | set(LIST())
    print(n-len(a))
    #print(a)
    
if __name__ == '__main__':
    do()

Submission status: Accepted

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

hito = [1]*N
A = []
for num in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for num1 in range(d):
        idx = A[num1] - 1
        hito[idx] = 0

ans = sum(hito)
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
have=[]
for i in range(K):
    D=int(input())
    a=list(map(int,input().split()))
    have +=a
print(N-len(set(have)))

Submission status: Accepted

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

Submission status: Accepted

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

print(N-len(set(Al)))

Submission status: Accepted

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

Submission status: Accepted

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

d = list()
s = set()
for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        s.add(a)

c = 0
for i in range(1, n+1):
    if i not in s:
        c += 1

print(c)

Submission status: Accepted

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

sunuke = [0] * N

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

  for j in A:
    sunuke[j-1] += 1

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

print(sum)

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n,k = map(int,input().strip().split())
    sunuke = [1 for i in range(n)]
    for i in range(k):
        x = int(input().strip())
        a = list(map(int, input().strip().split()))
        for j in a:
            sunuke[j-1] = 0
    print(sum([sunuke[i]==1 for i in range(n)]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,k = myinput()
d = []
A = []
for i in range(k):
    d.append( int(input()) )
    A.append(list(myinput()))
# print(d)
# print(A)

ls = [0]*n
for i in range(k):
    a = A[i]
    for j in range(len(a)):
        s = a[j] - 1
        ls[s] = 1
# print(ls)
ans = n - sum(ls)
print(ans)

Submission status: Accepted

Solution code:
num_man, num_candy = map(int, input().split())

lis = [0]*num_man
for i in range(num_candy):
    sum = int(input())
    l_tmp = list(map(int, input().split()))
    for j in range(sum):
        lis[l_tmp[j]-1] = 1
ans = 0
for i in range(num_man):
    if(lis[i] == 0):
        ans += 1
print(ans)

Submission status: Accepted

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

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

# print(a)
ans = 0

for i in range(1, n+1):
    for j in range(len(a)):
        if i in a[j]:
            break
    else:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = []
for i in range(1, N+1):
    li.append(i)
for i in range(K):
    s1 = input()
    s2 = list(map(int, input().split()))
    for j in s2:
        if j in li:
            li.remove(j)
print(len(li))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# sys.stdin.readline()
"""
import sys
input = sys.stdin.readline
import math
N = int(input())
n,m,q = map(int,input().split())
A = [list(map(int,input().split())) for i in range(q)]
"""

n,k = map(int,input().split())
A = [i for i in range(1,n+1)]
for j in range(k):
    s = int(input())
    K = list(map(int,input().split()))
    for i in range(s):
        if K[i] in A:
            A.remove(K[i])
print(len(A))

Submission status: Accepted

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

print(n-len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n,k = tuple([int(t)for t in input().split()])

    t = [0]*n
    for _ in range(k):
        input()
        k = tuple([int(t)-1 for t in input().split()])
        for k_i in k:
            t[k_i]+=1
    
    ans = 0
    for t_i in t:
        if t_i==0:
            ans+=1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
slist = [0]*n
for K in range(k):
  d = int(input())
  Alist = list(map(int, input().split()))
  for D in range(d):
    slist[Alist[D]-1] = 1
print(n-sum(slist))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = [0] * N
for _ in range(K):
  n = int(input())
  for a in [int(x) for x in input().split()]:
    S[a - 1] += 1
print(sum([1 for s in S if s == 0]))

Submission status: Accepted

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

n_list = [0 for n in range(N)]
 
for k in range(K):
    d = int(input())
    d_list = map(int, input().split())
    for d in d_list:
        n_list[d-1] = 1
print(n_list.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


ninzu, syurui = map(int, input().split())

shoji = [ 0 for _ in range(ninzu) ]

for _ in range(syurui):
    num = int(input())
    
    if num == 1:
        man = int(input())
        shoji[man-1] += 1
    else:
        mans = map(int, input().split())
        for man in mans:
            shoji[man-1] += 1

ans = 0
for sman in shoji:
    if sman == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
d = [0] * K
A = [None for _ in range(K)]
for i in range(K):
    d[i] = int(input())
    A[i] = [int(x) for x in input().split()]

trick = [False] + [True] * (N)

for i in range(K):
    for a in A[i]:
        trick[a] = False

print(trick.count(True))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = 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 p:
            p.remove(i)
print(len(p))

Submission status: Accepted

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

having = set()
for _ in range(k):
    d = int(input())
    a = {int(i) for i in input().split()}

    having |= a
print(n - len(having))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k):
    for j in range(1):
        _ = input()
        tl = list(map(int,input().split()))
        for t in tl:
            l[t-1]+=1
        # print(i,j)
ans = 0
for i in l:
    if i ==0:
        ans +=1

print(ans)

Submission status: Accepted

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

ans = 0
check = [True for i in range(n)]

for i in range(k):
    d = int(input())
    tmp = list(map(int, input().split()))
    for ii in tmp:
        check[ii - 1] = False

for c in check:
    if c:
        ans += 1
print(ans)

Submission status: Accepted

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

print(len(r))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0
for m in range(len(mans)):
    if mans[m] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

N, K = [int(x) for x in input().split()]

treat = [0] * N

for k in range(K):
    input()
    P = [int(x) for x in input().split()]
    for p in P:
        treat[p-1] = 1

print(N-sum(treat))

Submission status: Accepted

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