code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<iostream> #include<cmath> using namespace std; typedef long long ll; ll n; int main() { cin>>n; ll a,b,c; ll mins=1e19; for(int i=0;i<=60;i++) { a=n/pow(2,i); b=i; c=n-a*(ll)pow(2,i); mins=min(mins,(a+b+c)); } cout<<mins; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = 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) { ...
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder #include<bits/stdc++.h> //#include<atcoder/all> typedef long long ll; typedef long double ld; using namespace std; //using namespace atcoder; using Pii = pair<int, int>; using Pll = pair<ll, ll>; //ordered_set 重複不可 #include <ext/pb_ds/assoc_con...
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <utility> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using ll = long long; ll INF = 2e18; using namespace std; int N; int cnt; int main() { cin >> N ; for(int o = 1; o<N+1; o++){ int tmp = o; int div = 3; cnt ...
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; #define fi first #define se second #define mkp make_pair int dis[2002]; int n,m; vector<pii>g[2002]; void dij(int s){ for(int i=0;i<2002;i++)dis[i]=1e9; priority_queue<pii,vector<pii>,greater<pii> >pq; for(auto x:g[s]) if(dis[x.fi]>x.se)dis[x....
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return ...
#include <bits/stdc++.h> #define LL long long using namespace std; const int mod = 998244353; int n, m; int f[3005][3005]; int main() { cin >> n >> m; f[1][1] = 1; for (int i = 2; i <= n; ++i) { for (int j = i; j; --j) { f[i][j] = f[i - 1][j - 1]; if (j + j <= i) { f[i][j] += f[i][j + j]; if (f[i][j]...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define itn int #define rep2(i,a,n) for(int i = (a);i < (n);i++) #define rep(i,n) rep2(i,0,n) #define P pair<int,int> #define endl '\n' int dp[1001][1001]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m; ci...
#include<bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; void read(int &x){ static char c; while(!isdigit(c=getchar())); x=c^48; while(isdigit(c=getchar()))x=(x*10)+(c^48); } void read(ll &x){ static char ...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() #define int long long const int MOD=998244353; int dp[15][1000001]; int pw(int n,int k){ assert(k>=0); int res=1; while(k){ if(k&1)(res*=n)%=MOD; (n*=n)%=MOD; k>>=1; } return r...
#pragma GCC optimize("Ofast") #include <iostream> #include <stdio.h> #include <string> #include <vector> #include <algorithm> #include <cstdlib> #include <cmath> #include <iomanip> #include <cctype> #include <sstream> #include <stack> #include <deque> #include <queue> #include <list> #include <set> #include <map> #incl...
#include<bits/stdc++.h> #define N 200005 #define re register #define ll long long #define P 100007 using namespace std; int n,m,K,q,u; inline void Rd(int &res){ re char c;res=0;bool f=0; while(c=getchar(),c<48)(c=='-')&&(f=1); do res=(res<<3)+(res<<1)+(c^48); while(c=getchar(),c>47); f&&(res=-res); } int main(){ ...
#include <bits/stdc++.h> using namespace std; // #define int long long #define MOD 1000000007 #define pb push_back #define fi first #define se second #define endl "\n" #define all(v) v.begin(), v.end() typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPII; typedef vector<VI> VVI; const string YES...
#include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #include <iomanip> #include <vector> int main() { int M, H; cin >> M >> H; if (H % M == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include<bits/stdc++.h> using namespace std; inline int read(){ int x = 0 ,w = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-'){ w = -1; c = getchar(); } } while(c >= '0' && c <= '9'){ x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } return x * w; } inline int min(int a,int b){retu...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL; #define pb push_back #define mp make_pa...
#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; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order(k) -> iterator of kth element (in sort...
#include <iostream> #include <math.h> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <cassert> #include <numeric> //#include <bits/stdc++.h> //#define rep(i,a,n) for (int i=a;i<n;i++) #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for(ll i = 0; i < (n); ++i) #defi...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1010; const int mod=1e9+7; ll dp[maxn]; char x,y,z,f; ll mypow(ll a,ll b){ ll ans=1; while(b){ if(b&1)ans=1ll*ans*a%mod; a=1ll*a*a%mod; b>>=1; } return ans; } int main(){ ios::sync_with_stdi...
#include<bits/stdc++.h> #define llong long long #define mkpr make_pair #define x first #define y second #define iter iterator #define riter reverse_iterator #define y1 Lorem_ipsum_ #define tm dolor_sit_amet_ using namespace std; inline int read() { int x = 0,f = 1; char ch = getchar(); for(;!isdigit(ch);ch=getchar()...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--) #define rrep(i,n) RREP(i,(n)-1,0) #define all(v) v.begin(), v.end() #define endk '\n' co...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;} template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;} #define itn int #define fi first #define se second #def...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define print(x) cout << x << endl #define all(v) (v).begin(),(v).end() #define YN(ok) print((ok ? "YES" : "NO")) #define yn...
#include<bits/stdc++.h> #define ll long long #define re register #define INF 2147483647 using namespace std; inline int read() { int f=1,x=0;char s=getchar(); while(s<'0'||s>'9') { if(s=='-') f=-1; s=getchar(); } while(s>='0'&&s<='9') { x=x*10+s-48; s=getchar(); } return f*x; } int main() { int a=rea...
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #incl...
#include<iostream> #include <algorithm> using namespace std; int main() { string S; cin >> S; int result = 0; for (int i = 0; i < 9; i++) { if (S[i] == 'Z' && S[i+1]=='O' && S[i+2]=='N' && S[i+3]=='e') { result++; } } cout << result; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int x,y; cin >> x >> y; if(x == y){ cout << x; }else{ if(x!=1 && y!=1){ cout << 1; }else if(x!=2 && y!=2){ cout << 2; }else{ cout << 0; } } ...
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ip cin>> #define op cout<< #define int long long signed main(){ fast int a, b, c; ip a>>b; if(a == b) { c = a; } else if(a == 1 && b == 2){ c = 0; } e...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)n;i++) #define Rep(i,n) for(int i=0;i<=(int)n;i++) const ll mod = 1e9+7 ; const ll INF = 1e18 ; ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;} ll lcm(long long a,long long b){return a/gcd(a,b...
#include <bits/stdc++.h> using namespace std; int main() { long long N, count = 0; cin >> N; vector<vector<long long>> A(N, vector<long long>(3)); for (int i = 0; i < N; i++) { for (int j = 0; j < 3; j++) { cin >> A.at(i).at(j); } } for (int i = 0; i < (N - 1); i++) ...
// Fearless #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define pii pair <int, int> #define pll pair <long long, long long> #define PI (2.0 * acos(0.0)) #define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++) #define info pair<int, pii> #define mkp make_pair const lo...
/** * Coded by : lucky_21 * --------Lokesh Singh **/ #include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_upd...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using ll = int64_t; 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<pii>; using vpll =...
#include <bits/stdc++.h> #define int long long #define db(a) cout << a << endl #define db2(a,b) cout << a << " " << b << endl #define dbd(a) cout << #a << ": " << a << endl #define dbd2(a,b) cout << #a << ": " << a << ", " << #b << ": " << b << endl #define dbp(a) cout << a.first << " " << a.second << endl #define adb...
#include <iostream> using namespace std; int main(void){ int x, y; cin >> x >> y; if (x == y) { cout << x << endl; } else if (x == 0 && y == 1) { cout << 2 << endl; } else if (x == 1 && y == 0) { cout << 2 << endl; } else if (x == 0 && y == 2) { cout << 1 << endl; } else if (x == 2 && y =...
#include <bits/stdc++.h> using namespace std; int main() { int N, W; cin >> N >> W; int ans = N / W; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long const int nax=2e5+100,mod=1e9+7; int dp[nax][19]; int32_t main() { int t=1; //cin>>t; while(t--) { string a; cin>>a; int k; cin>>k; set<int> s; s.clear(); for(int i=0;i<a.size();i+...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i,a,n) for (ll i = a;i<(n);++i) #define all(v) v.begin(),v.end() #define bit(n) (1LL<<(n)) #define pu(n) push_back(n) #define INF 1000000000000 //10^12 #define MOD 10000007 //10^9+7 #define MAXR 100000 //10^5 template<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define ...
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define endl '\n' #define debug(x) cerr << #x << ": " << x << endl #define pb(a) push_back(a) #define pf(a) push_front(a) #define set0(a) memset(a,0,sizeof(a)) #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define dwn(i,a,b) for(int i=(a);i>=(b);i--...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll K,N,M; cin >> K >> N >> M; vector<ll> A(K),B(K); rep(i,K) cin >> A[i]; rep(i,K) B[i] = M * A[i] / N; ll x = M; vect...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return ...
#include <bits/stdc++.h> using namespace std; /* 提出前に確認! - 配列は+10ぐらい余分にとっておく - setとmultisetを間違えない */ /* デバッグ時にチェック! - RE 配列の取りうる最大値、最小値を**すべて**チェックする */ int a[110]; int b[110]; bool used[220]; bool dp[200][200]; int zero_cnt[200][200]; int main(void) { int n; cin >> n; int zero_all = 0; for (int i = 0; i < n; ...
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0);ios_base::sync_with_stdio(0); string to_string(string s) { return '"' + s + '"';} string to_string(char s) { return string(1, s);} string to_string(const char* s) { return to_string((string) s);} string to_string(bool b) { return (b ? "true" : "fa...
/*input */ #include <bits/stdc++.h> #define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i)) #define down(i,b,a) for(int (i) = (b);i>=(a);--i) #define bits(x,i) (((x) >> (i)) & 1) #define mid ((l+r)/2) #define pr pair<int,int> #define ll long long using namespace std; const int N = 2005; int n,m; int a[N]; const int mod = ...
#include <cstdio> #include <algorithm> using namespace std; typedef long long LL; LL mod = 1e9 + 7; const int MAXN = 4e6 + 5 + 2e3; LL inv[MAXN]; LL C(LL a , LL b) { LL res = 1; for (LL i = 1; i <= b; ++i) { res = res * (a - i + 1) % mod * inv[i] % mod; } return res; } int main() { inv[1] = 1; for (int i = 2...
// @author: the__martian // 108 #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = a; i >= (b); --i) #define trav(a, x) for (auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using ll = long long; using pii = pair<...
#include <bits/stdc++.h> #define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x) #define all(v) (v).begin(), (v).end() using namespace std; #define forn(i,n) for (int i = 0; i < (n); ++i) #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i) using ll = long long; int mod = (ll)1e9 + 7; #define PI ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; //int:2*10**9 typedef long double ld; typedef pair<ll,ll> P; #define REP(i,n) for(ll i = 0; i<(ll)(n); i++) #define FOR(i,a,b) for(ll i=(a);i<=(b);i++) #define FORD(i,a,b) for(ll i=(a);i>=(b);i--) #define pb push_back #define MOD 1000000007 //998244353...
#include <iostream> #include <queue> #include <string> #include <vector> using namespace std; int n, m; vector<pair<int, char>> edges[1000]; int main() { cin >> n >> m; for (int i = 0; i < n; ++i) edges[i].clear(); for (int i = 0; i < m; ++i) { int from, to; char c; cin >> fr...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[1000000],tree[1000000]; void update(ll i,ll val,ll s,ll e,ll idx) { if(i==s&&s==e) { tree[idx]=tree[idx]^val; return; } if(i>e||i<s) { return; } ll mid=(s+e)/2; update(i,val,s,mid,2*idx); ...
#include <bits/stdc++.h> using namespace std; struct BIT{ vector<int> a; BIT(int n):a(n+1){} void xadd(int i,int x){ while(i<a.size()){ a[i]^=x; i+=i&-i; } } int xsum(int i){ int ret=0; while(i>0){ ret^=a[i]; i-=i&-i; } return ret; } }; int main(){ int n,q...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#i...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=a;(i)<(b);++(i)) #define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i)) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,n,0) #define ALL(v) v.begin(), v.end() #define UNIQ(v) sort(ALL(v)); v.erase(unique(ALL(v))...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 1e9 #define linf 1e18 #define BASE 1000000 #define EPS 1e-10 #define PI acos(-1) #define pii pair<int,int> #define piii pair<int, pair<int, int> > #define pdi pair<double,int> #define vi vector<int> #define fi first #define se second #defi...
#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 A, B; cin >> A >> B; ll a...
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 #define pb push_back #define ss second #define ff first #define all(v) v.begin(), v.end() #define deb(x) cerr << "\n" \ << #x << "=" << x << "\n"; #define deb2(x, y) cerr << "\n" \ ...
#include<bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n-1); i >= 0; i--) #define all(v) (v).begin(),(v).end() #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) template <class T> bo...
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> neigh[105]; bool vis[105]; int cnt[105]; void dfs(int v) { if (vis[v]) return; vis[v] = true; cnt[v]++; for (int u : neigh[v]) { dfs(u); } } long double fact[105]; long double C(int n, int m) { if (m > n) return 0; return fac...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; ++i) { cin >> S[i]; } double ans = 0; for (int i = 0; i < N; ++i) { vector<bool> used(N, false); queue<int> q; q.emplace(i); used...
/* K.D. Vinit |,,| */ #include<bits/stdc++.h> using namespace std; #define int long long const int mod = 998244353; void solve() { int n, m; cin>>n>>m; int a[n+1][m+1]; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { char x; cin>>x; if(x...
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <iomanip> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <bitset> #include <chrono> #include <random> #define rep(...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=a;(i)<(b);++(i)) #define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i)) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,n,0) #define ALL(v) v.begin(), v.end() #define UNIQ(v) sort(ALL(v)); v.erase(unique(ALL(v))...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(v) v.begin(), v.end() 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)...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll = int64_t; using ull = uint64_t; using pll = pair<ll,ll>; const ll INF = 4e18; void print0() {} template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);} void print() { pri...
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> #include<algorithm> #include<iomanip> #include<set> #include<unordered_set> #include<map> typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #d...
#include <stdio.h> #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include <algorithm> #include <iostream> #include <map> using namespace std; long LCM(long m, long n){ //nPrime = 1000000007 if (m < n){ swap(m,n); } if (m % n == 0){ return n; } long a = m, b = n; ...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n-1); i >= 0; i--) #define all(v) (v).begin(),(v).end() #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; retur...
#include <bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; int ans = 0; for (int i = 1; i <n ; i++) { int j = n - i; if(j>=1)ans++; } cout<<ans+1/2<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ string s; cin>>s; if(s.size()%2){ string ss; for(int i=0;i<s.size()/2;i++){ ss+='9'; } if(ss.size()==0)ss="0"; cout<<ss; return 0; } string a=s.substr(0,s.size()/2),b=s.substr(s.size()/2,s.size()/2); int x=stoi(a),y=stoi...
#include<bits/stdc++.h> using namespace std; const int N=1000005,M=998244353; int n,m,i,mi[21],su[N]; int main() { scanf("%d",&n); for(i=0;i<n;++i) printf("%d %d\n",i*2%n+1,(i*2+1)%n+1); }
#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 <cstdio> #define For(i, l, r) for(i=int(l); i<=int(r); i++) #define Fo(i, n) For(i, 1, n) typedef long long int64; const int MOD = 1e9 + 7; inline int qpow(int64 b, int p, int mod=MOD) { int res=1; while(p) { if(p & 1) res=res*b%mod; b=b*b%mod; p>>=1; } return res; } int main() { int i, sum ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, m, sum = 0, ans; cin >> n >> k >> m; for (int i = 1; i < n; i++) { int p; cin >> p; sum += p; } if (m * n - sum < 0) ans = 0; else if (k < m * n - sum) ans = -1; else ans = m...
#include <bits/stdc++.h> #define int long long using namespace std; int solve(string s1,string s2) { int x=0,y=0,n1=s1.size(),n2=s2.size(); for(int i=0,f=0;i<n1;++i) { if(!f&&s1[i]=='0') continue; else f=1,x=(x<<3)+(x<<1)+(s1[i]^48); } for(int i=0,f=0;i<n2;++i) { if(!f&&s...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll powk(ll a, ll n = 2){ ll r = 1; for(ll i = 0;i < n;i++){ r *= a; } return r; } int main() { ll n, k; cin >> n >> k; ll t = n; for(ll i = 0;i < k;i++){ string st; st = to_string(t); sort(st.begin(),st.end()); ...
#include <bits/stdc++.h> #define fo(a,b,c) for (a=b; a<=c; a++) #define fd(a,b,c) for (a=b; a>=c; a--) #define max(a,b) (a>b?a:b) #define min(a,b) (a<b?a:b) #define ll long long //#define file using namespace std; int n,K,i,j,k,l,L,R,Mid,sum,s1,s2; int a[400001][2],ls[200001],len; int f[200001]; void New(int x,int y)...
//Target for Pupil //Implementation and Data structures //Prodip sarker(student_ip) #define bn begin() #define en end() #define mx 5000010 #define pb push_back #define PI (2.0*acos(0.0)) #define al(a) a.begin(),a.end() #define rb(a,b,c) for(int a=b;a<=c;++a) #define rep(a,b) for(int a=0;a<b;++a) #define fastio ios::syn...
#include<bits/stdc++.h> #define st first #define nd second #define pb(x) push_back(x) #define pp(x) pop_back(x) #define mp(a, b) make_pair(a, b) #define all(x) (x).begin(), (x).end() #define rev(x) reverse(all(x)) #define sor(x) sort(all(x)) #define sz(x) (int)(x).size() #define rsz(x) resize(x) using namespace std; ...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long #define inf 1000000000 #define pii pair<int,int> #define fi first #define se second #define inp(a) for(auto &x: a)cin>>x #define fr(i,a,b) for(int i=a;i<b;++i) #define rep(i,n) for(int i=a;i...
#include <bits/stdc++.h> #define watch(x) std::cout << (#x) << " is " << (x) << std::endl using LL = long long; using pii = std::pair<int, int>; using pll = std::pair<LL, LL>; int main() { //freopen("in","r",stdin); std::ios::sync_with_stdio(false); std::cin.tie(nullptr); LL s, p; std::cin >> s >> p; __int128 S ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, a, b) for(ll i = (a); i < (b); ++i) #define REP(i, n) for(ll i = 0; i < (n); ++i) #define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array) template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { int n,k; cin >> n >> k; int a[n]; for(int i=0;i<n;i++) cin >> a[i]; vector<int> fre(300001,0); for(int i=0;i<n;i++) fre[a[i]]++; vector<int> mn_fre(300001); ll ans = 0; for(in...
#include <string> #include <vector> #include<iostream> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> #include<cmath> #include<algorithm> #include<functional> #include<list> #include<deque> #include<bitset> #include<set> #include<map> #include<unordered_map> #include<unordered_set> #include<cstring>...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; string S, T; cin >> S >> T; deque<int> A, B; for (int i = 0; i < N; i++) { if (S[i] == '1') A.emplace_back(i); if (T[i] == '1') B.emplace_back(i); } long long ans = 0; for (...
#include<bits/stdc++.h> #define inf 0x3f3f3f3f3f3f3f3fll typedef unsigned long long ull; typedef long long ll; #define rep(i,l,r) for(int i=l;i<=r;i++) #define nep(i,r,l) for(int i=r;i>=l;i--) void sc(int &x){scanf("%d",&x);} void sc(int &x,int &y){scanf("%d%d",&x,&y);} void sc(int &x,int &y,int &z){scanf("%d%d%d",&x,&...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i =0; i <(n); i++) using ll = long long; int main(){ int n; cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; int ans = 1<<30; rep(s,1<<(n-1)){ int now = 0; int o = 0; rep(i,n){ o |= a[i]; ...
#include<bits/stdc++.h> int main(){ using namespace std; unsigned long N; cin >> N; vector<unsigned long> A(N), B(N); for(auto&& i : A)cin >> i; for(auto&& i : B)cin >> i; priority_queue<unsigned long> pq; reverse(begin(A), end(A)); unsigned long ans{0}; for(unsigned long i{0}; ...
#include <iostream> using namespace std; int main(){ int n, x; char c; cin >> n >> x; for (int i=1; i<=n; i++){ cin >> c; if (c == 'o') x++; else if (c == 'x'){ if (x != 0) x--; else continue; } } cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template<int M> struct static_mint { static_assert(0 < M, "Module must be positive"); int val; static_mint(): val() {} static_mint(long long x) : val(x % M) { if (val < 0) val += M; } static_mint pow(long long n) const { static_mint ans = 1, x(*this); while (n) { if ...
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <vector> #include <string> #include <algorithm> #include <queue> #include <stack> #include <map> #include <set> #include <unordered_set> #include <unordered_map> #include <bitset> #include <limits> #include <random> #include <complex>...
#pragma GCC optimize ("-O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> p32; typedef pair<ll,ll> p64; typedef pair<double,double> pdd; typedef vector<ll> v64; typedef vector<int> v32; typedef vector<vector<int> > vv32; typedef vector<vector<ll...
#include <bits/stdc++.h> using namespace std; using ll = 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; } #define ...
#include <iostream> #include <iomanip> #include <sstream> #include <vector> #include <string> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <functional> #include <iterator> #include <limits> #include <nume...
#include <iostream> #include <algorithm> using namespace std; int main(void){ int H, W, Abuf; int minNum = 101; int sumNum = 0; cin >> H >> W; for(int i=0; i<H; i++){ for(int j=0; j<W; j++){ cin >> Abuf; minNum = min(minNum, Abuf); sumNum +=Abuf; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(c) (c).begin(), (c).end() using namespace std; using ll = long long int; using pii = pair<int,int>; using vi = vector<int>; using vvi = vector<vi>; const long long INF = 1LL << 60; const int inf = 1001001001; const ll mod = 100000...
#include <bits/stdc++.h> using namespace std; #define rep(i, l, n) for (int i = (int)(l); i < (int)(n); i++) #define drep(i, n, l) for (int i = (int)(n); i > (int)(l); i--) #define INF INT_MAX #define INFF (pow(2,64)) #define def (200007) #define MOD (1000000007) typedef int64_t intt; typedef vector<int> veci; typedef ...
#include<iostream> int main(){ int max_gcd = 0, ans = 0; int n; std::cin >> n; int a[n]; for(int i=0; i < n; i++){ std::cin >> a[i]; } for(int h=2; h < 1000; h++){ int gcd=0; for(int i=0; i < n; i++){ if(a[i] % h == 0){ gcd++; } } if(gcd > max_gcd){ max_gcd =...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define e "\n" #define fl(x,n) for(ll i=x;i<=n;i++) #define fl2(x,n) for(ll i=x;i>=n;i--) using namespace std; int main() { ll n; cin >> n; if(n%100==0) cout << 100 << e; else { ll d=ceil((double)n/...
#include <bits/stdc++.h> using namespace std; int main() { int X; cin >> X; if (X % 100 == 0) { cout << 100 << endl; } else { cout << 100 - X % 100 << endl; } return 0; }
///////////////////////////////////////////////////////////// // Give me AC!!! // //////////////////////////////////////////////////////////// #include <bits/stdc++.h> using namespace std; using ll = long long; #define _GLIBCXX_DEBUG #define rep(i, c, n) for...
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; char x[n][m]; for (int i=0;i<n;i++) for (int j=0;j<m;j++) cin>>x[i][j]; int num1=0; for (int i=0;i<n-1;i++){ for (int j=0;j<m-1;j++){ int num2=0; if (x[i][j]=='#')num2++; if (x[i][j+1]=='#')num2++; if (x[i+1][j]=='#')n...
#include <stdio.h> #include <algorithm> #include <vector> using namespace std; #define cm (1 << 17) char cn[cm], *ci = cn + cm, ct; inline char getcha() { if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; } return *ci++; } inline int getint() { int A = 0; while ((ct = getcha()) >= '0') A = A...
#include <bits/stdc++.h> using namespace std; template <int mod = (int)(1e9 + 7)> struct ModInt { int x; constexpr ModInt() : x(0) {} constexpr ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} constexpr ModInt &operator+=(const ModInt &p) noexcept { if ((x += p.x) >= mod) x -= mo...
#include<bits/stdc++.h> using namespace std; #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); #define ll long long #define ull unsigned long long #define pb push_back #define All(x) (x).begin(),(x).end() #define mp make_pair #define nl "\n" typedef pair<int,int>ii; typedef vector<int>vi; typedef vector<ii>v...
#include <bits/stdc++.h> using namespace std; std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now(); // Defines #define all(x) (x).begin(),(x).end() #define sortall(x) sort(x.begin(),x.end()) #define maxin(x) *max_element(x.begin(),x.end()) #define minin(x) *min_...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required // template starts using namespace __gnu_pbds; //required using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_upd...
#include <iostream> #include <string.h> #include <math.h> #include <algorithm> using namespace std; int main() { long double sx,sy,gx,gy; cin>>sx>>sy>>gx>>gy; long double ans; ans=((sx*gy)+(sy*gx))/(sy+gy); cout.precision(10); cout<<ans<<endl; return 0; }
// abc193_d #pragma GCC optimize ("O3") #include <bits/stdc++.h> #ifdef LOCAL #include "../../debug_util/cxx-prettyprint/prettyprint.hpp" #include "../../debug_util/rng.hpp" #include "../../debug_util/timer.hpp" #endif using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, b) for(ll i = (a); i < (b); i++) #define REP(i, a) FOR(i, 0, a) ll T, X, Y, P, Q; ll extgcd(ll a, ll b, ll& x, ll &y){ ll d = a; if(b != 0){ d = extgcd(b, a % b, y, x); y -= (a / b) * x; }else{ x = 1; y = 0; } return d...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Kein Yukiyoshi */ #include "bits/stdc++.h" #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define FOR(i, a) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define data data123 const int N = 1005; vector<int> G[N*N]; int n, m; int pos(int i, int j) { return (i-1)*n+j; } vector<pii> data[N*N]; bool vis[N*N]; void solve() { scanf("%d%d", &n, &m); char ch[5]; ...
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; int n, m, c, a[2]; long long ans; string s; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s; c = 0; for (i...
#include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int a[2] = {0, 0}; for (int i = 0; i < n; i++) { string s; cin >> s; int t = 0; for (char c : s) if (c == '1') t ^= 1; a[t]++; } cout << (long long)a[0] * a[1] << endl; }
#include <bits/stdc++.h> #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), cout.tie(NULL); #define int long long #define ld long double using namespace __gnu_pbds; using namespace std; using ll = long long; template<class T> us...
#include<iostream> #include<vector> using namespace std; using ll=long long; const ll MOD=1000000007; int main(){ int n;cin>>n; vector<ll>sum(n+1,0); for(int i=0;i<n;i++){ ll a;cin>>a; sum.at(i+1)=sum.at(i)+a; } vector<vector<int>>idx(n+1,vector<int>(n+1,-1)); vector<vector<int>>pre(n+1,vector<int...
#include <bits/stdc++.h> using namespace std; // template {{{ #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1) #define whole(f, x, ...) ([&](decltype((x)) container) { return (f)( begin(container), end(container), ## ...
#include<bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> // Common file //#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update //using namespace __gnu_pbds; //typedef tree<long long,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;...
#include <bits/stdc++.h> using namespace std; const int N = 105; int n; typedef pair<int, int> pint; pint a[N], b[N], c[N]; int product(pint a, pint b) { return a.first * b.second - a.second * b.first; } pint diff(pint b, pint a) { return {b.first - a.first, b.second - a.second}; } int sqr(int x) { return x * ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using Pair = pair<int, int>;...
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair<ll, ll> pll; typedef pair<int, int> pint; int main() { cin.tie(0); ...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> // for less using namespace __gnu_pbds; using namespace std; #define int long long #define endl "\n" #define deb(x) cout<<#x<<" "<<x<<endl; #define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar...
#include <iostream> #include <vector> #include <algorithm> const int INF = 0x3fffffff; using namespace std; int main() { int n, m; cin >> n >> m; vector<int> H(n); vector<int> W(m); for (int i = 0; i < n; i++) cin >> H[i]; for (int i = 0; i < m; i++) cin >> W[i]; sort(H...
#include<stdio.h> double dp[101][101][101]; double f(int a,int b,int c){ if(dp[a][b][c])return dp[a][b][c]; if(a==100||b==100||c==100)return 0; double ans=0; ans+=(f(a+1,b,c)+1)*a/(a+b+c); ans+=(f(a,b+1,c)+1)*b/(a+b+c); ans+=(f(a,b,c+1)+1)*c/(a+b+c); dp[a][b][c]=ans; return ans; } int main(){ int a,b,c; sca...
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, C; cin >> A >> B >> C; auto power = []( long long x, long long n, long long m ) { long long res = 1; while( n > 0 ) { if( n % 2 ) res = res * x % m; x = x * x % m; n /= 2; } return res; }; long long bc = power( B, C, 4 )...
#include <iostream> #include <vector> #include <deque> #include <algorithm> #include <numeric> #include <string> #include <cstring> #include <list> #include <unordered_set> #include <tuple> #include <cmath> #include <limits> #include <type_traits> #include <iomanip> #include <map> #include <unordered_map> #include <que...
#include <map> #include <cmath> #include <ctime> #include <queue> #include <cstdio> #include <vector> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define LL long long #define Int register int #define Swap(a, b) a ^= b, b ^= a, a ^= b #define Abs(x) ((x) < 0 ? -(...
#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<cstdio> #include<algorithm> #define mod 1000000007 using namespace std; typedef long long ll; #define gc() getchar() inline bool ig(char c){return c>='0'&&c<='9';} inline void read(ll &oi){char c;ll f=1,res=0;while(c=gc(),(!ig(c))&&c^'-');c^'-'?res=(c^48):f=-1;while(c=gc(),ig(c))res=res*10+(c^48);oi=f*res;} in...
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include...
#include <iostream> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <utility> #include <string> #include <sstream> #include <algorithm> #include <random> #include <cstdio> #include <cstdlib> #in...
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=...
#include<bits/stdc++.h> #define ll long long #define ld long double #define db double #define pint pair<int,int> #define mk make_pair #define pb push_back #define eb emplace_back #define ins insert #define fi first #define se second #define Rep(x,y,z) for(int x=y;x<=z;x++) #define Red(x,y,z) for(int x=y;x>=z;x--) using...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mit map<int,int>::iterator #define sit set<int>::iterator #define itrm(g,x) for(mit g=x.begin();g!=x.end();g++) #define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) #define ltype int #define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++) #define r...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; typedef tuple<int,int,int> ti; typedef tuple<ll,ll,ll> tl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pi>...
#include<bits/stdc++.h> using namespace std; template<typename T>inline bool read(T&x){ x=0;char c=getchar();int f=1;while(!isdigit(c)&&(c!='-')&&(c!=EOF))c=getchar(); if(c==EOF)return 0;if(c=='-')f=-1,c=getchar(); while(isdigit(c)){x=x*10+(c&15);c=getchar();}x*=f;return 1; }template<typename T,typename...Args>inline b...
// YATIN KWATRA #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize ("Ofast") #define ll long long #define ar array #define sz(v) (int)(v.size()) #define inf ...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define int long long using namespace std; const int maxn = 3e5; const int inf = 0x3f3f3f3f; struct B{ int l, v; }p[maxn]; int N, M, Min[maxn], w[15], temp_w[15], sum[15], used[15]; int d[15][15], dis[15], Minw, ans, vis[15]; bool operator...
#include<bits/stdc++.h> using namespace std ; #define Next( i, x ) for( register int i = head[x]; i; i = e[i].next ) #define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i ) #define drep( i, s, t ) for( register int i = (t); i >= (s); -- i ) #define re register #define int long long int gi() { char cc = getc...
#include <iostream> #include <vector> using namespace std; typedef long long ll; int main(){ ll t, N; cin >> t >> N; ll p = 100 + t; vector<bool> vec_ori(p,true); for(int i=0 ; i<100 ; ++i){ vec_ori[p*i/100] = false; } vector<ll> vec; for(int i=0 ; i<p ; ++i){ if(vec_ori[i]){ vec.push_ba...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define F first #define S second #define Tsetso ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pr pair < int , int > const int N = 3e6+10,NN = 1005, length = 25 , mod = 1e9+7; ll dp[4][N]; int main() { Tsetso ...
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") #include <bits/stdc++.h> #include<set> #include <array> using namespace std; #define ll long long #define endl '\n' #define mod 1000000007 #define pb push_back #define ff first #define ss second #define con continue #define ub upper_bound #define lb lower_...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const long long mod=1e9+7; const int maxn = 1e4+4; ll read() { ll x=0,f=1;char c=getchar(); while(c<'0'||c>'9') { if(c=='-') f=-1; c=getchar(); } while(c>='0'&&c<='9') { x=x*10+c-'0'; c=getchar(); } ...
#include <bits/stdc++.h> using namespace std; int n, m, q, a[51][3], b[51], x, y; bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second > b.second); } void solve() { cin >> n >> m >> q; vector<pair<int, int> > t; for(int i=1; i<=n; i++) { cin >> a[i][1] >> a[i...
#include <iostream> #include <algorithm> #include <string> #include <vector> using namespace std; #define Fast_IO ios::sync_with_stdio(false) ,cin.tie(0) ,cout.tie(0) int main() { Fast_IO; int n, k, x, y, res = 0; cin >> n >> k; for (int i=1; i<=n; i++) { cin >> x >> y; res += (x*y...
#include <cstdio> #include <algorithm> #include <cmath> #include <iostream> #include <cstdlib> #include <cstring> using namespace std; inline int gi(){ char tmp=getchar();int ans=0; int flag=1; while(!isdigit(tmp)){ if(tmp=='-'){ tmp=getchar(); flag=-1; break; } tmp=getchar(); } while(isdigit(tmp)){...
#include<bits/stdc++.h> using namespace std; #include <numeric> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL); #define endl "\n" #define int long long int #define MOD 1000000007 #define INT_BITS 16 #define INF 1e18 #define pi 3.141592 #define watch(x) cout<<(#x)<<"="<<(x)<<"\n" #define pb push_back #...
#include<bits/stdc++.h> using namespace std; using namespace std::chrono; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define rep(i,a,b) for(int i=a;i<b;i++) #define repn(i,a,b) for(int i=a;i>=b;i--) #define ff first #define ss second #define lb lower_bound #define u...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<long long, long long>; using vi = vector<int>; using vl = vector<ll>; using vll = vector<vector<ll>>; constexpr char ln = '\n'; constexpr long long MOD = 1000000007; //constexpr long long MOD = 998244353; ...
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (i = 0; i < n; i++) #define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1) #define ll long long #define si(x) scanf("%d", &x) #define sl(x) scanf("%lld", &x) #define ss(s) scanf("%s", s) #define pi(x) printf("%d\n", x) #define p...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long double k=0.6180339887498948482045; ll x,y,tmp; vector<int> ans; int main(){ scanf("%lld",&tmp);if(tmp==0) {printf("0\n");return 0;} //printf("%lf\n",((long double)tmp)*k-50); for(ll i=max((ll)(((long double)tmp)*k)-50,0ll);;i++){ x=tmp;y...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fr(i,n) for(int i=0;i<n;i++) int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; int j=t*1.08; if(j>206) cout<<":("<<endl; else if(j==206) cout<<"so-so"<<endl; else cout<<"Yay!"<<endl; return 0; }
// You told me... // At your absolute best, you still won't be good enough for the wrong person... // At your worst, you'll still be worth it to the right person... // ............................................................................................ // It was good while it lasted, good bye... ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #pragma GCC optimize ("Ofast") #pragma GCC optimization ("unroll-loops, no-stack-protector") #pragma GCC target ("avx") #pragma GCC target ("avx2") #pragma GCC target ("fma") #define fastio ios_bas...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, b) for (ll i = a; i < b; i++) #define rrep(i, a, b) for (ll i = b - 1; a <= i; i--) ll MOD = 1000000007; ll K, cnt_a[10], cnt_t[10], ao, taka, win, total; string T, A; int main () { cin >> K >> T >> A; rep (i, 0, 4) { cnt_t...
#include <bits/stdc++.h> using namespace std; using ll = long long; #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 REP(i,a,b) for(int i = (a); i < (b); i++) #define MOD 1000000007 int main(void) { int m,h; cin >> m >> h; if(h%m==0) cout << ...
#include <iostream> #include <algorithm> using namespace std; int main(){ int m, h; cin >> m >> h; if (h % m == 0) cout << "Yes\n"; else cout << "No\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int H,W; cin >> H >> W; int min; vector<vector<int>> data(H,vector<int>(W)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> data.at(i).at(j); if (i == 0 && j == 0) { min = data.at(i).at(j); } el...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; ll sov(ll b,ll c){ if(c==1){ if (b==0) return 1; return 2; } if (b==0) return c; if (b>(c/2)) return c*2-1; if (b<=-(c/2)) return c*2-1; if (b>0) return c+2*b-1; if (b<0) return c-2*b; } ...
#include <iostream> #include <vector> //#include <string> //#include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used //#include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL;...
#include <iostream> //#include <vector> //#include <string> //#include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used //#include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long L...
#include <bits/stdc++.h> using namespace std; #define inf 1000000000 #define unvisited -1 #define visited 1 #define eps 1e-9 #define mp make_pair #define pb push_back #define pi acos(-1.0) #define uint64 unsigned long long #define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define d...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ln "\n" #define si(n) scanf("%d", &n); #define pi(n) printf("%d\n", n); #define sd(n) scanf("%lf", &n); #define pd(n) printf("%.2lf\n", ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX_N = 2e5+2; int n; int a[MAX_N]; int b[MAX_N]; int p[MAX_N]; vector<int> g[MAX_N]; void solve() { if(n == 1){ cout<<0<<'\n'; return; } for(int i=1;i<=n;++i)if(p[i]!=i && a[i] <= b[p[i]]){ cout<<-1<<'\n'; return; } vector<pai...
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 2e5+8, inf = 1e18+9, mod = 1e9+7; int n, m, a[maxn], b[maxn], p[maxn], vs[maxn]; void solve() { int i, j; //cin >> n; scanf("%lld", &n); vector<pair<int, int>> vec; for (i = 1; i <= n; i++) scanf("%lld", &a[i]);...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cctype> #define N 201000 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), c = ...
#include <iostream> #include <string> #include <algorithm> #include <vector> #define rep(i,n) for(int i=0;i<n;i++) #define ll long long using namespace std; int n,q; ll a[100010],c[100010]; ll k; int main(){ cin >> n >> q; rep(i,n){ cin >> a[i]; } sort(a, a+n); rep(i,n){ c[i] = a...
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { int day; cin >> day; if (day % 2 == 0) { cout << "White"; } if (day % 2 == 1) { cout << "Black"; } return 0; }
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <iomanip> #include <queue> #include <deque> #include <map> #include <unordered_map> #define rep(i,n) for(int i=0;i<n;i++) #define repn(i,n) for(int i=1;i<=n;i++) #define repr(e,x) for(auto& e:x) usi...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--) #define rrep(i,n) RREP(i,(n)-1,0) #define all(v) v.begin(), v.end() #define endk '\n' co...
#include <iostream> #include <iomanip> #include <string> #include <algorithm> #include <vector> #include <map> #include <set> #include <queue> using ll = long long; using namespace std; ll n, x; ll a[50]; ll v[50]; ll l[50]; ll dp[51]; ll dq[51]; int main() { cin >> n >> x; for (int i = 0; i < n; ++i) cin >> a[i]; ...
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef pair<string,int> psi; typedef pair<int,string> pis; typedef array<int,2> aii; typedef array<int,3> aiii; typedef array<int,4> aiiii; typedef unsigned long long ull; typedef long long int ll; typedef array<ll,2> all; typedef array<ll,3> all...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin(...
#include<bits/stdc++.h> #define mxn 100005 #define inf 1e9 using namespace std; int n, mem[mxn][26]; char str[mxn]; int dp(int pos, int ch) { if(pos==n)return inf; if(pos==n-1 && (str[n-1]-'a')!=ch)return 1; int &ret= mem[pos][ch]; if(ret!=-1)return ret; ret= dp(pos+1, ch); if((str[pos]-'a')!=c...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int ll using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vpii = vector<pii>; using vvpii = vector<vpii>; template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T,U>& p...
#include<iostream> using namespace std; int main(){ int a,b,c,d,l,m,n,o,p; cin>>a>>b; cin>>c>>d; l=a-c; m=b-c; n=a-d; o=b-d; int max=l; if(m>max){ max=m; } if(n>max){ max=n; } if(o>max){ max=o; } cout<<max; return 0; }
#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; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define oset_find(k) find_by_order(k) #define oset_o...
#include <bits/stdc++.h> #define fo(a,b,c) for (a=b; a<=c; a++) #define fd(a,b,c) for (a=b; a>=c; a--) #define ll long long using namespace std; int n,i,j,k,l,tot; int ans[200001]; int a[200001]; bool bz[200001]; void swap(int &x,int &y) {int z=x;x=y;y=z;} void Exit() { printf("-1\n"); exit(0); } int main() ...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t=0; char ch=getchar(); int f=1; while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f; } const int maxn=(4e5)+10; int n,fa[maxn],dis[maxn],dep[maxn]; vecto...
#include<bits/stdc++.h> using namespace std; using namespace std::chrono; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define int long long #define rep(i,a,b) for(int i=a;i<b;i++) #define repn(i,a,b) for(int i=a;i>=b;i--) #define ff first #define ss second #define lb lower_bound #define u...
/*      />  フ      |  _  _|      /`ミ _x 彡      /      |     /  ヽ   ?  / ̄|   | | |  | ( ̄ヽ__ヽ_)_)  \二つ */ #pragma GCC optimize(2) #include <queue> #include <vector> #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define MP make_pair #define ll long long #define fi first #define se secon...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define sz(x) (int) x.size() #define cat(x) cerr << #x << " = " << x << endl #define all(x) x.begin(), x.end() #define rep(i, j, n) for (int i = j; i <= n; ++i) #define per(i, j, n) for (int i = n; j <= i; --i) using...
#include <bits/stdc++.h> using namespace std; class BinaryIndexedTree{ private: const int N; vector<int> a; public: BinaryIndexedTree(const int& N): N(N){ a.resize(N + 1, 0); } void add(const int& POS, const int& VAL){ for(int i = POS; i <= N; i += i - (i & (i - 1))){ ...
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; using ll=long long; using Graph=vector<vector<int>>; #define MAX 100001 #define INF 1000000000000000000 #define MOD 1000000007 int main(){ vector<int> A(3); for(int i=0;i<3;i++){ cin>>A[i]; } sort(A.begin(),A....
/* JAI JAGANNATH! */ //@Author : zanj0 #include<bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back #define MOD 1000000007 #define inf 1e18 #define ps(x,y) fixed<<setprecision(...
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 10; const int mod = 1e9 + 7; int n; ll dp[N][2], w[N][2]; ll a[N]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } dp[1][0] = a[0]; w[1][0] = 1; for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss second #define PI 3.14159265 ll mod1=1000000007; // bool comp(pair<ll,ll>a,pair<ll,ll>b) // { // // if(a.second==b.second) // // return a.first<b.fir...
#include <bits/stdc++.h> using namespace std; #define debug(x) cout << #x << " is " << x << endl typedef long long ll; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; int t, n; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> t; while (t--) { cin >> n; vector<int> a(n); for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define FOR(i,f,n) for(int i=f;i<n;i++) #define FORI(i,f,n) for(int i=f;i>=n;i--) #define sz(a) ((int)(a).size()) #define ff first #define ss second #define all(a) (a).begin(),(a).end() #define alli(a) (a).rbegin(),(a).rend() #define approx(a) fixed<<...
#include <bits/stdc++.h> using namespace std; #define ld double #define ll long long #define pb emplace_back #define mk make_pair #define mod 1000000007 #define ff first #define sz(v) (int)v.size(); #define ss second #define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) x.begin(),x...
#include <iostream> #include <string> using namespace std; int main(void){ long long nCr[61][61]={};//0で初期化 nCr[0][0]=1; for(int i=1;i<=60;i++){ for(int j=0;j<=i;j++){ if(j!=0){ nCr[i][j] += nCr[i-1][j-1]; } if(j!=i){ nCr...
#include<bits/stdc++.h> #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstream> #include<algorithm> #define...
#include<bits/stdc++.h> using namespace std; void solution() { double s, e, w; cin >> s >> e >> w; w *= 1000; int end = floor(w / (double)s); int start = ceil(w / (double)e); int first = -1, last = -1; bool flag = true; for(int i = start; i <= end; i++) { if(w / w * w == w) { if(flag) ...
#include<iostream> #include<algorithm> using namespace std; int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); int flag = 1; for(int i=0;i<n;i++) { if(a[i] != i+1) { cout<<"No"<<endl; flag = 0; break; } } if(flag == 1) { ...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin(...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() typedef long long ll; ll dp[1 << 20]; vector<int> pr = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}; int getmask(ll v) { int mask = 0; for (int i = 0; i < 20; i++) { if (v % pr[i] == 0) mask...
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; int main() { ll n,k; std::cin >> n>>k; string s; std::cin >> s; string next = s+s; for (int jjjj = 0; jjjj < k; jjjj++) { s = next; for (int i = 0; i < 2*n; i++) { ...
//Codeforcesで128bit整数を使いたいとき //→__int128_tを使う&GNU C++17 (64)で提出する //インクルードなど #include<bits/stdc++.h> using namespace std; typedef long long ll; //イテレーション #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...
#pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double void iosetup(void){ ios::sync_with_stdio(false); std::cin.tie(nullptr); } int get_d(string& X){ int ret = 0; for (auto d : X) ret = max(ret, (int)(d - '0')...