Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    c = collections.Counter()
    for _ in range(K):
        D = int(input())
        A = [int(x) for x in input().split()]
        for a in A:
            c[a] += 1

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

    print(ans)

        


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n, k = map(int, input().split())
a = [0]*(n+1)
a[0] = 1
for _ in range(k):
    _ = input()
    d = list(map(int, input().split()))
    for di in d:
        a[di] += 1
cnt = Counter(a)
if 0 in cnt:
    print(cnt[0])
else:
    print(0)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=set([])
for i in range(b):
  d=int(input())
  l=list(map(int,input().split()))
  for x in l:
    s.add(x)
print(a-len(s))

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [0] * N

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

    for i in has_okashi:
        sunuke[i - 1] += 1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
def main():
    N, K = (int(_) for _ in input().split())
    snuke = set(range(1, N+1))
    okashi = []
    for _ in range(K):
        d = int(input())
        okashi += [int(_) for _ in input().split()]
    snuke = snuke - set(okashi)
    print(len(snuke))
    return



if __name__ == '__main__':
    main()

Submission status: Accepted

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

candy = []
for i in range(k):
    d = int(input())
    l = [int(x) for x in input().split(' ')]
    candy += l
    
candy_set = set(candy)

print(n - len(candy_set))

Submission status: Accepted

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

arr = [[False] * k for _ in range(n)] # person, snack

for i in range(k):
    m = int(input())
    for p in map(int, input().split()):
        arr[p-1][i] = True

total = 0
for i in range(n):
    if not any(arr[i]):
        total += 1

print(total)

Submission status: Accepted

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

print(sunukes.count(0))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict
N, K = map(int, input().split())
count = defaultdict(int)
for _ in range(K):
    d = int(input().rstrip())
    A = list(map(int, input().split()))
    for a in A:
        count[a-1] += 1
ans = 0
for i in range(N):
    if count[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

#s=input().rstrip()
n,k=MI()
A=[0 for i in range(n)]
for i in range(k):
    d=I()
    u=LI()
    for s in u:
        A[s-1]+=1
count=0
for a in A:
    if a==0:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inf = 10**15
mod = 10**9+7
n,k = map(int, input().split())
judge = [1 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for num in a:
        judge[num-1] = 0
print(sum(judge))

Submission status: Accepted

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

	print(s.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    res = set()
    for _ in range(k):
        d = int(sys.stdin.readline().rstrip())
        *a, = map(int, sys.stdin.readline().split())
        res |= set(a)
    print(n - len(res))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N - len(A))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

N,K = LI()
s = [0 for _ in range(N+1)]
for _ in range(K):
    d = NI()
    for a in LI():
        s[a] = 1

print(N-sum(s))

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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 range(d):
        lst[a[j]-1]+=1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n, k = map(int, input().split())
d = defaultdict(int)
for i in range(k):
    x = int(input())
    a = list(map(int, input().split()))
    for j in a:
        d[j]+=1
count = 0
for i in range(1, n+1):
    if not d[i]:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

n, k = [int(x) for x in input().split()]
flag = [0]*n
for _ in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        flag[i - 1] = 1
ans = 0
for i in flag:
    if not i:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, K = LI()
A = [False] * N
for _ in range(K):
    ss = I()
    D = LI()

    for d in D:
        A[d-1] = True

ans = 0
for a in A:
    if not a:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
# N = int(input())
# A = list(map(int,input().split()))
ls = []
N, K = map(int,input().split())
for k in range(K):
    _ = input()
    A = list(map(int,input().split()))
    ls+=A
print (N-len(set(ls)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = [1]*(n+1)
A[0] = 0
for _ in range(k):
    d = int(input())
    L = map(int, input().split())
    for l in L:
        A[l] = 0
print(sum(A))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
se = set()
for _ in range(K):
    d = int(input())
    A = [int(x) for x in input().split()]
    for a in A:
        se.add(a)

print(N - len(se))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n,k = invr()
ans = [0 for i in range(n)]
cnt = 0
for i in range(k):
    d = inp()
    nums = inlt()
    for j in nums:
        ans[j - 1]= 1

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n,k=map(int,input().split())
    A=[0]*n
    for i in range(k):
        _=int(input())
        a=[int(_) for _ in input().split()]
        for aa in a:
            A[aa-1]+=1
    ac=Counter(A)
    print(ac[0])

if __name__=='__main__':
    main()

Submission status: Accepted

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

print(N - len(A))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
snuke_list = []
for i in range(K):
    d = int(input())
    snuke_list.extend([int(x) for x in input().split()])

print(N - len(set(snuke_list)))

Submission status: Accepted

Solution code:
#create date: 2020-05-03 21:02

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    sunuke = [0] * n
    for i in range(k):
        d = ni()
        a = na()
        for b in a:
            sunuke[b-1] += 1
    print(sunuke.count(0))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    d = [None for _ in range(k)]
    a = [None for _ in range(k)]
    for i in range(k):
        d[i] = int(input())
        a[i] = list(map(int, input().split()))

    tricked = [True for _ in range(n)]
    for i in range(k):
        for j in range(d[i]):
            tricked[a[i][j]-1] = False

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    # S = get_input()
    # if S == "ABC":
    #     print("ARC")
    # else:
    #     print("ABC")

    N, K = get_inputs(int)
    A = set()
    for i in range(K):
        di = get_input(int)
        Ai = get_inputs(int)
        for a in Ai:
            A.add(a)

    print(N - len(A))




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N, K = mulinputs()
    bucket = [0] * N
    for _ in range(K):
        intinput()
        for m in list(mulinputs()):
            bucket[m-1] += 1


    # 出力
    print(len(list(filter(lambda x: x == 0, bucket))))

Submission status: Accepted

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

print(sum(target))

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())
    a = list(map(int, input().split()))

    for j in a:
        snuke[j-1] += 1

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = 0
s_P = list(set(P))
for i in range(1, N+1):
    if i not in s_P: ans+=1
print(ans)

Submission status: Accepted

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

snk_list = []
for i in range(k):
    input()
    b = list(map(int,input().split()))
    snk_list+=b

print(n-len(set(snk_list)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
snuke = set()
for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for Ai in A:
        snuke.add(Ai)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
d=[0 for i in range(K)]
X=[[0 for j in range(N)]for i in range(K)]
for i in range(K):
    d[i]=int(input())
    for j in input().split():
        X[i][int(j)-1]=1
ans=0
for j in range(N):
    flag=1
    for i in range(K):
        if X[i][j]==1:
            flag=0
            break
    if flag:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

print(N - len(sunukeA))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#x = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

c = []
for i in range(k):
    d = int(input())
    a = list(map(int, sys.stdin.readline().split()))
    for j in range(len(a)):
        c.append(a[j])

x = collections.Counter(c)
print(n-len(x))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    li = []
    for i in range(K):
        d = int(input())
        s = list(map(int, input().split()))
        li.extend(s)
    print(N - len(set(li)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(N- len(set(treat)))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = []

for i in range(k):
    d = ni()
    a.append(na())

l = [0] * n
for i in range(k):
    for j in range(len(a[i])):
        l[a[i][j] - 1] += 1

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import collections
n, k = map(int,input().split())

sunuke = [0 for i in range(1, n+1)]
ans = 0
for i in range(k):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        sunuke[j-1] += 1
c = collections.Counter(sunuke)
print(c[0])

Submission status: Accepted

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

ans = [0 for i in range(n)]
for i in range(k):
    for j in range(d[i]):
        ans[a[i][j]-1] = 1

print(ans.count(0))

Submission status: Accepted

Solution code:
input = raw_input

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

have = [False] * n
for _ in range(k):
    d = int(input())
    As = map(int, input().split(" "))
    for A in As:
        A -= 1
        have[A] = True

out = n - sum(have)    
print(out)

Submission status: Accepted

Solution code:
# coding: utf-8
n, k = map(int, input().split())
d=[]
su=[0]*n
for _ in range(k):
    d = int(input())
    lis = list(map(int, input().split()))
    for li in lis:
        su[li-1] += 1

print(su.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=list(range(1,n+1))
for i in range(m):
    p=int(input())
    q=list(map(int,input().split()))
    for j in q:
        if j in s:
            s[s.index(j)]=0
k=0
for i in s:
    if i>0:
        k+=1
print(k)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    d = {i:0 for i in range(1, N+1)}
    for i in range(K):
        D = int(input())
        a = list(map(int, input().split()))
        for j in a:
            d[j] += 1
    r = 0
    for i in d:
        if d[i] == 0:
            r += 1
    return r
print(main())

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 |= set(a)
print(n-len(snuke))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
chk = [1] * N
for i in range(K):
    n = int(input())
    a = [int(i) for i in input().split()]
    for j in range(len(a)):
        chk[a[j]-1] = 0
print(sum(chk))

Submission status: Accepted

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


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