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())
ln=[]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        if a in ln:
            pass
        else:
            ln.append(a)
print(N-len(ln))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_list = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    A.append(d)
    A_list.append(A)
dic_S = {}
for i in range(K):
    for j in range(len(A_list[i])-1):
        if A_list[i][j] in dic_S:
            dic_S[A_list[i][j]] += 1
        else:
            dic_S[A_list[i][j]] = 1
ans = 0
for i in range(1, N+1):
    if i not in dic_S:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N,K = FLI()
d = [0]*K
m = []
for i in range(K):
    d[i] = I()
    for j in FLI():
        m.append(j)
print(N-len(set(m)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [1 for i in range(n) if people[i] == 0]
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

li=[0]*n
for i in range(k):
        d=int(input())
        lis = list(map(int,input().split()))
        for j in range(len(lis)):
                li[lis[j]-1]+=1
        lis.clear
cnt=0
for i in range(len(li)):
        if li[i]==0:
                cnt+=1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    snk = [0] * (N + 1)
    for _ in [0] * K:
        D = int(input())
        A = map(int, input().split())

        for a in A:
            snk[a] += 1
    print(snk[1:].count(0))


main()

Submission status: Accepted

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

kid = [0] * (N + 1)

num = 0

for i in range(1, K + 1):
  d = int(input())
  sweet = input().split()
  for j in range(d):
    kid[int(sweet[j])] += 1
    
for s in range(1, N + 1):
  if kid[s] == 0:
    num += 1

print(num)

Submission status: Accepted

Solution code:
n , k = map(int, input().split())
nusukes = list(range(1, n+1))
for _ in range(k) :
    d = int(input())
    lst = list(map(int, input().split()))
    for i in lst :
        if i in nusukes :
            nusukes.remove(i)
print(len(nusukes))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sunu = [0]*n

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

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

arr = np.zeros((K, N))

for i in range(K):
    d = input()
    lists = list(map(int, input().split()))
    for j in lists:
        arr[i, j-1] = 1
arr = np.sum(arr, axis=0)
count = 0
for i in arr:
    if i == 0:
        count+=1
print(count)

Submission status: Accepted

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

for _ in range(k):
    d.append(int(input()))
    a_i = map(int,input().split())
    a.extend(a_i)

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

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    As = input().split()
    tmp = []
    for i in As:
        # tmp.append(i)
        A.add(i)

# print(A)


print(N-len(A))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
snack = []
for i in range(K):
    number = int(input())
    s = list(map(int, input().split()))
    for j in range(len(s)):
        snack.append(s[j])

answer = 0
for i in range(1, N+1):
    if i not in snack:
        answer += 1

print(answer)

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

s = set()
for aa in A:
    for a in aa:
        s.add(a)
print(N - len(s))

Submission status: Accepted

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

boy = [0]*N

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


print(boy.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
n, k = get_ints()
count = [False]*n
for i in range(k):
    d = int(input())
    li = get_array()
    for i in li:
        count[i-1] = True
ans = 0
for i in count:
    if i is False:
        ans += 1
print(ans)

# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline

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

dp = [0] * n

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

    for j in people:
        dp[j-1] += 1


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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1:]
    sunuke = set()
    for A_val in A[1::2]:
        for val in A_val:
            sunuke.add(val)

    return N - len(sunuke)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Accepted

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

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

total = 0
for n in range(N):
    if L[n] == 0:
        total += 1

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    sunuke = set()
    for i in range(K):
        d = int(input())
        seq = list(map(int, input().split()))
        for a in seq:
            sunuke.add(a)

    print(N-len(list(sunuke)))

Submission status: Accepted

Solution code:
nk = input().split()
n = int(nk[0])
k = int(nk[1])

su = [0] * n
d = []


for i in range(k):
	d.append(int(input()))
	a = input().split()
	for j in a:
		su[int(j)-1] = 1

cnt = 0
# print(su)

for i in su:
	if int(i) == 0:
		cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
flg = [False] * N
for _ in range(K):
    d = int(input())
    A = [int(a) for a in input().split()]
    for a in A:
        flg[a-1] = True
cnt = 0
for f in flg:
    if not f:
        cnt += 1
print(cnt)

Submission status: Accepted

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

ls =[]
for i in range(1,K*2,2):
    ls = ls + A[i]
print(N - len(set(ls)))

Submission status: Accepted

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N,K = LI()
dA = [[LI() for _ in range(2)] for _ in range(K)]
num = set()
for x in dA:
    d,A = x
    for y in A:
        num.add(y)
print(N-len(num))

Submission status: Accepted

Solution code:
line = input().split(" ")
n = int(line[1])
sunuke_num = int(line[0])

okasi_has_list = []

for i in range(n):
  okasi_num = int(input())
  okasi_list = input().split(" ")
  okasi_has_list = okasi_has_list + okasi_list

output = set(okasi_has_list)

print(sunuke_num - len(output))

Submission status: Accepted

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

for i in range(int(len(box)/2)):
    j = 2*i+1
    candy = list(map(int,box[j].split()))
    for k in candy:
        matrix[k-1][i] = 1

count = 0
for line in matrix:
    if sum(line) == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

N, K = map(int, input().split())
d_list = []
A_list = []
for _ in range(K):
    d_list.append([int(input())])
    A_list.append([int(i) for i in input().split()])

p_set = set([j for j in range(1, N+1)])

A_set = set(list(itertools.chain.from_iterable(A_list)))

print(len(list(p_set-A_set)))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  n,k = map(int, input().split())
  ll = []
  for i in range(k):
    d = int(input())
    ll.append(list(map(int, input().split())))

  ans = set()
  for item in ll:
    ans = ans | set(item)

  count = 0
  for i in range(1, n+1):
    if i not in ans:
      count += 1
  print(count)

Submission status: Accepted

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

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

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

print(a)

Submission status: Accepted

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

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

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

    sunuke = []
    for _ in range(K):
        _ = input()
        next_sunuke = list(map(int, input().split()))
        for i in next_sunuke:
            sunuke.append(i)
    sunuke = set(sunuke)

    print(N - len(sunuke))

    return

if __name__ == '__main__':
    main()
    sys.exit(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

for j in range(1, N+1):
    if j not in A:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = [int(x) for x in input().split()]
    all_ = set(x for x in range(n))
    snack_holders = set()
    for i in range(k):
        int(input())
        for x in input().split():
            snack_holders.add(int(x) - 1)

    return len(all_ - snack_holders)


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

Submission status: Accepted

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

arr = []
for i in range(N):
    arr.append(0)

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

print(len(list(filter(lambda x: x == 0, arr))))

Submission status: Accepted

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())
sunuke=[0 for i in range(N)]
for k in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for i in range(d):
        sunuke[A[i]-1]+=1
#print(sunuke)
print(len([i for i in sunuke if not i]))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
N,K = map(int,input().split(" "))
sunuke = [0]*N
for _ in range(K):
    d = int(input())
    for i in [int(i) for i in input().split(" ")]:
        sunuke[i-1] += 1

C = Counter(sunuke)
print(C[0])

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
n, k = map(int, input().split())
ds = [0] * k
As = [0] * n

for i in range(k):
    ds[i] = input()
    A = list(map(int, input().split()))
    for a in A:
        As[a - 1] += 1
ans = 0
for A in As:
    if (A == 0):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N, K = Is()
S = [0]*N

for _ in range(K):
    d = I()
    A = LI()
    for i in A:
        S[i-1] += 1


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

c = 0
for x in F:
    if x == 0:
        c += 1
print(c)

Submission status: Accepted

Solution code:
num, okashi = map(int, input().split(" "))
snk = [1 for i in range(num)]
for i in range(okashi):
    ninnzuu = (int)(input())
    temp = list(map(int, input().split(" ")))
    for j in temp:
        snk[j - 1] = 0
print(sum(snk))

Submission status: Accepted

Solution code:
N, K = input().split()
N = int(N)
K = int(K)
Sunuke = set(range(N))
for i in range(K):
  d = int(input())
  X = list(map(int, input().split()))
  for x in X:
    Sunuke.discard(x-1)
print(len(Sunuke))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
NK = input().split()
S = set()

N = int(NK[0])
K = int(NK[1])

for i in range(K):
    n = int(input())
    L = input().split()

    for x in L:
        if x in S:
            pass
        else:
            S.add(x)

print(N - len(S))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = 0
sunuke_list = set()

for _ in range(K):
    d = int(input())
    A_list = list((map(int, input().split())))
    sunuke_list |= set(A_list)

for i in range(1, N + 1):
    if i not in sunuke_list:
        ans += 1

print(ans)

Submission status: Accepted

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

oksi_list = []

for i in range(K):
    d = int(input())
    oksi_list.extend(list(map(int, input().split())))
print(N - len(set(oksi_list)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
darega = [[] for _ in range(N)]
for i in range(K):
    _ = input()
    hito = map(int, input().split())
    for j in hito:
        darega[j-1].append(i+1)
ans = 0
for x in darega:
    if x == []:
        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_list = [int(i) for i in input().split()]
  A.extend(A_list)

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

Submission status: Accepted

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

sunlist = [0]*n
dlist = []
alist = []

for i in range(k):
    d = int(input())
    dlist.append(d)
    # print(d)
    # print(dlist)

    a =list(map(int,input().split(" ")))
    for j in range(d):
        sunlist[a[j]-1] += 1
        # print(sunlist)

sunlist_plus = [i for i in sunlist if i > 0]
sunlist_plus_len = len(sunlist_plus)
print(n-sunlist_plus_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
snack = [False for i in range(N)]
for i in range(K):
    d = int(input())
    snack_k = [int(i) for i in input().split()]
    for j in snack_k:
        snack[j - 1] = True
sum = 0
for i in snack:
    if not i:
        sum += 1
print(sum)

Submission status: Accepted

Solution code:
n,k = map(lambda x:int(x),input().split())
snakhold = [0]*n
for i in range(k):
  snaknum = input()
  snakholders = list(map(lambda x:int(x),input().split()))
  for s in snakholders:
    snakhold[s-1] = 1
victim = 0
for s in snakhold:
  if s==0:
    victim += 1
print(victim)

Submission status: Accepted

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

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

    sunukes = [0 for _ in range(N)]
    for k in range(K):
        d = int(input())
        As = list(map(int, input().split()))
        for a in As:
            a = a-1
            sunukes[a] = 1

    ans = N - sum(sunukes)
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N, shurui = map(int, input().split())
ls_n = []
ls = []

set_ls = set()

for i in range(shurui):
  ls_n.append(int(input()))
  tmp = list(map(int, input().split()))
  for t in tmp:
    set_ls.add(t)


print(N - len(set_ls))

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))

    dic={}
    for i in range(k):
        d=int(readline())
        arr=list(readline().rstrip().split())
        for a in arr:
            dic[a]=1
    ans=n-len(dic.keys())
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

Solution code:

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

all_snucks = set(i for i in range(1, n + 1))

for snack in range(1, k + 1):
    d = int(input())
    snucks = map(int, input().split())

    for snuck in snucks:
        if snuck in all_snucks:
            all_snucks.remove(snuck)

print(len(all_snucks))

Submission status: Accepted

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

for i in range(1, n+1):
    for j in range(len(A)):
        if i in A[j] and i not in ans:
            ans.append(i)
cnt = 0
for i in range(1, n+1):
    if i not in ans:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
s = input()

N = int(s.split()[0])
K = int(s.split()[1])

have = []

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

result = 0
    
for i in range(N):
  if (i+1) not in have:
    result += 1
    
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().strip().split()]
sunuke = set([])
for i in range(K):
  d = int(input().strip())
  ai = [int(a) for a in input().strip().split()]
  sunuke |= set(ai)
print(N-len(sunuke))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
def search(A,i):
    for j in range(0,len(A)):
        for k in range(0,len(A[j])):
            if A[j][k] == i:
                return False
    return True
ans = 0
for i in range(1,N+1):
    if search(A,i):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:


def main():
    NK = list(map(int,input().split()))


    count = [0] * NK[0]

    for i in range(NK[1]):
        d = int(input())
        di = list(map(int,input().split()))
        for g in range(d):
            count[di[g]-1] += 1


    print(count.count(0))







if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
n,k = map(int, input().split())
hs = [False]*n
for _ in range(k):
  d = int(input())
  s = [int(i) for i in input().split()]
  for p in s:
    if not hs[p-1]:
      hs[p-1]=True
res=0
for i in range(n):
  if not hs[i]:
    res+=1
print(res)

Submission status: Accepted

Solution code:

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

    ds = []
    current_members = set(range(1,N+1))
    for i in range(K):
        d = int(input())
        members= map(int, input().split())
        current_members -= set(members)
    
    #print(current_members)
    print(len(current_members))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
sunukes = set([n for n in range(1, N+1)])
for k in range(K):
    dk = int(input())
    Ak = set(list(map(int, input().split())))
    sunukes = sunukes - Ak
print(len(sunukes))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
list_1=[]
for _ in range(n):
    list_1.append(0)
#print(list_1)

for i in range (k):
    d=int(input())
    list_temp=list(map(int,input().split()))
    for j in list_temp:
        list_1[j-1]+=1
#print(list_1)

print(list_1.count(0))

Submission status: Accepted

Solution code:
import sys
import os

def file_input():
    f = open('../Beginner_Contest_166/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()

    N,K=map(int, input().split())
    has_k=[False]*N
    count=0

    for i in range(K):
        d=int(input())
        A=list(map(int,input().split()))
        for a in A:
            if not has_k[a-1]:
                # print(a)
                has_k[a-1]=True
                count+=1

    print(N-count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for f in f_list:
  if f == 0:
    ans += 1
print(ans)