code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
// arc110_b #include <bits/stdc++.h> #ifdef LOCAL #include "../cxx-prettyprint/prettyprint.hpp" #endif using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; #define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i)) #define REPN(i, m, n) for (int (i) = m ; (i) < (int)(...
#include<bits/stdc++.h> #define f first #define int long long #define s second using namespace std; const int N=2e5+5,mod=1e9+7; int t,n,a,b; string s; main(){ // t=1; cin>>a>>b; if(a>=b) { int sum=0; for(int i=1;i<=a;i++){ cout<<i<<" "; if(i>=b) sum -= i; } for(int i=1;i<=b;i++) { if(i<b) cout<<-...
#include <bits/stdc++.h> #include <chrono> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; /*............................................................................*/ #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dd; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; const int Mx=1e6+11; const double PI = acos(-1); #define MOD 1000000007 #define nl '\n' #define pb push_back #define F first ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; vector<int> adj[200005]; int n, k; array<int, 3> dp[200005]; // (#special, min dist(u, special), max dist(u, not satisfy yet)) array<int, 3> combine(array<int, 3> a, array<int, 3> b, int d) { array<int, 3> res; res[0] = a[0] + b[0]; res[1...
#include <bits/stdc++.h> using namespace std; int main() { long long N, M; cin >> N >> M; vector<long long> X(M), Y(M); for (int i = 0; i < M; i++) cin >> X[i] >> Y[i]; set<pair<long long, long long>> Set; for (int i = 0; i < M; i++) { Set.insert(make_pair(X[i], Y[i])); } set<long long> Sec; Sec.insert(N);...
#include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() #define int long long bool can[(int) 1e5 + 5] = {false}; int32_t main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (auto &x: a) cin >> x; int s = accumulate(all(a...
#include <bits/stdc++.h> #define rep(i,n) for ((i)=1;(i)<=(n);(i)++) using namespace std; const int mod=1e9+7; int n,i,a[100005],s=1; int main(){ cin>>n; rep(i,n)cin>>a[i]; sort(a+1,a+n+1); rep(i,n){ s=1ll*s*(a[i]-a[i-1]+1)%mod; } cout<<s<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define rep(i, n) for(int i = 0;i < n;i++) #define rep1(i, n) for(int i = 1;i < n;i++) #define repr(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) vector<vector<l...
/* Before submitting, please CHECK: maxn, modu, inf, eps */ #include <bits/stdc++.h> #define lc (o<<1) #define rc ((o<<1)|1) #define PB push_back #define MK make_pair #define ALL(x) x.begin(), x.end() #define FT first #define SC second using namespace std; #define DebugP(x) cout << "Line" << __LINE__ << " " << #x...
#include <bits/stdc++.h> using namespace std; void solve(){ int n; long long c; cin>>n>>c; vector<long long> a(n),b(n); vector<long long> c1(n); set<int> s; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]>>c1[i]; s.insert(a[i]); s.insert(b[i]+1); } map<long long,long long> m; vector<long long> rev(2*n+1); int ...
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstring> #include <regex> #include <cmath> #include <algorithm> #include <vector> #include <list> #include <map> #include <unordered_set> #include <queue> #include <unordered_map> #include <set> #include <cassert> #include <climits...
#include <bits/stdc++.h> using namespace std; int main() { //freopen("in.txt", "r", stdin); int tt; cin >> tt; while (tt--) { long long n; cin >> n; if (n & 1) { puts("Odd"); } else { n >>= 1; if (n & 1) puts("Same"); else puts("Even"); } } return 0; }
#include<bits/stdc++.h> typedef long long ll; #define int ll #define endl '\n' using namespace std; const int mod = 998244353; const int MAXN = 1000000; //int fa[MAXN]; int b[205]; void solve() { int n; cin >> n; int res = 0; for(int i=0;i<n;i++) { int x; cin >>x; b[x%200]++; ...
#include<bits/stdc++.h> using namespace std; int n,m; long long f[20][1<<18]; vector<pair<int,int>> cs[25]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=0;i<m;i++){ int x,y,z; cin>>x>>y>>z; x--; y--; cs[x].emplace_...
#include<bits/stdc++.h> using namespace std; int main(){ int n, t; cin >> n; double a, b; vector<double> l(n), r(n); for(int i = 0; i < n; ++i){ cin >> t >> a >> b; if(t == 2){b -= 0.1;} else if(t == 3){a += 0.1;} else if(t == 4){a += 0.1; b -= 0.1;} l[i] = a; r[i] = b; } // for(int ...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using lli = long long int; int main(){ int t; cin >> t; for(int rep=0; rep<t; rep++){ int n; cin >> n; vector<int> a(n); for(int i=0; i<n; i++){ cin >> a[i]; } vector<...
/* ** *** Be Name Khoda *** ** */ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e3 + 10; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, z = 1; cin >> n; int x = 38, y = 26; vector<ll> v3, v5; while (x--) { z *= (ll)3L...
#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> #define ll long long #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(0); ll k,n,m; cin>>k>>n>>m; vector<ll> a(k); rep(i,k) cin>>a[i]; vector<ll> b(k, 0); rep(i,k) { b[i] = a[i] * m; b[i] /= n; } ll lim = m; rep(...
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. ******************************************...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll startTime; const int Di[] = {-1,+1, 0, 0}; const int Dj[] = { 0, 0,-1,+1}; long long getTime() { timespec ts; clock_gettime(CLOCK_REALTIME_COARSE, &ts); long long r = ts.tv_sec; r *= 1000000000; r += ts.tv_nsec; return r; } struct Input { int...
#include <iostream> #include <string> #include <algorithm> #include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cc...
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double const int mod = 1000000007; int s, p;bool ans=0; // Function to print the divisors void printDivisors() { // Note that this loop runs till square root for (int i=1; i*i<=p; i++) { if (p%i == 0) ...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<LD> VLD; typedef vector<string> VS; #define rep(i, max) for (LL i = 0; i < (LL)(max); i++) #define repm(i, min, max) for (LL i = (LL)(min); i < (LL)(max); i++) #defi...
#pragma GCC optimize ("Ofast") #define _USE_MATH_DEFINES #include <bits/stdc++.h> #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define FORD(i, a, b) for (int i=(a); i>(b); i--) #define PPC(x) __builtin_popcount(x) #define MSB(x) (31 - __builtin_clz(x)) #define SZ(x) ((int)(x).size()) #define pb push_back #define AL...
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define FOR(i,a,b) for(int _n(b),i(a);i<_n;i++) #define REP(i,n) FOR(i,0,n) void setIO() { ios_base::sync_with_stdio(0); cin.tie(0); } const int MX = 3; int a[MX]; int n; int main() { setIO(); REP(i, 3) cin >> a[i]; sort(a, a+...
#include<bits/stdc++.h> #define loop(i, n) for(int i = 0; i < n; i++) #define pb push_back #define ll long long int #define vi vector<int> #define pi pair<int, int> #define W(t) int t; cin >> t; while(t--) #define FIO ios_base::sync_with_stdio(0); cin.tie(0); c...
#include <bits/stdc++.h> #define pb push_back #define ll long long #define mp make_pair #define si short int #define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define pill pair<ll,ll> #define f first #define s second #define pilc pair<ll,char> #define all(a) (a).begin(),(a).end() #define rep(s,e,step) ...
#include <bits/stdc++.h> #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto &i : (a)) #define SZ(x) ((int)(x).size()) #define X first #define Y second #define MP std::make_pair #define PR std::pair typedef long long ll; typedef std::pair<int, ...
/*Allah Vorosha*/ #include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define in insert #define rev reverse #define all(x) (x).begin(),(x).end() #define all2(x) (x).rbegin(),(x).rend() #define sz(v) (int)v.size() #define yes cout << "YES\n" #define no cout << "NO\n"; #define take fo...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll N, M; cin >> N >> M; ll MM = M*M; auto pow = [](ll x, ll n, ll m) -> ll { ll t = x, r = 1; t %= m; while ( n > 0 ) { if ( n & 1 ) { r *= t; r %= m; ...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } r...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define INF LONG_MAX/3 #define DIV 1000000007 //#define DIV 998244353 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> using namespace std; #define MOD 1000000007 #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD) typedef long long i64; typedef v...
#include <bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b,c,d; cin >> a >> b >> c >> d; cout << a * d - b * c << endl; }
#include <iostream> #include <vector> #include <string> #include <array> #include <functional> #include <algorithm> #include <stack> #include <map> #include <set> #include <climits> #include <queue> #include <bitset> #include <cassert> #include <math.h> #include <complex> #include <iomanip> using namespace std; #define...
// JG GAP GG #include <iostream> #include <cstring> #include<vector> #include <algorithm> #include<cstdlib> #include<set> #include<math.h> #include<map> #include<unordered_map> #include<iomanip> #include<queue> #include<bitset> using namespace std; using ll = long long; using ull = unsigned long long; const ll MOD...
#include <set> #include <iostream> #include <string> #include <vector> #include <map> #include <cmath> #include <algorithm> #include <queue> #define INFL 100100100100100 #define INF 100100100 using namespace std; int main() { int sx,sy,gx,gy; cin >> sx >> sy >> gx >> gy; printf("%.15lf", sx + (double)(gx-sx) *...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) using namespace std; using namespace __gnu_pbds; auto random_addres...
#include<bits/stdc++.h> #include<iomanip> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);} #define ar array #define all(x) (x).begin(), (x).end() #define Unique(a) a.erase(unique(all(a)), a.end()) #define ld long double #d...
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int h, w, m; struct BIT{ private: vector<LL> node; int n; public: BIT(int _n){ n=_n; node.resize(n,0); } void add(int a,LL w){ for(int i=a;...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> #define int long long int #define endl "\n" #define ...
#include <bits/stdc++.h> using namespace std; // For Policy Based DS #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; // --------------------------------------- #define endl "\n" #define ff first #define ss second #define int...
#include <bits/stdc++.h> using namespace std; #define vi vector<int> #define ff first #define ss second #define pb push_back #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define ps(x) fixed << setprecision(10) << x #define mod 1000000007 #define inf 1e18 #define w(tc) \ int tc;...
#include <bits/stdc++.h> #define int long long #define pb push_back #define ppb pop_back #define all(x) (x).begin(),(x).end() #define w(x) int x; cin>>x; while(x--) #define fr first #define sc second #define sz(x) (int) ( (x).size() ) #define pii pair<int,int> using namespace std; int INF = 1e1...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i, s, n) for (int i = (s); i <= (n); ++i) using ll = long long; using P = pair<int, int>; const ll MX = 1000000000; int main() { int n; cin >> n; vector<ll> a(n), p(n), x(n); rep(i, n) cin >> a[i] >> p[i...
#include<bits/stdc++.h> using namespace std; vector<int>T[100005]; int p[100005],d[100005],sz[100005]; int c1[100005],c2[100005]; int cmp(int x,int y){ return c1[x]-c2[x]<c1[y]-c2[y]; } void dfs(int rt){ int l=T[rt].size(); sz[rt]=1; c1[rt]++; if(l==0)return; for(int i=0;i<l;i++){ int v=T[rt][i]; dfs(v); sz...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define len(x) int((x).size()) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define randint(n) uniform_int_distribution<int>(1, (n))(rng) const int ...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define fr first #define sc second using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long double a , b , ans; cin >> a >> b; long double x = a - b; ans = (x/a)*100; printf("%llf",ans); retu...
#include <bits/stdc++.h> using namespace std ; typedef long long ll ; #define rep(i,n) for(int i = 0 ; i < n ; i++) int a , b ; map<int,int> rem ; int main(){ cin >> a >> b ; for(int i = 1 ; i <= b ; i++){ rem[i] = b / i - (a - 1) / i ; } int res = 1 ; for(int i = 1 ; i <= b ; i++){ ...
# include <bits/stdc++.h> typedef long long lint; using namespace std; lint gcd(lint x, lint y) { if(x == 0) { return y; } else { return gcd(y%x,x); } } lint lcm(lint x, lint y) { return x/gcd(x,y)*y; } lint C(lint n, lint k) { if(n == k) { return 1; } else if(n < k) { return 0; } else if(k == 0) { return ...
///131111129.......... #include<bits/stdc++.h> using namespace std; #define ll long long int #define pi acos(-1) #define pb push_back #define mp make_pair #define rip() for(ll i=0;i<n;i++) #define rip1() for(ll i=n-1;i>=0;i--) #define cin(a) cin>>a #define cout(a) cout<<a #define nl '\n' ///Chess moves......... // in...
#include <bits/stdc++.h> #define rep(i, e, n) for (int i = e; i < (n); ++i) using namespace std; typedef long long ll; using P = pair<int,int>; const ll inf=1000000000007; const int mod=1000000007; int main() { char s; cin >> s; char t; cin >> t; if(s=='Y'){ t=toupper(t); } cout << t << endl; retur...
#include <bits/stdc++.h> #define N 100005 #define SpeedCode ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; int a; int main(){ SpeedCode; cin>>a; cout<<a-1; }
#include <bits/stdc++.h> using namespace std; #define repr(i,a,b) for (int i=a; i<b; i++) #define rep(i,n) for (int i=0; i< n; i++) #define PI 3.14159265359 const long long INF = 1LL << 60; long long MOD = 1000000007; long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; } long long lcm (int a, in...
#include<bits/stdc++.h> using namespace std; int main() { string S; cin >> S; string ans; ans += S.at(1); ans += S.at(2); ans += S.at(0); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b; ++i) int debug = 0; const int N = 2010, inf = 1e9; int n, m, ans, dp[N][N]; vector <int> g[26][N]; main() { cin >> n >> m; rep(i, 1, n + 1) { rep(j, 1, n + 1) { if (i == j) { dp[i][j] ...
#include <bits/stdc++.h> #define fi first #define se second using namespace std; int st[100][26]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m,ex,ey; cin >> n >> m; char mt[n+1][m+1]; queue<pair<int,int> >q; vector<pair<int,int> >p[26]; int dst[n+1][m+1]; memset(dst,-1,s...
#include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long #define ull unsigned long long #define pi 2*acos(0.0) #define readl(v,n) for(ll i=0;i<n;i++) {ll val; cin>>val; v.pb(val);} #define readi(v,n) for(int i=0;i<n;i++) {int val;...
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n+1]; int ans=0; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]>10) ans+=a[i]-10; } cout<<ans; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cout<<setprecision(10)<<fixed; int a,b,c,d; cin>>a>>b>>c>>d; cout<<(a*d-b*c)<<'\n'; }
#include<bits/stdc++.h> #define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define Freed freopen ("0in.txt","r",stdin); #define Fout freopen ("0out.txt","w",stdout); #define ll long long int #define pb push_back #define mp make_pair #define pi acos(-1.0) #define Mod 1000000007 #define limit 1000008 using name...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll i=0;i<(ll)n;i++) #define dump(x) cerr << "Line " << __LINE__ << ": " << #x << " = " << (x) << "\n"; #define spa << " " << #define fi first #define se second #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() using ld =...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
#include <iostream> #include <string> #include <iomanip> #include <algorithm> #include <cassert> #include <numeric> #include <queue> #include <set> #include <vector> #include <cmath> #include <bitset> #include <functional> #include <limits> #include <map> using namespace std; typedef long long ll; #define rep2(i, n) f...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long int #define double long double #define pb push_back #define fi first #define se second #define vi vector<int> #define pii pair<int,int> #defi...
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector>...
#include<bits/stdc++.h> using namespace std; using lli = long long; #define rep(i,n) for(int i=0;i<n;i++) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } template<class T> ostream &operator<<(...
/*ver 7*/ #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll b,c,ans; ll solve1(ll b,ll c){ ll depth=c/2,flip=c&1; if(depth<b)return (1+depth)*2-(!flip); else return b*2+1; } ll solve2(ll b,ll c){ ll depth=c/2,flip=c&1; return max(ll(0),depth*2-(!flip)); } int main(){ scanf("%lld%lld...
/* Great things never come from comfort zones, "whatever the mind of a man can conceive and believe,it can achieve." */ #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; // ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define sz(a) ((int)a.size()) #define re return #define all(a) a.begin(),a.end() #define int long long #define Type int #define rept(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,a) rept(i,0,a) using namespace std; const int dx[4]={-1,1,0,0}; const int ...
#include<bits/stdc++.h> #define int long long using namespace std; #define rep(i, n) for(int i=0;i<(n);++i) typedef pair<int, int> pii; const int INF = 1l << 60; int N; int P[200200]; int F[200200]; int ans[200200]; signed main() { memset(F, -1, sizeof(F)); cin >> N; rep(i, N) { cin >> P[i]; ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> prime_factor(int n) { vector<pair<int, int>> ret; for (int i = 2; i * i <= n; i++) { if (n % i != 0) continue; int tmp = 0; while (n % i == 0) { tmp++; n /= i; } ret.push_back(ma...
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define pb push_back typedef long long ll; const double pi = acos(-1.0); #define debug puts("*****************") #define memset(a,b) memset(a,b,sizeof(a)) const int mod = (1 ? 1000000007 : 998244353); const int inf = (1 ? 0x3f3f3f3f : 0x7fffffff); const int...
#include<bits/stdc++.h> #define int long long typedef long long ll; using namespace std; //template<class T>T ABS(T x) {return x<0?-x:x;} //int ksm(int x,int y) {int r=1;while(y) y&1?r=1ll*r*x%mod:0,x=1ll*x*x%mod,y>>=1;return r;} int read() { int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=...
#include<bits/stdc++.h> #define rint register int #define ll long long using namespace std; char S[501000],T[500100]; int N; queue<int> q; int main(){ scanf("%d",&N); scanf("%s",S+1); scanf("%s",T+1); int las=-1; ll ans=0; for(rint i=1;i<=N;++i) { if(T[i]=='1') { q.push(i); } if(S[i]=='1') { if(las...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; #if DEBUG && !ONLINE_JUDGE ifstream input_from_file("input.txt"); #define cin input_from_file #else #endif int N, L; vector<LL> A, B; LL goingleft(int l, int r) { if (B[l] != A[l]) return -1; if (l ...
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i, l, r) for (int i = l; i <= r; ++i) #define dep(i, r, l) for (int i = r; i >= l; --i) void read (int &x) { x = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = ge...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long void solve(){ int n,m;cin>>n>>m; vector<int>A(n); vector<int>B(m); for(int i=0;i<n;i++)cin>>A[i]; for(int i=0;i<m;i++)cin>>B[i]; int dp[n+1][m+1]={0}; for(int i=0;i...
#include<bits/stdc++.h> #define int long long using namespace std; int a,b; void solve(){ cin>>a>>b; int c=b-a; while(true){ if(a%c==0||b%c==0)break; if((b/c)-(a/c)>=2)break; c--; } cout<<c<<'\n'; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); s...
//@Author: KeinYukiyoshi // clang-format off #include <bits/stdc++.h> //#pragma GCC optimize("Ofast") //#pragma GCC target("avx") #define int long long using namespace std; #define stoi stoll #define fi first #define se second #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++) #define rep2(i, a, b) for (int i...
#include<bits/stdc++.h> #define ll long long #define inf 999999999999999 #define ull unsigned long long #define F first #define S second #define eb emplace_back #define mpp make_pair #define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n' #define dbg ...
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <vector> #include <iomanip> using ll = long long; using namespace std; int main(){ int x,y; cin >> x >> y; if(x == y) cout << x; else cout << 3-x-y; }
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; using ll =long long; typedef pair<int,int> P; #define SORT(a) sort((a).begin(),(a).end()) #define REV(a) reverse((a).begin(),(a).end()) #define For(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define rep(i, n) Fo...
#include<bits/stdc++.h> using namespace std; #define int long long const int M=998244353; const int inf=4e18; const int N=300; int fact[N+1]; int power(int x,int y) { if(y<0) return power(x,M-2)*power(x,y+1)%M; y%=(M-1); int res=1; while(y>0) { if(y&1) res=res*x%M; y=y>>1; x=x*x%M; } return res; ...
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n; cin >> n; vector<int> a(n), b(n); for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++) cin >> b[i]; vector<int> c(n); int ma = 0; for(int i = 0; i < n; i++){ c[i] = max(ma, a[i]); ma = max(ma, a[i]); ...
#define LOCAL #include <bits/stdc++.h> #define fi first #define se second #define ins insert #define pb push_back #define eb emplace_back #define sz(x) ((int)x.size()) #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; // template <ty...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <limits> #include <queue> #include <string> #define int long long int const N = 100000; int const INF = std::numeric_limits<int>::max(); int const NINF = std::numeric_limits<int>::min(); int const...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__) #else #define DEBUG(...) 6 #endif template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";} template<typename C, typen...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define x1 first #define y1 second #define frb(i,a,b) for(ll (i)=(a);(i) <= (b); (i)+=(i)&-(i)) #define rfrb(i,a) for(ll (i)=(a);(i) > 0;(i)-=(i)&-(i)) #define fr(i,a,b) for(ll (i) = (a); (i) <= (b); (i)++) #define rep(i,c) for(auto ...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; const ll MOD = 1000000007; int main() { ll N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } sort(A.begin(), A.end()); ll ans = A[0]+1; for (int i = 0; i < N-1; ++i) { ll dif = A...
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define LD long double #define ST string #define BS bitset #define PA pair<LL...
/*--ILRS-- sr4saurabh */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define popb pop_back #define mp make_pair #define ve vector #define vii vector < int > #define vll vector < ll > #define pii pair < int , int > #define pll pair < ll , ll > #define vpl vector < pll...
#include <algorithm> #include <cassert> #include <queue> #include <vector> #include <iostream> using namespace std; int main() { int n; cin >> n; vector<int> adj[n+1]; vector<int> leaves; for (int i = 1; i <= n; i++) { if (2 * i <= n) { adj[i].push_back(2 * i); adj[i].pu...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long l...
#include <bits/stdc++.h> //#include <atcoder/all> #define endl "\n" using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bo...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl using lint = long long; typedef pair<int,int> P; const bool debugFlag=true; const lint linf=1e18+7; const lint inf=1e9+7; cons...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> // for less using namespace std; #define int long long #define pb push_back #define mp ma...
//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<algorithm> #include<iostream> #include<cstring> #include<bitset> #include<cstdio> #include<string> #include<cmath> #include<queue> #include<stack> #include<map> #include<set> using namespace std; #define neinf 0xc0c0c0c0c0c0c0c0ll #define inf 0x3f3f3f3f3f3f3f3fll #define uint unsigned int #define ull unsigned ...
#include <bits/stdc++.h> using namespace std; #define int long long //#define double long double #define max(x,y) (((x)>(y))?(x):(y)) #define min(x,y) (((x)<(y))?(x):(y)) #define all(v) v.begin(),v.end() #define vi vector<int> #define MOD 1000000007 #define inf 1e18 #define ps(num...
#include <bits/stdc++.h> using namespace std; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> struct P { T x; T y; P(T x, T y): x(x), y(y) {} }...
#include <bits/stdc++.h> #define EOL "\n"; typedef long long ll; using namespace std; int main(){ int N, W; cin >> N >> W; vector<pair<int, int>> event; int s, t, p; for (int i = 0; i < N; ++i) { cin >> s >> t >> p; event.push_back(make_pair(s, p)); event.push_back(make_pa...
#include <bits/stdc++.h> #include <cassert> typedef long long int ll; using namespace std; // #include <atcoder/all> // using namespace atcoder; // @@ !! LIM() int main(/* int argc, char *argv[] */) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(20); ll N; cin >> N; vector<ll> A...
#include <iostream> #include <deque> #include <unordered_map> #include <unordered_set> #include <vector> //#include "maybe.h" #include <limits> #include <bitset> #include <queue> #include <algorithm> #include <list> #include <cmath> #include <cstring> #include <bits/stdc++.h> using namespace std; using ull = unsigned...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") #define ios ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #d...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define Mp make_pair #define pb push_back using ll = long long; using db = double; using pii = pair<int, int>; using vi = vector<int>; mt19937 mrand(time(0)); ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; } ll get(ll l, ll r)...
#include<bits/stdc++.h> #define rep(a,b,c) for(int a=b;a<=c;a++) #define per(a,b,c) for(int a=b;a>=c;a--) #define pb push_back #define mk make_pair #define pii pair<int,int> #define mem(a,b) memset(a,b,sizeof(a)) #define inf 0x3f3f3f3f3f3f3f3f using namespace std; typedef long long ll; typedef double db; const int mod ...
#include <iostream> using namespace std; int main(){ int N,K,M; cin>>N>>K>>M; int A[110]; for (int i=0; i<N-1; i++) cin>>A[i]; int points=N*M; int sum=0; for ( int i=0; i<N-1; i++) sum+=A[i]; int t=points-sum; if (t<=0) cout<<'0'<<endl; else if (t<=K) cout<<t<<endl; else cout<<"-1"<<endl; }
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #define ll long long #define double long double #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #define sz size #define f first #define s second #define pb push_back #define er erase #define in insert #define mp make_...
#include <bits/stdc++.h> using namespace std; using ll = long long; // a + bi <=> a + bx using P = complex<double>; int main(){ int n, m, k; cin >> n >> m >> k; vector<int> a(k); for(int i=0; i<k; ++i) cin >> a[i]; // 「振出しに戻る」が M マス連続していないことを確認する int conti_cnt = 1; for(int i=0; i<k; ++i){ ...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int dp[3030][10][50]; void init(){ rep(i, 3030) rep(j, 10) rep(k, 50) dp[i][j][k] = 0; dp[0][0][0] = 1; } int main(vo...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int,int> pii; typedef long long ll; const long long MOD=1000000007; #define rep(i,n) for(ll i=0;i<(n);i++) #define rep2(i,m,n) for(ll i=(m);i<(n);i++) #define ALL(v) v.begin(), v.end() #define pb push_bac...
#include<bits/stdc++.h> using namespace std; int main(){ long long int A,B,C; cin >> A >> B >> C; A %= 10; if(A == 0) cout << 0 << endl; if(A == 1) cout << 1 << endl; if(A == 5) cout << 5 << endl; if(A == 6) cout << 6 << endl; if(A == 2){ B %= 4; if(B == 1) cout << 2 << endl; if(B == 2){ ...
#include <bits/stdc++.h> using namespace std; int A, B, C; int qp(int x, int y, int P) { int z = 1; for (; y; y >>= 1, x = 1LL * x * x % P) { if (y & 1) z = 1LL * z * x % P; } return z; } int main() { scanf("%d %d %d", &A, &B, &C); if (B <= 4 && C <= 4) { A = qp(A % 10, qp(B, ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } constexpr ll mod=998244353; ll mod_pow(ll a,ll b){ a%=mod; if(b==0)return 1; if(b=...
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin >> n; long long box[210]; for(int i=0;i<=199;i++){ box[i]=0; } for(long long i=0;i<n;i++){ long long a; cin >> a; a %= 200; if(a < 0){ a += 200; } if(a >= 200){ a -= 200; } box[a] += 1; } long...
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N=100010; int n; ll a[N]; ll ans=1e19; void dfs(ll i,ll pre,ll xo)//x表示当前的位置,我们通过位置去判断是否需要去异或或者或 { //pre表示我们当前的答案,xo表示我们前面统计的所以答案的异或起来的数 if(i>n) { ans=min(ans,xo^pre); retu...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007 in...
/* C - Robot on Grid */ #include <bits/stdc++.h> using namespace std; using ll = int64_t; using pii = pair<int, int>; const int N = 5e3 + 10; const int mod = 998244353; int h, w, n, s[N][N]; char a[N][N]; int ksm(int a, int b, int p) { int res = 1 % p; while (b) { if (b & 1) res = (ll)res * a % p; ...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i<n;i++) #define all(i, v) for(auto& i : v) typedef long long ll; using namespace std; const ll mod=998244353, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; ///////modin...
#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; int mod = 1e9 + 7; const int bit...
#include <iostream> #define int long long using namespace std; int binpow(int a, int b, int c) { int ret = 1; while (b) { if (b & 1) ret = ret * a % c; a = a * a % c; b >>= 1; } return ret % c; } signed main() { int a, b, c; cin >> a >> b >> c; a %= 10; b %= 4; int exp = binpow(b, c, 4); if (exp == 0) e...
#pragma GCC optimize(2) #include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define mp make_pair #define pb push_back #define visit asdf const int N=2e5+5; int n; int a[N],b[N],c[N],p[N]; vector< vector<int> > v; bool visit[N]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); ...
#include <bits/stdc++.h> using namespace std ; const int MAX = 2e5 + 10 ; int n ; int a[MAX] , b[MAX] , p[MAX] , pos[MAX] ; vector< pair<int , int> >vp , ans ; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n ; for(int i = 0 ; i < n ; ++i) cin>>a[i] ; for(int i = 0 ; i < n ; ++i) cin>>b[i] ...
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define md 998244353 #define N 200010 #define ll long long ll a[N], ans = 0; ll ksm(ll x, ll y) { if(y < 0) return 1; if(!y) return 1; ll l = ksm(x, y / 2); if(y % 2) return l * l % md * x % md; return l * l % md; } int main() { int n, i,...
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define ll long long //#define MOD 1000000007LL #define MOD 998244353LL #define doublecout(a) cout<<setprecision(16)<<a<<endl; using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける usi...
#include <bits/stdc++.h> #define pb push_back #define sz size() #define all(c) (c).begin(), (c).end() using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MOD = 1e9 + 7; const int maxn = 5e5 + 7; int main(){ ios::sync_with_stdio(false); cin.tie(0); i...
//*** Author: ShlokG ***// #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fast ios::sync_with_stdio...
#include <bits/stdc++.h> #pragma GCC target("arch=skylake-avx512") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ld = long double; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rrep(i, n) for (int i = 1;...
/* _|_| _| _| _| _| _| _| _|_| _|_|_|_| _| _| _| _| _| _|_| _| _| _|_| _| _| _| _| _| _| _| _| _|_| _| _|_|_|_| _|_| _| _| ...
#include<bits/stdc++.h> using namespace std; int modpow(int p, long long n, int mod) { if (n == 0) return 1; int t = modpow(p, n / 2, mod); return n % 2 == 0 ? 1LL * t * t % mod : 1LL * t * t % mod * p % mod; } int main() { long long N; int M; cin >> N >> M; cout << (modpow(10, N, M * M) / M) % M...
#include<bits/stdc++.h> #define int long long #define pb emplace_back #define INF 0x3f3f3f3f #define f first #define s second #define FOR(i, n) for(int i = 1; i <= n; i ++) #define FFOR(i, a, b) for(int i = a; i <= b; i ++) #define pii pair<int, int> #define mod 1000000007 #define all(x) x.begin(), x.end() #define mem(...
//x<<y=x*2^y,x>>y=x/2^y //1e5+3 is prime // in a matrix, all elements of a primary diagonal have constant diff of coordinates // and a secondary diagonal has constant sum of coordinates //use ll() for using an integer in self-built fn //(x&-x) bitwise and of (x and its 2's complement) returns (last set bit) //eg if x=1...
#include <bits/stdc++.h> using namespace std; int dist(vector<array<int, 3>> &vp, int i, int j) { auto [a, b, c] = vp[i]; auto [p, q, r] = vp[j]; return abs(p - a) + abs(q - b) + max(0, r - c); }; int solve(vector<array<int, 3>> &vp, int s, int cur, vector<vector<int>> &memo) { if (s + 1 == (1 << v...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define V vector #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), ...
#include <algorithm> #include <iostream> #include <deque> #include <climits> #include <cmath> #include <map> using namespace std; struct S { int left; int right; }; int main() { int N; std::cin >> N; std::map<int, S> colors; for (int i = 0; i < N; i++) { int x, c; std::cin >...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define pb push_back #define mp make_pair #define vi vector<int> #define vll vector<ll> const int maxn = 1e6 + 5; const int mod = 1e9 + 7; int a[maxn]; int main() { int n; cin >> n; double ans = 0; for (int i = 1 ; i...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define MV 200001 #define LMV 21 #define ff first #define ss second #define pb push_back #define eb emplace_back #define emp emplace #define mp make_pair #define ins in...
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; //using namespace atcoder; using ll = long long; typedef pair<ll,ll> P; typedef pair<ll,P> PP; typedef vector<vector<int> > Graph; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } temp...
#include<bits/stdc++.h> using namespace std; #define int long long void test(){ int n; cin >> n; vector<int> a(n), b(n); map<int,int> mp; for(int &x:a) cin >> x; for(int &x:b) cin >> x; for(int i = 0; i < n; i++){ for(int x = a[i]; x <= b[i]; x++){ mp[x]++; } } int ans = 0; for(int i = 0; i <= 100...
//Let's join Kaede Takagaki Fan Club !! #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> ...
//#undef DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; const ll llinf = (1ll<<61)-1; #define sz(a) int(a.size()) #define all(x) begin(x), end(x) #ifdef DEBUG const int DEBUG_END = 26; #define DOS cout #include <debug.h> #else #define bug(args...) void() #define cbug(a, args...) #endif #defin...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vll = vector<ll>; using vvll = vector<vll>; using vc = vector<char>; using vcc = vector<vc>; using Pii = pair<int,int>; using ld = long double; #define rep(i,n) for(int i...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { long N, A, B, Ans=0; cin >> N; rep(i, N){ cin >> A >> B; if((B-A+1)%2==0) Ans+=(A+B)*((B-A+1)/2); else Ans+=(A+B)*((B-A+1)/2)+(A+B)/2; } cout << Ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> Pii; typedef pair<int, ll> Pil; typedef pair<ll, ll> Pll; typedef pair<ll, int> Pli; typedef vector < vector<ll> > Mat; #define fi first #define se second const ll MOD = 1e9 + 7; const ll MOD2 = 99824435...
#include <iostream> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair <int,int> pii; typedef pair<ll,ll> pll; /*bool compare_function(const pair<int, int> a, const pair<int, int> b...
#include <iostream> #include <iomanip> #include <cctype> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define ALL...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #defin...
#include <iostream> using namespace std; int main(void){ // Your code here! int n; cin >> n; if(n % 2 == 0){ cout << "White" << endl; } else{ cout << "Black" << endl; } }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // oset Operations: order_of_key(k) -> Number of elemen...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i) #define For(i,a,b) for(auto i=(a);i<=(b);++i) #define rFor(i,a,b) for(auto i=(b);i>=(a);--i) #define call(var) cerr<<#var<<"="<<var<<"\n"; #define dup(x,y) (((x)+(y)-1...
#include<iostream> #include<vector> #include<functional> #include<algorithm> using namespace std; int main(){ int n; cin>>n; vector<int> a(n); for(int i=0;i<n;i++){ cin>>a[i]; } int ans=2; int max=0; for(int i=2;i<=1000;i++){ int counter=0; for(int j=0;j<n;j++){ if(a[j]%i==0){ ...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long int #define mod 1000000007 #define FIO ios_base::sync_with_stdio(false);cin.tie(NULL); int main() { FIO; int t,n,i,j; cin>>n; int x[n]; int y[n]; for(i=0;i<n;i++){ cin>>x[i]>>y[i]; } int cnt=0; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++) #define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--) #define REP(i, n) FOR(i, 0, (n)-1) #define sqr(x) ((x) * (x)) #define all(x) (x).begin(), (x).end() #de...
#include<bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; #define rep(i,n) for(int i=0;i<(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep1(i,n) for(int i=(n);i>0;i--) #define fore(i_in,a) for (auto& i_in: a) #define sz(x) (int)x....
#include<iostream> #include<string> #include<vector> #include<set> #include<iomanip> #include<algorithm> #include<cmath> #include<bitset> #include<queue> #include<stack> #include<utility> #include<cstdlib> #include<cstdio> #include<map> #include<unordered_set> #include<unordered_map> #include<list> #include<tuple> usin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dbl; typedef float flt; #define for0(i, n) for(ll i=0; i<n; i++) #define for1(i, n) for(ll i=1; i<=n; i++) #define forab(i, a, b) for(ll i=a; i<=b; i++) #define clr0(a) memset(a, 0, sizeof(a)) void solv...
#include<bits/stdc++.h> #define endl "\n" using namespace std; typedef long long ll; int main() { int a , b ; cin >> a >> b ; if((a+b)>=15 && b>=8) { cout << 1 ; /// "ice cream"; return 0; } if((a+b)>=10 && b>=3) { cout << 2 ; /// "1 ice milk"; return 0; } if((a+b)>=3) { ...
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin>> #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeo...
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define...
#include<bits/stdc++.h> using namespace std; int power(long long int x,long long int y,long long int p) { int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p; } ret...
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<string> #include<unordered_map> #include <iomanip> using namespace std; #define intmax INT_MAX #define lmax LON...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mp make_pair #define pb push_back #define pll pair<ll,ll> #define deb1(a) cout<<#a<<" = "<<(a)<<endl; #define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl; #define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<...
// ********************************************************************************* // * MURTAZA MUSTAFA KHUMUSI * // * NIT-DGP,CSE - 2019-2023 * // **************************************************************...
#include<bits/stdc++.h> #define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i) #define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i) #define foreach(i, n) for(auto &i:(n)) #define all(x) (x).begin(),...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (int)(n); ++i) using namespace std; #define MAX 1000000010 using ll = long long; int main(){ ll N, C; cin >> N >> C; vector<pair<ll,ll>>event; for(int i=0;i<N;i++){ ll a, b, c; cin >> a >> b >> c; event.push_back(make_pair(...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) ...
#include<bits/stdc++.h> #include<iostream> #include<set> #include<map> #include<iterator> using namespace std; ///defines..... #define ll long long #define lli long long int #define pb push_back #define mp make_pair #define RIP(i,n) for(ll i=0; i<n; i++) #defi...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e2+5; #define endl '\n' ll num; int cnt[5]; int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cout.setf(ios::fixed),cout.precision(3); cin>>num; while(num){ int bit=num%10; cnt[bit%3]++; num/=10; } int ans; if(...
#include<bits/stdc++.h> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; ///--->>> CONTAINERS <<<---/// using i64 = int64_t; using ll = long long; using ld = long double; using vi = vector<ll>; using vvi = vector<vector< ll > >; using vpi = ve...
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define _overload(_1, _2, _3, _4, name, ...) name #define _rep1(Itr, N) _rep3(Itr, 0, N, 1) #define _rep2(Itr, a, b) _rep3(Itr, a, b, 1) #define _rep3(Itr, a, b, step) for (i64(Itr) = a; (Itr) < b; (Itr) += step) #define repeat(....
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define mp make_pair #define pb push_back #define lp(i,s,f) for(ll i = s; i < ll(f); i++) #define inF freopen("input.in", "r", stdin); #define outF freopen("output.in", "w", stdou...
#include <iostream> #include <cmath> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #inc...
#include <bits/stdc++.h> using namespace std; vector<int> a[27]; int used[27], color[27]; vector< pair<int,int> > t; long long n,m,v1,v2,res,globalres; void dfs(int v,int type) { used[v]=type; t.push_back({v,used[v]}); for(auto to : a[v]) if(used[to] == 0) dfs(to,2); } void put(int pos, int col...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; string s; cin >> s; rep(i, k) { int len = s.size(); int original = len; if (len % 2) { len *= 2; } ...
#include <bits/stdc++.h> #define int long long using namespace std; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')w=-1;ch=getchar(); } while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } inline bool read(int& a){ int s=0,w=1; ...
#include <bits/stdc++.h> #define debug(x) cout << #x << ":\t" << (x) << endl; using namespace std; #define ll long long const int N = 2e6 + 10; const int INF = 0x3f3f3f3f; const ll inf = 0x3f3f3f3f3f3f3f3f; const ll mod = 998244353; int n; char s[N]; vector<int>G[N]; int vis[110]; void dfs(int u) { vis[u] = 1; for (i...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define p push #define pp pop #define deci(n) fixed << setprecision(n) #define high(n) __builtin_popcount(n) //no of 1 in binary #define highll(n) __builtin_popcountll(n) #define pa...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back ll A,B,C,D; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>A>>B>>C>>D; vector<ll>V; V.pb(A); V.pb(B); V.pb(C); V.pb(D); sort(V.begin(),V.end()); if((V[0] + V[3]) == (V[1] + V...
#include <iostream> using namespace std; int cookies[4]; bool dfs(int index, int sum) { if(!sum) { return 1; } if(index == 4 || sum < 0) { return 0; } return dfs(index + 1, sum) || dfs(index + 1, sum - cookies[index]); } int main() { ios::sync_with_stdio(0); cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a,a+3); if((a[2] - a[1]) == (a[1] - a[0]) ){ cout << "Yes" << endl; } else cout << "No" << endl; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { set<ll>s; map<ll, ll>mp; ll d = 0; for(ll i = 0; i < 3; i++) { ll x; cin >> x; s.insert(x); mp[x]++; d = x; } if(s.size() == 3) { cout << 0 << '\n'; return 0; } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3; int main(void) { int n; ll k; cin >> n >> k; vector<vector<ll>> dp(N + 1, vector<ll>(N * n + 2, 0LL)); dp[0][0] = 1LL; for (int i = 0; i < N; i++) { for (int j = 0; j <= (i * n); j++) { dp[i + 1][j + 1] += dp[i][j]; dp...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<long long> Vll; ll mm=1000000000;ll MM=mm+7; #define rep(i, n) for(int i=0;i<n;i++) #define PI 3.141592653589793 int main(){ int h,w; cin >> h >> w; vector<vector<char>> s(h,vector<char>(w)); ...
#include<bits/stdc++.h> #define lli long long #define lld double #define test int t;cin>>t;while(t--) #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL) #define mod 1000000007 #define ff first #define ss second #define ppl pair<lli , lli> #define ppi pair<int , int> #define large 1000000000000000000 using ...
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; using ll = long long; using ld = long double; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_nod...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; //#define ACL #ifdef ACL #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #if __has_include("acl-all.h") #include "acl-all.h" //on Wandbox using namespace atcoder; #endif #endif //#ifdef ACL typedef long...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define len(a) (int)a.size() #define all(a) a.begi...
#include<cstdio> #define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i) using namespace std; const int N=5e5+5; template<typename T>void read(T &x) { bool neg=false; unsigned char c=getchar(); for(;(c^48)>9;c=getchar())if(c=='-')neg=true; for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48); if(neg)x=-x; } char s[N...
#include <bits/stdc++.h> using namespace std; /* * * * * * * * * * */ #define mp make_pair typedef long long ll; typedef pair<int, int> pii; /* * * * * * * * * * */ /* * * * Too many mind, no mind. * * */ const ll mod = 998244353; ll add(ll a, ll b) { return a + b >= mod ? a + b - mod : a + b; } ll sub(ll...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; using vv = vector<vector<int>>; const int INF = (int)1e9; const LL LINF = (LL)1e18; long long const mod = 998244353; struct mint{ long long val; mint(long long val = 0): va...
#include <iostream> #include<bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define endl "\n" #define vi vector<int> #define vii vector<pair<int,int>> #define pb push_back using namespace std; using ll = long long; const ll mod = 1e9+7; ll fac[1000001]; void pre(){ fac[0]=fac[1]=1; for(int i=2;i<=100000...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define x first #define y second #define FOR(i, m, n) for (ll i(m); i < n; i++) #define DWN(i, m, n) for (ll i(m); i >= n; i--) #define REP(i, n) FOR(i, 0, n) #define DW(i, n) DWN(i, n, 0) #define F(n) REP(i, n) #define FF(n) REP...
#include<bits/stdc++.h> using namespace std; const int MOD=3; const int msize=400005; int warusan[msize]; int mod3[msize]; void initComb(){ for(int i=1;i<msize;i++){ int t=i; while(t%3==0){ t/=3; warusan[i]++; } mod3[i]=t%3; } for(int i=2;i<msize;i++){ warusan[i]+=warusan[i-1]; ...
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define maxm 600005 #define maxn 150005 #define ls (tot << 1) #define rs (tot << 1 | 1) #define PII pair<int, int> typedef long long ll; typedef unsigned long long ull; using namespace std; const double pi = acos(-1); const ll mod = 1e9 + 7; const double eps = 1e-10; inl...