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: Runtime Error

Solution code:
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    j=int(input())
    member[i] = set(int(input()) for _ in range(j))
if(N==1):
    print(member(1))
    sys.exit(0)

match_set=member[1]
for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(match_set.length)

Submission status: Runtime Error

Solution code:
# N = number of people
# M = number of foods

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

result = [0]*M

for i in range(N):
  foods = map(int,raw_input().split())
  pers_count = foods.pop(0)
  
  for f in foods:
    results[f-1] += 1

res_count = 0
for r in results:
  if M == r:
    res_count += 1
print res_count

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
q=[input() for i in range(n)]
l=[i+1 for i in range(m)]
l1=[i+1 for i in range(m)]
for i in q:
  t=list(map(int, i.split()))
  for k in l1:
    if (k not in t[1:]):
      l.remove(k)
print(len(l))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & se t(a) # and > & 
    #print(c)
print(len(c))

Submission status: Runtime Error

Solution code:
import sys

lines = sys.stdin.read().rstrip().split("\n")
n, m = [int(x) for x in lines[0].split(" ")]

result = set(lines[1].split(" ")[1:])

if len(lines) == 2:
  print(len(result))
else:
  for x in range lines[2:]:
    result = result & set(x.split(" ")[1:])
  print(len(result))

Submission status: Runtime Error

Solution code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
	  for saj in sa[1:]:
    	aj = int(saj)
    	flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Submission status: Runtime Error

Solution code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
	  for saj in sa[1:]
    	aj = int(saj)
    	flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Submission status: Runtime Error

Solution code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa[1:]
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Submission status: Runtime Error

Solution code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa:
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in range(flg):
  if sumaj == n:
    suma += 1
print(suma)

Submission status: Runtime Error

Solution code:
File Edit Options Buffers Tools Python YASnippet Help                           
import sys
import collections

l = map(int, raw_input().split())
a=[]
for n in range(l[0]):
    x = map(int, raw_input().split())
    a.extend(x[1:])

c = collections.Counter(a)
values, counts = zip(*c.most_common())
print(counts.count(l[0]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Fm = [0]*M
KA = [list(map(int, input().split())) for _ in range(N)]
for n in range(N):
  for i in range(KA[n][0]):
    Fm[KA[n][i+1]] += 1
ans = 0
for m in range(M):
  if Fm[m] == N:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Fm = [0]*M
for n in range(N):
  KA = list(map(int, input().split()))
  for i in range(KA[0]):
    Fm[KA[i+1]] += 1
ans = 0
for m in range(M):
  if Fm[m] == N:
    ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * m #c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = input()
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        j = str(j)# jを文字列に変換
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1



print(ans)

Submission status: Runtime Error

Solution code:
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * m #c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = input()
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    print(td)
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        j = str(j)# jを文字列に変換
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1

print(c)

print(ans)

Submission status: Runtime Error

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

tmp=[0]*M
for i in range(N):
	for j in range(KA[i][0]):
		tmp[KA[i][j]]+=1
# print(tmp)
ans=0
for i in range(M):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
num = [int(s) for s in sys.stdin.readline().split()]
d = {}
for line in sys.stdin.readlines():
  n = [int(s) for s in line.split()]
  print n
  for s in range(1,n[0]+1):
    if s in d :
      d[n[s]] = d[n[s]]+1
    else :
      d[n[s]] = 1
keys = [k for k, v in d.items() if v == num[0]]
print(len(keys))

Submission status: Runtime Error

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
#    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

   for K_n_list_num in K_n_list:
       all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]
#for dish_kind_num in dish_kind:
#    if all_dish.count(dish_kind_num) == N:
#        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
flag = []
for _ in range(m): flag.append(True)
for _ in range(n):
    line = list(map(int, input()))
    for i in range(line[0]): flag[line[i+1]] = False
count = 0
for j in range(m):
    if(flag[j]): count += 1
print(count)

Submission status: Runtime Error

Solution code:
x1 = input().split()
N = int(x1[0])
M = int(x1[1])
S = []
A = []
K = []
F = []
for i in range(M):
    S.append(0)
for i in range(N):
    K.append(0)
for i in range(N):
    A.append(input().split())
    K[i] = int(A[i][0])
    for j in range(K[i]):
        F.append(int(A[i][j]))
    for j in F:
        S[j] += 1
ans = 0
for i in range(M):
    if S[i] == N:
        ans += 1
print(ans)

Submission status: Runtime Error

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

def parse_input():

    # 出力
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(0, n):
        rows.append([int(e) for e in input().split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()

Submission status: Runtime Error

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

def parse_input():

    # 出力
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(0, n):
        rows.append([int(e) for e in line.split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()

Submission status: Runtime Error

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

def parse_input():

    # 出力
    params = []
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])
    params.append(n)
    params.append(m)

    for i in range(0, n):
        params.append(input())   

    rows = []
    for line in lines:
        rows.append([int(e) for e in line.split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()

Submission status: Runtime Error

Solution code:
import numpy as np
nums = input().split(" ")
person_num = int(nums[0])
food_num = int(nums[1])
like_rate = np.zeros(food_num)
for i in range(person_num):
	foods = input().split(" ")
    for j in range(len(foods)):
    	like_rate[int(foods[j])-1]+=1
count = 0
for i in range(food_num):
	if like_rate[i] == person_num:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
 
nums = input().split(" ")
person_num = int(nums[0])
food_num = int(nums[1])
like_rate = np.zeros(food_num, dtype = int)
 
for i in range(person_num):
	foods = input().split(" ")
    length = len(foods)
    for j in range(length):
    	like_rate[int(foods[j])-1]+=1
count = 0
for i in range(food_num):
	if like_rate[i] == person_num:
        count += 1
        
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np

nums = input().split(" ")
person_num = int(nums[0])
food_num = int(nums[1])
like_rate = np.zeros(food_num, dtype = int)

for i in range(person_num):
	foods = input().split(" ")
    length = len(foods)
    for j in range(length):
    	like_rate[int(foods[j])-1]+=1

count = 0
for i in range(food_num):
	if like_rate[i] == person_num:
        count += 1
        
print(count)

Submission status: Runtime Error

Solution code:
n, m = [int(i) for i in input().split(" ")]

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

for i in range(n):
    sel = [int(i-1) for i in input().split(" ")][1:]
    for s in sel:
        pre_res[s] += 1

res = 0
for i in range(m):
    if pre_res[s] == n:
        res += 1

print(res)

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = [int(i) for i in input().split(" ")]

pre_res = np.array([0 for i in range(m)])

for i in range(n):
    sel = [int(i-1) for i in input(().split(" "))][1:]
    for s in sel:
        pre_res[s] += 1

res = 0
for i in range(m):
    if pre_res[s] == n:
        res += 1

print(res)

Submission status: Runtime Error

Solution code:
N_M = input().split()

for i in range(len(N_M)-1):
  N_M[i] = int(N_M[i])

data = []

for _ in range(N_M[0]-1):
  a = input().split()
  for i in range(len(a)-1):
    a[i] = int(a[i])
  data.append(a)

total = 0  

for i in range(N_M[1]-1):
  total_mini=0
  for j in range(N_M[0]-1):
    if i in data[j]:
      total_mini +=1
    if j ==N_M[0]-1 and total_mini == j:
      total += 1

print(total)

Submission status: Runtime Error

Solution code:
import sys

v = []
for line in sys.stdin:
  v.append([int(l) for l in line.split()])

n, m = v[0]
min_k = -1
min_idx = -1
for idx, line in enumerate(v[1:]):
  if min_k == -1 or min_k > line[0]:
    min_k = line[0]
    min_idx = idx + 1

count = 0
min_v = line[min_idx, 1:]
for min_v_v in min_v:
	if n == sum(min_v_v in v[1:,1:]):
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main(void){

	int N, M;
	int i, j;
	scanf("%d%d", &N, &M);
	int n = N;
	int m = M;
	int a[50][50];
	for(i = 0; i < 50; i++) for(j = 0; j < 50; j++) a[i][j] = 0;

	for(i = 0; i < N; i++){
		int k;
		scanf("%d", &k);
		for(j = 0; j < k; j++){
			int A;
			scanf("%d", &A);
			// i 番目の人はA 番目の料理がすき
			a[i][A - 1] = 1;
		}
	}

	
	int ans = 0;
	for(j = 0; j < m; j++){
		int flag = 1;
		for(i = 0; i < n; i++){
			if(a[i][j] == 0){
				flag = 0;
				break;
			}
		}

		if(flag == 1) ans++;
	}

	printf("%d\n", ans);



	return 0;
}

Submission status: Runtime Error

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


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n, m; cin >> n >> m;
    vector<int> d(m);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a; a--;
            d[a]++;
        }
    }

    int cnt = 0;
    for(int i = 0; i < m; i++) cnt += (d[i] == n);
    cout << cnt << endl;
    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m = [int(x) for x in input().split(" ")]

c = []
d = []
for i in range(n):
	a = [int(x) for x in input().split(" ")]
	if i == 0:
        c = a[- a[0] + 1:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for i in range(N):
    lst = list(map(int, input().split()))
    for a in range(1, len(lst)):
        d[lst[a]] += 1
ans = 0
for i in range(1, M+1):
    if d[i] == N:
        ans += 1
print(ans)
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for i in range(N):
    lst = list(map(int, input().split()))
    for a in range(1, len(lst)):
        d[lst[a]] += 1
ans = 0
for i in range(1, M+1):
    if d[i] == N:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
for i in range(n):
  k = int(input())
  l = list.extend(map(int,input().split))
c = collections.Counter(l)
cv = c.values()
print(len([i for i in cv if i == n]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
check = [0] * M
for i in range(N):
    a = [int(i - 1) for i in input().split()]
    a = a[1:]
    for j in check:
        check[j] += 1
    

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(sum(check))

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in input().split())
hoge = {i for i + 1 in range(M)}
for i in range(N):
    likes[i] = set()
    likes[i] = {i for i in input().split()}
    hoge &= likes[i]

c = len(hoge)

print(hoge)

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in input().split())
hoge = set((int(i) for i + 1 in range(M)))
for i in range(N):
    likes[i] = set()
    likes[i].add((int(i) for i in input().split()))
    hoge &= likes[i]

c = len(hoge)

print(hoge)

Submission status: Runtime Error

Solution code:
n = int(input())
k = 0
alist = []
while k < n :
  a = list(map(int,input().split()))
  alist.append(a)
  k += 1
#
for blist in alist :
  b = blist[0]
  blist.remove(b)
#
anslist = []
ans = 0
i_roop = len(alist[0])
while i_roop >= 0 :
  if i_roop == 0 :
    break
  else:
    c = min(alist[0])
    for j in range(1,n) :
      if c in alist[j] :
        anslist.append("OK")
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
      else:
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
        break
    alist[0].remove(c)
  anslist = []
  i_roop += -1

print(ans)

Submission status: Runtime Error

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

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x] += 1

ans = sum(1 for x in res if x == n)

print(ans)

Submission status: Runtime Error

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


a = {}

for i in range(n):
  a.add(input().split()[1:])
 
if not len(a) == 0:
  for i in range(1, len(a)):
    a[0] = a[0] & a[i]
  
print(len(a[0]))

Submission status: Runtime Error

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


a = {}

for i in range(n):
  a.add(input().split()[1:])
 
if not len(a) == 0:
  for i in range(len(a)-1)+1:
    a[0] = a[0] & a[i]
  
print(len(a[0]))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = set()
for i in range(n):
  a.add(input().split()[1:])

if not len(a) == 0:
	for i in range(len(a)-1)+1:
  		a[0] = a[0] & a[i]
  
print(len(a[0]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(string):
    string = string.split("\n")
    n, m = map(int, string[0].split())
    ans = set([i + 1 for i in range(m)])
    for loves in string[1:]:
        ans &= set(map(int, loves.split()[1:]))
    return str(len(ans))


if __name__ == '__main__':
    base = input()
    n, m = map(int, base)
    tmp = [base]
    for _ in range(n):
        tmp.append(input())
    print(solve('\n'.join(tmp)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(string):
    string = string.split("\n")
    n, m = map(int, string[0].split())
    ans = {i + 1 for i in range(m)}
    for loves in string[1:]:
        ans = ans & (set(map(int, loves.split()[1:])))
    return str(len(ans))


if __name__ == '__main__':
    base = input()
    n, m = map(int, base)
    tmp = [base]
    for _ in range(n):
        tmp.append(input())
    print(solve('\n'.join(tmp)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(string):
    string = string.split("\n")
    n, m = map(int, string[0].split())
    ans = {i + 1 for i in range(m)}
    for loves in string[1:]:
        ans.intersection_update(set(map(int, loves.split()[1:])))
    return str(len(ans))


if __name__ == '__main__':
    base = input()
    n, m = map(int, base)
    tmp = [base]
    for _ in range(n):
        tmp.append(input())
    print(solve('\n'.join(tmp)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(string):
    string = string.split("\n")
    n, m = map(int, string[0].split())
    ans = {i + 1 for i in range(m)}
    for loves in string[1:]:
        ans &= set(map(int, loves.split()[1:]))
    return str(len(ans))


if __name__ == '__main__':
    base = input()
    n, m = map(int, base)
    tmp = [base]
    for _ in range(n):
        tmp.append(input())
    print(solve('\n'.join(tmp)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A_list = [[int(i) for i in input().split()] for i in range(N)] 

a = A_list[0].pop(0)
for i in range(1, N):
  a = set(a) & set(A_list[i].pop(0))

if len(a)==0:
  print(0)
else:
  print(a)

Submission status: Runtime Error

Solution code:
#ABC118-B

N,M = (int(x) for x in input().split())
food = [0]*M
count = 0
for i in range(N):
    a = list(map(int, input().split()))
    for j in range(1,a[0]+1):
        food[a[j]] = food[a[j]] + 1
for i in range(M):
    if food[i] == N:
        count = count + 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = []
for i in range(n):
  b = list(map(int, input().split()))
  a.append(b)

c = [0] * m
for i2 in range(n):
    for j in range(1, a[i2][0] + 1):
        c[a[i2][j - 1]] = c[a[i2][j - 1]] + 1

count = 0
for k in range(m):
    if c[k] == n:
        count += 1

print(count)

Submission status: Runtime Error

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

a = []
for i in range(n):
  b = list(map(int, input().split()))
  a.append(b)

c = [0] * m
for i2 in range(n):
    for j in range(1, a[i2][0] + 1):
        c[a[i2][j]] = c[a[i2][j]] + 1

count = 0
for k in range(m):
    if c[k] == n:
        count += 1

print(count)

Submission status: Runtime Error

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

a = []
for i in range(n):
  b = list(map(int, input().split()))
  a.append(b)

c = [0] * m
for i2 in range(n):
    for j in range(1, a[i2][0] + 1):
        c[a[i2][j]] = c[a[i2][j]] + 1

count = 0
for k in range(n):
    if c[k] == m:
        count += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))
ans.union(b)
for n in range(n):
  s=list(map(int,input().split()))
  s=s[1:]
  ans=ans-s
print(len(ans))

Submission status: Runtime Error

Solution code:
n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(n)]
dic = {}
for hobbies in e:
    for i in range(1,len(hobbies)+1):
        if hobbies[i] in dic:
            dic[hobbies[i]] +=1
        else:
            dic[hobbies[i]] = 0
everyoneLike = []
for key,num in dic.items():
    if num == n:
        everyoneLike.append(key)
print(len(everyoneLike))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
(N,M) = map(int,input().split())
r = int32(-1)
for i in range(M):
  A = list(map(int,input().split()))
  A.pop(0)
  c = 0
  for a in A:
    c |= (1 << (a-1))
  d &= c

ans = sum([(d>>n)&1 for n in range(n)])
print(ans)

Submission status: Runtime Error

Solution code:
n,m=list(map(int,input().split()))
t=np.zeros(m)
for i in range(n):
  tmp=list(map(int,input().split()))  
  for j in range(tmp[0]):
    t[tmp[j+1]-1] += 1
  
maxIndex = [i for i, x in enumerate(t) if x == max(t)]
print(len(maxIndex)

Submission status: Runtime Error

Solution code:
n,m=list(map(int,input().split()))
t=np.zeros(m)
for i in range(n):
  tmp=list(map(int,input().split()))  
  for j in range(tmp[0]):
    t[tmp[j+1]-1] += 1
  
maxIndex = [i for i, x in enumerate(a) if x == max(tmp)]
print(len(maxIndex)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

int N, M;
bool like[30]; // 全員が好き

int main()
{
    cin >> N >> M;
    for(int i=0; i<M; i++){
        like[i] = true;
    }

    for(int i=0; i<N; i++){
        int k;
        int a;
        bool flag[30];
        for(int j=0; j<M; j++) flag[j] = false;
        cin >> k;
        for(int j=0; j<k; j++){
            cin >> a;
            flag[a-1] = true;
        }
        for(int j=0; j<M; j++){
            if(flag[j] == false) like[j] = false;
        }
    }

    int cnt = 0;
    for(int j=0; j<M; j++) {
        if(like[j]) cnt++;
    }

    cout << cnt;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

r = [0 for x in range(0, m)]

for _ in range(0, n):
    a = [x for x in map(int, input().split())]
    for i in a[1:]:
        r[i - 1] += 1

print(f'{len([x for x in r if x == n])}')

Submission status: Runtime Error

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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(inputs[1:])

print(len(ans))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers, 1)

n = int(input())
print(gcd(list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
print(gcd(list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values()() if i == n]))

Submission status: Runtime Error

Solution code:
#coding: utf-8

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

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    #print(l)
    del l[0]
    #print(l)
    List.append(l)
    #print(List[i])
    #print(List)
    #print( )

    all_and = set(all_and) & set(List[i])
    all_and = List(all_and)

all_and_list = list(all_and)
#print(all_and)
#print(all_and_list)
print(len(all_and_list))

Submission status: Runtime Error

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

listA = [[list(map(int, input().split()))] for j in range(n)]

ans = 0


for a in range(m):
    for i in range(n):
        listA[i].pop(0)
        if a in listA[i]:
            ans += 1


print(ans)

Submission status: Runtime Error

Solution code:
n, m  = [int(x) for x in input().split()]
full = set(list(range(1, m+1)))
non = set([])
for i in range(n):
  k = set([int(x) for x in input().split()][1:])
  non += (full - k)
 print(len(full - none))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
s=0
a = [list(input().split())for i in range(N)]
for i in range(N):
    del a[i][0]
b=set(a)
print(len(b))

Submission status: Runtime Error

Solution code:
#coding: utf-8

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

List = []
for i in range(N):
    l = list(map(int, input().split()))
    #print(l)
    del l[0]
    #print(l)
    List.append(l)
    #print(List[i])
    #print(List)
    #print( )

    if i != 0:
        all_and = set(List[i-1]) & set(List[i])

all_and_list = list(all_and)
print(len(all_and_list))

Submission status: Runtime Error

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

list = [list(map(int, input().split())) for i in range(n[0])]

a = {}
for i in list:
    for j in i[1:]:
        if j in a:
            a[j] = a[j] + 1
        else:
            a[j] = 1

cnt = 0
for x in a.values():
    if x == n[0]:
        print(f'ok:{x}')
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i+1)
_ans = ans.copy()
for a in A:
  for i in range(len(ans)):
    if not ans[i] in a[1:]:
      _ans.remove(ans[i])
print(len(_ans))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a=range(n)
a= [[0 for i in range(n)] for j in range(m)]
for N in range(n):
    a[N] = list(map(int,input().split()))
b=[]
d=[]
e=0
for N in range(n):
    for M in range(a[N][0]):
        c=int(a[N][M+1])
        b.append(c)
for N in range(m+1):
    if b.count(N)==n:
        e=e+1

print(e)