text
stringlengths
49
983k
//To debug : g++ -g file.cpp -o code //to flush output : fflush(stdout) or cout.flush() //cout<<setprecision(p)<<fixed<<var //use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll //take care of precedence rule of operators //do not forget to change the sizes of arrays and value of contants and other t...
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define ps push #define in insert #define f first #define s second #define ca(v) for(auto i:v) cout<<i<<" "; #define nl cout<<"\n" #define gcd(a, b) __gcd(a, b) #define lcm(a, ...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n, m; cin >> n >> m; vector<ll> a(n); ll allSum = 0; vector<ll> pref; vector<int> ind; int curInd = 0; for (ll &e : a) { cin >> e; allSum += e; if (pref.empty() || allSum > pref.back()) { pref.push...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "trace.h" #else #define trace(args...) #endif using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; #define mp make_pair #define ub upper_bound #define lb lower_bound #define fi first #define se second #defi...
#include<bits/stdc++.h> using namespace std; //https://blog.csdn.net/Phoenix_ZengHao/article/details/113833938 typedef long long LL; const int maxn=2e5+50; LL n,m,T; LL a[maxn],sum[maxn],maxx[maxn],ans[maxn]; int main() { cin>>T; while(T--) { cin>>n>>m; memset(maxx,0,sizeof(maxx)); for(int i=1;i<=n;i++) { ...
#include<bits/stdc++.h> using namespace std; #define Fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); #define fWrite freopen ("out.txt","w",stdout); #define TC int t;cin >> t;FOR(tc,1,t) #define LL long long #define ULL unsigned long lo...
#include <bits/stdc++.h> // #include <atcoder/all> //using namespace atcoder; //tabaicho see https://boostjp.github.io/tips/multiprec-int.html // #include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; // cpp_int // int128_t // int256_t // int512_t // int1024_t // uint128_t // uin...
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <cmath> #include <iomanip> #include <string> #include <fstream> #include <vector> #include <queue> #include <stack> #include <sstream> #include <list> #include <map> #include <set> #include <limits> #include <random> #include <functional>...
#include <iostream> #include <map> #include <vector> using namespace std; int main() { int t; cin >> t; int vivod = 0; for (int i = 0; i < t; ++i){ int n, m; cin >> n >> m; vector<pair<long long, long long>> prirost; vector <long long> mas(n); long long prirost_max = 0, prir...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define ll long long #define f first #define s second #define pii pair<int,int> #define lui long unsigned int const int N =2e5+5; const int MOD = 998244353; const ll M = 1e18; ll qpow(ll a, ...
/* Author: Manish Kumar Username: manicodebits created: 23:43:03 16-02-2021 */ #include <bits/stdc++.h> using namespace std; #define int long long #define PI 3.141592653589 #define MOD 1000000007 #define FAST_IO ios_base::sync_with_stdio(false), cin.tie(0) #define deb(x) cout<<"[ "<<#x<<" = "<<x<<"] " v...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << "[" << H << "]"; debug_out(T...); } #ifdef dddxxz #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debu...
#include <bits/stdc++.h> using namespace std; #define rep(i, a) for (int i = 0; i < (int)(a); i++) #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll typedef long long ll; template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;} template<typename T>string join(const vec...
//#pragma GCC optimize ("Ofast") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstdarg> #include <cassert> #include <climits> #include <cstring> #include <complex> #include <cstdio> #include <vector> #include <string> #include <queue> #include <cmath> #include <ctime> #include <set> #include <m...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long const ll mod = 1000000007; vector<ll> cnt(200005); void preprosy(){ vector<ll> mp(10, 0); mp[9] = 1; for(ll i = 0; i < 200005; i++){ vector<ll> t = mp; for(ll j = 0; j < 10; j++){ cnt[i] = (cnt[i] + mp[j]) % mod; mp[j] = ...
#include <bits/stdc++.h> using namespace std; #define int long long #define vec vector <int> #define pb push_back #define po pop_back #define mp make_pair #define mt make_tuple #define F first #define S second #define f(i,x,n) for(int i=x;i<n;i++) #define rf(i,x,n) for(int i = x; i >= x; i--) #define all(c) c.begin()...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define all(x) (x).begin(), (x).end() #define len(s) (int)((s).size()) #define str(ch) string(1, ch) using namespace std; using ll = long long; using ull = unsigned long long; using graph = vector<vector<int>>; long long calc[200...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; #define f(i,k,n) for(ll i=k;i<n;i++) #define all(s) s.begin(),s.end() #define vec vector<ll> #define pb push_back #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) const ll maci=200002; const ll mod=1e9+7; ll dp[10][maci]; i...
#include<bits/stdc++.h> #include <unordered_map> using namespace std; #define _USE_MATH_DEFINES # define M_PI 3.14159265358979323846 /* pi */ #define ll long long #define ld long double #define vbe(v) ((v).begin()), ((v).end()) #define sz(v) ((int)((v).size())) #define clr(v, d) memset(v, d, sizeof(v...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); ll t; cin>>t; ll cnt[10]; ll dp[200005]; dp[0] = 1; cnt[9] = 1; for(ll i=0;i<9;i++) { cnt[i] = 0; } for(ll i=1;i<=200000;i++) { ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll f[200005][11]; ll ans[200005][11]; ll g[11]; const ll mod=1e9+7; void solve(){ for(int i=0;i<=9;i++){ for(int j=0;j<=9;j++) f[0][j]=0; f[0][i]=1; for(int j=1;j<=200000;j++){ for(int k=2;k<=9;k++) f[j][k]=f[j-1][k-1]; f[j][1]=(f[j-1][...
#include<bits/stdc++.h> #define int long long #define ld long double #define all(X) (X).begin(), (X).end() #define reset(X) memset(X, 0, sizeof(X)) #define mp(a, b) make_pair(a, b) #define pb push_back #define endl '\n' #define ff first #define ss second using namespace std; const int mod=1e9+7; // const int mod=99...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define sz(a) (ll)a.size() #define lli long long int #define pb push_back #define pf push_front #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ; #define M 1000000007 #define pi 3.141592653...
#include <iostream> #include <vector> #include <map> using namespace std; const int MAX_N = 2e5 + 5, MOD = 1e9 + 7; int length[MAX_N]; void precompute() { for(int i = 0; i <= 8; i++) { length[i] = 2; } length[9] = 3; for(int i = 10; i < MAX_N; i++) { length[i] = (length[i - ...
// amit #include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL); #define ll long long int using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define pi pair<ll,ll> #define pb push_back ll dp[200022]={1,1,1,1,1,1,1,1,1,1}; void fun() { for(int i=10;i<200022;i++) ...
/** D Bag*/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define fr(iter,n) for(ll iter=0;iter<n;++iter) #define forr(iter,s,e) for(ll iter=s;iter<e;++iter) #define ufr(iter,s,e) for(ll iter=s;iter>=e;--iter) #define MOD (ll)1000000007 #define pii p...
#include <bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::val...
#include<bits/stdc++.h> using namespace std; #define d1(a) {cout<<#a<<"="<<(a)<<'\n';} #define d2(a,b) {cout<<#a<<"="<<(a)<<" "<<#b<<"="<<(b)<<'\n';} #define d3(a,b,c) {cout<<#a<<"="<<(a)<<" "<<#b<<"="<<(b)<<" "<<#c<<"="<<(c)<<'\n';} #define D1(a) {cout<<#a<<"里的元素为 ";for(auto x:a)cout<<x<<' ';cout<<'\n';} #define...
// MD. Ashiqur Rahman #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define scn(x) scanf("%d",&x) #define scnl(x) scanf("%lld",&x) #define prnt(x) printf("%d\n",x) #define prntl(x) printf("%lld\n",x) #d...
#include <iostream> #include<bits/stdc++.h> #include<math.h> #include<stdio.h> using namespace std; #define ld long double #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define pb push_back #define pf push_front //#define mp make_pair #define mt make_tuple #define popb pop_back #define p...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<l...
//go to line 54 for some useful code. #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.hpp" #else #define dbg(...) 47 #define dbgm(...) 47 #endif // refer https://codeforces.com/blog/entry/66279 #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-...
#include "bits/stdc++.h" using namespace std; #define ll long long #define ld long double #define F first #define S second #define all(v) v.begin(),v.end() #define sz(v) (int)v.size() #define precision cout << fixed << setprecision(15); const int inf = 1e9; const long long INF = 1e18; const int mod = 1e9 + 7; const i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for(int (i)=0; (i)<(n); (i)++) #define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++) #define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--) template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y...
//Template Starts Here //Headers #include <iostream> #include <string> #include <vector> #include <climits> #include <algorithm> #include <cfloat> #include <sstream> #include <unordered_set> #include <queue> #include <deque> #include <iomanip> #include <bitset> #include <iterator> #include <list> #include <stack> #inc...
#include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mk make_pair #define pb push_back const int inf=0x3f3f3f3f; const int maxn=2e5+10; using namespace std; typedef long long ll; const ll mod=1e9+7; void useiostream() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } ll num[15]={0}...
#include <iostream> #include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define fr(i,n) for(int i=0;i<n;i++) #define fr1(i,k,n) for(int i=k;i<n;i++) #define foreach(i,arr) for(auto i: arr) #define sort_inc(a) sort(a.begin(),a.end()) #define sort_dec(a) sort(a.begin(),a.end(),greater<>()) #define exist...
#include <cmath> #include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <vector> #include <fstream> #include <cassert> using namespace std; istream& inp = cin; //ifstream inp("in"); template<typename T> vector<T> readV(int size) { vector<T> result; for (int i = 0; i < size; ++i) { T x; inp...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 233333; const ll mod = 1e9 + 7; ll dp[10][N]; int main() { int m = 200011; for(int i = 0; i <= 9; ++i) dp[i][0] = 1; for(int i = 1; i <= m; ++i) { for(int d = 0; d <= 9; ++d) { if(d <= 8) { ...
#include<iostream> #include<algorithm> #include<vector> #include<cstring> #include<cstdio> #include<cmath> #include<map> #include<set> #include<queue> #include<stack> #include<bitset> #include<cstdlib> #include <iomanip> #include<climits> #include<fstream> using namespace std; //=========================MACROS=====...
#include <bits/stdc++.h> #define PI 3.14159265359 #define lp(i, n) for (size_t i = 0; i < n; i++) typedef long long ll; typedef long double ld; using namespace std; const char nl = '\n'; const ll MOD = (ll)1e9 + 7; vector<ll> lenDigit(int d, int m) { ll occ[10] = {0}; occ[d] = 1; vector<ll> v; v.pus...
#include<bits/stdc++.h> using namespace std; #define ll long long #define f(i,a,n) for(ll i=a ;i<n ;i++) #define fr(i,a,n) for(ll i=n-1;i>=a;i--) #define pb push_back #define read(a,n) for(ll i=0 ;i<n ;i++)cin>>a[i] #define F first #define S second #define endl "\n" bool pali(string s) { for(ll i=0 ;i<s.size()/2 ;...
#include<bits/stdc++.h> using namespace std; #define int long long const int max_n = 200005, mod = 1000000007; int p[max_n]; signed main() { for (int i = 0; i < 9; i ++)p[i] = 2; p[9] = 3; for (int i = 10; i < max_n; i ++) { p[i] = (p[i - 9] + p[i - 10]) % mod; } ios_base :: sync_with_stdio...
#include <iostream> #include <stdio.h> using namespace std; int main() { long long t,n,sum[10],total[200001],temp,temp1,temp2,inf=1000000007,j,ans,formulation; long long i,m,xiao=200000; for(i=0; i<10; i++) sum[i]=0; sum[0]=1; sum[1]=1; total[0]=2; for(i=1; i<=xiao; i++) { ...
#include <iostream> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> ...
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int m=200000; int p=1000000007; vector<int> dp(m+1); for(int i=0;i<9;i++){dp[i]=2;} dp[9]=3; for(int i=10;i<=m;i++){dp[i]=(dp[i-10]+dp[i-9])%p;} int t; cin>>t; while(t--...
#include<iostream> using namespace std; #include<vector> #include<algorithm> #include<functional> #include<iterator> int main() { vector<int> operate; for (int i = 0; i < 200001; i++) { if (i < 9) operate.push_back(2); if (i == 9) operate.push_back(3); if (i > 9) operate.push_back((operate[i - 9] + op...
#include<bits/stdc++.h> using namespace std; inline int read(){ int X=0; bool flag=1; char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();} while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();} if(flag) return X; return ~(X-1); } int T,n,m; typedef long long ll; ll mod=1e9+7,ans=0l...
#include <stdio.h> #include <iostream> #include <vector> #include <algorithm> // for copy #include <iterator> // for ostream_iterator using namespace std; const int P = 1000000007; const int M = 200000; int answer_for_0[M+10]; // the result for the digit 0 is answer_for_0[m] // the result for any other digit d is ans...
// Просто решаю.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. // //KiruxaLight #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <iostream> #include <vector> #include <string> #include <set> #include <map> #include <algorithm> #include <utility> #inclu...
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define gap ' ' #define fastIO {ios_base::sync_with_stdio(false);cin.tie(NULL);} #define Inf 1e1...
#include<bits/stdc++.h> #define ll long long using namespace std; const int mxn=2e5+10,mod=1e9+7; int dp[12][mxn]; int main() { int arr[]={1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; for(int i=0;i<=9;i++) for(int j=0;j<10;j++) dp[i][j]=arr[i+j]; for(int i=0;i<=9;i++) for(int j=10;j<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int big = pow(10, 9) + 7, size = 200000; int tt; cin >> tt; vector<ll> dp(size+1); dp[0] = 1; for (int i = 0; i < size; i++) { if (i + 9 < size) ...
#include<iostream> #include<vector> #include<queue> #include<cstring> #include<cmath> #include<map> #include<stack> #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int inf = 0x3f3f3f3f; #define mp make_pair #define pb push_back #define fi first #define se second #define fast ios::s...
#include<bits/stdc++.h> #define MAX 200000 #define MOD 1000000007 using namespace std; int dp[11][MAX+10]; int go(int x,int m) { if(dp[x][m]!=-1) return dp[x][m]; if(m==0) return dp[x][m] = 1; if(x==9) return dp[x][m] = (go(1,m-1)+go(0,m-1))%MOD; return dp[x][m] = go(x+1,m-1); } int main() { ios_base::sync_...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <bitset> #include <math.h> #include <fstream> #include <iomanip> using namespace std; using ll = long long; using ld...
#include<bits/stdc++.h> using namespace std; long long m=200000,k=1; long long sum[200001][10]={{}}; long long a[10]={1,1,1,1,1,1,1,1,1,1},b[10]; int main(){ ios_base::sync_with_stdio(false); long long j=9; k=1; ios_base::sync_with_stdio(false); for(long long i=0;i<=9;i++) a[i]=0; a[j]=1; while(k<=m) { for...
#include<bits/stdc++.h> #define mp make_pair #define s second #define pb push_back #define eb emplace_back #define all(v) v.begin(),v.end() #define mx(a,b) a>b?a:b #define mn(a,b) a<b?a:b using namespace std; const int maxn = 5+2e5; typedef long long ll; const int mod = 1e9+7; int dp[maxn]; int main(){ ios::sync_with...
#include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(int i = k ;i<=n;i++) #define FO(i,n,k) for(int i = n;i>=k;i--) #define ll long long #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long int #define fab(i,a,b) for(i=a;i<=b;i++) #define fabr(i,a,b) for(i=b;i>=a;i--) #define f(i,n) for(i=0;i<n;i++) #define sc second #define fr first #define pb push_back #define mp make_pair #define mo...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; const int mod = 1e9 + 7; int dp[MAXN][10]; void solve() { for(int i = 0; i <= 9; i++) { dp[0][i] = 1; } for(int i = 1; i < MAXN; i++) { for(int j = 0; j <= 9; j++) { if(j == 9) dp[i][j] = (dp[i - 1][0] + dp[i - 1][1]) % mod; ...
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; #define debug(x) cout << #x << " is " << x << endl typedef pair<int, int> pii; typedef long long ll; const int INF = 0x3f3f3f3f, N = 2e5 + 15; const ll MOD = 1e9 + 7; int t, n, m; ll a[N]; int main() ...
#pragma GCC optimize("Ofast") #include "bits/stdc++.h" #define rep(i,j,n) for(int i=(j);i<=((int)n);++i) #define rev(i,n,j) for(int i=(n);i>=((int)j);--i) typedef long long int ll; #define int long long int const ll INFL=0x3f3f3f3f3f3f3f3fLL; const int INF=0x3f3f3f3f; const int mod=1000000007; #define endl "\n" #define...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define MAX 1000000007 #define vi vector<int> #define vl vector<long long> #define pi pair<int,int> #define pl pair<long long,long long> #define pb push_back #define mi map<int,int> #define ml map<long long,long long> ll dp[10][200001]; ll a[10]; ll...
#include <bits/stdc++.h> #define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) typedef long long ll; typedef long double ld; using namespace std; mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count()); const int MOD = 1e9 + 7; template<typename T, typename U> pair<T, U> operator+...
#include <bits/stdc++.h> using namespace std; #define int long long const int max_n = 200005, mod = 1000000007; int dp[max_n]; signed main(){ for(int i=0; i<9; i++)dp[i] = 2; dp[9] = 3; for(int i=10; i<max_n; i++){ dp[i] = (dp[i-9] + dp[i-10])%mod; } ios_base::sync_with_stdio(false); ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constex...
#include <bits/stdc++.h> using namespace std; //define ONLINE_JUDGE #ifndef ONLINE_JUDGE #define debug(x) cout << #x <<'\t' << x <<endl #else #define debug(x) #endif typedef long long ll; typedef unsigned long long ull; const ll mod = 1e9 + 7; const double eps = 1e-8; const ll LINF = 0x3f3f3f3f3f3f3f3f; #define fast io...
#include<bits/stdc++.h> #include <sys/types.h> #include <unistd.h> #define ull unsigned long long int //#define lli long long int #define int long long int #define NUM 1000000007 #define mp make_pair #define pb push_back #define ITR ::iterator #define endl "\n" #define fast_io ios_base::sync_with_stdio(false);cin.tie(N...
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 #define MAXM 200015 long long y; int pd[MAXM]; int solve(int x){ if(x < 0) return 0; if(pd[x] == -1){ if(x <= 9) pd[x] = 1; else{ y = (solve(x - 10) + solve(x - 9)); if(y > MOD) y -= MOD; pd[x] = y; } } return p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 //typedef unsigned long long int ull; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); vector<vector<ll>> v(10,vector<ll> (200001,0)); ll A[10];ll B[10] = {0}; ll maxx = 200000; for(int I=0;I<...
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long ll mod=1000000007; using namespace std; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll dp[10][200001]; //ll dp[200001][10]; // void calc() // { // for(int i=0;i<=9;i++) dp[0][i]=1;//base case // for(int i=1;i<=20000...
#include<bits/stdc++.h> using namespace std; #define long long long #define fi first #define se second const long MOD = 1e9+7; const long LINF = 1e18; const long INF = 1e9; typedef pair<int,int> ii; typedef pair<int,ii> iii; int D[10][200003][10]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);...
#include<bits/stdc++.h> using namespace std; typedef long long ll; char a[20]; ll dp[200020]; ll cnt1[10]; ll cnt2[10]; ll mod=1e9+7; int main() { cnt1[0]=1; for(int i=1;i<=9;i++){ cnt1[i]=0; } dp[0]=1; for(int i=1;i<200020;i++){ if(i%2==1){ memset(cnt2,0,sizeof(cnt2)); }else{ memset(cnt1,0,sizeof(cnt1...
#include<bits/stdc++.h> using namespace std; const int N = 300005; const int mod = 1e9 + 7; #define ll long long #define rep(i, a, b) for(int i=(a);i<=(b);++i) #define per(i, a, b) for(int i=(a);i>=(b);--i) #define ms(a, b) memset(a, b, sizeof a) int n, T, m; ll f[N + 100]; int main(){ for(int i=0;i<=9;i++)f[i]=1; f...
#include <bits/stdc++.h> #define int long long int #define F first #define S second #define MK make_pair #define pb push_back #define mid (l + r) / 2 using namespace std ; const int N = 3e5 + 100 , M = 1e9 + 7; int n , m , k , a[N] , f[10][N] , s[N] ; int32_t main(){ ios::sync_with_stdio(false),cin.tie(0),cout....
//#pragma GCC optimize("Ofast,fast-math,unroll-loops") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt") #include <bits/stdc++.h> //#define int32_t int64_t /* const size_t MAX_MEM = 2e8; char MEM[MAX_MEM]; size_t MEM_POS = 0; void* operator new(size_t x) { auto ret = MEM + MEM_POS; MEM_...
#include<iostream> #include<stack> #include<string> #include<set> #include<map> #include<vector> #include<math.h> #include<functional> #include<limits.h> #include<utility> #include<queue> #include<algorithm> #include<cstring> #include<iomanip> #include<bitset> #include<time.h> #include<unordered_map> #define lowbit(x) ...
#include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const int M = 1e9+7; ll mod(ll x){ return (x%M + M)%M; } ll mul(ll a, ll b){ return mod((mod(a)*mod(b))); } ll add(ll a , ll b){ return mod(mod(a)+mod(b)); } void solve(){ vector<vector<int>>dp(200001,vector<int>...
// Problem: C. Add One // Contest: Codeforces - Divide by Zero 2021 and Codeforces Round #714 (Div. 2) // URL: https://codeforces.com/contest/1513/problem/C // Memory Limit: 256 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org) #include<iostream> #include<cstring> #include<cmath> #include<s...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define ifs freopen("aa.in","r",stdin); #define ofs freopen("aa.out","w",stdout); #define iof ifs ofs #define ll long long #define ld ...
//Bismillahir Rahmanir Raheem #include <bits/stdc++.h> using namespace std; typedef long long int ll; #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define mod 1000000007 ll dp[200001][11]; ll f(ll m,ll x){ if(m==0)return 0; if(dp[m][x]!=-1)return dp[m][x]; dp[m][x]=0; if(m>=(...
#include "bits/stdc++.h" using namespace std; /* find my code templates at https://github.com/galencolin/cp-templates also maybe subscribe please thanks */ #define send {ios_base::sync_with_stdio(false);} #define help {cin.tie(NULL);} #define f first #define s second #define getunique(v) {sort(v.begin(), v.end()); v....
#include <bits/stdc++.h> using namespace std; const long long N=1e9+7; #define int long long #define pb push_back #define f first #define si second #define mp make_pair #define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define endl "\n" #define PI 3.1415926535897 string alp="abcdefghijk...
#include <bits/stdc++.h> #define int long long #define MOD 1000000007 using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "[ "; for (auto v : V) os << v << " "; os << "]"; return os; } template <class T> ostream &operator<<(ostream &os, set<T> S) {...
#include <bits/stdc++.h> using namespace std; #define ios ios_base::sync_with_stdio(false);cin.tie(NULL); #define ll long long int #define pb push_back #define max3(a,b,c) max(max((a),(b)),(c)) #define max4(a,b,c,d) max(max((a),(b)),max((c),(d))) #define min3(a,b,c) min(min((a),(b)),(c)) #define min4(a,b,c,d) min(min((...
#include <iostream> const int MOD = 1e9 + 7; const int MX = 2e5 + 55; int memo[MX + 1]; int d[10]; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int t = 1; scanf("%d", &t); d[0] = 1; for (int i = 1; i <= MX; i++) { int tmp[10] = { 0 }; for (int j = 0; j <= 9; j++) { if (j =...
#include<bits/stdc++.h> using namespace std; #define DONTSYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now! #define TEST unsigned long long T; cin>>T; while(T--) //loop over each testcase #define endl "\n" #define for...
#include <bits/stdc++.h> using namespace std; #ifndef _LOCAL //#pragma GCC optimize("O3,Ofast") #else #pragma GCC optimize("O0") #endif #define ttt template<typename t, typename u> ttt inline void umin(t &a, const u b) {if(b < a) a = b;} ttt inline void umax(t &a, const u b) {if(a < b) a = b;} ttt vector<t>& operator<<...
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long const int N = 2e5 + 5, M = 1e9 + 7; vector<vector<int>> dp; void pre() { dp = vector<vector<int>> (N, vector<int> (10, 1)); for(int i = 1 ; i < N ; i++) { for(int j = 0 ; j < 9 ; j++) { dp[i][j] = dp[i - 1][j + 1]; } ...
/** * author : madhav * handle : madhav10 **/ #include <bits/stdc++.h> using namespace std; #define For(start,end,inc) for( int i=(start);i<(end);i+=inc) typedef long long ll; int nax=1e6+15; vector<ll> f(nax,0); vector<ll> num(10,0); ll convert(){ int mod=1e9+7; vector<ll> tmp(10,0); For(1,10,1){ tmp[i]=num[i...
#include <bits/stdc++.h> #include<sstream> #include<string> #include<vector> #include <set> #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define pb push_back #define mp make_pair #define ll long long #define ff first #define ss second long long M=1000000007; using namespace std; ll fact[10...
/*...................................................................* *............___..................___.....____...______......___....* *.../|....../...\........./|...../...\...|.............|..../...\...* *../.|...../.....\......./.|....|.....|..|.............|.../........* *....|....|.......|...../..|....|.....
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define MOD 1000000007 #define fi first #define se second #define rep(i,n) for(ll i = 0 ; i < n ; i++) #define repe(i,n) for(ll i = 0 ; i <= n ; i++) #define repb(i,a,b) for(ll i = a ; i < b ; i++) #define repeb(i,a,b) for(ll i = a...
#include <bits/stdc++.h> #define ll long long #define for0() for(int i = 0; i < n; i++) #define for1() for(int i = 1; i < n; i++) #define forv(c, k) for(int i = c; i < k; i++) #define vi vector<int> #define endl '\n' #define mod 1000000007 using namespace std; int dp[12][200010]; int main() { cin.tie(NULL); ios...
#include <bits/stdc++.h> using namespace std; // DATA TYPES typedef long long ll; typedef long double ld; typedef unsigned long long ull; // FUNCTIONS #define F first #define S second #define PB push_back #define MP make_pair #define B begin #define I insert #define E erase #define LB lower_boun...
#include<bits/stdc++.h> #include<string> #include<map> #include<set> #include<sstream> using namespace std; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define linebreak cout<<"\n" #define lli long long int const int MOD = 1000000007; const int N = 100005; const lli p = 53; const lli m = 100000...
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define take ll a[n]; for(int i=0;i<n;i++){cin>>a[i];} #define ll long long int #define output for (int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl; #define vv vector<ll> #define VIN(a) for(auto &it:a) cin>>i...
#include<bits/stdc++.h> #define pii pair<int,int> #define fi first #define sc second #define pb push_back #define ll long long #define trav(v,x) for(auto v:x) #define all(x) (x).begin(), (x).end() #define VI vector<int> #define VLL vector<ll> using namespace std; const int N = 1e6 + 100; const ll mod = 1e9 + 7; signed...
#include<iostream> #include<cstdio> #include<unordered_map> using namespace std; const int N=105; const int MOD=1000000007; int n,q; int c[N]; int b[N]; int sb[N],sc[N]; int l,r; int solve(int x) { static int f[N][N*N],g[N][N*N]; f[0][0]=g[0][0]=1; for(int i=1;i<=n;i++) { for(int j=0;j<max(i*x+s...