Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

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

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    tlist = []
    for i in range(K):
        di = int(input())
        li = list(map(int, input().split()))
        tlist += li
    tset = set(tlist)
    print(N-len(tset))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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 a:
        s[j - 1] += 1

print(s.count(0))

Submission status: Accepted

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, K = MAP()

s = [0] * N
d, A = [], []
for i in range(K):
    d = INT()
    ai = LIST()
    for aii in ai:
        s[aii-1] += 1

print(s.count(0))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    # input
    N, K = map(int, readline().split())
    okashi = [0] * N
    for i in range(K):
        d = int(input())
        A = list(map(int, readline().split()))
        for a in A:
            okashi[a-1] += 1
    
    ans = 0
    for o in okashi:
        if o == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
a = []
for i in range(k):
    d = int(input())
    a += list(map(int, input().split()))
print(n - len(set(a)))

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################
def f():
    return
def main():
    n,k=map(int,input().split())
    S=set()
    for a in range(k):
        input()
        A=list(map(int,input().split()))
        for b in A:
            S.add(b)
    print(n-len(S))
main()

Submission status: Accepted

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

A = []

for k in range(K):
    d = input()
    A+=input().split()
ans = N - len(set(A))

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().strip().split())
ls = [0]*n
for _ in range(k):
    d = int(input())
    temp = list(map(int,input().strip().split()))
    for val in temp:
        ls[val-1] = 1
c = 0
for val in ls:
    if val==0:
        c += 1
print(c)

Submission status: Accepted

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

for _ in range(k):
    _d = int(input())
    for a in input().split():
        i = int(a) - 1
        lis[i] = True

print(len(list(filter(lambda a: not a, lis))))

Submission status: Accepted

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

for j in range(k):
    dlist.append(int(input()))
    tmplist=list(map(int,input().split()))
    for tmp in tmplist:
        if tmp in alist:
            alist.remove(tmp)

print(len(alist))

Submission status: Accepted

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

B = [False for _ in range(N + 1)]
for _ in range(K):
    _ = input()
    for i in map(int, input().split()):
        B[i] = True

ans = 0
for i in range(1, N + 1):
    if not B[i]:
        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 = set(list(a) + list(map(int, input().split())))

print(n-len(a))

Submission status: Accepted

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

Submission status: Accepted

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

ls = set()

for k in range(K):
    d = input()
    A = list(map(int, input().split()))
    for a in A:
        ls.add(a)

print(N - len(ls))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k =map(int, input().split())
used = [False] * (n + 10)
for i in range(k):
    x = int(input())
    #print("x", x)
    dat = list(map(int, input().split()))
    #print(dat)
    for j in range(len(dat)):
        used[dat[j]] = True
res = 0
#print(used)
for i in range(n):
    #print(i)
    if used[i + 1] is False:
        res += 1
print(res)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n, k = map(int, input().split())
    s = set()

    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            if j not in s:
                s.add(j)
    
    ans = n - len(s)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    n,k = na()
    ans = [i for i in range(n)]
    for _ in range(k):
        d = ni()
        As = na()
        for a in As:
            if a-1 in ans:
                ans.remove(a-1)
    print(len(ans))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
cnt={}
for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for j in a:
    if j in cnt:  
      pass
    else:
      cnt[j]=1
print(n-len(cnt))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
v = [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):
    v[a[j]-1] += 1
ans = 0
for i in range(n):
  if v[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):
  input()
  for a in input().split():
    l[int(a)-1]+=1
print(l.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
cands = [0] * N
for i in range(K):
    _ = readline()
    a = list(map(int, readline().split()))
    for x in a:
        cands[x - 1] += 1


def solve():
    # print(cands)
    return sum(1 for c in cands if c == 0)


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    N, K = map(int, input().split())
    T = [0] * N
    for _ in range(K):
        d = int(input())
        for a in map(int, input().split()):
            T[a-1] += 1
    print(len([1 for t in T if 0 == t]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = [0]*n

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

Submission status: Accepted

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

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 i in range(d):
        S[A[i]-1]+=1
t=0
for i in range(n):
    if S[i]==0:
        t+=1
print(t)

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

print(S.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().strip().split())

snukes = [0] * N
for i in range(K):
    d = int(sys.stdin.readline().strip())
    A = list(map(int, sys.stdin.readline().strip().split()))
    for a_i in A:
        snukes[a_i-1] += 1

ans = 0
for count in snukes:
    if count == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

sunuke_list = [0 for i in range(n)]

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


n,k = MI()
d = []
a = []
for _ in range(k):
	tmp = II()
	d.append(tmp)
	tmp = LI()
	for i in (tmp):
		a.append(i)
p = n -len(list(set(a)))
print(p)

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 = [int(i) for i in input().split()]
    for j in a:
        A[j-1] += 1
    
print(A.count(0))

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


N, K = readnums()
d = []
A = []
for _ in range(K):
    d = readint()
    a = list(readnums())
    for x in a:
        A.append(x)

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

Submission status: Accepted

Solution code:
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())

n,k=mi()
m=[0]*(n+1)
for i in range(k):
    d=ii()
    a=li()
    for i in a:
        m[i]+=1
        
m=m[1:]
print(m.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print(s)

Submission status: Accepted

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

print(sum(Flag))

Submission status: Accepted

Solution code:
import numpy as np
import math
n,k = map(int,input().split())
ans = [0 for i in range(n+1)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        if ans[j] == 0:
            ans[j] += 1

num = 0
for i in ans:
    num += i

print(n-num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

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 a in A:
        if ans[a-1]==0:
            ans[a-1]=1

print(n-sum(ans))

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


def input():
    return stdin.readline().strip()

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, K = [int(str) for str in input().strip().split()]


def solve():
    is_have = [False] * N
    for k in range(K):
        d = int(input().strip())
        A = [int(str) - 1 for str in input().strip().split()]
        for a in A:
            is_have[a] = True
    print(sum([1 for a in is_have if not a]))


solve()

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 = [1] * n
for x in a:
    for i in x:
        ans[i - 1] = 0

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(x) for  x in input().split()]
l = []
for i in range(K):
  d = int(input())
  l2 = [int(x) for x in input().split()]
  for j in range(d):
    if l2[j] not in l:
      l.append(l2[j])
print(N - len(l))

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

Submission status: Accepted

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

ans = len([1 for x in s if x == 0])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

treat = [1 for i in range(n)]

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

print(sum(treat))

Submission status: Accepted

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

a=[]

for i in range(n+1):
	a.append(0)

for i in range(k):
	d=int(input())
	temp=[int(x) for x in input().split()]
	for j in range(d):
		a[temp[j]]=1

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys, bisect, math, itertools
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, k = inpl()
ans={i for i in range(1,n+1)}
for i in range(k):
    d = inp()
    a=set(map(int, input().split()))
    ans -= a
print(len(ans))

Submission status: Accepted

Solution code:
(N, K) = tuple([int(s) for s in input().split()])
d = {i: 0 for i in range(1, N + 1)}
for _ in range(K):
    n = int(input())
    A = [int(s) for s in input().split()]
    for a in A:
        d[a] += 1
print(len([i for i in d if d[i] == 0]))

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 A:
        L[j-1] += 1
print(len([i for i in L if i == 0]))

Submission status: Accepted

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

b=[0]*N

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

    for ai in a:
        b[ai-1]-=1

print(b.count(0))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:39 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

#graph = [[] for _ in range(N+1)]
#for _ in range(N-1):
#    a, b = map(lambda x : int(x)-1, input().split())
#    graph[a].append(b)
#    graph[b].append(a)

su = [False for _ in range(N)]

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

ans = 0
for s in su:
    if not s:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n,k = map(int,input().split(" "))
    l =[True]*n
    for i in range(k):
        d = int(input())
        As = list(map(int,input().split(" ")))
        for A in As:
            l[A-1] = False
    
    print(l.count(True))
main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().rstrip().split())
# print(N, K)
l = []
for _ in range(K):
    d = input().rstrip()
    As = [int(x) for x in input().rstrip().split()]
    l.extend(As)
    # print(d, As)
print(N - len(set(l)))

Submission status: Accepted

Solution code:
# coding:utf-8

N, K = map(int, input().split(' '))
l = []
for _ in range(K):
    d = input()
    i = input().split(' ')
    l += i
    l = list(set(l))

print(N - len(l))

Submission status: Accepted

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

print(sum(people))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)


def main():
    N, K = map(int, input().split())
    nums = [0] * N
    for i in range(K):
        _ = int(input())
        A = [int(c) for c in input().split()]
        for a in A:
            nums[a-1] += 1

    num = 0
    for i in range(N):
        if nums[i] == 0:
            num += 1

    print(num)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for _ in range(K):
  d = int(input())
  A = [int(i) for i in input().split()] 
  for a in A:
    if lis[a-1] == 0:
      lis[a-1] = 1
      
print(N - sum(lis))

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 j in a:
        ans[j-1]=1
print(n-sum(ans))

Submission status: Accepted

Solution code:
from sys import stdin
[N, K] = [int(x) for x in stdin.readline().rstrip().split()]

sunuke = [0 for _ in range(N)]
for i in range(K):
    d = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    for j in range(d):
        sunuke[As[j]-1] += 1

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

print(tot)

Submission status: Accepted

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

Submission status: Accepted

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

# initialization
p_list = [0]*N

# count
for i in range(K):
    d = int(input())
    a_nums = list(map(int, input().split()))
    for j in range(d):
        p_list[a_nums[j]-1] += 1

# check
ans = 0
for i in range(N):
    if p_list[i]==0:
        ans += 1

# output
print(ans)

Submission status: Accepted

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

count = [1]*n

for i in range(k):
  m = int(input())
  lst = list(map(int, input().split()))
  for j in range(m):
    if count[lst[j]-1] == 1:
      count[lst[j]-1] = 0

print(sum(count))

Submission status: Accepted

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

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

for i in range(k):
    input()
    snk = [int(a)-1 for a in input().split()]
    for j in snk:
        count[j] += 1

ans = 0
for c in count:
    if c == 0:
        ans += 1

print(ans)

Submission status: Accepted

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


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

print(boys.count(0))

Submission status: Accepted

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

print(N-sum(sunuke))

Submission status: Accepted

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

suke = set()
for _ in range(k):
  _ = input()
  suke |= set([int(i) for i in input().split()])
  
l = list(set(range(1,n+1)) - suke)
print(len(l))

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = [int(x) for x in input().split()]
snukes = defaultdict(list)
for i in range(K):
    d, = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    for x in A:
        snukes[x].append(i)
count = 0
for i in range(1, N + 1):
    if len(snukes[i]) == 0:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split(' '))
sunuke=set()
for k in range(K):
    d=int(input())
    a=list(map(int,input().split(' ')))
    for i in range(d):
        sunuke.add(a[i])

print(N-len(sunuke))

Submission status: Accepted

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

print(n-len(s))

Submission status: Accepted

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