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:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

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

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

nn=[i for i in range(1,n+1)]
for i in range(k):
    for j in range(d[i]):
        #print(a[i][j])
        if a[i][j] in nn:
            nn[a[i][j]-1]=0

#print(nn)
cnt=0
for i in range(len(nn)):
    if nn[i]!=0:
        cnt+=1
print(cnt)

Submission status: Accepted

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

ans=0
for i in range(1,N+1):
    if i in A:
        continue
    else:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().split())
d = []
A = []
for i in range(K):
    temp_d = int(sys.stdin.readline())
    temp_A = list(map(int, sys.stdin.readline().split()))
    d.append(temp_d)
    A.append(temp_A)

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

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

print(N - len(set(sss)))

Submission status: Accepted

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

l = [1] * N

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

print(sum(l))

Submission status: Accepted

Solution code:
import math

def resolve():
    N, K= map(int, input().split())
    A_list = []
    ans_list = []

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

    print(N - len(set(ans_list)))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

s = set()

for i in range(k):
    d = int(input())
    p = map(int, input().split())
    for j in p:
        s.add(j)

print(n-len(s))

Submission status: Accepted

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

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

A.sort

for k in range(1, N+1):
  if k in A:
    continue
    
  else:
    ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
arr = []
for i in range(K):
    C = int(input())
    A = list(map(int, input().split()))
    for ele in A:
        if ele not in arr:
            arr.append(ele)

print(N-len(arr))

Submission status: Accepted

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

Submission status: Accepted

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

d_list = []
a_list = []
for k_tmp in range(k):
    d_tmp=int(input())
    d_list.append(d_tmp)
    a_list_tmp = list(map(int,input().split()))
    a_list.append(a_list_tmp)

ans_set = set()
for i in range(len(a_list)):
    for j in range(len(a_list[i])):
        ans_set.add(a_list[i][j])

print(n - len(ans_set))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n,k=map(int,input().split())
l=[]
for i in range(k):
    d=input()
    a=list(map(int,input().split()))
    l+=a
s=set(l)
print(n-len(s))

Submission status: Accepted

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

b={i:0 for i in range(1,n+1)}

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

count=0
for i in range(1,n+1):
  if b[i]==0:
    count+=1
print(count)

Submission status: Accepted

Solution code:
# ABC166 B

def main():
    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
    
    print(sunuke.count(0))



if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(n - len(a))

Submission status: Accepted

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

while True:
    try:
        d.append(int(input()))
        a.append(list(map(int,input().split())))
    except:
        break
        
anslist = [0]*n
cnt = 0
for i in range(k):
    for j in range(d[i]):
        anslist[a[i][j]-1] +=1
        
for i in anslist:
  if i==0:
    cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def main():
    N,K = MAP()
    have = [False]*N

    for i in range(K):
        d = INT()
        A = LI()

        for a in A:
            have[a-1] = True
    
    answer = 0
    for i in range(N):
        if not have[i]:
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    a_list = [False] * n
    for i in range(k):
        v = int(input())
        for j in input().split():
            a_list[int(j)-1] = True

    ans = len([i for i in a_list if i == False])
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

A=[]

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

print(N-len(set(A)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
hoge = []
cnt = 0
for i in range(k):
    d = int(input())
    c = list(map(int,input().split()))
    for i in range (len(c)):
        hoge.append(c[i])
for i in range (n):
    if i+1 in hoge:
        cnt += 0
    else:
        cnt += 1
print(cnt)

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in range(len(a)):
        dic[a[i]-1] = 1

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

print(ans)

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 A:
    a[j-1]+=1
print(a.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
list = [0] * N
# K個のお菓子について
for i in range(K):
    d = int(input())
    for j in (int(x) for x in input().split()):
        list[j-1] = 1
count = 0
for i in list:
    if i == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
def main():
    n, k = [int(e) for e in input().split()]
    D = []
    A = []
    for i in range(k):
        D.append(input())
        A.append([int(e) for e in input().split()])

    S = set()
    for Aa in A:
        S = S.union(Aa)

    print(n - len(S))


if __name__ == '__main__':
    main()

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(len(a)):
        A[a[j]-1] += 1

ans = 0
for i in range(len(A)):
    if A[i] == 0:
        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 = map(int, input().split())
  for j in A:
    l.append(j)
l = set(l)
print(N - len(l))

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

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    lst = list(map(int, input().split()))
    for num in lst:
        aly[num - 1] = 1

print(aly.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

flag = 0
for i in a:
    if i == 0:
        flag += 1
        
print(flag)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

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

  ary = set([i+1 for i in range(N)])
  mem = set([])
  for i in range(K):
    sumN = int(input())
    for i in list(map(int, input().split())):
      mem.add(i)

  print(len(ary - mem))

if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

print(N - len(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

for l in on:
    if l == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

s = [0]*n

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

print(s.count(0))

Submission status: Accepted

Solution code:

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

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

import numpy as np

S = np.zeros(N)
for i in A:
    for j in i:
        S[j-1] += 1
    
count = 0
for i in S:
    if i == 0:
        count += 1
    
print(count)

Submission status: Accepted

Solution code:
from collections import Counter
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())))
print(n - len(list(Counter(a))))

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [1]*n
for i in range(k):
  d = int(input())
  motterus = list(map(int, input().split()))
  for motteru in motterus:
    sunuke[motteru-1] = 0
 
print(sum(sunuke))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    K = first_input[1]

    sunuke_list = [0]*N
    for i in range(K):
        _dummy = input()
        current_input = list(map(lambda x:int(x), input().split(" ")))
        for j in current_input:
            sunuke_list[j-1] = 1

    print(N-sum(sunuke_list))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
has = set()
for _ in range(k):
    input()
    has.update(map(int, input().split()))

no_has = set(range(1, n+1)) - has
print(len(no_has))

Submission status: Accepted

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

sunuke = [0]*N
okashi = []

for i in range(K):
    gomi = input()
    temp = input().split()
    okashi.append(temp)
    
    


for i in range(len(okashi)):
    for j in okashi[i]:
        sunuke[int(j) - 1] += 1
        

count = 0

for i in range(N):
    if sunuke[i] == 0:
        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())))

snk = [0]*n

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

c = 0
for i in range(n):
	if snk[i] == 0:
		c += 1

print(c)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    dictionary={}
    N,K=map(int,input().split())
    for i in range(K):
        d=int(input())
        A=[int(x) for x in input().split()]
        for num in A:
            if num in dictionary:
                dictionary[num]+=1
            else:
                dictionary[num]=1
                
     
    d=deque()            
    for key in sorted(dictionary.keys()):
        d.append(key)
    
    print(N-len(d))
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

for i in range(K):
    d.append(int(input()))
    trick.append(input().split())

for i in range(K):
    tmp = d[i]
    for j in range(tmp):
        child[int(trick[i][j]) - 1] += 1
        
print(child.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[]
c=[1]*n
for i in range(k):
  input()
  a=a+input().split()
for j in range(n):
  if a.count(str(j+1))>0:
    c[j]=0
print(sum(c))

Submission status: Accepted

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

okashi=[0]*n
for i in range(k):
    for j in alists[i]:
        if okashi[j-1]==0:
            okashi[j-1]=1

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

print(ans)

Submission status: Accepted

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

    print(C.count(0))

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
def b166(n, k):

    count = []
    for i in range(k):
        d = int(input())
        al = []
        a = 0
        if d == 1:
            a = int(input())
            count.append(a)
        else:
            al = list(map(int, input().split()))
            for w in al:
                count.append(w)

    return n - len(set(count))

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

A=set(A)
n=len(A)

print(N-n)

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

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

    have = set([])

    for i in range(K):
        have = have | set(A[i])

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

    trick = all - have

    print(len(trick))



main()

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n, k = wi()
    d = []
    a = []
    b = []
    cnt = 0
    for i in range(k):
        d = int(input())
        a.append(wi())
    for i in range(k):
        for j in a[i]:
            if j in b:
                continue
            else:
                b.append(j)
                cnt += 1
    print(n-cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ans=[None]*n
while k>0:
  d=input()
  a=list(map(int,input().split()))
  #print (d,a)
  for i in a:
    ans[i-1]=d
  k-=1
count=0
for item in ans:
  if item==None:
    count+=1
print (count)

Submission status: Accepted

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

Submission status: Accepted

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

have_treat = list()

for _ in range(k):
    _ = input()
    have_treat.extend(list(map(int,input().split())))

print(n-len(set(have_treat)))

Submission status: Accepted

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

a = [1] * n

for i in range(k):
  d = int(input())
  t = [num for num in map(int, input().split())]
  for j in range(d):
    idx = t[j]-1
    a[idx] = 0

print(sum(a))

Submission status: Accepted

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

s = set()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[]
for i in range(k):
    d=int(input())
    x=[int(w) for w in input().split()]
    for j in range(len(x)):
        if x[j] not in l:
            l.append(x[j])
    
s=[i for i in range(1,n+1)]
ans=0
for i in s:
    if i not in l:
        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.extend(int(a) for a in input().split())
print(max(0,N-len(set(A))))

Submission status: Accepted

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

# -- submit ----

# --- fetch input ---
inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---
n, k = [int(i) for i in inputs[0].split()]
snacks = inputs[1:]

nusukes = {i: False for i in range(1, 1 + n)}

for n, sn in enumerate(snacks):
    if n % 2 == 0:
        continue
    else:
        temp = [int(i) for i in sn.split()]
        for i in temp:
            nusukes[i] = True

counter = 0
for key, value in nusukes.items():
    if not value:
        counter += 1

print(counter)

Submission status: Accepted

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

for i in range(k):
    for j in range(d[i]):
        p[A[i][j]]=1
print(n-sum(p))

Submission status: Accepted

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

for i in range(k):
    d = input()
    a = set(list(input().split()))
    A = A | a

print(n - len(A))

Submission status: Accepted

Solution code:
import collections

N, K = map(int,input().split())
sunuke = [0]*N# for _ in range(N)]
for i in range(K):
    _ = input()
    n = map(int,input().split())
    for j in n:
        sunuke[j-1] +=1
sunuke = collections.Counter(sunuke)
#print(sunuke)
print(sunuke[0])

Submission status: Accepted

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

a = set(a)
ans = 0

for i in range(1, n+1):
    if not i in a:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
okasi = set()
for i in range(K):
    d = int(input())
    a = set(map(int, input().split()))
    okasi = okasi | a
N = set(i + 1 for i in range(N))
print(len(N - okasi))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
li_d=[]
li_A=[]
for i in range(k):
    li_d.append(int(input()))
    li_A.append(input().split())
li=[]
for i in range(k):
    lis=li_A[i]
    li=li+lis
li=list(set(li))
print(n-len(li))

Submission status: Accepted

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

Submission status: Accepted

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

L = [0]*N

for i in range(K):
  d = int(input())
  A = [int(j) for j in input().split()]
  for a in A:
    L[a-1] += 1
    
print(L.count(0))

Submission status: Accepted

Solution code:
inputLine=input()
N=int(inputLine.split(" ")[0])
K=int(inputLine.split(" ")[1])

A = []
for i in range(K):
    inputLine=input()
    d = int(inputLine)
    inputLine=input()
    A.append(inputLine.split(" "))

allSunukeStates=[]
for i in range(N):
    allSunukeStates.append(True)

for i in range(len(A)):
    for j in range(len(A[i])):
        allSunukeStates[int(A[i][j]) - 1] = False

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

print(result)

Submission status: Accepted

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

ans = b.count(0)
print(ans)

Submission status: Accepted

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

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 a in A:
    sunuke[a-1] = 1
    
print(sunuke.count(0))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
sunuke = {x: 0 for x in range(1, n + 1)}
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for x in a:
        sunuke[x] += 1
print(len([k for k, v in sunuke.items() if v == 0]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n, k = nm()
l = [0]*(n+1)
for _ in range(k):
    d = ni()
    f = nl()
    for x in f:
        l[x] += 1
g = sum(1 for i in range(1, n+1) if not l[i])
print(g)

Submission status: Accepted

Solution code:
# This was written by chizuchizu
import sys
# import collections

# import bisect
# import math
# import numpy as np
import itertools
"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    n, k = ip.IL()
    memo = ip.SILS(2*k)[1::2]
    memo = list(itertools.chain.from_iterable(memo))
    memo = list(set(memo))
    memo = [x - 1 for x in memo]
    new = [1 for _ in range(n)]
    for x in memo:
        new[x] = 0
    print(sum(new))
    # memo


main()

Submission status: Accepted

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

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

print(sum(1 for e in l if not e))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

print(n - len(s))