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())
snuke=[0]*n
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for i in a:
        i-=1
        snuke[i]+=1
ans=0
for i in snuke:
    if i==0:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def ox(s, i):
	return s[i]=="o"


def main():
	n,k=nextIntList()
# 	aa=[]
	s=set()
	for ki in range(k):
		d=nextIntList()[0]
		ai=nextIntList()
# 		aa.append(ai)
		s.update(ai)
	c=0
	for ni in range(1,n+1):
		if ni not in s:
			c+=1
	print(c)
	
	
if __name__=="__main__":
	main()

Submission status: Accepted

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

answer = n

for i in range(k):
  d0 = int(input())
  d.append(d0)
  a = list(map(int,input().split()))
  aa.extend(a)
  
for i in range(n):
  if aa.count(i + 1) > 0:
    answer -= 1
    
print(answer)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
#a = [int(i) for i in read().split()]

n,k = [int(i) for i in readline().split()]

res = [0]*n
for i in range(k):
    d = input()
    d = [int(i) for i in readline().split()]
    for i in d:
        res[i-1] = 1

print(res.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
mochi = set([])
zenbu = set(list(range(1,N+1)))

for k in range(K):
    di = int(input())
    AAi = list(map(int,input().split()))
    for a in AAi:
        mochi.add(a)
        
print(len(zenbu - mochi))

Submission status: Accepted

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

check = [False] * N
for a in A:
    for aa in a:
        if not check[aa - 1]:
            check[aa - 1] = True


print(N - sum(check))

Submission status: Accepted

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

print(sum(Trick))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
for i in range(K):
  d=input()
  #A.append(list(map(int, input().split())))
  A.extend(map(int, input().split()))
#print(A)
B=set(A)
count=0
for i in range(1,N+1):
  if i not in B:
    count+= 1

print(count)

#for i in

Submission status: Accepted

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

has_sweets = [False] * n
for i in range(k):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        has_sweets[a - 1] = True

cnt = has_sweets.count(False)

print(cnt)

Submission status: Accepted

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

temp_list = [1] * (n + 1)
temp_list[0] = 0
for _ in range(k):
    d = int(input())
    a_list = [int(x) for x in input().split()]
    for a in a_list:
        temp_list[a] = 0
print(sum(temp_list))

Submission status: Accepted

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

mp = {}
for i in range(1, N+1):
    mp[i] = 0
for _ in range(K):
    _ = int(input())
    A = list(map(int, input().split()))
    for a in A:
        mp[a] += 1
ans = 0
for i in mp.values():
    if i == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

a=set(a)
cnt=0
for i in range(1,n+1):
  if i not in a:
    cnt+=1
print(cnt)

Submission status: Accepted

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

n_li = [0]*n
for i in range(k):
    d = int(input())
    a_input = [int(i) for i in input().split()]
    for a in a_input:
        n_li[a-1]+=1

print(len([i for i in n_li if i==0]))

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    snuke.update(set(A))

ans = n - len(snuke)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
n, k = list(map(int, input().split()))
d = [0]*k
A = []
for i in range(k):
    d[i] = int(input())
    A.extend(list(map(int, input().split())))
# print(set(A))

print(n-len(set(A)))

Submission status: Accepted

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

ans = np.array([0 for _ in range(n)])

for i in range(k):
    d = int(input())
    al = [int(i) -1 for i in input().split()]
    for j in al:
        ans[j] = 1 if ans[j] == 0 else ans[j]
        

print(n - np.count_nonzero(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for k in range(K):
    d = int(input())
    A = set(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 = map(int,input().split())
p = []
for _ in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(d):
        if a[i] not in p:
            p.append(a[i])
print(n-len(p))

Submission status: Accepted

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

cnt = [0] * n

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

print(cnt.count(0))

Submission status: Accepted

Solution code:
import numpy as np
n,k=list(map(int,input().split()))
t=np.zeros(n)
for i in range(k):
  d=int(input())
  tmp=list(map(int,input().split()))
  for j in range(d):
    t[tmp[j]-1] = 1

ans=n-np.sum(t)
print(int(ans))

Submission status: Accepted

Solution code:
def main():
    N,K=map(int,input().split())
    ans=[i for i in range(1,N+1)]
    for _ in range(K):
        d = int(input())
        A=[int(_) for _ in input().split()]
        for a in A:
            if a in ans:
                ans.remove(a)
    print(len(ans))

main()

Submission status: Accepted

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

snuke = [0] * (n+1)

for i in range(k):
    for j in range(d[i]):
        snuke[a[i][j]] += 1
ans = -1
for s in snuke:
    if s==0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans = [False]*n
for i in range(k):
  b = int(input())
  A = list(map(int,input().split()))
  for a in A:
    ans[a-1] = True

print(n-sum(ans))

Submission status: Accepted

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

for _ in range(K):
  D = 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(' '))

res = set()
for i in range(k):
    d = int(input())
    a = list(map(int, input().split(' ')))
    for j in a:
        res.add(j)
print(n-len(res))

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lst1 = [0]*n

for i in range(k):
    d = int(readline())
    lst2 = list(map(int,readline().split()))
    for j in lst2:
        lst1[j-1] += 1

ans = 0
for i in lst1:
    if i == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

sunuke = [0] * N
for i in range(K):
    for x in A[i]:
        sunuke[x-1] += 1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


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





if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,k = I2()
    l = [1]*n
    for i in range(k):
        d = I()
        a = Intl()
        for i in a:
            l[i-1] = 0
    print(sum(l))

Submission status: Accepted

Solution code:
from itertools import chain


def flatten(list_of_lists):
    return chain.from_iterable(list_of_lists)


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

As = set(flatten(As))
print(N - len(As))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [0] * N
for _ in range(K):
  d = input()
  lists = map( int, input().split() )
  for j in lists:
    l[j-1] += 1
cnt = 0
for i in l:
  if i == 0:
    cnt += 1
print( cnt )

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 j in range(len(A)):
    ans.append(A[j])
aaa = set(ans)
print(n-len(aaa))

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

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

print(ans.count(0))

Submission status: Accepted

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

all_group = set([i for i in range(1, n+1)])
has_group = set()
for i in range(k):
    d = input()
    a = set(list(map(int, input().split())))
    has_group |= a

print(len(all_group - has_group))

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 range(d):
        sunuke[A[j]-1] = 1
ans = N - sum(sunuke)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# process
ans = 0
for i in range(1, N+1):
    if not i in A:
        ans += 1

# output
print(ans)

Submission status: Accepted

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


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


main()

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()

used = [1]*N
for i in range(K):
  d = I()
  a = IL()
  for j in a:
    used[j-1] = 0

print(sum(used))

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
d = []
nums = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    a = [int(x) for x in input().split()]
    for a_i in a:
        nums[a_i - 1] += 1

count = 0
for num in nums:
    if num == 0:
        count += 1
print(count)

Submission status: Accepted

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

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

print(per.count(False))

Submission status: Accepted

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

Submission status: Accepted

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

# print(A)

snuke = [False] * N
for i in range(K):
    for j in range(d[i]):
        snuke[A[i][j] - 1] = True
# print(snuke)
print(snuke.count(False))

Submission status: Accepted

Solution code:
from collections import Counter

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

sunuke = [0]*N
for i, A_list in okasi:
    for k in A_list:
        sunuke[k-1] += 1

print(Counter(sunuke)[0])

Submission status: Accepted

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

ans_set = set()
for i in range(K):
    _ = int(input())
    ans_set |= set(list(map(int, input().split())))

print(N - len(ans_set))

Submission status: Accepted

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

Submission status: Accepted

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

ans=[False]*n

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

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

print(pr)

Submission status: Accepted

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

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

S=[0]*N
for i in range(K):
    d=int(input())
    A=input().split()
    for j in range(d):
        a=int(A[j])-1
        S[a]+=1

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

print(ans)

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

n,k = mp()
dt = {}
for i in range(1,n+1):
    dt[i] = 0
for i in range(k):
    d = inp()
    x = ip()
    for i in x:
        dt[i] = 1
print(list(dt.values()).count(0))

Submission status: Accepted

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

L = [1]*N
for i in range(K):
    B = A[i]
    for S in B:
        L[S-1]=0

print(sum(L))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, k = map(int, input().split())
    d = []
    a = []
    for i in range(k):
        d.append(int(input()))
        a.append(list(map(int, input().split())))
    snuke = [0] * n
    for i in range(k):
        for j in range(d[i]):
            snuke[a[i][j]-1] += 1
    ans = 0
    for i in range(n):
        if snuke[i] == 0:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

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

#d=int(input())
a = [1]*(n+1)
for i in range(k):
    di=input()
    *aij,=map(int, input().split( ))
    for ij in aij:
        a[ij]=0
print(sum(a)-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
have=set()
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for a in A:
    have.add(a)
ans=0
for n in range(N):
  n+=1
  if n not in have:
    ans+=1
print(ans)

Submission status: Accepted

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

snk = [0]*n

for i in range(k):
    d = int(input())
    ai = [int(i) for i in input().split()]
    for j in range(d):
        snk[ai[j]-1] = 1

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(N - len(have))

Submission status: Accepted

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

ans = n
for i in range(n):
    if a[i] != 0:
        ans -= 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

s = set()
for _ in range(k):
    d = int(input())
    a = map(int, input().split())
    for num in a:
        s.add(num)
print(n - len(s))

Submission status: Accepted

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

M = set([])
for i in range(N):
  M.add(i+1)

for i in range(K):
  d = int(input())
  L = list(map(int, input().split()))
  for j in range(len(L)):
    if L[j] in M:
      M.remove(L[j])

print(len(M))

Submission status: Accepted

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

s=[0]*n

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
D=[]
A=[0 for _ in range(N)]
for _ in range(K):
    d=int(input())
    a=map(int,input().split())
    D.append(a)
for z in D:
    for y in z:
        A[y-1]+=1
print(A.count(0))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ans = 0
c = [0]*N
da = [list(map(int,input().split())) for _ in range(K*2)]

for i in range(len(da)):
  if i%2==0:
    continue
  else:
    for j in da[i]:
      c[j-1]+=1
      
for i in c:
  if i==0:
    ans+=1
    
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
tmp = set()
for i in range(K):
    d = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    tmp = tmp | set(A)
print(len(set(range(1,N+1))-tmp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(trick))

Submission status: Accepted

Solution code:
def main():
    N,K = map(int,input().split())
    have = set()
    for _ in range(K):
        d = int(input())
        a = list(map(int,input().split()))
        for z in a:
            have.add(z)
    print(N-len(have))
if __name__ == "__main__":
    main()

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 i in a:
    if ans[i-1] != 0:
      ans[i-1] = 0
print(sum(ans))

Submission status: Accepted

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

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

print(n-len(a_all_list))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
    num = int(input())
    D = [int(j) for j in input().split(" ")]
    for d in D:
        n[d-1] += 1

ans = 0
for i in n:
    if i == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

def input_one_number():
    return int(input())

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

def input_multiple_number_as_list():
    return list(map(int, input().split()))

N,K = input_multiple_number()

isTaz = [True]*N

for i in range(K):
	d = int(input())
	a = input_multiple_number_as_list()
	for _a in a:
		isTaz[_a-1] = False

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

print(ans)

Submission status: Accepted

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

for k in range(K):
  d = int(input())
  A = list(map(int, input().strip().split()))
  S = S - set(A)
  
print(len(S))

Submission status: Accepted

Solution code:
# 2020/05/03
# AtCoder Beginner Contest 166 - B

# Input
n, k = map(int,input().split())
snlist = [0] * (n + 1)

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

ans = 0
for k in range(1, n+1):
    if snlist[k] == 0:
        ans = ans + 1

# Output
print(ans)

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 = map(int, input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

l = [0] * N

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

print(l.count(0))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
f = []
for _ in range(k):
  x = int(input())
  l = list(map(int,input().split()))
  for i in range(len(l)):
    f.append(l[i])
f = set(f)
print(n-len(f))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split(" "))
ans = N
snuke = [False] * (N + 1)
for i in range(K):
    d = int(input())
    A = list(map(int,input().rstrip().split(" ")))
    for i2 in range(d):
        if snuke[A[i2]] == False:
            snuke[A[i2]] = True
            ans -= 1
print(ans)