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())
A = [[0]* N for i in range(K)]
d = [0] * K
for i in range(K):
    d[i] = int(input())
    A[i][:] = map(int,input().split())
     
#print("d",d)
#print("A:",A)
ans = 0
count = [0] * (N+1)
for i in range(K):
    for j in range(d[i]):
        #print(A[i][j])
        count[A[i][j]]=1 # お菓子持っていたら1にする

#print(count)
for i in range(1,len(count)):
    if count[i]==0:
        ans +=1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split(' '))
a=[0 for i in range(n+1)]
for z in range(k):
  x=int(input())
  temp=map(int,input().split(' '))
  for i in temp:
    a[i]+=1
c=0
for i in range(1,n+1):
  if(a[i]==0):
    c+=1
print(c)

Submission status: Accepted

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

ans = [0]*n
for ki in range(k):
  d = int(input())
  al = map(int, input().split())
  for a in al:
    ans[a - 1] = ans[a - 1] + 1

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

print(cnt)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l = []
for k in range(K):
    a = int(input())
    lis=list(map(int,input().split()))
    l.extend(lis)
c=0
for j in range(N):
    if not j+1 in l:
        c+=1
print(c)

Submission status: Accepted

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


def main():
    import sys
    input = sys.stdin.readline

    n, k = map(int, input().split())
    count = [[] for _ in range(n)]

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

        for ai in a:
            count[ai - 1].append(i)

    ans = 0

    for c in count:
        if len(c) == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
 
snukes = [0] * N
for i in range(K):
  d_i = int(input()) # throw away
  a_i = map(int, input().split())
  for a in a_i:
    snukes[a-1] += 1
 
counter = 0
for i in range(N):
  if snukes[i] == 0:
    counter += 1
 
print(counter)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(sum(cur))

Submission status: Accepted

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

x = set()
for _ in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        x.add(a)

print(N - len(x))

Submission status: Accepted

Solution code:
def main() :
    N, K    = list(map(int, input().split()))
    sunukes = []
    for itr in range(N) :
        #お菓子もち・・・True
        sunukes.append(False)
    itr = 0

    for itr in range(K) :
        d = int(input())
        A = list(map(int, input().split()))
        for inner_itr in range(d) :
            sunukes[A[inner_itr] - 1] = True
        A = None
    
    count = 0
    for itr in range(N) :
        if sunukes[itr] == False :
            count+=1
    
    print(count)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

O = [1] * N

for i in range(K):
    d = int(input())

    for j in list(map(int, input().split())):
        O[j-1] = 0

print(sum(O))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
result = []
for i in range(K):
    d = int(input())
    x = [int(i) for i in input().split()]
    for i in x:
        if i not in result:
            result.append(i)

print(N - len(result))

Submission status: Accepted

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

x = set([i+1 for i in range(N)])
for _ in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        if a in x:
            x.remove(a)

print(len(x))

Submission status: Accepted

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

Submission status: Accepted

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

ans={0}
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    #print(A)
    for j in range(d):
        s=A[j]
        ans.add(s)

print(N-len(ans)+1)

Submission status: Accepted

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

sunuke = [1] * N

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

print(sum(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [1] * N

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split(' '))
a=list(range(1,N+1))
for i in range(K):
  count=int(input())
  b=[int(x.strip()) for x in input().split(' ')]
  for j in range(count):
    if b[j] in a:
      a.remove(b[j])
print(len(a))

Submission status: Accepted

Solution code:
N,K = map(int, input().split(' '))
a=list(range(1,N+1))
for i in range(K):
  count=int(input())
  b=input().split(' ')
  for j in range(count):
    if int(b[j]) in a:
      a.remove(int(b[j]))
print(len(a))

Submission status: Accepted

Solution code:
import numpy as np

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

d = []
ai = []
count = 0

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

for i in range(N):
    if i + 1 not in ai:
        count += 1

print(count)

Submission status: Accepted

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

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

B = [m + 1 for m in range(N)]
print(len(list(set(B) - set(A))))

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

list = [0 for i in range(N)]

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

print(list.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

for j in range(k):
  d.append(int(input()))
  A.append(list(map(int,input().split())))
  
  
for i in A:
  for j in i:
    if j in a:
      a.remove(j)
      
      
print(len(a)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[0 for i in range(n+1)] #要素ｎこのリスト
for t in range(k):
	K=int(input()) #どっから持ってきた dか？
	b=list(map(int,input().split())) #aかもしや
	for i in b: #bの要素を取り出す
		a[i]+=1
print(a.count(0)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

def main():
    sunukes, eating = map( int, input().split() )
    counts = [ 0 for _ in range(sunukes) ]

    for _ in range(eating):
        has = int( input() )
        having = list( map( int, input().split() ) )

        for i in range( len(having) ):
            counts[ having[i] - 1 ] += 1
    
    print(counts.count(0))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
NM=list(map(int,input().split()))
person=[0 for i in range(NM[0])]
for i in range(NM[1]):
    d=input() 
    snack=list(map(int,input().split()))
    for i in snack:
        person[i-1]=1
d=0
for i in range(len(person)):
    if person[i]==0:
        d+=1
print(d)

Submission status: Accepted

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

x = set()
for i in range(K):
    d = input()
    for i in input().split():
        x.add(i)
print(N - len(x))

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

x = set()
for n in range(K):
    d = input()
    for n in input().split():
        x.add(n)
print(N - len(x))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
pepele=set()
for _ in range(k):
    candies = input()
    pepele |= set(map(int, input().split()))

# listから重複を削除し
print(n-len(pepele))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
ans=n
done=defaultdict(lambda:False)
for _ in range(k):
    d=int(input())
    a=list(map(int,stdin.readline().split()))
    for i in a:
        if(i not in done):
            ans-=1
            done[i]=True
print(ans)

Submission status: Accepted

Solution code:
def resolve():
	n, k = map(int, input().split())
	seq = [0]*n
	for i in range(k):
		_d = int(input())
		g = list(map(int, input().split()))
		for p in g:
			seq[p-1] += 1
	print(seq.count(0))
resolve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
n = list(map(str, range(1, n+1)))

for i in range(k):
    _ = input()
    a = input().split()
    for ai in a:
        for ni in n:
            if ai == ni:
                n.remove(ai)
print(len(n))

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int,input().split())

sunuke = [0]*N

for i in range(K):
    d = input()
    a = input()
    for j in a.split():
        sunuke[int(j)-1] = 1


print(sunuke.count(0))

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
List=[list(map(int,input().split())) for i in range(2*K)]

a=[List[2*j+1] for j in range(K)]
print(N-len(set(sum(a,[]))))

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

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

sweet_people = []
for i in range(K):
  for j in range(d[i]):
  	sweet_people.append(A[i][j])
diff = all_people ^ set(sweet_people)
diff = list(diff)
print(len(diff))

Submission status: Accepted

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

A = [0] * n

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

    for j in A_okashi:
        if A[j-1] == 0:
            A[j-1] = 1

print (A.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

def main():
    number_of_human,number_of_sweets = map(int,input().split())
    
    human_own_information_list = []
    
    for sweets_number in range(number_of_sweets):
        number_of_own_human = int(input())
        own_human_list = list(map(int,input().split()))
        for own_human in own_human_list:
            if not own_human in human_own_information_list:
                human_own_information_list.append(own_human)
    
    result = 0
    for human_number in range(1,number_of_human+1):
        if not human_number in human_own_information_list:
            result += 1
    
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


print(l.count(0))

Submission status: Accepted

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

r = set()
for _ in range(k):
  d = int(input())
  r |= set(map(int, input().split()))
print(n-len(r))

Submission status: Accepted

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

Submission status: Accepted

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

for x in A:
  if x == 0:
    count +=1
print(count)

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:
N,K= (int(x) for x in input().split(' '))
N = [i for i in range(1,N+1)]
d_lst = []
for i in range(0,K):
    d = int(input())
    d_lst.append(d)
    A= [int(x) for x in input().split(' ')]
    N.extend(A)

print(len([x for x in set(N) if N.count(x) == 1]))

Submission status: Accepted

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

print(N-len(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
n, k = map(int, input().split())
a = []
for i in range(k):
    di = int(input())
    ai = list(map(int, input().split()))
    a.append(ai)

count=set()

for i in range(k):
    for j in range(len(a[i])):
        count.add(a[i][j])

print(n-len(count))

Submission status: Accepted

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

d = list()
[d.append(list(input().split())) for i in range(K * 2)]
print(N - len(set(sum(d[1::2], []))))

Submission status: Accepted

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

d = list()
d = [d + list(input().split()) for i in range(K * 2)]
print(N - len(set(sum(d[1::2], []))))

Submission status: Accepted

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

n = set()
for i in range(K):
    ds = input()
    n = n | set(input().split())

print(N - len(n))

Submission status: Accepted

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

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

print(N - len(n))

Submission status: Accepted

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

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

print(len(n) - sum(n))

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


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

for i in range(K):
    for j in range(len(A[i])):
        if(A[i][j] in non_given):
            non_given.remove(A[i][j])

print(len(non_given))

Submission status: Accepted

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

s = set()

for i in range(K):
    d = int(input())
    As = input().split()
    s |= set(As)

print(N - len(s))

Submission status: Accepted

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

n, k = map(int, input().split())
have = [0] * (n + 1)
for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for x in a:
		have[x] += 1
res = 0
for i in range(1, n + 1):
	if have[i] == 0:
		res +=1 
print(res)

Submission status: Accepted

Solution code:
n ,k = [int(x) for x in input().split()]
dg = [0]*(n+1)
while(k):
    di = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        dg[i]+=1
    k-=1

cnt = -1
for i in dg:
    cnt+=(i==0)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt.count(0))

Submission status: Accepted

Solution code:
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(' ')))))
    print(main(N, A))

Submission status: Accepted

Solution code:
m,t=map(int,input().split())
c=0
ar=[]
for i in range(t):
    n=(int)(input())
    l=list(map(int,input().split()))
    for i in range(n):
        ar.append(l[i])
ans=len(set(ar))
print(m-ans)

Submission status: Accepted

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

L = [True] * N
for i in range(K):
    d = input()
    l = [int(a.strip()) for a in input().split()]
    for a in l:
        L[a-1] = False

ans = sum(v==True for v in L)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

N = inp[0]
K = inp[1]

sunuke_w_okashi = []

for okashi in range(K):
    _ = input()
    inp = inp = list(map(int, input().split()))
    sunuke_w_okashi = sunuke_w_okashi + inp

num_sunuke_wo_okashi = N - len(set(sunuke_w_okashi))

print(num_sunuke_wo_okashi)

Submission status: Accepted

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

s_set = set()
for i in range(K):
    d = int(input())
    l_d = [int(x) for x in input().split()]
    for d in l_d:
        s_set.add(d)

print(N-len(s_set))

Submission status: Accepted

Solution code:
okashimochi_set = set()
N_set = set()

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

for n in range(N):
    N_set.add(n + 1)
    n = n + 1

for i in range(K):
    d = int(input())
    A = input().split()
    for a in range(d):
        okashimochi_set.add(A[a])

result = len(N_set) - len(okashimochi_set)
print(result)

Submission status: Accepted

Solution code:
def main():

    N, K = map(int, input().split())
    p = set()
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for i in range(d):
            p.add(A[i])
    return N - len(p)

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

n, k = [int(x) for x in input().split()]
s = set()
for _ in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        s.add(i)
ans = 0

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

print(ans)

Submission status: Accepted

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

print(n - len(set(okashi_lst)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A = [0] * N

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

print(A.count(0))

Submission status: Accepted

Solution code:
# Problem B - Trick or Treat

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

# initialization
snuke = [0]*N
ans = 0

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

# check
for s in snuke:
    if s==0:
        ans += 1

# output
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

# 入力読み込み
n, k = stdin.readline().rstrip().split()
n = int(n)
k = int(k)
A_lst = []

for i in range(k):
  d = int(stdin.readline().rstrip())
  a_lst = [int(a) for a in stdin.readline().rstrip().split()]
  A_lst.extend(a_lst)
    
A_set = set(A_lst)
print(n - len(A_set))

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        if j-1 in tricked_set:
            tricked_set.remove(j-1)

print(len(tricked_set))

Submission status: Accepted

Solution code:
import itertools

N,K = map(int,input().split())
sunuke = []

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

ans_li = list(itertools.chain.from_iterable(sunuke))

count = 0
for i in range(N):
    if i+1 not in ans_li:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Sunuke = [0 for i in range(N)]
S = 0
for i in range(K):
    d = int(input())
    d_list = list(map(int, input().split()))
    # print(d_list)
    for j in range(d):
        Sunuke[d_list[j]-1] += 1
for i in range(N):
    if Sunuke[i] == 0:
        S += 1
print(S)

Submission status: Accepted

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

while k:
    k -= 1
    d = int(input())
    ad = list(map(int,input().split()))
    for e in ad:
        a[e] = 1
print(a.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunukes = {i for i in range(1,N+1)}

for _ in range(K):
    d = int(input())
    sunukes_having = set(map(int, input().split()))
    sunukes -= sunukes_having

print(len(sunukes))

Submission status: Accepted

Solution code:
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*k

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

    syugou = syugou+a[i]

num = set(syugou)

print(n-len(num))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

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

n, k = na()
l = [1] * n
for i in range(k):
    d = ni()
    a = na()
    for i in range(d):
        l[a[i] - 1] = 0
print(sum(l))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# first line
N, K = list(map(int, input().rstrip().split()))

ans = []
for k in range(K):
    d = input().rstrip()
    for i in input().rstrip().split():
        ans.append(i)

print(N - len(set(ans)))

Submission status: Accepted

Solution code:
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, k = map(int, sys.stdin.readline().split())
    v = set()
    for i in range(k):
        d = int(sys.stdin.readline())
        a = list(map(int, sys.stdin.readline().split()))
        for i in a:
            v.add(i)
    print(n - len(v))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A = [int(i) for i in range(1,n+1)]
for _ in range(k):
	d = int(input())
	a = [int(i) for i in input().split()]
	for j in a:
		if j in A: A.remove(j) 
print(len(A))

Submission status: Accepted

Solution code:
N, K = [ int(i) for i in input().strip().split(' ') ]
counter = [ 0 for _ in range(N) ]
for k in range(K):
    d = int(input())
    for a in [ int(i) for i in input().strip().split(' ') ]:
        counter[a-1] += 1

c_0 = [ c for c in counter if c == 0]
print(len(c_0))

Submission status: Accepted

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

for i in range(N):
    A.append(0)

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = []
a = []
result = 0
for i in range(2 * k):
    if i % 2 == 0:
        d.append(int(input()))
    else:
        a.append(list(map(int, input().split())))

mem = [i + 1 for i in range(n)]
for i in range(n):
    for s in a:
        if (i + 1) in s:
            mem.remove(i + 1)
            break
        
print(len(mem))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
ans = []
for i in range(K):
    d = int(input())
    P = input().split() 
    for p in P:
        ans.append(p)
    # ans.append(P)
    # print(P)

ans = set(ans)
print(N-len(ans))

Submission status: Accepted

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

for i in range(1,N+1):
    list1.append(i)

for j in range(K):
    d =int(input())
    lista = list(map(int,input().split()))
    for l in lista:
        for h in list1:
            if (l==h):
                list1.remove(h)

print(len(list1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split(" "))
ar = [0 for i in range(a)]
for i in range(b):
    j = int(input())
    br = list(map(int,input().split(" ")))
    for r in br:
        ar[r-1] += 1
print(ar.count(0))