Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; void Read(int &n) { int sign = 1; n = 0; char c; do { c = getchar(); } while (!isdigit(c) && c != '-'); if (c == '-') { c = getchar(); sign = -1; } do { n = n * 10 + c - 48; c = getchar(); } while (isdigit(c)); n *= sign; } void Read(...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int l[200000], r[100000]; int main() { int n; cin >> n; int suml = 0, sumr = 0, ans, p = 0; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; suml += l[i]; sumr += r[i]; } ans = abs(suml - sumr); for (int i = 1; i <= n; i++) { if (ans < abs(s...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
if __name__ == '__main__': n = int(input()) #l = [] #r = [] dif = [] left_sum = 0 right_sum = 0 for i in range(n): l_val, r_val = (int(ch_num) for ch_num in input().split(' ')) left_sum += l_val right_sum += r_val dif.append(l_val - r_val) index = 0 ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int l[100010], r[100010]; int main() { int n, tl = 0, tr = 0, res = 0, b = 0; scanf("%d ", &n); for (int i = 1; i < n + 1; i++) { scanf("%d %d ", l + i, r + i); tl += l[i]; tr += r[i]; } b = abs(tl - tr); for (int i = 1; i < n + 1; i++) { int x =...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l = [] r = [] c = [] for i in range(n): x,y = map(int,input().split()) c.append([x,y]) l.append(x) r.append(y) p = sum(l) q = sum(r) res = abs(p-q) chg = -1 for i in range(n): e = p-c[i][0] f = q-c[i][1] e+=c[i][1] f+=c[i][0] if abs(e-f)>res: chg = i ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=raw_input() n=int(n) maxlr=0 indexlr=-1 maxrl=0 indexrl=-1 total=0 for i in range(n): l,r=raw_input().split(" ") l=int(l) r=int(r) total+=(l-r) if l>r and l-r>maxlr: indexlr=i+1 maxlr=l-r if l<r and r-l>maxrl: indexrl=i+1 maxrl=r-l if indexlr==-1 or inde...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) L, R = 0, 0 a = [] for i in range(n): l, r = map(int, input().split()) L += l R += r a.append([l, r]) ans = [L, R, 0] for i in range(n): nL = L - a[i][0] + a[i][1] nR = R - a[i][1] + a[i][0] #print(abs(ans[0] - ans[1]), abs(nL - nR)) if abs(ans[0] - ans[1]) < abs(nL - nR...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> int main() { int n, i, sum1 = 0, sum2 = 0, index = 0; scanf("%d", &n); int arr1[n], arr2[n]; for (i = 0; i < n; i++) { scanf("%d %d", &arr1[i], &arr2[i]); sum1 = sum1 + arr1[i]; sum2 = sum2 + arr2[i]; } int beauty = abs(sum1 - sum2); for (i = 0; i < n; i++) { int p...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//package edu.vn.haui.leson; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import ja...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
INF = float('+inf') n = input() a = [] L, R = 0, 0 for i in xrange(n): t = map(int, raw_input().split()) a.append(t) L += t[0] R += t[1] #mm = -INF mm = abs(L - R) ans = 0 for i in xrange(n): l, r = a[i] #t = l - r #t = abs(t) #if t > mm: # mm = t # ans = i + 1 z = ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) A=[0]*n B=[0]*n l=0 r=0 for i in range(n): A[i],B[i]=list(map(int,input().split())) l+=B[i] r+=A[i] m=abs(l-r) ic=0 for i in range(n): rc=r-A[i]+B[i] lc=l+A[i]-B[i] mc=abs(rc-lc) if mc>m: ic=i+1 m=mc print(ic)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
// CodeForces Round 378 -- slowe import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B378 { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(); int n = in.nextInt(), total = 0; int diff[] = new int[n]; ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int Pow = 1000009, mod1 = 999997, mod2 = 88899987, N = 100005, M = 1000005, Mod = 1000000007; int n, m, num1, num2, Hash[M], _hash[M], _sum, x, Ans, Power[M]; map<int, int> Map[mod1 + 5]; inline int Read() { int t = 0, f = 1; char c = getchar(); for (;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int fact[1000005]; int main() { int n, m, i, j, k, l; cin >> n >> m; vector<int> v[m + 2]; fact[0] = 1; fact[1] = 1; for (i = 2; i < 1000005; i++) { long long int jl = i; fact[i] = (fact[i - 1] * jl) % 1000000007; } unordered_map<string, in...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; template <class T> inline bool updateMin(T& a, T b) { return a > b ? a = b, 1 : 0; } template <class T> inline bool updateMax(T& a, T b) { return a < b ? a = b, 1 : 0; } inline int nextInt() { int x; scanf("%d", &x); return x; } inline long long nextI64() { long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> const int mod = 1e9 + 7; using namespace std; const int N = 1e6 + 5; int a[N]; bool f[N]; vector<int> e[N]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int t; scanf("%d", &t); while (t--) { int x; scanf("%d", &x); e[x].push_ba...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const long double pi = acos(-1); const int MOD = 1e9 + 7; const int MAXN = 1000005; vector<int> g[MAXN]; int qtosgruposta[MAXN]; vector<pair<int, int> > info[MAXN]; int n, m; long long int fat[MAXN]; int...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long MOD = 1e9 + 7; long long fact[N + 1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); fact[0] = fact[1] = 1; for (long long i = 2; i <= N; i++) fact[i] = (fact[i - 1] * i) % MOD; int n, m; cin >> n >> m; vector<...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict,Counter from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10...
PYTHON3
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 100; const int MAXM = 1e6 + 100; const long long MOD = 1e9 + 7; vector<pair<int, int>> pr[MAXM]; map<vector<pair<int, int>>, long long> for_ans; long long fact[MAXM]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { void solve() throws IOException { int n = ni(); int m = ni(); ArrayList<HashSet<Integer>> G = new ArrayList<>(); G.add(ne...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class C { FastScanner in; PrintWriter out; void solve() { Random rnd = new Random(); int n = in.nextInt(); int m = in.nextInt(); int[] count = new int[m]; long[] vals = new long[m]; for (int i = 0; i < n; i++) { int cnt = in.nextInt(); int[] a = new in...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main4 { static long ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, maxn = 1e6 + 6; int n, m, k, x, res = 1, fact[maxn]; map<vector<int>, int> f; vector<int> a[maxn]; int main() { fact[0] = 1; for (int i = 1; i < maxn; ++i) fact[i] = 1LL * fact[i - 1] * i % mod; scanf("%d%d", &n, &m); for (int i = 1; i <= n;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; import java.util.Map.Entry; public class ProblemC { public static void main(String[] args) { // TODO Auto-generated method stub FastScanner input = new FastScanner(); int gyms = input.nextInt(); int pokemon = input.nextInt(); StringBuilder[] pokemonMapToGymFreq = new S...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> const long long INF = (long long)1e18 + 123; const int inf = (int)2e9 + 123; const int mod = 1e9 + 7; using namespace std; struct pok { int old, nw, cnt, id; pok() { old = cnt = 0; id = nw = 0; } pok(int a, int b, int c, int d) { old = a; nw = b; cnt = c; id = d;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int INF = 0x3f3f3f3f; template <class T> inline bool RD(T &ret) { char c; in...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.util.*; import java.io.*; public class FelicityisComing { /************************ SOLUTION STARTS HERE ***********************/ static class Pair { int prevClass , freq; Pair (int pc , int f) { prevClass = pc; freq = f; } @Override public int hashCode() { return Objects.hash(pre...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int g[1000010]; vector<int> st[1000010], in[1000010]; map<vector<int>, vector<int> > M; int par[1000010], sz[1000010]; set<vector<int> > s; long long int fact[1000010]; int root(int v) { if (par[v] == v) return v; return par[v] = root(par[v]); }...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod1 = 1000000007; const int mod2 = 1000000009; long long p1 = 1, p2 = 1; int n, m, x, t[100005]; pair<int, int> s[1000005]; long long silnia[1000005]; int main() { scanf("%d%d", &n, &m) ?: 0; for (int i = 0; i < (n); ++i) { scanf("%d", &x) ?: 0; for (...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long arr[6666666]; map<long long, long long> vis; vector<long long> v[6666666]; long long F(long long num) { long long s = 1; for (long long i = 1; i <= num; i++) s = (s * i) % 1000000007; return s; } signed main() { long long n, m; cin >> n >> m; for (long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void minimize(X &x, const Y &y) { if (x > y) x = y; } template <class X, class Y> void maximize(X &x, const Y &y) { if (x < y) x = y; } template <class T> T Abs(const T &x) { return (x < 0 ? -x : x); } const int mod = (int)1e9 + 7; vector<p...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = int(1e6) + 10, mod = int(1e9) + 7; vector<int> g[N]; int n, m; long long first[N + 10], ans; int main() { scanf("%d%d", &n, &m); for (int i = 1, k, x; i <= n; i++) { scanf("%d", &k); for (int j = 1; j <= k; j++) { scanf("%d", &x); g[x]....
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 1000 + 300; const int mod = 1000000007; map<int, int> mp[N]; int cnt[N]; int szt = 1; void addChar(int &state, int ch) { if (!mp[state].count(ch)) { mp[state][ch] = szt; state = szt; szt++; } else { int nstate = mp[state][ch]; st...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class CC { static StringTokenizer s...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Div2_391C { int numG; int numE; public static void main(String...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.*; public class C1 { private static final long M = 1000000007; private static Random random = new Random( 34975 ); private static void solve() throws IOException { ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
from array import array from collections import Counter n, m = [int(x) for x in raw_input().split()] inv = [array('I') for t in range(m)] for i in xrange(n): tcs = (int(x) for x in raw_input().split()) tcs.next() for t in tcs: inv[t-1].append(i) r = 1 mod = 10**9+7 for c in Counter(x.tostring()...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int MOD = 1e9 + 7; int n, m; vector<int> tmp; vector<pair<int, int> > g[N]; int cnt1[N]; int marked[N]; int f[N]; map<vector<pair<int, int> >, int> cnt; int product(int a, int b) { return (1ll * a * b) % MOD; } void mult(int &a, int b) { a = (1l...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import static java.lang.Math.*; import static java.util.Arrays.* ; import java.util.*; import java.io.*; public class C { final int MOD = (int)1e9 + 7 ; void main() throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.ne...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> struct Node { std::map<long, long> g; std::vector<long> type; long count; Node() : count(0) {} }; int main() { std::ios_base::sync_with_stdio(false); long n, m; std::cin >> n >> m; std::vector<std::vector<long> > type(m + 1); for (long i = 0; i != n; ++i) { long g; std...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package cdr; import java.util.*; import java.math.*; import java.io.*; public class Luck{ public static InputReader sc; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); static Queue<Integer>[] inEdges; static Queue<Integer>[] outEdges; public static void main(String[...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000005; vector<int> vec[MAX_N]; long long fac[MAX_N]; void make() { fac[0] = fac[1] = 1; for (int i = 2; i < MAX_N; i++) { fac[i] = fac[i - 1] * (long long)i % 1000000007; } } long long mul(long long x, long long y) { return x * y % 1000000007; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> c[1000005]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int j = 1; j <= n; ++j) { int g; cin >> g; for (int i = 1; i <= g; ++i) { int v; cin >> v; c[v].push_back(j); } } sort(c + 1, c + 1 ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
/** * DA-IICT * Author : Savaliya Sagar */ import java.io.*; import java.math.*; import java.util.*; public class C { public static int mod = 1000000007; public static FasterScanner in = new FasterScanner(); public static PrintWriter o = new PrintWriter(System.out); static long factorial[] = new long[5000005];...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int md = 1000000007; const int N = 1234567; vector<int> a[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { int foo; scanf("%d", &foo); while (foo--) { int bar; scanf("%d", &bar); a[bar].push_back(i);...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int fact[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m, i, j, x, g, ans, cursize; fact[0] = 1; for (i = 1; i < 1000005; i++) fact[i] = (fact[i - 1] * i) % 1000000007; cin >> n >> m; vector<vector<long long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.awt.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.List; import static java.lang.Math.max; import static java.lang.Math.min; public class C implements Runnable{ // SOLUTION!!! // HACK ME PLEASE IF YOU CAN!!! // PLEASE!!! ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; inline string toString(long long x) { string ans = ""; while (x) ans.push_back(x % 10 + '0'), x /= 10; if (ans.size() == 0) ans = "0"; for (long long i = 0; i < ans.size() / 2; i++) swap(ans[i], ans[ans.size() - 1 - i]); return ans; } inline long long gcd(long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 7; int sz[MAX]; set<int> color[MAX]; int id; vector<int> temp[MAX]; unordered_map<int, int> hashh; long long fact[MAX], inv[MAX]; int n, m; const long long q = 100000007LL; vector<int> v[MAX]; int c; map<set<int>, int> H; int func() { fact[0] = 1; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; signed main() { int64_t n, m; cin >> n >> m; vector<int64_t> h1(m, 1); vector<unsigned long long> h2(m, 1); vector<int64_t> last(m, -1); int64_t mod1 = 1000000007; int64_t mod2 = 1000000009; vector<int64_t> pow1(100001); pow1[0] = 1; vector<unsigned long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int mod = 1e9 + 7; vector<int> s[maxn]; int fac[maxn]; int main() { ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { int g; cin >> g; while (g--) { int x; cin >> x; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const pair<int, int> DD[] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}; inline int readChar(); template <class T = int> inline T readInt(); template <class T> inline void writeInt(T first, char end = 0); inline vo...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.util.*; import java.io.*; import java.util.HashMap; import java.util.Map; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s1[]=br.readLine().split(" "); int...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const double eps = (double)1e-8; const int mod = (int)1e9 + 7; const int maxn = (int)1e6 + 5; int ans, n, m, x, y, cnt, t[maxn], tg[maxn], k[maxn], g[maxn], fact[maxn]; int K; vector<int> vpg; vector<pair<int, int> > vg[maxn]; int main() { ios_ba...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Map; import java.util.Map.Entry; import java.util.HashMap; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual s...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; map<pair<long long, long long>, long long> M; long long H1[1000001], H2[1000001], fact[1000001], v[1000001]; ; long long n, m, p; int main() { fact[0] = 1; for (long long i = 1; i <= 1000000; ++i) { fact[i] = (fact[i - 1] % 1000000007) * (i % 1000000007) % 100000000...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict,Counter from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10...
PYTHON3
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector<int> ind[m + 1]; long long int fact[m + 1]; fact[0] = 1; for (int i = 1; i < m + 1; i++) fact[i] = (fact[i - 1] * i) % 1000000007; for (int i = ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 100001; const int M = 1000001; vector<int> v[M]; map<vector<int>, int> MP; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { int g; scanf("%d", &g); while (g--) { int x; scanf(...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.IOException; import java.math.BigInteger; import java.util.*; import java.util.stream.Stream; /** * * @author Pradyumn Agrawal coderbond007 */ public class Codeforces{ public...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; public class C391 { static long MOD = (long) 1e9 + 7; s...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n; int m; cin >> n >> m; auto xs = vector<vector<int>>(m); for (int i = 0; i < n; ++i) { int l; cin >> l; for (int j = 0; j < l; ++j) { int x; cin >> x; xs[x - 1].push_back(i); } } s...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long fact(int k) { long long ans = 1; for (int i = 1; i <= k; ++i) { ans *= i; ans %= 1000000007; ; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, g; long long ans = 1; map<int, vector<pair<int, int...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long fact[2000005]; void init() { fact[0] = 1; for (int i = 1; i < 2000005; i++) { fact[i] = fact[i - 1] * i; fact[i] %= 1000000007; } } vector<pair<int, int> > v1[2000005]; int main() { init(); cin.sync_with_stdio(0); cout.tie(0); int n, m; cin...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005, MAXM = 1000006; int P1[MAXN], P2[MAXN], MOD1 = 1e9 + 7, MOD2 = 1e9 + 9; pair<int, int> hesh[MAXM]; int last[MAXM]; int fact[MAXM]; void add(int x, int y, int g) { int diff = g - last[x]; last[x] = g; hesh[x].first = ((long long)hesh[x].first *...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, ans; vector<int> v[1000005]; unsigned long long h1[1000005], h2[1000005]; unsigned long long e1[100005], e2[100005]; map<pair<unsigned long long, unsigned long long>, int> vis; map<pair<unsigned long long, unsigned long long>, int>::iterator it; int fc[1000005]; i...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; const int M = 1111111; vector<int> a[M]; int x, k; long long fact = 1, res = 1; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> k; for (int j = 1; j <= k; j++) { cin >> x; a[x].push_back(i);...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int MOD = 1e9 + 7; int n, m; vector<int> tmp; vector<int> g[N]; int cnt1[N]; int marked[N]; int f[N]; map<vector<int>, int> cnt; int product(int a, int b) { return (1ll * a * b) % MOD; } void mult(int &a, int b) { a = (1ll * a * b) % MOD; } int ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int fact[1016027 + 2]; vector<vector<int> > g; void fill(int n) { long long int i = 2; fact[1] = 1; fact[0] = 1; while (i <= n) { fact[i] = (fact[i - 1] * i) % 1000000007; i++; } } long long int poww(int a, int b) { long long int x, y; y = a;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Map; import java.util.NoSuchElementException; import java.util.TreeMap; public class C { private final long MOD = (long) (1e9 + 7); private final long BASE = (long) (1e9 + 9); private void solve(FastScanner in, P...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const int INF = 1e9 + 7; const long double PI = 3.14159265359; vector<int> types[MAXN]; int main() { int n, m; cin >> n >> m; vector<long long> fact(m + 1); fact[0] = fact[1] = 1; for (int i = 2; i <= m; i++) fact[i] = (fact[i - 1] * i) %...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; long long f[1111111]; vector<pair<int, int>> v[1111111]; map<vector<pair<int, int>>, int> z; int main() { ios_base::sync_with_stdio(0); cin.tie(0); f[0] = 1; for (int i = 1; i <= 1000000; i++) { f[i] = f[i - 1] * i; f[i] %= 1000000007; } cin >>...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class TestClass { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int num...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1000005; const long long mod = 1e9 + 7; const int N = 1e6; vector<int> rec[maxn]; long long fac[maxn], ans; int n, m; int ord[maxn], bit; bool comp(int a, int b) { return rec[a][bit] < rec[b][bit]; } void mysort(int l, int r, int j) { if (l == r) return; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e5; const long long MAX = 1e18; vector<int> arr[1000010]; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; long long ans = 1, temp = 1; for (int...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10**8) mod...
PYTHON3
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long MOD = 1e9 + 7; long long fact[N + 1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); fact[0] = fact[1] = 1; for (long long i = 2; i <= N; i++) fact[i] = (fact[i - 1] * i) % MOD; int n, m; cin >> n >> m; vector<...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
from array import array from collections import Counter n, m = [int(x) for x in raw_input().split()] inv = [array('i') for t in range(m)] for i in range(n): tcs = Counter([int(x) for x in raw_input().split()][1:]) for t, c in tcs.iteritems(): inv[t-1].append(i) inv[t-1].append(c) r = 1 mod ...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000001; const long long md = 1000000007; int n, m, k, x; long long f[N]; long long kol, ans; int main() { cin >> n >> m; vector<vector<int> > a(m + 1); f[0] = 1; f[1] = 1; ans = 1; for (int i = 1; i <= 1000000; ++i) { f[i] = (f[i - 1] * 1ll * ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; void fast() { ios::sync_with_stdio(0); cin.tie(0); } void file() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } vector<pair<int, long long> > v[1000005]; long long fact[1000005]; int main() { fast(); long long mod = 1e9 + 7; fact[0] ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000005, P = 1000000007, Mod1 = 233, Mod2 = 109; int n, m, ans, fac[MAXN]; long long Hash[MAXN]; map<long long, int> vis; int main() { scanf("%d%d", &n, &m); for (int i = fac[0] = 1; i <= m; ++i) fac[i] = 1LL * i * fac[i - 1] % P; long long Pow = 1; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; vector<int> a[1000001]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { int g; scanf(" %d", &g); while (g--) { int p; scanf(" %d", &p); a[p].push_back(i); } } sort(a, a + m + 1); ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.InputMismatchException; import java.util.List; imp...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; constexpr int64_t P0 = 2000003; constexpr int64_t P1 = 2000017; constexpr int64_t M0 = 3000000000013; constexpr int64_t M1 = 2000000000003; class TaskC { public: struct Class { int id; int cnt; }; struct Hash { int64_t a, b; Hash() : a(0), b(0) {} ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MX = 1e6 + 5; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; int n, m; unsigned long long A[2][MX]; pair<unsigned long long, unsigned long long> sta[MX]; long long F[MX]; void presolve() { srand(time(NULL)); for (int t = 0; t <= 1; t++) { for (int i ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> a[1000050]; int n, m, t, s; long long cnt = 1, ans = 1; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> t; for (int j = 1; j <= t; j++) { cin >> s; a[s].push_back(i); } } sort(a + 1, a + m + 1); for (int i = 2;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using ull = unsigned long long; vector<int> a[1001001]; const ll mod = 1000000007; int main() { int n, m; cin >> n >> m; int g, h; for (int i = 0; i < n; ++i) { cin >> g; for (int j = ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> #pragma GCC target("sse4,avx") const int mod = 1000000007; void run(std::istream& in, std::ostream& out) { int n; in >> n; int m; in >> m; std::vector<std::vector<std::pair<int, int>>> kind(m); for (int i = 0; i < n; i++) { int g; in >> g; for (int j = 0; j < g; j++) { ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int val[2][MAXN]; const int MOD[] = {1000000007, 1000000009}; const int QTD = 2; const int B = 31; long long powers[2][MAXN]; long long fact[MAXN]; int main() { int n, m; scanf(" %d %d", &(n), &(m)); for (int i = 0; i < (QTD); ++i) { powe...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int maxn = 1e6 + 9; const double pi = 3.14159265358979323846264; const int inf = 2e9; const long long mod = 1e9 + 7; int op[maxn]; long long gh[maxn]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; int num = 1; fo...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int MOD = 1e9 + 7; int n, m; vector<int> tmp; vector<int> g[N]; int cnt1[N]; int marked[N]; int f[N]; int product(int a, int b) { return (1ll * a * b) % MOD; } void mult(int &a, int b) { a = (1ll * a * b) % MOD; } int main() { f[0] = 1; for ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long double const PI = acos(-1); int const M = 1e6 + 2, mod = 1e9 + 7; vector<pair<int, int> > msk[M]; int inp[M], fac[M]; bool cmp(vector<pair<int, int> > a, vector<pair<int, int> > b) { if (a.size() < b.size()) return 1; if (a.size() > b.size()) return 0; for (int i...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MM = 1e6; vector<int> loai[MM + 2]; map<vector<int>, int> mp; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < (n); i++) { int t, k; scanf("%d", &t); while (t--) { scanf("%d", &k); loai[k - 1]...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.util.*; public class C { static final long MOD = 1_000_000_007; public static void main(String[] args) { // Scanner sc = new Scanner(System.in); FastScanner sc = new Fa...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict,Counter from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10...
PYTHON3
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > mh[1000010]; int ft[1000010]; const int MOD = 1e9 + 9; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { int q; scanf("%d", &q); map<int, int> f; for (int j = 0; j < q; j++) { int t; scanf("...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.math.BigInteger; import java.util.*; public class C { InputStream is; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/T"; FastScanner in; PrintWriter out; long MOD1 = 1000000007; long MOD2 = 816599183081670881L; public void...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package baobab; import java.io.*; import java.util.*; public class C { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve2(); ...
JAVA