code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>...
#include <cstdio> #include <algorithm> using namespace std; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; int a[maxn]; int main() { long long *f = new long long[maxn]; f++; int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", a + i); } f[-1] = 1; f[0] = 1; f[1] = 2; f[2] = 3; for (...
#include<bits/stdc++.h> using namespace std; const int MOD = 1000000007; long bimod(int x, int exp){ long res = 1, mul = x; for(long i = exp; i > 0; i >>= 1){ if(i & 1) res = (res * mul) % MOD; mul = (x * x) % MOD; } return res; } int main(){ int n, a[100000], i; cin >> n; lon...
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout<<fixed<<setprecision(10) #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #define P...
// Problem: C - ABC Tournament // Contest: AtCoder - AtCoder Beginner Contest 188 // URL: https://atcoder.jp/contests/abc188/tasks/abc188_c // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <iostream> #include <cmath> #define pii pair<int,int> usin...
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define int long long #define endl '\n' /* ifstream in("test.txt"); #define cin in */ void solve(){ int n; cin >> n; n = 1 << n; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; if(*m...
#include <bits/stdc++.h> #define ll long long #define db long double #define x first #define y second #define mp make_pair #define pb push_back #define all(a) a.begin(), a.end() using namespace std; void solve() { int n; cin >> n; string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1.back() == s2.back() && s2.back()...
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> par; vector<int> siz; UnionFind(int N) : par(N),siz(N) { for (int i=0; i<N; i++) { par[i]=i,siz[i]=1; } } int root(int x) { if (par[x]==x) return x; return par[x]=root(par[x]); ...
#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; using ll = long long; using ld = long double; using ordered_set = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>; void fastio() { cin.tie...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll MOD = 1000000007; int main(){ int n; cin>>n; vector<ll> lista(n+1); for(int i = 1; i<=n; i++){ cin>>lista[i]; } vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0)); for(int i = 1; i<=n; i++){ dp[i][1] = 1; } for(int i = 2; i<=n; i...
#include<cstdio> #include<iostream> using namespace std; int n,t[2010]; int l[2010],r[2010]; int cnt=0; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%d%d%d",&t[i],&l[i],&r[i]); l[i]*=2,r[i]*=2; if (t[i]==2) r[i]--; else if (t[i]==3) l[i]++; else if (t[i]==4) l[i]++,r[i]--; } for (in...
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <utility> #include <string> #include <fstream> #include <map> #include <set> #include <queue> #include <memory.h> using namespace std; typedef vector<int> VI; typedef pair<int, int> PI; typedef vector<PI> VPI; #define FOR(i,a,n) fo...
#include<bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(i=0;i<n;i++) #define pb push_back #define mp make_pair #define ff first #define ss second #define debug cout<<"debug"<<endl; ll Pow(ll x,ll y){return y==0?:x*pow(x,y-1);} int main() { ///"In the name of Allah,most gracious and...
#include <bits/stdc++.h> using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vb=vector<bool>;using vvb=vector<vb>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>; #define all(v)(v).begin(),(v).end() #define...
#include <bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin >> a >> b >> c; if(a==b){ cout << c << endl; } else if(b == c){ cout << a <<endl; } else if(c == a){ cout << b << endl; } else{ cout << 0 << endl; } return 0; }
///Bismillahir Rahmanir Rahim /* Author: Tanzin Ahammad */ #include<bits/stdc++.h> #define u64 uint64_t #define ll long long #define endl "\n" #define PI acos(-1) #define fi first #define si second #...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define test() int t;cin>>t;for(int test=1;test<=t;test++) #define pb pus...
#include <bits/stdc++.h> using namespace std; int main() { int m, h; cin >> m >> h; if (h % m == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; vector<long long> A, B; int main() { long long int n; cin >> n; long long A = 3ll; while (true) { if (n <= A) break; long long m = n - A; while (m % 5 == 0) { m /= 5; } if (m == 1) { ...
#include <iostream> // cout, endl, cin #include <cmath> //sqrt pow #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // in...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define pb push_back #define endl ("\n") #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define vi vector<lli> #define ff first #define ss second #define rep(i, a, b) for (int i = a; i < b; i++) #define repr(i, a, b) ...
#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 ll long long using pss = pair<string, string>; using pll = pair<ll, ll>; using pls = pair<ll,string>; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, t...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; using Graph = vector<vector<int>>; using P = pair<int, int>; #define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i)) #define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i)) #define all(x) (x).begin(),(x).end() ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define MOD 1000000007 vector<string> s(3), ss(3); vector<bool> word(26, false), yet(10, false); vector<int> n(26); void dfs(int x) { if(x == 26) { ss[0] = ss[1] = ss[2] = ""; for(int i = 0; i < 3; i++) { for(int...
// Problem: F - GCD or MIN // Contest: AtCoder - AtCoder Beginner Contest 191 // URL: https://atcoder.jp/contests/abc191/tasks/abc191_f // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using ...
#include <cstdio> #include <cmath> #include <iostream> #include <set> #include <algorithm> #include <vector> #include <map> #include <cassert> #include <string> #include <cstring> #include <queue> using namespace std; #define rep(i,a,b) for(int i = a; i < b; i++) #define S(x) scanf("%d",&x) #define S2(x,y) scanf("%d%...
#include<fstream> #include<iostream> #include<sstream> #include<vector> #include<stack> #include<string> #include<algorithm> #include<cmath> #include<unordered_map> #include<map> #include<queue> #include<tuple> #include<iomanip> #include<bitset> #include<stdio.h> #include<set> #include<array> using namespace std; #defi...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define DEBUG #ifdef DEBUG inline void debug_print() { cerr << endl; } template <typename T1, typename... T2> void debug_print(const T1 a, const T2 &... b) { cerr << a << ' '; debu...
#include<iostream> #include<unordered_set> #include<vector> #include<map> using namespace std; int main() { char x,y; cin>>x>>y; if(x == y) cout<<x<<"\n"; else if((x == '0' && y == '1') || (x == '1' && y == '0')) cout<<"2\n"; else if((x == '0' && y == '2') || (x == '2' && y == '0')) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<pll> vpll; typedef vector<vpll> vvpll; typedef vector<bool> vbl; typedef vector<vector<bool>> vvbl; void INX(){} template<typenam...
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define rep(i, n) FOR(i,0,n) #define irep(i, n) IFOR(i,0,n) #define all(v) begin(v), end(v) using namespace std; using ll = long long; using ull = unsigned long long; using P ...
#include <bits/stdc++.h> using namespace std; long long n, sum; int main() { cin >> n; for (long long i=1000, ert=0; ; i*=1000, ert++) { sum+=(min(n, i-1)-i/1000+1)*ert; if (n<i) { cout << sum << "\n"; return 0; } } return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f; const double pi=3.1415926535897932384626; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<...
/* AtCoder Regular Contest 109 https://atcoder.jp/contests/arc109/tasks/arc109_a By 242 */ /*     ∧__∧ ☆・*。・゜+.・*。    (´・ω・) ☆・*。    /ヽ○==○ _____ _____ ・゜+.・*。   /  || |100%||AC| ☆・*。・*。   し' ̄(_)) ̄(_)) ̄(_)) ̄ */ /* fstream fcout; fcout.open("out.txt",ios::out); */ #include <bits/stdc++.h>...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,x,y) for(ll i=(x);i<(y);i++) #define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--) #define all(x) (x).begin(),(x).end() #define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");} #ifdef LOCAL #define de...
//#include <atcoder/all> #include <bits/stdc++.h> //using namespace atcoder; using namespace std; typedef long long ll; #define MOD (long long)(1e9+7) #define INF (1LL<<60) #define rep(i,n) for(ll i = 0; i < (n); i++) #define rep1(i,n) for(ll i = 1; i <= (n); i++) template<class T> inline bool chmin(T& a, T b) { if...
#include <bits/stdc++.h> #define MOD 1000000007 #define all(v) v.begin(),v.end() #define ninpo ios_base::sync_with_stdio(false);cin.tie(NULL); #define dbg(x) cout<<#x<<" = "<<(x)<<endl; #define sz(cntainer) (int)cntainer.size() #define tc int t;cin>>t;for(int i=0;i<t;++i) #define ll long long #define pii pair<int,int> ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ff first #define ss second #define pb push_back #define mp make_pair #define PI 3.1415926535897932384626 #define mod 1000000007 #define mod1 998244353 #define ms(arr, v) memset(arr, v, sizeof(arr)) #define fo1(i,a,b...
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> #include <set> #include <map> #include <queue> #include <deque> #include <bitset> #include <math.h> #include <random> #include <chrono> using namespace std ; using ll = long long ; us...
#include "bits/stdc++.h" using namespace std; void solution() { int n, k; cin >> n >> k; vector<vector<int>> f(n + 1, vector<int> (n + 1, -1)); auto dp = [&](auto &&self, int N, int K) -> int { if (K == 0) return N == 0; if (N <= K) return N == K; if (f[N][K] != -1) return f[N][K]; return f[N][K...
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define rep(i, n) FOR(i,0,n) #define irep(i, n) IFOR(i,0,n) #define all(v) begin(v), end(v) using namespace std; using ll = long long; using ull = unsigned long long; using P ...
#include<bits/stdc++.h> using namespace std; #define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define fo(i, strt, end) for(i=strt;strt<end?i<end:i>end;strt<end?i+=1:i-=1) #define deb(var) cout << #var << " = " << var << endl; #define deba(i, arr, n) fo(i,0, n){cout << arr[i] << " ";} #d...
#pragma GCC optimize("O3") #pragma GCC target("avx") #include <cstdio> #include <functional> #include <queue> #include <tuple> using namespace std; int main() { int R, C; scanf("%d%d", &R, &C); int A[250000], B[250000]; int dist[500000], seen[500000] = {0}, cost, pt, to_hide = R * C; priority_queue...
// #include "pch.h" #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <string> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <ctime> #include <cassert> #include <fstream> #include <stack> #include ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ss second #define ff first #define all(a) a.begin(), a.end() #define All(a) a.rbegin(), a.rend() #define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed template <typename T> T binpow(T base, T exp) { T result...
#include <bits/stdc++.h> using namespace std; int main() { long long n,num; cin >> n; if(n>=100000) num=100000; else num=n; set<long long> Set; long long tmp,ans=0; for(int i=2;i<num;i++){ for(int j=2;j<34;j++){ tmp = pow(i,j); if(tmp>n) break; Set.insert(tmp); } } cout <...
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); int i,n,t,x; bool flag; cin >> t; while(t--) { cin >> n; map<int,bool>mp; for(i=0;i<n;i++) { cin >> x; mp[x] ^= ...
#include <bits/stdc++.h> using namespace std; using ll = long long; // エラトステネスのふるい vector<int> primes; void sieve(int n) { set<int> primes_set; for (int i{2}; i <= n; ++i) primes_set.insert(i); for (int i{2}; i <= n; ++i) { if (primes_set.find(i) != primes_set.end()) { for (int j{i * 2}; j <= n; j...
//DUEL #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define pii pair<int,int> #define pb push_back #define eb emplace_back #pragma GCC optimize("unroll-loops") #define shandom_ruffle(a, b) shuffle(a, b, rng) #define vi vector<int> #define vl vector<ll> #define popcn...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; cin >> n; vector<ll> x(n), y(n); rep(i, n) cin >> x[i] >> y[i]; int m; cin >> m; vector<ll> sousa11(m + 1), sousa12(m + 1), sousa2...
#include<bits/stdc++.h> using namespace std; namespace mymtx{ array<array<int64_t,3>,3> mult(array<array<int64_t,3>,3> a, array<array<int64_t,3>,3> b){ array<array<int64_t,3>,3> ret{{ {0,0,0}, {0,0,0}, {0,0,0} }}; for(int64_t i=0;i<3;i++){ for(int64_t j=0;j<3;j++){ for(int64_t k=0;k<3;k++){ ...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; #define pb push_back #define T ll testx; cin>>testx; while(testx--) #define print(name) for(auto t:name){cout<<t<<" ";}cout<<endl; #define printii(name) for(auto t:name){cout<<t.first<<" "<<t.second<<e...
#include<bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const int maxn=2e5+4; vector <int>e[maxn]; int dep[maxn]; ll bt[maxn]; struct node{ int u,v; }ee[maxn]; void dfs(int u,int pa){ dep[u]=dep[pa]+1; for(auto v:e[u]){ if(v!=pa)dfs(v,u); } } void dfs2(int u,int p...
#include <bits/stdc++.h> #define mp make_pair #define fi first #define se second #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #defin...
#include <iostream> #include <string> using namespace std; int main() { int n, x; string s; cin >> n >> x >> s; for(int i = 0; i < n; ++i) { if(s[i] == 'o') x++; else { if(x > 0) x--; } } cout << x << endl; }
#include <bits/stdc++.h> using ull = unsigned long long int; using ll = long long; using ld = long double; using pii = std::pair<int,int>; using pll = std::pair<ll, ll>; using vi = std::vector<int> ; using vvi = std::vector<vi> ; using vll = std::vector<ll>; using vvll = std::vector<vll>; using vd = std::vector<double...
#include<bits/stdc++.h> using namespace std; namespace Sakurajima_Mai{ #define ms(a) memset(a,0,sizeof(a)) #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ? #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i) #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].t...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> using namespace std; #define ll long long int #define pll pair<ll,ll> #define ...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0); #define mod 1000000007 #define decimal(n,k) cout<<fix...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cctype> typedef long long ll; template<typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == '-') flag = true ;c = getchar(); } while (isdigit(c)) x = x * 10 + (c ^ 48),...
#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int a, b, c; cin >> a >> b; if (a == b) { c = b; } else { c = 3 - a - b; } cout << c << endl; return 0; }
#include<stdio.h> #include<stdlib.h> #include<bits/stdc++.h> //Do DEBUG OR NOT #define DEBUG #ifdef DEBUG #define debug(var) do{std::cout << #var << " : ";view(var);}while(0) template<typename T> void view(T e){std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){for(const auto& e : v...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int n; vector<int> a, b; vector<vector<int>> e; vector<int> depth; vector<ll> ans; void dfs_depth(int v, int d) { depth[v] = d; for (auto nv : e[v]) { if (depth[nv] !...
// Knapsack DP is harder than FFT. #include<bits/stdc++.h> using namespace std; typedef int64_t ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define ff first #define ss second #define pb emplace_back #define FOR(i,n) for(int i=0;i<(n);++i) #define FOO(i,a,b) for(int i=(a);i<=int(b);++i) #define OOF(i,a,b) fo...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; using pii = pair<int, int>; /* [💭] [💡] [🎈] */ int n; int a[501], reva[501]; int swap_op(int i) { iter_swap(reva + a[i], reva + a[i + 1]); iter_swap(a + i,...
#include <bits/stdc++.h> using namespace std; template<class C>constexpr int sz(const C&c){return int(c.size());} using ll=long long;using ld=long double;constexpr const char nl='\n',sp=' '; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // freopen("err.txt", "w", stderr); i...
#include <bits/stdc++.h> // #include<iomanip> using namespace std; #define int long long int typedef pair<int, int> pii; #define f(i,a,b) for(int i=a;i<b;i++) #define fo(i,a,b) for(int i = a; i<=b;i+=1) // #define Vector vector #define rf(i,a,b) for(int i=a;i>=b;i--) #define vll vector<int> #define sz(a) int(a.size(...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using ll = int64_t; using db = double; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vector<int>>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector...
#include <bits/stdc++.h> #ifdef _DEBUG_ #define debug(x) cerr<<#x<<" : "<<x<<" " #define cout_n cerr<<endl #else #define debug(x) #define cout_n #endif using namespace std; const int MAXN=1e5+100; vector<int>G[MAXN]; void add(int u,int v){ G[u].push_back(v);G[v].push_back(u); } int n,m,k; int c2v[20],v2c[MAXN]; int...
#include <bits/stdc++.h> using namespace std; #define endl "\n" int main() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); long long int n; cin>>n; long long int a[n],b[n],c[n],i; for(i=0;i<n;++i) cin>>a[i]; for(i=0;i<n;++i) cin>>b[i]; ...
#include <cstdio> #include <algorithm> #define N 200007 int n; long long a[N]; long long max[N]; long long sum[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%lld", &a[i]); max[i] = std::max(max[i - 1], a[i]); sum[i] = sum[i - 1] + a[i]; } long long tm...
#include<bits/stdc++.h> using namespace std; long long n,u_i[200005],sub,v_i[200005],d[200005],m,t,node,e,x,u,p[200005],val[200005],dp[200005]; vector<long long> v[200005]; queue<long long> q; int main() { scanf("%lld",&n); for(int i=1;i<n;i++) { scanf("%lld%lld",&u_i[i],&v_i[i]); v[u_i[i]].push_back(v_i[i]); ...
#include <bits/stdc++.h> #define ll long long int using namespace std; vector<int> graph[400001]; void dfs(int k, bool visited[], int par, bool &cond, int &si) { if (visited[k]) { return; } si++; visited[k] = true; for (auto i : graph[k]) { if (i != par && visited[i] == true...
#include<bits/stdc++.h> using namespace std; /**templates**/ typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<ll> vl; #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define sull(x) scanf("%llu",&x) #define sf(x) scanf("%lf",&x) #def...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define f first #define s second const int N = 3e5+5; ll n , m , q , a[N] , BIT[N]; void update(int idx , ll val) { a[idx] = val; for(idx; idx<=n; idx = (idx + (idx&-idx))) { BIT[idx] ^= val; } } ll ...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<cmath> #include<queue> #include<stack> #include<deque> #include<list> #include<bitset> #include<sstream> using namespace std; using ll = long long; const ll MOD = 1e9+7; const ll INF = 1e18; #define REP(i, n) for(int i = 0;...
#pragma region head #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using pi = pair<int, int>; using pll = pair<ll, ll>; template <class T> using vv = vector<vector<T>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (in...
#include <bits/stdc++.h> #define f first #define s second using namespace std; using ll = long long; using ii = pair<int, int>; using pl = pair<ll, ll>; constexpr int MX = 5005, MOD = 998244353; pl DP[MX][2]; int main() { if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout); cin.tie(0)->sync...
#include <bits/stdc++.h> #define task "F" #define all(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i <= (r); ++i) #define Rep(i, r, l) for (int i = (r); i >= (l); --i) #define DB(X) { cerr << #X << " = " << (X) << '\n'; } #define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; } #de...
#include<iostream> using namespace std; #include<vector> using ll = long long; using vi = vector<int>; ll C(int n, int k) { int f1 = n, f2 = 1; ll ret = 1; if (k>n/2) { ret = C(n,n-k); } else { for (int i=0;i<k;i++) { ret *= f1; ret /= f2; f1--; f2++; } } return ret; } ...
#include <bits/stdc++.h> #define eb emplace_back using namespace std; template<class T> using vc = vector<T>; template<class T> using vv = vector<vector<T>>; template<class T> using PQ = priority_queue<T, vc<T>, greater<T>>; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ cout << fixed << setprecision(15); int K; string S, T; cin >> K; cin >> S; cin >> T; map<int,int> card,tkh,aok; for(int i=1; i<=9; i++){ card[i] = K; tkh[i] = 0; aok[i] = 0; } ...
#include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define deb(x) cout<<#x<<" "<<x<<endl; #define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl; #define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin() #define lb(x,el) lower_bound(x.be...
//2021. by ljz //email 573902690@qq.com //if you find any bug in my code //please tell me #include<bits/stdc++.h> //#include<ext/pb_ds/tree_policy.hpp> //#include<ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; //using namespace __gnu_cxx; #define res register int #define LL long long ...
#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; using ll = long long; using ld = long double; template <typename T> using orderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; te...
#include <bits/stdc++.h> using namespace std; int main() { int V, T, S, D; cin >> V >> T >> S >> D; if (V*T <= D and D <= V*S) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }
#include<bits/stdc++.h> #define ll long long int using namespace std; #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define mp make_pair #define fi first #define se second #define pb push_back #define endl "\n" #define maxpq priority_queue<ll> #define minpq priority_queue<ll, vector<ll>, g...
#include <stdio.h> typedef long long ll; int num[105][105], max = -1, vis[20], k, n, m; struct node { int x1, x2; } a[20], b[105]; void dfs(int now) { if (now >= k) { int sum = 0; //for (int i = 0; i < 17; i ++) printf("%d ", vis[i]);printf("\n"); for (int i = 0; i < m; i ++) if (vis[b[i].x1] && vis[b[i]....
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { double n; double x2, y2, ans = 0; cin >> n >> x2 >> y2; for (ll i = 0; i < n; i++) { double x1, y1; cin >> x1 >> y1; double y3 = ((y2 - y1) / (x2 - x1)) * (0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define forn(i,x,n) for(int i = x;i <= n;++i) #define forr(i,x,n) for(int i = n;i >= x;--i) #define Angel_Dust ios::sync_with_stdio(0);cin.tie(0) const int N = 2e5+7; int x[N],y[N]; map<int,vector<int>> E; int main() { int n,m;scanf("%d%d",&n,&m)...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define NUM 2520 #define INF (1LL<<50) #define DEBUG 0 #define mp(a,b) make_pair(a,b) #define SORT(V) sort(V.begin(),V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) # VariableName #de...
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for(int i=(a); i<=(b); ++i) #define iFOR(i, a, b) for(int i=(a); i>=(b); --i) #define make_unique(a) sort(all((a))), (a).resize(un...
// .------------------------------------------------------------. // | K U S A Y A R O U | // | | // | ---|---|--- ___ ____ _\_ ___ | // | _______ |_|_| / ...
#pragma GCC optimize("Ofast") #include <limits.h> #include <iostream> #include <algorithm> #include <vector> #include <set> #include <unordered_set> #include <map> #include <cmath> #include <iomanip> #include <string> #include <deque> #include <assert.h> #include <random> #include <ctime> #include <unordered_map> #incl...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define P pair<int, int> #define fi first #define se second #define rep(i, n) for (int i = 0; i < n; i++) #define all(v) v.begin(), v.end() #define pb push_back template <class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; ...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) #define pre(i,a,b) for(int i=a;i>=b;i--) #define N 1000005 using namespace std; int n,a[N]; double calc(double x){ double sum=0; rep(i,1,n)sum+=(a[i]-min(1.00*a[i],x*2))/(1.00*n); return sum+x; } int main(){ scanf("%d",&n); rep(i,1,n)scanf("%d",&a[i]...
#include <bits/stdc++.h> #include <time.h> #define rep(i, n) for(int i=0;i<(int)(n);i++) #define ALL(a) (a).begin(),(a).end() using namespace std; using ll=long long; typedef pair<int,int> P; const int INF=1e9; bool LOCAL_TEST = false; int h[30][30],v[30][30],u[30][30]; double priority[30][30]; vector<string> paths; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, st, n) for (int i = (st); i < (n); ++i) #define rrep(i, n) for (int i > (n)-1; i >= 0; ++i) #define RREP(i, st, n) for (int i = (st); i > (n); ++i) using namespace std; using ll = int64_t; using P = pair<ll, ll>; template <class T> ...
//#include <atcoder/maxflow.hpp> #include <memory> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <sstream> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #include <limits> #include <unordered_map> #include <...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll> pql; typedef set<ll> sl; typedef pair<ll, ll> pl; ty...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define int long long int max(int a,int b) { if(a>b) return a; return b; } int min(int a,int b) { if(a<b) return a; return b; } signed main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); string s; cin>>s; map<int,int> mp; ...
//#include "bits/stdc++.h" #define _USE_MATH_DEFINES #include <iostream> #include <sstream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <numeric> #include <functional> #include <utility> #include <tuple> #include <vector> #include <string> ...
#include <bits/stdc++.h> using namespace std; int main(){ int64_t a1,b1,c1,C,n,day; int64_t fee=0,feeall=0; vector<pair<int, int>> event; cin>>n>>C; for(int64_t i=0;i<2*n;i+=2){ cin>>a1>>b1>>c1; event.push_back(make_pair(a1,c1)); event.push_back(make_pair(b1+1,-1*c1)); } sort(event.begin(),ev...
// UpS0lver #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c).e...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) fo...
#include<bits/stdc++.h> #define ld double long #define ll long long #define ull unsigned long long #define all(A) A.begin(), A.end() #define pb push_back #define fri(start , end , step) for(int i = start; i < end ; i = i + step) #define frj(start , end , step) for(int j = start; j < end ; j = j + step) #define fast ...
#pragma GCC optimize("Ofast") #define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <sys/time.h> using namespace std; class XorShift128 { private: uint32_t x, y, z, w; public: XorShift128() : x(123456789), y(362436069), z(521288629), w(88675123) { } uint32_t rnd() { uint32_t t = x ^ (x << 11); x = y; ...
//{{{ #include<algorithm> #include<cmath> #include<deque> #include<fstream> #include<iomanip> #include<iostream> #include<map> #include<numeric> #include<queue> #include<random> #include<set> #include<sstream> #include<sys/time.h> #include<unordered_map> #include<unordered_set> #include<vector> using ll = long long; en...
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
#include <bits/stdc++.h> #define endl '\n' #define ll long long #define ull unsigned long long #define PI 3.14159265359 #define rep(i, init, max) for (int i = (init); i < (int)(max); i++) #define eqrep(i, init, max) for (int i = (init); i <= (int)(max); i++) #define veccin(name) rep(i, 0, name.size()) cin >> name[i] #d...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; if(a>=b && b>=c){ cout<<a+b<<endl; } else if(a>=b && b<=c){ cout<<a+c<<endl; }else if(a<=b && a>=c){ cout<<a+b<<endl; } else { cout<<b+c<<endl; } }
/*---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---*/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define rep(a, b) for(int a = 0; a < (b); ++a) #define rep1(a, b, c) for(int a = ...
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <cmath> using namespace std; const int maxn = 100 + 5; const int modu = 1e9 + 7; const double eps = 1e-5; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; typedef long long LL; ...
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; using vll = vector<ll>; using vpl = vector<pair<ll, ll>>; using pll = pair<ll, ll>; #define rep(i, k, n) for(ll i = k; i < n; i++) #define pb push_back #define mp make_pair ll n, m, s; //頂点の数, 辺の数, スタート地点 vll A(3010); //辺の始点 vll B...
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <algorithm> #include <math.h> #include <vector> #include <map> #include <queue> #include <limits.h> #include <stack> using namespace std; typedef long long ll; const int maxn = 110; int H, W, A, B, ans = 0; void solve(int s, int bit, int a, int b) { i...
#include <bits/stdc++.h> using namespace std; int main() { int r,c; cin>>r>>c; vector<vector<char>>vec(r,vector<char>(c)); for(int i=0;i<r;i++) { string s; cin>>s; for(int j=0;j<c;j++) vec[i][j]=s[j]; } int ans=0; for(int i=0;i<r;i++){ for(int...
#include "iostream" #include "algorithm" #include "cstring" #include "cstdio" #include "cmath" #include "vector" #include "map" #include "set" #include "queue" #include "string" #include "unordered_map" #include "assert.h" using namespace std; #define MAXN 200006 //#define int long long #define rep( i , a , b ) for (in...
#include <bits/stdc++.h> using namespace std; int main(){ long n; cin >> n; set<long> ans; for(long d=1;d*d<=n;d++){ if(n%d==0){ ans.insert(d); ans.insert(n/d); } } for(auto x:ans)cout << x << endl; }
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; using vpi = vector<pair<int, int>>; using pl = pair<ll, ll>; using vl = vector<ll>; #define all(v) (v).begin(), (v).end() #define ar array #defin...
//g++ 7.4.0 #include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAXN 100005 ll C[MAXN]; ll D[MAXN]; vector<pair<ll,ll>> adj[MAXN]; ll dis[MAXN]; ll getDis(ll t, ll c, ll d) { return(t + c + d/(t + 1LL)); } void dijkstra(ll source) { set<pair<ll,ll>> s; s.inser...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,ll> #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x)...
#include<bits/stdc++.h> using namespace std; typedef long long ll;typedef double db; typedef pair<int, int> pii;typedef pair<ll, ll> pll; typedef pair<int,ll> pil;typedef pair<ll,int> pli; #define Fi first #define Se second #define _Out(a) cerr<<#a<<" = "<<(a)<<endl const int INF = 0x3f3f3f3f, MAXN = 1e6 + 50; const ll...
// // main.cpp // #include <algorithm> #include <array> #include <assert.h> #include <complex> #include <iomanip> #include <iostream> #include <limits> #include <inttypes.h> #include <map> #include <math.h> #include <memory> #include <memory> #include <queue> #include <random> #include <set> #include <stdio.h> #inclu...
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <algorithm> #include <iostream> #include <vector> #include <array> using namespace std; #define f(x,y,z) for(int x=y;x<=z;++x) vector<int> v[200001]; array<int, 200001> jr, dkt, tdk, at, uj; int n, k, a, b, l, r, m, hit; void jrk(int x) { for(int &i:v[x...
#include <bits/stdc++.h> using namespace std; inline long long read(){ long long 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(); } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>; #define FOR(i,a,n) for(int i=(a);i<(n);++i) #define eFOR(i,a,n) for(int i=(a);i<=(n...
#include<bits/stdc++.h> #define pb push_back #define mk make_pair #define ll long long #define ss second #define ff first #define mod 1000000007 #define w(x) ll x; cin>>x; while(x--) #define ps(x,y) fixed<<setprecision(y)<<x; #define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in) #define re(i, j) fo(i, 0, j, 1) #define pi ...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define pb push_back #define fo(i, start, end) for (ll i = start; i < end; i++) #define rep(i, start, end, step) for (ll i = start; i < end; i += step) #define print(x) cout << #x << " is " << x << endl #define all(arg) arg.begin(), arg.end() #define sz(a...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ string s; cin>>s; string ss=""; ll x=s.length(); for(ll i=(x-1);i>=0;i--){ ss+=s[i]; } for(ll i=0;i<(ll)ss.length();i++){ if(ss[i]=='6'){ss[i]='9'; continue;} if(ss[i]=='9')ss[i]='6'; } cout...
#include<bits/stdc++.h> #define icantcode ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; bool can = 1; string s; int main(){ icantcode cin>>s; int l = s.length(); for(int i=0;i<l;i++){ if(i%2 == 0){ if(s[i]>='A' && s[i]<='Z'){ can = 0; break; } } else{ if(s[i]>='...
#include <iostream> #include <vector> #include <cassert> using namespace std; #include <iostream> #include <cassert> template<long long mod> class modint{ private: using T = long long; T a; public: constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {} constexpr T& value() noexcept { return ...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (ll i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define pb push_back using ll = long long; using ld=long double; using vin=vector<int>; using v...
#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 int long long #define all(x) begin(x), end(x) #define SZ(x) ((int)(x).size()) #define EB emplace_back #define PB push_back #define PP pop_back #define MP make_pair #define F first #define S second #define de(x) if(x && x == MODE) #define MODE 0 using namespace std; typedef pair<int, in...
/* Another source code by: _ _ _ _ _ _____ _ | \ | (_) | (_) / ____| | | | \| |_| |_ _ _ __ | | __ _ __ | |_ | . ` | | __| | '_ \| | |_ | '_ \| __| | |\ | | |_| | | | | |__| | |_) | |_ |_| \_|_|\__|_|_| |_|\_____| .__/ \__| | | ...
/* code by:- __ | \ _______ ______ ______ ____ ______ ____ __ __ __ ______ \▓▓_______ / \| \| \ \| \ ...
//インクルードなど #include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #i...
#include <bits/stdc++.h> #include <cmath> using namespace std; #define int long long #define pb push_back #define mkp make_pair #define ms(a) memset(a, 0, sizeof(a)); #define all(a) a.begin(), a.end() #define endl '\n' #define boost \ ios::sync_with_stdio(false); \ cin.tie(0); ...
// ********************************************************************************* // * MURTAZA MUSTAFA KHUMUSI * // * NIT-DGP,CSE - 2019-2023 * // **************************************************************...
#include<bits/stdc++.h> #define HohleFeuerwerke using namespace std #pragma GCC optimize(3,"Ofast","-funroll-loops","-fdelete-null-pointer-checks") #pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx") #define int long long HohleFeuerwerke; inline int read(){ int s=0,f=1;char c=getchar(); for(;!isdigit(c);c=ge...
#include<iostream> using namespace std; template<long long Mod>struct modInt { long long x; constexpr modInt()noexcept:x(){} template<typename T> constexpr modInt(T v=0)noexcept:x(v%Mod){if(x<0)x+=Mod;} constexpr long long getval()const noexcept{return x;} constexpr modInt operator-()const noexcept{return x?Mod-x...
#include<bits/stdc++.h> using namespace std; #define PI 3.14159265 #define double long double #define DB #ifdef DB #define el cerr << "\n"; #define db(...) cerr << " [" << #__VA_ARGS__ << " : " << __VA_ARGS__ << "] "; #else #define el #define db(...) #endif // DB #define ll long long int main() { ios_base::sync_wi...
#include <bits/stdc++.h> #define int long long #define double long double using namespace std; const int MOD = 1000000007; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) signed main(){ int N, M; cin >> N >> M; vector<int> A(N); rep(i, N) cin >> A[i]; vector<int> fg(...
#include <bits/stdc++.h> using namespace std; const int L = 1.5 * 1e6 + 2; int n, m, a[L], pos[L], dis[L]; bool vis[L]; int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); a[i]++, vis[a[i]] = true; dis[a[i]] = max(dis[a[i]], i-pos[a[i]]); pos[a[i]] = i; } for (int i...
/* Author : MatsuTaku Date : 06/13/21 Certificate: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDF9T447OEo8XSQ6O1AznN5tKC8mzvYc4Zs3+oOKfMqgLXfOwQnpfcoxKs4MAP1eICBD13PkcIezJ9IlV6nKQZKs1BQmvjSXJ+zKK8YCKvAueNPuNO0Bim43IBaNHNFWcMvcmUvHgRb6hUSO0V8I7OsjiFo20KDBj3gAznu9tir0Q== CompetitiveProgrammingCertification:tk...
#include <bits/stdc++.h> using namespace std; using lli = long long int; #define ip(a) lli a; cin >> a #define ipfl(a) double a; cin >> a #define ipstr(a) string a; cin >> a #define op(a) cout << a #define opspc(a) cout << a << "\n" #define FOR0(i, n) for(lli i = 0; i < n; i++) #define FORa(i, a, n) for(lli i = a; i <=...
#include <bits/stdc++.h> #define clr(x) memset(x,0,sizeof(x)) #define For(i,a,b) for (int i=(a);i<=(b);i++) #define Fod(i,b,a) for (int i=(b);i>=(a);i--) #define fi first #define se second #define kill _z_kill #define y0 _z_y0 #define y1 _z_y1 #define x0 _z_x0 #define x1 _z_x1 #define pb(x) push_back(x) #define mp(x,y)...
// Problem: B - DNA Sequence // Contest: AtCoder - AtCoder Regular Contest 104 // URL: https://atcoder.jp/contests/arc104/tasks/arc104_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<iostream> #define t(x) (tot[j][(x)]-tot[i-1][(x)]) using namespace std; in...
using namespace std; #define visual #ifdef visual #include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <set> #include <map> #include <assert.h> #include <functional> #include <math.h> #include <string> #include <ctime> #endif #ifndef visual #include <bits/stdc++.h> ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll maxn=2e5+10; const ll m1=1e18+7; const ll mod=1e18+7; const ll INF64 = ll(1e18); #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") ll t[4*maxn]; void build(ll a[]...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <stdio.h> #include <...
#include <bits/stdc++.h> using namespace std; #define int long long 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; } int n, t; int a[100]; set<int> zen, kou; void dfs(int i, int ma, int no...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll lim = 1000000000000000000ll; vector <ll> seq; const int Maxn = 90; bool op[Maxn]; vector <int> res; int main() { seq.push_back(1); seq.push_back(1); while (seq.back() <= lim) { ll nw = seq.back() + seq[int(seq.size()) - 2]; seq.pu...
#include <iostream> #include <cassert> #include <vector> #include <algorithm> using namespace std; int main(){ long long n; cin >> n; long long x = 0, y = 0; vector<int> Q; auto q = [&](int i){ if(i == 0){ x += 1; } if(i == 1){ y += 1; } if(i == 2){ x += y; } if(...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef int Int; typedef pair<Int, Int> pii; typedef pair<Int, double> pid; typedef pair<double, double> pdd; typedef pair<Int, pii> pip; typedef pair<pii, Int> ppi; typedef pair<double, Int> pdp; typedef vector<Int> vec...
#include<bits/stdc++.h> using namespace std; using ll = long long int; #define pb push_back #define mp make_pair #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef pair<ll,ll> pii; typedef vector<pii> vii; typedef vector <ll> vi; #define MAX 100003 bool comp(pii a,pii b) { return a.s...
/*Lucky_Glass*/ #include <set> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> typedef long long llong; #define con(typ) const typ & const int N = 1e5 + 10; const llong INF = 0x3f3f3f3f3f3f3f3fll; int n; std::set<llong> exi[3]; std::vector<llong> ele[3]; llong aAbs(con(llong) k) { return...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define ll long long #define int ll #define pb push_back #define INF 1e18 #define MOD 1000000007 #define mp make_pair const double PI=3.141592653589793238462643383279502884197169399375105820974944; #define REP(i,n) f...
//https://atcoder.jp/contests/abc182/tasks/abc182_c //C - To 3 #include <bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; //特判 if (0==n%3) { cout<<"0\n"; return 0; } else if (n<=2) { cout<<"-1\n"; return 0; } //转换为数字 int cnt[3]={};...
#include <bits/stdc++.h> using namespace std; int main () { string s; cin >> s; int right = s.length()-1; while (s[right] == '0') { right--; } for (int left = 0; right >= 0; ++left) { if (s[left] != s[right]) { cout << "No"; return 0; } ...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int l, r; scanf("%d%d", &l, &r); printf("%lld\n", r < l << 1 ? 0 : 1ll * (r - (l << 1) + 1) * (r - (l << 1) + 2) >> 1); } return 0; }
#include <bits/stdc++.h> #define repp(i, l, r) for (long long i = (l); i < (r); i++) #define rep(i, n) for (long long i = 0; i < (n); ++i) #define per(i, n) for (long long i = (n); i >= 0; --i) #define all(v) v.begin(), v.end() const int INF = 1 << 30; const long long LINF = 1LL << 60; const long long int MOD = 1000000...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define mem0(a) memset(a,0,sizeof(a)) #define mem1(a) memset(a,-1,sizeof(a)) #define memf(a) memset(a,false,sizeof(a)) #define all(v) (v).begin(),(v).end() #define lb lower_bound #define ub upper_bound #define pll pair<ll,ll> #defi...
#include <bits/stdc++.h> using namespace std; bool isCollinear(int x1, int y1, int x2,int y2, int x3, int y3) { int result = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2); return result==0; } int main() { int t; cin>>t; vector<pair<int, int>> points; while(t--) { int a , b; c...
#include<bits/stdc++.h> using namespace std; long long int MOD = 1000000007; void mult(vector<vector<long long int>> &a, vector<vector<long long int>> &b, int n) { vector<vector<long long int>> c(n, vector<long long int>(n, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector <ll> vi; typedef vector <pi> vpi; typedef pair<pi,ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i) #define DEC(i,s,e) for(ll i=s;i...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int X, Y, Z; int main(void) { cin >> X >> Y >> Z; int ans = 0; for (int i = 0; i <= 1000000; i++) { if (Y*Z > i*X) { ans = i; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; /* ループ処理 0からnまで*/ #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { double X, Y, Z; cin >> X >> Y >> Z; double a = Y / X; double b = a * Z; cout << int(ceil(b - 1)) << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define BE(x) x.begin(), x.end() int main() { ll s, p; cin >> s >> p; for (ll i = 1; i*i <= p; i++) { if (p % i > 0) continue; ll n = i, m = p / i; if (n + m == s) { cout << "Yes" << endl; r...
#include <bits/stdc++.h> #define ll long long int using namespace std; const int N = 2e5 + 5; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin >> n; string str; cin >> str; string s = ""; char ch[3] = {'1','1','0'}; if(str.size() ==1) { ll a...
#include<bits/stdc++.h> using namespace std; #define int long long const int maxn=2e5+5; struct edge{ int u,to,nxt; }e[2*maxn]; int head[maxn],cnt; int x,y; void add(int x,int y){ e[++cnt].to=y; e[cnt].u=x; e[cnt].nxt=head[x]; head[x]=cnt; } int c[maxn],n,m,p,dep[maxn]; void dfs(int u,int fa){ d...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // -------------------------------------------------------- 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...
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ vector<int> a(3); cin >> a[0] >> a[1] >> a[2]; sort(a.begin(), a.end()); 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; #define int long long #define pb push_back #define endl '\n'; #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define mi map<int,int> #define pqb priorit...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb p...
#include <bits/stdc++.h> #define lli long long int using namespace std; #define mod 1000000007 #define MOD 1000000037 #define mod1 998244353 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define INF 2147483607 #define common cout << "Case #" << w+1 << ": " int main() { int te; ...
#include <bits/stdc++.h> #define Fast cin.tie(0), ios::sync_with_stdio(0) #define All(x) x.begin(), x.end() #define louisfghbvc int t; cin >> t; for(int tt = 0; tt < t; ++tt) #define sz(x) (int)(x).size() #define sort_unique(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end())); using namespace std; typedef...
//...Bismillahir Rahmanir Rahim. . . #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; // typedefs... typedef double db; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vect...
//Created By:Hardik Kapoor #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 begins #define int long long int #define ios ios_base::sync_with_stdio(false);cin.tie(NULL); #define itt vector<int>:: iterator #...
#include <bits/stdc++.h> using namespace std; int main () { int a, b, c; cin >> a >> b >> c; if (a == b) { cout << c << endl; } else if (a == c) { cout << b << endl; } else if (b == c) { cout << a << endl; } else { cout << 0 << endl; } }
#include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<algorithm> #include<queue> #include<vector> #include<cstring> #include<map> #include<set> #include<cstdlib> #include<bitset> using namespace std; #define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef long long ll; #define N 200005 ...
//#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<map> #include<cmath> #include<cctype> #include<vector> #include<set> #include<queue> #include<algorithm> #include<sstream> #include<ctime> #include<cstdlib> #define X first #define Y second #define L (u<<1) #define...
#include <iostream> #include <vector> #include <queue> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) template<class T> using nega_queue = priority_queue<T,vector<T>,greater<T>>; ll waittime(ll D){ ll l=0, r=40000; while(r-l > 1){ ll m = (l...
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> #in...
#include<bits/stdc++.h> using namespace std; #define int long long #define deb(x) cout << #x << "=" << x << endl //------------------------------------------------------------ void solve(){ int n; cin >> n; int A[n]; for (auto &it: A) cin >> it; int P[n+1] = {0}, PP[n+1] = {0}; int emax = A[0]...
// //#ifdef ONLINE_JUDGE //#pragma GCC optimize("Ofast") //#pragma GCC optimize("O2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") ////// //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") //#endif #include <bits/stdc++.h> #include <utility> #define all(x) (x).begin(), (x).end() #...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define all(x) (x).begin(),(x).end() #define X first #define Y second #define sep ' ' #define endl '\n'...
#include<bits/stdc++.h> #define LL long long using namespace std; const int mod=1000000007,inv2=(mod+1)/2; int n,a[100010]; LL ans=1; inline int read() { int x=0;bool w=0;char ch=0; while(!isdigit(ch)){w|=ch=='-';ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} return w?-x:x; } LL ksm(LL B,L...
#include<bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 mrand(42); #define ii for(int i=1;i<=n;++i) #define ji for(int j=1;j<=n;++j) #define jj for(int j=1;j<=m;++j) #define ij for(int i=1;i<=m;++i...
#include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <bitset> #include <vector> #include <cstdio> #include <string> #include <cassert> #include <climits> #include <sstream> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace...
// // main.cpp // test // // Created by wyzwyz on 2021/5/13. // #include<cstdio> #include<cctype> #include<map> #define maxn 505505 template<class T> inline T read(){ T r=0,f=0; char c; while(!isdigit(c=getchar()))f|=(c=='-'); while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar(); return f?-r:r...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pll pair<ll,ll> #define ff first #define ss second #define pb push_back #define endl "\n" const ll maxn =7e5+100; const ll mod=1e9+7 ; const ll base=2e18; ll n; vector<pll> adj[maxn]; ll dp[(1ll<<18)]; int main...
#include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; if(b%a==0){ cout<<"Yes"<<endl; } else{ cout<<"No"<<endl; } return 0; }
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; #define FOR(i, a, b) for (int i = a; i <= (b); i++) #define F0R(i, a) for (int i = 0; i < (a...
// Problem: // B - Reversible Cards // // // Contest: AtCoder - AtCoder Regular Contest 111 // URL: https://atcoder.jp/contests/arc111/tasks/arc111_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> us...
#include <bits/stdc++.h> using namespace std; template <typename T> using vec = vector<T>; template <typename T> using vvec = vec<vec<T>>; template <typename T> using lqueue = priority_queue<T, vector<T>, greater<T>>; template <typename T> using gqueue = priority_queue<T, vector<T>, less<T>>; constexpr int max_v = 400...
#include<bits/stdc++.h> #define ll long long int #define mk make_pair #define pb push_back #define INF (ll)1e18 #define pii pair<ll,ll> #define mod 1000000007 //998244353 #define f(i,a,b) for(ll i=a;i<b;i++) #define fb(i,a,b) for(ll i=a;i>b;i--) #define ff first #define ss second #define srt(v) if(!v.empty())sort(v.be...
#include <bits/stdc++.h> #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(),(x).rend() #define SIZE(x) ((ll)(x).size()) #define ...