Problem:


Score : 200 points

Problem Statement

Katsusando loves omelette rice.

Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.

To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.

The i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.

Find the number of the foods liked by all the N people.

Constraints

All values in input are integers.

1 \leq N, M \leq 30

1 \leq K_i \leq M

1 \leq A_{ij} \leq M

For each i (1 \leq i \leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.

Constraints

Input is given from Standard Input in the following format:

N M
K_1 A_{11} A_{12} ... A_{1K_1}
K_2 A_{21} A_{22} ... A_{2K_2}
:
K_N A_{N1} A_{N2} ... A_{NK_N}

Output

Print the number of the foods liked by all the N people.

Sample Input 1

3 4
2 1 3
3 1 2 3
2 3 2

Sample Output 1

1

As only the third food is liked by all the three people, 1 should be printed.

Sample Input 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

Sample Output 2

0

Katsusando's hypothesis turned out to be wrong.

Sample Input 3

1 30
3 5 10 30

Sample Output 3

3



Sample input:
3 4
2 1 3
3 1 2 3
2 3 2


Sample output:
1

Submission status: Accepted

Solution code:
import sys
import collections
import itertools

N,M = map(int,input().split())
array_2 = []
for I in range(N):
    array_2.append(input().split())
for I in array_2:
    del I[0]

array_2 = itertools.chain.from_iterable(array_2)
array_2 = collections.Counter(array_2)
count = 0
for I in array_2:
    if array_2[I] == N: count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
B = [True] * M
for i in range(N):
    A = list(map(int, input().split()))[1:]
    _B = [False] * M
    for a in A:
        _B[a - 1] = True
    B = list(map(lambda x: x[0] and x[1], zip(B, _B)))
print(sum(filter(lambda x: x, B)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M  = (int(X) for X in input().split())
Food = set(range(1,M+1))
for T in range(0,N):
    Food = Food.intersection(set([int(X) for X in input().split()][1:]))
print(len(Food))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
food=set(range(1,M+1))
for i in range(N):
    K,*A=map(int,input().split())
    food&=set(A)
print(len(food))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[map(int,input().split()[1:]) for i in range(N)]
food=set(range(1,M+1))
for i in range(N):
    food&=set(A[i])
print(len(food))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, m), *a = [[*map(int, i.split())] for i in open(0)]
like = [0] * m
for i in a:
    for j in i[1:]:
        like[j - 1] += 1
print(sum(i == n for i in like))

Submission status: Accepted

Solution code:
(n,m), *ka = [list(map(int, s.split())) for s in open(0)]

c = [0]*(m+1)

for k, *a in ka:
    for elm in a:
        c[elm] += 1

print(c.count(n))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [0]*m
for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1
print(sum([i==n for i in li]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
KA = []
for n in range(N):
    KA.append([ka for ka in map(int,input().split())])

ans = set(range(1,M+1))

for ka in KA:
    ans = ans & set(ka[1:])

print(len(ans))

Submission status: Accepted

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

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

print(l.count(n))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

nums = [0]*m
for i in ka:
  for j in range(1,i[0]+1):
    nums[i[j]-1] += 1
print(nums.count(n))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
food = {i+1 for i in range(m)}

for i in range(n):
    k, *l = map(int, input().split())
    food = set(l) & food

print(len(food))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
f = []
for i in range(N):
  f.append(list(map(int,input().split())))
c = 0
for i in range(M):
  b = False
  for j in range(N):
    if not i+1 in f[j][1:]:
      b = True
      break
      
  if not b:
    c+=1
print(c)

Submission status: Accepted

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

S = set(i for i in range(1, M + 1))
for i in range(N):
    K, *A = map(int, input().split())
    S &= set(A)
print(len(S))

Submission status: Accepted

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

favorite=[0]*(m+1)

for i in range(n):
  k_=list(map(int,input().split()))
  for j in range(1,k_[0]+1):
    
    favorite[k_[j]]+=1
    
  
print(favorite.count(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
n, m = map(int, raw_input().split(' '))
cc = collections.Counter()
for _ in range(n):
	for a in map(int, raw_input().split(' '))[1:]: cc[a] += 1
count = 0
for k in cc:
  	if cc[k] == n: count +=1
print count

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=list(map(int,input().split()))
ans=set(ans[1:])
for i in range(n-1):
    t=list(map(int,input().split()))
    t=set(t[1:])
    ans=ans&t
print(len(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ansers = [list(map(int, input().split())) for _ in range(n)]
foods = [0] * (m + 1)

for i in range(n):
    for j in range(1, len(ansers[i])):
        foods[ansers[i][j]] += 1

print(foods.count(n))

Submission status: Accepted

Solution code:
n, m = [int(w) for w in input().split()]
menu = [0] * m

for i in range(n):
    _, *la = [int(w) for w in input().split()]
    for a in la:
        menu[a - 1] += 1

print(len([w for w in menu if w == n]))

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans))

Submission status: Accepted

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

X=[0]*(M+1)
for _ in range(N):
    A=list(map(int,input().split()))[1:]
    for a in A:
        X[a]+=1
print(X.count(N))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
R=set(range(1,M+1))
for i in range(N):
  L=list(map(int,input().split()))
  R=set(L[1:])&R
print(len(R))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
K =[set(input().split()[1:]) for _ in range(N)]
T = K[0]
for k in K:
  T = T&k
print(len(T))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
Like=[0 for i in range(M)]
A=[[] for i in range(N)]
for i in range(N):
  A[i]=[int(x) for x in input().split()]
for i in range(N):
  for j in range(1,A[i][0]+1):
    Like[A[i][j]-1]=Like[A[i][j]-1]+1
print(Like.count(N))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
res = set(list(range(1, M+1)))
for _ in range(N):
    k, *a = map(int, input().split())
    res = res.intersection(a)
print(len(res))

Submission status: Accepted

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

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

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

Submission status: Accepted

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

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

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
B = set(m for m in range(1,1+M))

for n in range(N):
  A = list(map(int,input().split()))
  B&=set(A[1:])

print(len(B))

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
LikeL = []
for i in range(N):
    temp = list(map(int, input().split()))
    temp.pop(0)
    LikeL.append(temp)

ans = 0
for Mi in range(M):
    all = True
    for i in range(N):
        if not(Mi+1 in LikeL[i]):
            all = False
            break
    if all:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:])

foods = [0] * M
for row in A:
    for a in row:
        foods[a-1] += 1
count = 0
for f in foods:
    if f == N:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A=[]
for i in range(0,N,1):
    a = list(map(int,input().split()))
    A.append(a[1::])

ans = [i for i in range(1,M+1,1)]
for i in range(0,N,1):
    ans = list(set(ans) & set(A[i]))
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=set(i+1 for i in range(m))

for i in range(n):
    t=[int(i) for i in input().split()]
    t=set(t[1:])
    s=s&t
print(len(s))

Submission status: Accepted

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

for _ in range(N):
    K, *A = input().split()
    for a in A:
        love_count[int(a)-1] += 1

count = 0
for num in love_count:
    if num == N:
        count += 1

print(count)

Submission status: Accepted

Solution code:
def resolve():
    N,M = map(int,input().split())
    S = set(range(1,M+1))
    
    for i in range(N):
        K,*A = map(int,input().split())
        S&=set(A)
    print(len(S))

resolve()

Submission status: Accepted

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

s = set([])
for i in range(1,31):
    s.add(i)

for _ in range(n):
    _,*a = list(map(int, input().split()))
    s &= set(a)

print(len(s))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = A[1:]
for i in range(N-1):
  B = list(map(int, input().split()))
  B = B[1:]
  A = set(A) & set(B)
ans = len(A)
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
KA=[]
food=[N]*M
for i in range(N):
    KA.append(list(map(int,input().split())))
for i in range(N):
    for j in range(len(KA[i])-1):
        food[KA[i][j+1]-1]-=1
print(food.count(0))

Submission status: Accepted

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

D = [0]*M

for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    for j in A:
        D[j-1] += 1

print(D.count(N))

Submission status: Accepted

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

ans = [0 for i in range(M)]
for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 1

count = 0
for i in range(M):
    if ans[i] == N:
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
del a[0]
if n != 1:
  for i in range(n-1):
    b = list(map(int, input().split()))
    del b[0]
    a = a+b
    a = [x for x in set(a) if a.count(x) > 1]
print(len(a))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
fset = set([i for i in range(1, m + 1)])
allset = fset
for i in range(n):
  temp = set(list(map(int, input().split()))[1:])
  fset = fset - (allset - temp)
print(len(fset))

Submission status: Accepted

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

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s))

Submission status: Accepted

Solution code:
def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n))


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N,M = map(int,list(input().split()))
i_list = [0]*M
for i in range(N):
    s = list(input().split())
    for j in range(int(s[0])):
        i_list[int(s[j+1])-1] += 1
     #   print(i_list)
counter = 0
for i in range(M):
    if i_list[i] == N:
        counter += 1   
    
print(counter)

Submission status: Accepted

Solution code:
N, M, *_ = map(int, open(0).read().split())

A = []
K_i = 0
for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
    
ans = 0

for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1

print(ans)

Submission status: Accepted

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

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

print(array.count(n))

Submission status: Accepted

Solution code:
n, m = map(int, (input().split()))
b = []
for _ in range(n):
    a = list(map(int, input().split()))
    b.extend(a[1:])

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

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,m = i2()
ls = []
for _ in range(n):
	a = intl()
	a = a[1:]
	ls.append(a)

for i in range(n-1):
	tmp = []
	for j in ls[i]:
		for k in ls[i+1]:
			if j == k:
				tmp.append(j)
	ls[i+1] = tmp

print( len(ls[-1]) )

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = [set(input().split()[1:]) for _ in range(N)]
 
like = a[0]
for i in range(1, N):
    like = like & a[i]
print(len(like))

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
A=set(range(1, m+1))
for _ in range(n):
  a,*b=map(int, input().split())
  A = A & set(b)
print(len(A))

Submission status: Accepted

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

for j in range(N):
    lis = list(map(int, input().split()))
    count = lis[0]
    answer = lis[1:]
    for k in answer:
        dic[k] += 1

num = [x for x in dic.values() if x == N]
print(len(num))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=list(range(1,m+1))
for i in range(n):
    l=list(map(int,input().split()))[1:]
    ans=list(set(ans)&set(l))
print(len(ans))

Submission status: Accepted

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

info = [input().split() for i in range(n)]
achi = []
for i in range(m):
    achi.append(0)

# print(info[0][0])

for i in range(n):
    for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1


print(achi.count(n))

Submission status: Accepted

Solution code:
from collections import Counter
n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *a = map(int, input().split())
    l += a
c = Counter(l)

cnt = 0
for val in c.values():
  if val == n:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
K = []
sum = 0
if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
  exit()
for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1
print(sum)

Submission status: Accepted

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

# print(n)
# print(m)

d = {str(i):0 for i in range(1, m + 1)}
# print(d)

for _ in range(n):
    l = input().split()
    k = l[0]
    a = l[1:]
    
    # print(k)
    # print(a)
    
    for aa in a:
        d[aa] += 1
        
# print(d)

count = 0
for key, value in d.items():
    if value == n:
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
s = set(map(str, range(m+1)))
for _ in range(n):
    s &= set(input().split()[1:])
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
K_A = [list(map(int, input().split())) for _ in range(N)]
candidate = {i for i in range(1, M + 1)}
for line in K_A:
    candidate = candidate & set(line[1:])
print(len(candidate))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x=[]
sum=0
for i in range(n):
  s=list(map(int,input().split()))
  s.pop(0)
  x+=s
for j in range(1,m+1):
  if x.count(j)==n:
    sum+=1
print(sum)

Submission status: Accepted

Solution code:
def MI():
    return map(int, input().split())

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

N, M = MI()
love = [0] * M
ans = 0

for i in range(N):
    K, *A = MI()
    for a in A:
        love[a - 1] += 1
    
for l in love:
    if l == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,m = map( int,input().split() )
k = [ list(map( int,input().split() )) for _ in range(n) ]

c = [0] * (m+1)

for i in k:
  for j,data in enumerate(i):
    if j == 0:
      continue
    else:
      c[data] += 1

ans = 0
for i in c:
  if i == n:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
ans = set(x for x in range(1, m+1))
for i in range(n):
    k, *a = map(int, input().split())
    ans = set(a) & ans
print(len(ans))

Submission status: Accepted

Solution code:
def resolve():
    N, M = map(int, input().split())
    K = []
    A = []
    ans = 0
    for _ in range(N):
        a = list(map(int, input().split()))
        K.append(a[0])
        A.append(a[1:])
    for i in range(M):
        count = 0
        for j in range(N):
            if i+1 in A[j]:
                count += 1
        if count == N:
            ans += 1
    print(ans)
resolve()

Submission status: Accepted

Solution code:
#

import sys
from copy import deepcopy
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
n,m=map(int,input().split())
s=list(input().split() for i in range(n))
l=[]
c=0
for j in range(n):
    l.append(s[j][1:])
l=list(itertools.chain.from_iterable(l))    

for i in range(1,m+1):
    if l.count(str(i))==n:
        c+=1
print(c)

Submission status: Accepted

Solution code:
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
import collections as C

#N = int(input())
N,M= map(int,input().split())
#P = list(map(int,input().split()))

#S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)

num=[0 for x in range(31)]
for i in range(N):

    K = list(map(int,input().split()))
    for j in K[1:]:
        num[j]+=1
c=0
for k in num:
    if k==N:
        c+=1
print(c)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)

if N>1:
    for _ in range(N-1):
        B=list(map(int,input().split()))
        B.pop(0)
        A=[num for num in A if num in B]

print(len(A))

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
d={i:0 for i in range(1,m+1)}
for i in range(n):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        d[a[j+1]]+=1
ans=0
for i in d.keys():
    if d[i]==n:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  A[i].pop(0)
 
ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
 
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    l = []
    ls = list(range(1, M+1))

    for i in range(N):
        l = list(map(int, input().split()))
        ls = set(l[1:]).intersection(ls)
    print(len(ls))
    return

resolve()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ka= [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    ka[i].pop(0)
ans = ka[0]
for i in range(1,n):
    ans = set(ans) & set(ka[i])
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N,M = map(int,input().split())
lst = [i+1 for i in range(M)]


for _ in range(N):
    tmp = list(map(int,input().split()))
    K = tmp[0]
    A = tmp[1:]
    lst = list(filter(lambda x: x in A,lst))

print(len(lst))

Submission status: Accepted

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

lis = []
for _ in range(n):
    lis.append(list(map(int, input().split())))
    
like =[0] * 31

for i in range(n):
    for j in lis[i][1:]:
        like[j] += 1
        
cnt = 0
for k in like:
    if k == n:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s)


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

K = []
A = []

for _ in range(N):
    ka = list(map(int, input().split()))
    K.append(ka[0])
    A.append(ka[1:])

print(actual(N, M, K, A))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Foods = [0]*(M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for j in range(1, K[0]+1):
        Foods[K[j]] += 1
cnt = 0
for i in range(M+1):
    if Foods[i] == N:
        cnt += 1
print(cnt)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m=inp()
l=[0]*m
for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1

ans=0
for x in l:
    if x==n:ans+=1
print(ans)

Submission status: Accepted

Solution code:
#ABC118-B
n,m = map(int,input().split())
anke = []
for i in range(n):
    tmp = list(map(int,input().split()))
    anke.append(tmp[1:])
#print(anke)    
result = []
for i in range(1,m+1):
    flg = True
    for j in anke:
        if i not in j:
            flg = False
            break
    if flg:
        result.append(i)
        

print(len(result))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
B = [0 for _ in range(M+1)]

for i in range(N):
    KA = list(map(int, input().split()))
    for a in KA[1:]:
        B[a] += 1
count = 0
for b in B:
    if b == N:
        count += 1
print(count)

Submission status: Accepted

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

ans=0
for y in x:
  if y==n:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  A[i].pop(0)

ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,m = readInts()
data = []
for i in range(n):
	data.append(readInts()[1:])

d = defaultdict(int)

for i in data:
	for j in i:
		d[j]+=1

ans = 0
for i in d:
	if d[i]==n:
		ans+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, m = map(int, input().split())
    likeList =[0]*m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


    count =0
    for i in likeList:
        if n == i:
            count+=1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
f = [i for i in range(1, m + 1)]
for i in range(n):
  a = list(map(int, input().split()))
  k = a[0]
  a = a[1:]
  f = set(f) & set(a)
f = list(f)
print(len(f))