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:
N,M = map(int, input().split())
A = [input().split() for _ in range(N)]

B = [0]*30

for i in range(N):
	for j in range(int(A[i][0])):
		#print(i,j)
		B[int(A[i][j])] += 1

print(B.count(N))

Submission status: Runtime Error

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

B = [0]*30

for i in range(N):
	for j in range(int(A[i][0])):
		print(i,j)
		B[int(A[i][j])] += 1

print(B.count(N))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
from collections import deque
n, m = map(int, input().split())
a = [0]*m
for _ in range(n):
    A = deque(map(int, input().split()))
    k = A.popleft()
    if i == 0:
        S = set(A)
    else:
        S = S & set(A)
print(len(S))

Submission status: Runtime Error

Solution code:
from collections import deque
n, m = map(int, input().split())
a = [0]*m
for _ in range(n):
    A = deque(map(int, input().split()))
    k = A.popleft()
    if i == 0:
        S = set(A)
    else:
        S = S & set(A)
 
print(len(S))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

check = [0]*m

for i in range(n):
  for a_i in tuple(map(int,input()))[1:]:
    check[a_i]+=1
    
print(check.count(n))

Submission status: Runtime Error

Solution code:
import itertools
n,m=map(int,input().split())
a=[]
for i in range(0,n):
  a.append(list(map(int,input().split())))
  del a[i][0]
a=list(itertools.chain.from_iterable(a))
count=0
for i in range(0,m):
  if a.count(i)==n
  count=count+1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = gets.chomp.split.map(&:to_i)
ary = (1..m).to_a

N.times do |i|
  buf = gets.chomp.split.map(&:to_i)
  ary = ary & buf[1..-1]
end

puts ary.length

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())
k = [0] * n
for i in range(n):
    k[i] = list(map(int, input().split()))
b = np.zeros((n, m))
for i in range(n):
    w = a[i]
    for j in range(len(w)):
        b[i, int(w[j])-1] = 1
print(sum(b.sum(axis=0) == n))

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, Q = MAP()
abcd = [LIST() for _ in range(Q)]
abcd.sort(key = lambda x: (x[0], x[1], x[3]))

for n in permutations(range(N)):
	print(n)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[x]==n:
    count+=1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  t=list(map(int,input().split()))
  k=t.pop(0)
  b=copy.deepcopy(a)
  for j in range(0,len(a)):
    if not b[j] in t:
      a.remove(a[j])
print(len(a))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
K=[]
ans=0
for _ in range(N):
  K+=[input().split()]
S=set(K)
for s in S:
  if K.count(s)==N:
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
all = {int(i) for i in range(1, i + 1)}
for _ in range(n):
    k, *i_th = map(int, input().split())
    all &= set(list(i_th))
print(len(all))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(N)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]+1):
    tabelist[c[k]-1] = tabelist[c[k]-1] + 1
#    print(i,k,tabelist)
print(len([1 for x in tabelist if x==N]))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(N)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]):
    tabelist[k-1] = tabelist[k-1] + 1
print(len([1 for x in tabelist if x==N]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
lists = [list(map(int, input().split())) for i in range(N)]
ans = set(lists[0][1:])
for i in range(1, N):
    ans = set(lists[i][1:]) * ans
print(*list(ans), sep='')

Submission status: Runtime Error

Solution code:
# from math import gcd
def gcd(a,b):
    if b == 0 :return a
    return gcd(b,a%b)


n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)

Submission status: Runtime Error

Solution code:

n,m = map(int,input().split())
t = [0]*m
s = []

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

count = 0

for i in range(len(t)):
    if t[i] == n:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:

n,m = map(int,input().split())
t = [0]*m
s = []

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

count = 0

for i in range(len(t)):
    if t[i] == n:
        count += 1

print(count)

Submission status: Runtime Error

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

k, *a = [int(i) for i in input().split()]

a = set(a)

for _ in range(n-1):
  _, *b = [int(i) for i in input().split()]
  a = a & b
print(len(a))

Submission status: Runtime Error

Solution code:
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=[]
for w in range(a):
    c.append(list(map(int,input().split())))
mini=30
d=0
for i in range(a):
    if c[i][0]<mini:
        mini=c[i][0]
        d=i
for j in range(mini+1)[1:mini+1]:
    for k in range(a):
        for m in range(c[k][0])[1:c[k][0]]:
            ans=list(c[d])
            if c[d][j]==c[k][m]:
                ans.append(int(c[d][j]))
if a==1:
    print(len(c[0])-1)
else:
    print(len(set(ans))-c[d][0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
     in range(N)]
for i in range(N):
  del l[i][0]
if N!=1:
  for i in range(N-1):
    a = set(l[i])&set(l[i+1])
    l[i+1] = a
    print(len(a))
else:

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

for i in range(n):
  for j in range(a[i][0]):
    count[a[i][j+1]]+=1
ans =0

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
favorites = {*tuple(range(1, M + 1))}
for _ in range(N):
    K, *fav = map(int, input().split())
    favorites = favorites & set(fav)
print(len(favorites))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int n, m, ans=0;
    cin>>n>>m;
    Vec v(n);
    rep(i,n){
        int k;
        cin>>k;
        while(k--){
            int a;
            cin>>a;
            v[a]++;
        }
    }
    rep(i,m) if(v[i]==n) ans++;
    co(ans);
}

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
list=[]
for i in range(n):
  l=list(map(int,input().split()))
  if i==0:
    for j in range(1,l[0]+1):
      list.append(l[j])
  else:
    for j in range(len(list)):
      l.remove(l[0])
      if not list[j] in set(l):
        list.remove(l[j])
print(len(list))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

ans = 0
all_list = [input().split() for l in sys.stdin]
numOfFavoritesList = all_list[:, 0]

target_idx = numOfFavoritesList.index(min(numOfFavoritesList))
for checkedFavorite in all_list[target_idx, :]:
  sumNum = sum(sum(all_list[:, 2:]))
  if sumNum == len(numOfFavoritesList):
    ans = ans + 1

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
list=[]
s=[]
if N == 1:
    a, *b=map(int, input().split())
    print(a)
else:
    for i in range(N):
        list.append(input().split())
        s &= set(list[1:])
        list=[]
    print(len(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = []
d = [0]*m
for _ in range(n):
    tmp = list(map(int,input().split()))
    a.append(tmp[1:])
for b in a:
    for c in b:
        d[c] += 1
cnt = 0
for p in d:
    if p == n:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = []
d = [0]*m
for _ in range(n):
    tmp = list(map(int,input().split()))
    a.append(tmp[1:])
for b in a:
    for c in b:
        d[c] += 1
print(d.count(n))

Submission status: Runtime Error

Solution code:
# 入力
N, M = [int(i) for i in input().split()]

# カウント用の配列
count = [0] * (M-1)

for i in range(N):  # 入力しながら
    _, *A = [int(i)-1 for i in input().split()]
    for j in A:     # 数える
        count[j] += 1

res = 0
for i in count:
    if i == N: res += 1

print(res)

Submission status: Runtime Error

Solution code:
n,m= map(int, input().split())
k=[]*n
a=[]*n
s=set(range(1,M+1))
for i in range(n):
    tmp=list(map(int, input().split()))
    a=tmp[1:]
    s= s & set(a)

print(len(s))

Submission status: Runtime Error

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

print(len(s))

Submission status: Runtime Error

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

print(len(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(c.count(N))

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

Submission status: Runtime Error

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

lst = list(range(1, m+1)):

for _ in range(n):
  for i in lst:
    if i not in list(map(int, input().split()))[1:]:
      lst.pop(lst.index(i))
print(len(lst))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
  b=list(map(int,input().split()))
  k.append(b[0])
  a.append(b[1:])
d={}
for i in range(n):
  for j in range(k[i]):
    if a[i][j] not in d:
      d[a[i][j]]=1
    else:
      d[a[i][j]]+=1
nd=list(d.values())
cnt=0
for i in range(len(nd)):
  if nd[i]==n:
    cnt+=1
print(cnt

Submission status: Runtime Error

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

l=[0]*n
for i in range(n):
    ka=list(map(int,input().split()))
    A=ka[1:]
    for a in A:
        l[a-1]+=1
ans=0
for i in l:
    if i==n:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
    k.append(int(input()))
    a.append(list(map(int,input().split())))
ans=0
for i in range(n):
    f=True
    for j in range(m):
        if a[j]==0:
            f=False
    if f:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input())
k=[]
a=[]
for i in range(n):
    k.append(int(input()))
    a.append(list(map(int,input().split())))
ans=0
for i in range(n):
    f=True
    for j in range(m):
        if a[j]==0:
            f=False
    if f:
        ans+=1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import log
n, m = map(int, input().split())
f1 = lambda x, y: 1 << x | 1 << y
f2 = lambda x, y: x & y
lst = []
for i in range(n):
  tmplst = [int(i) for i in input().split()]
  tmp = reduce(f1, tmplst[1:])
  lst.append(tmp)
ret = reduce(f2, lst)
if ret:
  print(int(log(ret, 2)))
else:
  print(0)

Submission status: Runtime Error

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

ls_k = [0] * m
ls_a = [0] * m
st_ans = {_ for _ in range(1, m+1)} 

for i in range(n):
    ls_k[i] = ls_ka[i][0]
    ls_a[i] = ls_ka[i][1:]
    st_ans &= set(ls_a[i])

print(len(st_ans))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop[0]
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
ctr = Counter()
N, M = map(int,input().split())
for _ in range(N):
  ctr.update(map(int,input().split())[1:])
print(len([None for v in ctr.values() if v == M]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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(les(s))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
s=set(range(1,m+1))
for i in range(n):
    k,*a=list(map(int,input().split()))
    s&=set(a)
print(les(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

K = [list(map(int, input().split())) for row in range(N)]
if N = 1:
	print(K[0][0])
else:
	for i in range(N):
		K[i].pop(K[i][0])

	foods = set(K[0])
	i = 0
	while i < N:
		foods = foods.intersection(set(K[i]))
		if foods == set():
			break
		
		else:
			i += 1
	print(len(list(foods)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for a in buf:
  if a == n:
    ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
for i in range(m):
  for j in range(n):
    if(not(i+1 in like[j])):
      frag = 0
      break
  if(frag == 1):
    cnt += 1
  frag = 1
print(cnt)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
  like.append(s[1:])
for i in range(m):
  for j in range(n):
  	if(!(i+1 in like[j])):
      frag = 0
    if(frag == 0):
      break
  if(frag == 1):
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:


def main():
	N,M=map(int,input().split())
	like=[0]*M
	for _ in range(N):
    	K,*A=map(int,input().split())
    	for num in A:
        	like[num-1]+=1
print(like.count(N))

if __name__=='__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m=map(int,input().split())

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

Submission status: Runtime Error

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

counter = []
ans = 0
for i in range(m):
  counter.apeend(0)

for i in range(n):
  ls = [map(int, input().split())]
  for i in range(1, ls[0]+1):
    num = counter[ls[i] - 1]
    counter.insert(ls[i]-1, num + 1)
for i in range(m):
  if counter[i] == n:
    ans += 1
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = map(int, input().split())
foods = np.zeros(M)
for i in range(N):
    a = list(map(int, input().split()))
    K = a[0]
    a = a[1:]
    for k in range(K):
      #print("i", i, foods[a[k]])
      foods[a[k]] += 1

#every = N * np.ones(M)
ans = np.count_nonzero(foods == N)
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input())
a = list(map(int, input().split()))[1:]
for i in range(n - 1):
  foods = list(map(int, input().split()))[1:]
  for food in a:
    if not food in foods:
      a.remove(food)
print(len(a))

Submission status: Runtime Error

Solution code:
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(Ans))

Submission status: Runtime Error

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

counter=collections.defaultdict
for _ in range(N):
  text = list(input().split())
  for x in text[1:]:
    counter[x]+=1
ans=0
for _ in counter:
  if counter[x]== N:
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in range(d.values()):
    if value == n:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = map(int, input().split())
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in range(d.values()):
    if value == n:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
atcoder

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

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

ans = [0]*M

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

count = 0

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

print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = []
S = []
for i in range(N):
  A.append(list(map(int,input().split())))
for i in range(1,K):
  S.append(A[i])
s_count = [x for x in S if S.count(x) == N]
  print(len(S_count))

Submission status: Runtime Error

Solution code:
list1=[]
A=[]
for i in range(N):
    list1=LIST[i]
    list1=list1.split(" ")
    list1[0:1]=[]
    A+="".join(list1)

A = [int(s) for s in A]
print(A)
print(type(A))
COUNT=[]
for i in range(1,M):
    COUNT+=A.count(i)
print(max(COUNT))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = [a[1],a[0],a[1] % a[0]]
a.sort()
for i in range(1,n+1):
    while x[2] > 0:
        x[0] = x[1]
        x[1] = x[2]
        x[2] = x[0] % x[1]
    x[0] = a[i+1]
    x[2] = x[0] % x[1]

print(x[1])