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
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
s = set()

for i in range(k):
    d = ni()
    a = na()
    for j in a:
        s.add(j)

print(n-len(s))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


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

    cnt = 0
    for s in snuke:
        if s == 0:
            cnt += 1
    print(cnt)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    LIST = [0] * n
    for i in range(k):
        d = int(input())
        A = readInts()
        for i in range(d):
            LIST[A[i]-1] = 1
    cnt = 0
    for i in range(n):
        if LIST[i] == 0:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k = m()

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

for i in range(k):
    d = onem()
    a = l()
    for j in a:
        po[j-1] += 1

co = 0

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

Submission status: Accepted

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

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

print(l.count(0))

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
flg = [False]*n
for i in range(k):
    d = I()
    a = LI()
    for j in a:
        flg[j-1] = True
ans = 0
for i in range(n):
    if not flg[i]:
        ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans.count(0))

Submission status: Accepted

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


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

res = 0
for c in C:
    if c > 0:
        res += 1

print(N - res)

Submission status: Accepted

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

aset=set()
for i in range(K):
  d=int(input())
  alist=list(map(int,input().split()))
  for a in alist:
    aset.add(a)
    
print(N-len(aset))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
snuke=[0 for i in range(0,N)]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        snuke[A[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())
x = [True] * (N + 1)
for _ in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for v in a:
        x[v] = False

print(sum(x[1:]))

Submission status: Accepted

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

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:
N, K = map(int, input().split())
snuke = [1] * (N + 1)
for _ in range(K):
    d = int(input())
    for a in map(int, input().split()):
        snuke[a] = 0
print(sum(snuke[1:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
used = [False]*N
for i in range(K):
  d = input()
  s = [int(c) for c in input().split()]
  for c in s:
    used[c-1]=True
print(N-sum(c for c in used))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    aa=set()
    for _ in range(k):
        II()
        for a in LI():aa.add(a)
    print(n-len(aa))

main()

Submission status: Accepted

Solution code:
import math
import sys
def mips():
    return map(int,input().split())
def msps():
    return map(str,input().split())
N,K = mips()
res = set()
for i in range(K):
    d = int(input())
    L = [el for el in mips()]
    for el in L:
        res.add(el)
print(N-len(res))

Submission status: Accepted

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

    for j in A:
        snuke[j-1] += 1
cnt = 0
for i in snuke:
    if i == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

cnt = [0] * (n + 1)
for _ in range(k):
    d = int(input())
    a = tuple(map(int, input().split()))
    for ai in a:
        cnt[ai] += 1

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
have = [False] * N
for _ in range(K):
    d = int(input())
    for a in map(int, input().split()):
        have[a-1] = True
print(N - sum(have))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, K=map(int, input().split())
s=[0]+[1]*N
for i in range(K):
    d=int(input())
    tmp=list(map(int, input().split()))
    for j in tmp:
        s[j]=0
print(sum(s))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
s = set()
for _ in range(K):
  input()
  a = set(map(int, input().split()))
  s |= a
print(N - len(s))

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 snuke:
    if i == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N,K = map(int,input().split())
    atack = [1] * N
    for  i in range(K):
        d = int(input())
        A = list(map(int,input().split()))
        for k in A:
            atack[k - 1] = 0
    print(sum(atack))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, K = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(K):
        di = int(input())
        Ai = list(map(int, input().split()))
        for a in Ai:
            count[a] += 1
    ans = 0
    # print(count)
    for v in count[1:]:
        if v == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for _ in range(K):
    _ = input()

    for c in map(int, input().split()):
        A[c-1] = True

print(N - sum(A))

Submission status: Accepted

Solution code:
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,K = Ints()
Have = [0]*N

for i in range(K):
    d = Int()
    A = IntList()
    for j in A:
        Have[j-1]+=1
ans = 0

for i in Have:
    if i==0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

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


cnt = [0] * (N + 1)
for _ in range(K):
    d = int(sys.stdin.buffer.readline())
    A = list(map(int, sys.stdin.buffer.readline().split()))
    for a in A:
        cnt[a] += 1
ans = cnt.count(0) - 1
print(ans)

Submission status: Accepted

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

buf = [0 for i in range(n)]
for i in range(k):
    d=int(input())
    arr = list(map(int,input().split()))

    for a in arr:
        buf[a-1] += 1

ans = 0
for b in buf:
    if b==0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunukes = set(range(1, n + 1))
for _ in range(k):
    d = int(input())
    sunukes.difference_update(map(int, input().split()))
print(len(sunukes))

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=[0]*n

  for _ in range(k):
    d=I()
    a=LI()
    for x in a:
      l[x-1]+=1

  return l.count(0)

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
cnt = [0]*N

for _ in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    
    for ai in a:
        cnt[ai-1] += 1

ans = cnt.count(0)
print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    have = set()
    for i in range(K):
        _ = I()
        for x in LI():
            have.add(x)
    print(N-len(have))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = [0]*n

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

print(ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

flag = [1]*N

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

print(sum(flag))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
SET=set()
for i in range(K):
    d=map(int,input().split())
    SET|=set(map(int,input().split()))
print(N-len(SET))

Submission status: Accepted

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

def main():
    N, K = map(int, readline().rstrip().split())
    S = [0] * N
    for _ in range(K):
        d = int(readline())
        A = list(map(int, readline().rstrip().split()))
        for a in A:
            S[a-1] += 1
    
    print(len([s for s in S if s == 0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
s = set()
for i in range(k):
    a = inp()
    b = inpl()
    for i in b:
        s.add(i)
print(n-len(s))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    s = set()
    for i in range(k):
        input()
        s |= set(map(int, input().split()))
    print(n-len(s))


main()

Submission status: Accepted

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

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()))
    s |= set(A)
print(N - len(s))

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

Submission status: Accepted

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


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


def main():
    N, K = inpl()
    D = []
    As = []
    for _ in range(K):
        D.append(int(input()))
        As.append(inpl())
    ans = [0] * (N + 1)
    ans[0] = 1
    for A in As:
        for a in A:
            ans[a] += 1
    print(ans.count(0))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, k = MAP()
arr = [1 for _ in range(n)]
for i in range(k):
    d = INT()
    a = LIST()
    for j in a:
        arr[j - 1] = 0
print(sum(arr))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
cnt=[0]*(n+1)
for _ in range(k):
  tmp=int(input())
  arr=list(map(int,input().split()))
  for val in arr:
    cnt[val]+=1
ans=0
for i in range(1,n+1):
  if cnt[i]==0:
    ans+=1
print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = list(map(int, input().split()))
    S = [0] * N
    for _ in range(K):
        input()
        for i in list(map(int, input().split())):
            S[i - 1] += 1
    return S.count(0)

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
lis = [0 for i in range(n)]
for turn in range(k):
  nn = int(input())
  li = list(map(int,input().split()))
  for num in li:
    lis[num-1] = 1
print(lis.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K=int(input())
S= input()

if len(S)<=K:
    print(S)
else:
    print(S[:K]+'...')

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
ans=list()
for i in range(K):
  D=int(input())
  L=list(map(int,input(),split()))
  ans+=L
  ans=list(set(ans))
print(N-len(ans))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    sunukes[a] += 1
  assert len(A) == d
print(len([k for k in sunukes if k == 0]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=[]
people=list(range(1,N+1,1))
for idx in range(K):
    d=int(input())
    X=list((map(int,input().split())))
    for i in range(len(X)):
        A.append(X[i])
ans =[i for i in people if not i in A]
print(ans[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
import itertools
n, k = map(int, input().split())
d = []
sunuke = []
for i in range(k * 2 - 2):
    d.append(int(input()))
    sunuke.append(list(map(int, input().split())))

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

c = Counter(new)

print(n - len(c))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(k):
  if sum(s[i])==0:
    r=r+1
print(r)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int,input().split())
B = []
C = np.zeros(N)
e = 0
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(1, N + 1):
    B.append(A.count(j))
  for k in range(N):
    C[k] += B[k] 
  B = []
for l in range(N):
  if C[l] == 0:
    e += 1
print(e)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
l=[False for _ in range(N)]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(N):
        if l[j]==A[j]:
            l[j]=True
print(list.count(False))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
l=[False for _ in range(N)]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(N):
        if l[i]==A[i]:
            l[i]=True
print(list.count(False))

Submission status: Runtime Error

Solution code:
N,M=list(map(int,input().split()))
    si=[0]*N
    ans=0
    for i in range(M):
        S=int(input())
        who=list(map(int(input())))
        for k in range(S):
            si[who[k]]+=1
    for h in range(N):
        if si[h]==0:
          ans+=1
print(ans)