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

Solution (Python):
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(int)
for i in range(n):
    a = list(map(int,input().split()))
    for i in range(a[0]):
        d[a[i+1]] += 1
ans = 0
for k,v in d.items():
    if v==n:
        ans += 1
print(ans)

Solution (Python):

from itertools import permutations
def  inpl(): return list(map(int, input().split()))

N, M = inpl()
OK = [0]*(M+1)

for i in range(N):
    for a in inpl()[1:]:
        OK[a] += 1
print(sum([ok == N for ok in OK]))

Solution (Python):
N,M=map(int,raw_input().split())
Ans=[i for i in range(1,M+1)]
for i in range(N):
    A=map(int,raw_input().split())
    Ans=set(Ans)&set(A[1:])
    
print len(list(Ans))

Solution (Python):
N, M = map(int, input().split())
s = set([i for i in range(1, M + 1)])
for i in range(N):
    A = list(map(int, input().split()))
    A = A[1: ]
    for j in range(1, M + 1):
        if j not in A and j in s:
            s.remove(j)

print(len(s))

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

cnt = [ 0  for i in range(m) ]

for i in range(n):
    a = [ int(i) for i in input().split() ]
    for j in range(1,len(a)):
        cnt[a[j]-1]+=1

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

Solution (Python):
N, M = (int(i) for i in input().split())
L = [0] * M
for i in range(N):
    A = [int(i) for i in input().split()]
    A = A[1:]
    for a in A:
        L[a-1] += 1
aa = 0
for l in L:
    if l == N:
        aa += 1
print(aa)

Solution (Python):
from collections import Counter
c = Counter()
cnt = 0
N,M = map(int,input().split())
for i in range(N):
    src = list(map(int,input().split()))
    for j in src[1:]:
        c[j] += 1

for i in c:
    if c[i] == N:
        cnt += 1
print(cnt)

Solution (Python):
N,M = map(int,input().split())
bit = [0]*M
for i in range(N):
    info = list(map(int,input().split()))[1:]
    for e in info:
        bit[e-1] += 1
cnt = 0
for b in bit:
    if b == N:
        cnt +=1
print(cnt)

Solution (Python):
n,m=map(int,input().split())
data=[0 for k in range(m)]
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(x[0]):
        data[x[j+1]-1]+=1
print(data.count(n))

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

L = [0] * M
for n in range(N):
    I = list(map(int, input().split()))
    for i in I[1:]:
        L[i - 1] += 1
print(L.count(N))

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()
vote = [0]*(m+1)
for _ in range(n):
    like = list(li())
    
    for i in like[1:]:
        vote[i] += 1
        
ans = 0
for vi in vote:
    if vi == n:
        ans += 1
        
print(ans)

Solution (Python):
N, M = map(int, input().split())
from collections import defaultdict
g = defaultdict(int)
for i in range(N):
    l = list(map(int, input().split()))
    for j in range(1, l[0]+1):
        g[l[j]] += 1

ans = 0
for i, v in g.items():
    if v == N:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
like = [0 for i in range(M+1)]
for i in range(N):
    A = list(map(int, input().split()))
    for j in range(A[0]):
        like[A[j+1]] += 1
ans = 0
for i in range(M):
    if like[i+1] == N:
        ans += 1
print(ans)

Solution (Python):



from collections import deque
import heapq
import math
import bisect


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

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

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

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, raw_input().split())
f = [0 for i in xrange(m+1)]
for i in xrange(n):
	a = map(int, raw_input().split())
	for j in xrange(1,len(a)):
		f[a[j]] += 1
ans = 0
for i in xrange(1,m+1):
	if f[i] == n:
		ans += 1
print ans

Solution (Python):

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

L = [0]*(M+1)

for i in range(N):
    x = list(map(int, input().split()))
    
    A = x[1:]
    for a in A:
        L[a] += 1

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

Solution (Python):
N,M=map(int,input().split())
LIKE=[list(map(int,input().split())) for i in range(N)]

FOOD=[0]*(M+1)

for i in range(N):
    for l in LIKE[i][1:]:
        FOOD[l]+=1

ANS=0
for f in FOOD:
    if f==N:
        ANS+=1

print(ANS)

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


A1 = list(map(int, input().split()))
ans = set(A1[1:])
for i in range(N - 1):
    Ai = list(map(int, input().split()))
    ans = ans & set(Ai[1:])

print(len(ans))

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

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

aset = None

for _ in range(n):
  alist = list(map(int, input().strip().split()))[1:]
  if aset is None:
    aset = set(alist)
  else:
    aset = aset.intersection(set(alist))
print(len(aset))

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

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

count=0
for i in range(m):
    if d[i]==n:
        count+=1
print(count)

Solution (Python):
N, M =map(int, input().split())
k_list = []
items = []
for i in range(N):
    tmp = tuple(map(int, input().split()))
    k_list.append(tmp[0])
    items.append(tmp[1:])

ans = set(items[0])

for i in range(1, N):
    item = items[i]
    item = set(item)
    ans = ans & item

print(len(ans))

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

Solution (Python):


n, m = [int(x) for x in input().split()]
foods = set(range(m + 1))
for _ in range(n):
    foods = foods & set([int(x) for x in input().split()][1:])
print(len(foods))

Solution (Python):
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:])

ms = [0 for i in range(M)]
for a_s in A:
    for a in a_s:
        ms[a - 1] += 1
ans = 0
for m in ms:
    if m == N:
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
C = [0]*M
for i in range(N):
    _, *A = map(int, input().split())
    for a in A:
        C[a-1] += 1
ans = 0
for i in range(M):
    if C[i] == N:
        ans += 1
print(ans)

Solution (Python):
from collections import Counter
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
ctr = Counter()
for row in src:
    ctr += Counter(row[1:])

ans = 0
for v in ctr.values():
    if v==N:
        ans += 1
print(ans)

Solution (Python):
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)

n,m = map(int,input().split())
l = []
for i in range(n):
    p = list(map(int,input().split()))
    l += p[1:]
g = gb(sorted(l))
res = 0
for k,v in g:
    q = len(list(v))
    if (q == n):
        res += 1
print(res)

Solution (Python):
N, M = map(int, input().split())
cnt = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        cnt[a - 1] += 1
print(sum(c == N for c in cnt))

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

Solution (Python):
N, M = map(int, raw_input().split())
ans = [0 for _ in xrange(M+1)]

for _ in xrange(N):
    A = map(int, raw_input().split())[1:]
    for a in A:
        ans[a] += 1

a = 0

for b in ans:
    if b == N:
        a += 1

print a

Solution (Python):
N,M = map(int, raw_input().split())
C = [0]*M
for i in range(N):
  A = map(int, raw_input().split())
  for a in A[1:]:
    C[a-1] += 1
print C.count(N)