Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

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

d = []
a = []

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

a_set = set(a[0])
for i in a:
    a_set = a_set | set(i)

ans = set((range(1, N+1))) - a_set
print(len(ans))

Submission status: Accepted

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

for k in range(K):
  d=int(input())
  A.append(list(map(int,input().split())))
  
counts=[0]*N

for n in range(K):
  for a in A[n]:
    counts[a-1] +=1

print(counts.count(0))

Submission status: Accepted

Solution code:
N,K = map(int,input().split()) 
sunuke = list(range(1,N+1))
for i in range(K):
    d = int(input())
    s = list(map(int,input().split()))
    for j in s:
        if j in sunuke:
            sunuke.remove(j)
print(len(sunuke))

Submission status: Accepted

Solution code:
import sys
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from decimal import Decimal
inf = float('inf')
MOD = 1000000007

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


s = [0 for _ in range(n)]

for i in range(k):
    for j in range(d[i]):
        s[A[i][j]-1] += 1

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

print(ans)

Submission status: Accepted

Solution code:
_=list(map(int,input().split()))
N=_[0];K=_[1]
D=[]
A=set()
for k in range(K):
    D.append(int(input()))
    a=list(map(int,input().split()))
    for i in a:
        A.add(i)
print(N-len(A))

Submission status: Accepted

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

sunukes = [0] * N

for i in range(K):
    d = int(input())
    kashimochi = list(map(int, input().split()))
    for j in kashimochi:
        sunukes[j-1] = 1


print(sunukes.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
n_list = [0] * n
for i in range(k):
  _ = int(input())
  d = list(map(int, input().split()))
  for _ in d:
    n_list[_-1] += 1
result = 0
for _ in n_list:
  if _ == 0:
    result += 1
print(result)

Submission status: Accepted

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

for j in range(1, n+1):
    TF.append(j in a_list)

print(TF.count(False))

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
d=[]
A = []
sunuke = set()
for i in range(K):
    d_i = int(input())
    A_i = list(map(int,input().split()))
    for j in A_i:
        sunuke.add(j)


print(N-len(sunuke))

Submission status: Accepted

Solution code:
from math import gcd
from functools import reduce
from itertools import product

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

  a = []
  for k in range(K):
    d = int(input())
    a.extend([int(x) for x in input().split(" ")])

  a = list(set(a))
  print(N-len(a))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def input_from_console():
    n, k = map(int, input().split())
    a_list = []
    for i in range(k):
        d = input().rstrip()
        a = map(int, input().rstrip().split())
        for ii in a:
            if not ii in a_list:
                a_list.append(ii)
    return n, a_list


def solve(n, a_list):
    # print("n, a_list", n, a_list)
    return n - len(a_list)


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))

if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Accepted

Solution code:
import numpy as np

N,K = (int(x) for x in input().split())
x = np.zeros(N)
count = 0

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

for i in range(N):
    if x[i] == 0:
        count = count + 1

print(count)

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())))            
dp = [0]*(N+1)
for i in range(K):
    for j in range(d[i]):
        dp[A[i][j]] = 1
print(N-sum(dp))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
table = [0] * n
for i in range(k):
    di = int(input())
    ai = list(map(int, input().split()))
    for aij in ai:
        table[aij - 1] += 1
print(table.count(0))

Submission status: Accepted

Solution code:
#! python3

def main():
    n, k = map(int, input().split())
    nset = set()
    for i in range(k):
        d = int(input())
        have = list(map(int, input().split()))
        have_set = set(have)
        nset |= have_set

    ans = n - len(nset)

    print(ans)

main()

Submission status: Accepted

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

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):
        if L[A[j-1]-1]==0:
            L[A[j-1]-1]+=1
print(n-sum(L))

Submission status: Accepted

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

d = set(d)
d = list(d)
print(n - len(d))

Submission status: Accepted

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

Submission status: Accepted

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


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

print(mans.count(0))

Submission status: Accepted

Solution code:
def tot(lookup, n):
    print(n - len(lookup.keys()))

if __name__ == "__main__":
    import sys
    from collections import defaultdict as DD
    lookup = DD(list)
    n, k = [int(_) for _ in input().split()]
    for i in range(k):
        di = int(input())
        ss = [int(_) for _ in input().split()]
        for s in ss:
            lookup[s].append(i)
    tot(lookup, n)

Submission status: Accepted

Solution code:
N = input().split()
n= int(N[0])
k = int(N[1])
o = [0 for _ in range(n)]
a = 0
for i in range(k):
    A= input()
    a = int(A)
    q = input().split()
    for j in range(a):
        o[int(q[j])-1] += 1

print(o.count(0))

Submission status: Accepted

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

num = []

for i in range(K):
    d = int(input())
    s = list(map(int,input().split()))
    for j in s:
        num.append(j)

print(N - len(set(num)))

Submission status: Accepted

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

Submission status: Accepted

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

s = set()

for i in range(k):
    d = int(input())
    set_k = set(map(int, input().split()))
    s = s | set_k

print(n - len(s))

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
d = []
A =[]
s = list(range(1,N+1))

for i in range(K):
  di = int(input())
  d += [di]
  Ai = list(map(int, input().split()))
  A += [Ai]
  #print(Ai)

  for j in Ai:
    if j in s:
      #print(j)
      s.remove(j)
      #print(s)

ans = len(s)
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()))
  for a in list(map(int, input().split())):
    A.append(a)
A = sorted(A)
count = 1
for i in range(len(A)-1):
  if A[i] != A[i+1]:
    count += 1
print(N-count)

Submission status: Accepted

Solution code:
import numpy as np 
import math

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

counter = 0
for i in range(N):
    if i+1 in A:
        counter == 0
    else:
        counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

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

    ds = []
    aks = []
    for i in range(k):
        ds.append(int(input()))
        aks.append(list(map(int, input().split())))

    dict = {}
    for i in aks:
        for j in i:
            dict[j] = 0

    print(n - len(dict.items()))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2
2
1 3
1
3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 3
1
3
1
3
1
3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict 
import math
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1]) 
    d = []
    candycount = defaultdict(int)
    for k in range(K):
        d.append(int(input()))
        s = input().rstrip().split(' ')
        for elem in s:
            candycount[int(elem)] += 1

    c = 0

    for k in range(1,N+1):
        if not k in candycount:
            c += 1

    print(c)

Submission status: Accepted

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




import itertools



c=list(itertools.chain.from_iterable(a))
for i in range(1,n+1):
    if c.count(i)==0:
        b+=1
print(b)

Submission status: Accepted

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

print(x)

Submission status: Accepted

Solution code:
def main():
    n, k = [int(v) for v in input().strip().split(' ')]
    lst_is_possession = [False for _ in range(n)]

    for _ in range(k):
        _ = input()
        lst_possession_peple = [int(v) - 1 for v in input().strip().split(' ')]
        for p in lst_possession_peple:
            lst_is_possession[p] = True
    ans = n - sum(lst_is_possession)
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke = [False for i in range(n + 1)]
for i in range(k):
    input()
    for a in map(int, input().split()):
        sunuke[a] = True
print(len([s for s in sunuke[1:] if not s]))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
list1=[0]*(a+1)
for i in range(b):
    c=int(input())
    d=list(map(int,input().split()))
    for j in d:
        list1[j]+=1
for i in range(list1.count(0)):
    list1.remove(0)
print(a-len(list1))

Submission status: Accepted

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


def main():
    N, K = map(int, input().split())
    sunuke = [0]*N
    for _ in range(K):
        A = []
        d = int(input())
        A = map(int, input().split())
        for j in A:
            sunuke[j-1] += 1
    answer = collections.Counter(sunuke)
    print(answer[0])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
T=[x+1 for x in range(N)]
for y in range(K):
    a=int(input())
    b=list(map(int,input().split()))
    for z in range(a):
        if b[z] in T:
            T.remove(b[z])
print(len(T))

Submission status: Accepted

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

for k in range(K):
    tmp = input().split()
    d = int(tmp[0])
    tmp = input().split()
    for di in range(d):
        A = int(tmp[di])
        sunuke[A-1] = sunuke[A-1] + 1

trick = 0

for s in sunuke:
    if s == 0:
        trick = trick + 1

print(trick)

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
ls=[]
for i in range(N):
    ls.extend([i])
for i in range(K):
    input()
    temp=list(map(int,input().split()))
    for j in temp:
        try:
            ls.remove((j-1))
        except:
            pass
print(len(ls))

Submission status: Accepted

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

n, k = map(int, input().split())
A = [1]*n
for i in range(k):
    d = int(input())
    x = [int(h) for h in input().split()]
    for k in x:
        if A[k - 1] == 1:
            A[k - 1] = 0

sum = 0
for m in A:
    sum += m
print(sum)

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()))
#print(a)
A=[]
for i in range(len(a)):
  for j in range(len(a[i])):
    A.append(a[i][j])
#print(A)
print(N-len(set(A)))

Submission status: Accepted

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

print(N-len(a))

Submission status: Accepted

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

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

    for j in range(d):
        buf = a[j]-1
        ha[buf] += 1

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

print(ans)

Submission status: Accepted

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

count = 0
for j in sunuke:
    if j == 0:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  #print(1,i,d)
  x = list(map(int, input().split()))
  for k in x:
    state[k-1] = 0
print(sum(state))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
hav = set()
for _ in range(k):
    d = int(input())
    for i in input().split():
        hav.add(int(i))
print(n - len(hav))

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""
def main():
    """main function"""
    N, K = map(int, input().split(' '))
    answer_li = [1 for _ in range(N)]
    for _ in range(K):
        input()
        tmp_li = map(int, input().split(' '))

        for num in tmp_li:
            answer_li[num-1] = 0

    answer = sum(answer_li)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
N = NK[0]; K = NK[1]

result = [0]*N

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

cnt = 0

for i in range(N):
    if result[i] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n,k=[int(_) for _ in input().split()]
list1=[]
for j in range(n):
    list1.append(j+1)
for i in range(k):
    q=int(input())
    b=[int(b) for b in input().split()][:q]
    for z in range(q):
        try:
            list1.remove(b[z])
        except:continue
            
print(len(list1))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
def main():
    n, k = map(int, input().split())
    p = []
    for _ in range(k):
        d = int(input()) 
        a = [int(i) for i in input().split()]
        for i in a:
            p.append(i)   
    dd = Counter(p)    
    cnt = 0
    for i in range(1, n+1):
        if dd[i] == 0:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
n,k = [int(x) for x in stdin.readline().rstrip().split()]
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append([int(x) for x in stdin.readline().rstrip().split()])
b = [0]*n
for i in range(k):
    for j in range(d[i]):
        b[a[i][j]-1] = 1
ans =0
for i in range(n):
    if b[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n,k = map(int, input().split())
n_n = np.zeros(n+1) 
for i in range(k):
    d = input()
    a = map(int, input().split())
    for j in a:
        n_n[j] += 1
print(list(n_n).count(0)-1)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(a.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

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

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

hasmans = itertools.chain.from_iterable(hasmans)

print(len(list(set(mans) - set(hasmans))))

Submission status: Accepted

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

Submission status: Accepted

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

d = []
for i in range(k):
    d.append(int(input()))
    li = []
    li = input().split()
    a = a + li

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

Submission status: Accepted

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

Submission status: Accepted

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

print(len(s))

Submission status: Accepted

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

sunukes = [0 for i in range(N)] 
for i in range(K):
    for j in range(d[i]):
        sunukes[A[i][j]-1] += 1

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

Submission status: Accepted

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

for i in range(K):
  b = input()
  c = list(map(int,input().split()))
  for j in range(len(c)):
    a[c[j]-1] += 1
count = 0
for i in range(N):
  if(a[i] == 0):
    count+=1

print(count)

Submission status: Accepted

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

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

for d in d_list:
  for a in d:
    sunukes[a-1] += 1

count = 0
for s in sunukes:
  count += 0 if s else 1
print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
check = [0] * n
for i in range(k):
    D = int(input())
    A = list(map(int, input().split()))
    for d in range(D):
        if check[A[d] - 1] == 0:
             check[A[d] - 1] = 1
print(check.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d=[]
al=[]
a=[0]*k
for i in range(k):
  d.append(int(input()))
  a[i]=input().split()
  for j in range(d[i]):
    al.append(a[i][j])
  
al=set(al)
print(str(n-len(al)))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
b=[0]*n
for i in range(k):
    m=int(input())
    a=list(map(int,input().split()))
    for j in range(len(a)):

            b[a[j]-1]+=1

print(b.count(0))

Submission status: Accepted

Solution code:
from collections import Counter

N, K = map(int, input().split())
cnt=[0]*(N+1)
for i in range(K):
  n = int(input())
  a = list(map(int, input().split()))
  for j in range(n):
    cnt[a[j]] +=1
print(cnt.count(0)-1)

Submission status: Accepted

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

dlst = sum(dlst, [])
dlst = set(dlst)
print(n - len(dlst))

Submission status: Accepted

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

A = [0 for _ in range(N)]

for _ in range(K):
  d = int(input())
  L = input().split()
  L = [int(x) for x in L]
  for x in L:
    A[x-1] +=1
c = 0
for x in A:
  if x == 0:
    c +=1
print(c)

Submission status: Accepted

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

x = []
for i in range(N):
    x.append(1)

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for num in A:
        x[num-1] = 0

count = 0
for num in x:
    if num == 1:
        count += 1

print(count)

Submission status: Accepted

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

pe=[0]*N

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

Submission status: Accepted

Solution code:
def task(n, k, ak):
    table = {}

    for i in range(1, n + 1):
        table[i] = False

    for a in ak:
        for snack in a:
            table[snack] = True

    total = 0
    for flag in table.values():
        if not flag:
            total += 1

    print(total)


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

task(n, k, ak)

Submission status: Accepted

Solution code:
def flatten_by_extend(nested_list):
  flat_list = []
  for e in nested_list:
    flat_list.extend(e)
  return flat_list


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

a = set(flatten_by_extend(a))
print(n - len(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
[N, K] = list(map(int, input().split()))
A_list = []
x = 0
for i in range(K):
  u = input()
  B_list = list(map(int, input().split()))
  A_list = A_list + B_list
for j in range(1,N+1):
  if not j in A_list:
    x = x + 1
print(x)

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
a = [0] * n

for i in range(k):
    d = ii()
    at = li()
    for j in at:
        a[j-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())

xs = [0] * n

for _ in range(0, k):
    input()
    tmp = map(int, input().split())
    for index in tmp:
        xs[index - 1] += 1

ans = 0
for a in xs:
    if a < 1:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
n, k = list(map(int, input().split()))

d_a = stdin.readlines()

a_s = [0] * n

for i in range(1, k * 2 + 1, 2):
    l_s = [int(x) for x in d_a[i].rstrip().split()]
    for n in range(len(l_s)):
        a_s[l_s[n]-1] = 1

res = 0
for su in range(len(a_s)):
    if a_s[su] == 0:
        res = res + 1

print(res)

Submission status: Accepted

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

c=[]

for i in range(k):

    d.append(input())

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

    for o in range(len(a)):

        c.append(a[o])

b=list(set(c))

print(n-len(b))

Submission status: Accepted

Solution code:
N,K =map(int,input().split())
have=[0]*N
for i in range(K):
    d=int(input())
    a_list=list(map(int,input().split()))
    for pick in a_list:
        have[pick-1]+=1

#print(have)
cnt=0
for chk in have:
    if(chk==0):
        cnt+=1
print(cnt)

Submission status: Accepted

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

sunukes = [0]*N

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

    for l in lis:
        sunukes[l-1] += 1

ans = 0
for s in sunukes:
    if s == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
M = set()
S = set(range(1, N + 1))
for _ in range(K):
    d = int(input())
    M = M | set(map(int, input().split()))
ans = len(S - M)
print(ans)

Submission status: Accepted

Solution code:
import collections
n,k=input().split()
n=int(n)
k=int(k)
z=[]
for i in range(k):
    d=int(input())
    x=list(input().split())
    for i in range(d):
        z.append(x[i])
c = collections.Counter(z)
y=n-(len(c))
print(y)

Submission status: Accepted

Solution code:
from collections import Counter
import itertools


def main():
    N, K = (int(x) for x in input().split())
    A = []
    for i in range(K):
        d = int(input())
        A.append([int(x) for x in input().split()])
    A = itertools.chain.from_iterable(A)
    p = Counter(A)
    print(N-len(p))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = []
for i in range(K):
    d =int(input())
    r = input().split()
    for y in r:
        l.append(int(y))
    
ans = len(set(l))
print(N - ans)

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()))
    for a in A:
        ans[a] = 1

print(n-sum(ans.values()))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = map(int, input().split())
    snuke = [0] * n
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            snuke[j - 1] += 1
    print(snuke.count(0))

Submission status: Accepted

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

print(n-len(set(t)))

Submission status: Accepted

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

agent = [False] * (N+1)
agent[0] = True
for _ in range(K):
    _ = input()
    A = list(map(int, input().split()))
    for a in A:
        agent[a] = True

# print(agent)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
m=[1 for i in range(n)]
for _ in range(k):
    d=int(input())
    x=list(map(int,input().split()))
    for i in x:
        m[i-1]=0
ans=0
for i in m:
    if i==1:
        ans+=1
print(ans)