code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int h, w; cin >> h >> w; string s[h]; REP(i, h) cin >> s[i]; int res = 0; REP(i, h-1) REP(j, w-1) { int cnt = 0; REP(x, 2) REP(y, 2) if (s[i+y][j+x] == '#') cnt++; if (cnt%2) res++; } cout << res ...
#include <bits/stdc++.h> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; using ll = long long; #define rep(i,n) for (ll i=0; i < (n); ++i) #define rep2(i,n,m) for(ll i=n;i<=m;i++) #define rep3(i,n,m) for(ll i=n;i>=m;i--) #define P pair<ll,ll> #define pb push_back #define eb emplace_back #...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <queue> using namespace std; int R, C; long long int A[520][520], B[520][520]; long long int INF = 99999999999999; long long int dis[300000]; vector<int> Adj[300000]; vector<long long int> cost[300000]; pri...
#ifdef _DEBUG #define _GLIBCXX_DEBUG #endif #if __has_include(<atcoder/all>) #include <atcoder/all> #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; #define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++) #define rrep(i, a, b) for(int i ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define mp make_pair #define pb push_back #define inF freopen("input.txt", "r", stdin); #define outF freopen("output.txt", "w", stdout); #define endl '\n' #define MOD 1000000007 #d...
#include<bits/stdc++.h> #define int ll #define sz(x) int((x).size()) #define all(x) (x).begin(),(x).end() #define pb push_back #define x first #define y second using namespace std; using ll = long long; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; const int mod = 1e...
#include <bits/stdc++.h> using namespace std; typedef long long i64; typedef unsigned long long ui64; typedef vector<i64> vi; typedef vector<vi> vvi; typedef pair<i64, i64> pi; #define pb push_back #define sz(a) i64((a).size()) #define all(c) (c).begin(), (c).end() #define REP(s, e, i) for(i=(s); i < (e); ++i) inlin...
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; const int N=3e5+5; int n,m,k,cnt,tot,cas,ans; int a[N]; bool vis[N]; char s[N]; #define ll long long long long qmi(long long a,long long b) { long long ans=1; while(b){ if(b&1) ans=ans*a%mod; b>>=1;a=a*a%mod; } return ans; } ll C(ll n,ll r) { if...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pb emplace_back #define pii pair<int , int> #define F first #define S second const int mod = 1000000007; const int MAXX = 1e5 + 5; const int N = 1e5; int t ...
#include<bits/stdc++.h> #define int long long int n,now,ans; using namespace std; signed main() { scanf("%lld",&n); int p=sqrt((n+1)*2); while(p*(p+1)/2<=n+1) { p++; } p--; //cout<<p<<endl; //if(p*p==n*2) p--; //cout<<p<<endl; printf("%lld\n",n-p+1); return 0; }
#include <iostream> #include <deque> #include <climits> #include <cmath> using namespace std; int main() { int N; std::cin >> N; double x0, y0, xh, yh; std::cin >> x0 >> y0 >> xh >> yh; double dx = x0 - (x0 + xh) / 2; double dy = y0 - (y0 + yh) / 2; double ox = cos(M_PI * 2 / N); do...
/** P L E X I U S ** 2021 Jan 29 17:22:53 **/ #include<bits/stdc++.h> using namespace std; #define int long long void solve(){ int n; cin>>n; int cnt = 0; for(int i= 1; i*(i+1)<=2*n; i++) { if((n-i*(i-1)/2)%i==0) cnt++; } cout<<cnt*2<<"\n"; } int32_t main() { ios_base::sync_with_stdio(false); ci...
#include <bits/stdc++.h> using namespace std; long long multi(string x){ long long a,i,minus,multiple=10000,n=x.size(); a=0; if(x[0]=='-'){ minus=-1; i=1; }else{ minus=1; i=0; } while(i<n){ if(x[i]=='.'){ i++; continue; }else{ a=a*10+(x[i]-'0'); i++; } } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() templa...
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } int main() { int h = ri(); int w = ri(); int x = ri() - 1; int y = ri() - 1; std::string s[h]; for (int i=0; i<h; i++) std::cin >> s[i]; int cnt = -3; for (int i = x; i < h && s[i][y] != '#'; i++) cnt++; for (int i = x; i >= 0 && s[...
#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> using namespace std; #define max(x,y) ((x)>(y)?(x):(y)) inline int read(){ int f=1,r=0;char c=getchar(); while(!isdigit(c))f^=c=='-',c=getchar(); while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar(); return f?r:-r; } const int N=2e5+5; int mx[N<<2],tg[N<<2]; #define ls (p<<1) #define rs (p<<...
#include <bits/stdc++.h> #define rei register int #define ll long long using namespace std; const int N=4e5+100; int head[N],ver[N],Next[N],tot; int depth[N],len[N]; int son[N]; int ans[N],cnt; int root,n; inline void add(int u,int v){ ver[++tot]=v; Next[tot]=head[u]; head[u]=tot; } void init(int x,int f...
#include "bits/stdc++.h" #define ll long long int #define ld long double #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr) #define pb push_back using namespace std; typedef pair<int, int> pii; int main() { fastIO; string s; cin >> s; map<int, int> digits; for (int i = 0; i < s.len...
#include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<n;++i) #define rrep(i, n) for(ll i=n-1;i>=0;--i) #define rep1(i, n) for(ll i=1; i<=n; ++i) #define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++) #define ALL(a) (a).begin(),(a).end() template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}} ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(ll i=0; i<(ll)n; i++) #define ALL(obj) begin(obj), end(obj) typedef long long ll; int n, m, a, b, cnt; vector<vector<int> > G(22); vector<int> color(22, -1), ts; vector<bool> vit(22, 0); void dfs(int now){ ts.push_back(now); vit[now]=1; for(int i...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define ordered_set_pair tree<pair<int,i...
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" #define rep(i,n) repi(i,0,n) #define repi(i,a,n) for(ll i=a;i<(ll)n;++i) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() using namespace std; using ll = long long; usin...
#include <bits/stdc++.h> /*#include <iostream> #include <algorithm> #include <math.h> #include <iomanip> #include <string> #include <vector> #include <set> #include <sstream>*/ #define ll long long #define fop(i,m,n) for(int i=m; i<n; i++) #define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define X first...
#include<bits/stdc++.h> using namespace std; int n,a[200005],parent[200005],s=0; int findparent(int x) { if (x==parent[x]) return x; return parent[x]=findparent(parent[x]); } void Union(int u,int v) { int p=findparent(u);//find parents of u int q=findparent(v);//find parents of v; if(p!=q)parent[q]...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 ...
#include <iostream> #include <bits/stdc++.h> using namespace std; void amain() { long long n; cin >> n; if (n%4==0) cout << "Even" << endl; if (n%4==2) cout << "Same" << endl; if (n%2) cout << "Odd" << endl; return; } int main() { ios_base::sync_with_stdio(0); int t; cin >> t; while (...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define all(a) (a).begin(), (a).end() #define mp make_pair template<typename T1, typename T2> inline void chkmin(T1& x, const T2& y) { if (y < x) x = y; } template<typename T1, typename ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<ll> w(n); for (int i = 0; i < n; i++) { cin >> w[i]; } vector...
#include<iostream> using namespace std; int l[200005], r[200005]; long long dp[200005][2]; int n, x, c; const int aa = 1 << 30; int main() { cin >> n; fill(l + 1, l + 1 + n,aa); fill(r + 1, r + 1 + n,-aa); for (int i = 1; i <= n; i++) { cin >> x >> c; l[c] = min(l[c], x); r[c] = max(r[c], x); } ...
#include <string> #include <iostream> #include <vector> #include <algorithm> //#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; vector<vector<int>> X(H, vector<int>(W)); for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { cin >> X[i][j];...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define rep(i,a,b) for( i=a;i<b;++i) #define repr(i,a,b) for( i=a;i>=b;i--) #define up upper_bound #define lb lower_bound // #define t() ...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define pii pair<int, int> #define pll pair<long long,long long> #define vl vector<long long> #define vll vector<pll> #define vi vector<int> #define vii vector<pii> #define...
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<cmath> #include<iomanip> #include<cstring> #include<complex> #include<cstdio> #define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1; #define fi first #define se second #define pb push_back #d...
# include<bits/stdc++.h> using namespace std; # define l long long # define db double # define rep(i,a,b) for(l i=a;i<b;i++) # define vi vector<l> # define vvi vector<vi> # define vsi vector<set<l> > # define pb push_back # define mp make_pair # define ss second # define ff first # define pii pair<l,l> # define trvi...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using VI = vector<int>; int h, w; int g(VI& a, int i, int d); int f(VI& v) { int i = find(cbegin(v), cend(v), 0) - cbegin(v); return i < v.size() ? g(v, i, 0) + g(v, i, 1) : 1; } int g(VI& v, int i, int d) { int j = i + (d...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #ifndef PRELUDE_H #define PRELUDE_H #define M_PI 3.14159265358979323846 #define EPS 1e-9 #include <algorithm> #include <cmath> #include <numeric> #include <vector> #include...
#include <bits/stdc++.h> #define MAXN 2000005 #define ll long long #define F first #define S second #define MOD 1000000007 #define ll long long using namespace std; ll n, m, k; ll gt[MAXN], inv[MAXN]; ll poW(ll A, ll B) { ll C = 1; for(; B; B /= 2, A = (A * A) % MOD) { if(B % 2) C = (C * A) % M...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<string> vs; #define PB push_back #define pb pop_back int main(){ ios::sync_with_stdio(0); cin.tie(0); int a,b; cin>>a>>b; a *=2; a += 100; cout<< a - b; return 0; }
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; signed main(){ fastio int n,k; cin >> n >> k; auto f = [&](int a, int b){ return min(b-1,2*a+1-b); }; int ans = 0; for(int i = 2;i <= 2*n;i++){ if(i-k < 2 || i-k > 2*n)...
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace chrono; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vii; typedef vector<ll> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define pb push_back #define odd(x) ((x)&1) #define even(x) (!odd(...
#include <iostream> using namespace std; int main() { int N,X; cin >> N >> X; string s; cin >> s; for(int i=0;i<N;i++) { if(s[i]=='x' && X==0) { continue; } else if(s[i]=='x' && X!=0) { X--; } else if(s[i]=='o') { X++; } } cout << X << endl...
#include <iostream> #include <algorithm> #include <vector> #include <deque> #include <queue> #include <set> #include <iomanip> #include <cmath> #include <map> #include <bitset> #include <numeric> using namespace std; using ll = long long; struct UnionFind { vector<int> data; UnionFind(int sz) { d...
#include <bits/stdc++.h> #define fi first #define se second #define lc (x << 1) #define rc (x << 1 | 1) #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++) #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define IT iterator #define V vect...
#include <algorithm> #include <cassert> #include <iostream> #include <memory> #include <numeric> #include <array> #include <deque> #include <map> #include <set> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> #include <cstring> #include <ostream> #include <type_traits> #include ...
///OM ///SUVOM SHAHA ///AUST CSE 39 #include<bits/stdc++.h> #define loo(i, n) for(int i = 0; i < n; i++) #define mod 1000000007 #define pb push_back #define ff first #define sc second #define ii pair<int, int> #define vi vector<int> #define vii vector<ii> #define ll long long int #define inf 1000000000 #define mpch ma...
#include <bits/stdc++.h> using namespace std; #define ll long long #define SZ(v) ((int)(v.size())) const int N = 2e5+9; void run () { int a, b, c; cin >> a >> b >> c; int sum = 6 * 7 / 2; sum -= a; sum -= b; sum -= c; cout << sum << endl; } int main () { int tt; tt = 1; // cin >> ...
#include<bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(int)(x);i<(int)(y);i++) #define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl; #define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);} const long mod=1e9+7; const int siz=3e5; const int inf=1e9; int main(){ int a,b,c; cin>>a>>b>>c;...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <iomanip> #include <climits> #include <functional> #include <cassert> using namespace std; typedef long long ll; typedef pair<int,int> ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() using C = complex<double>; C inC() { double x, y; cin >> x >> y; return C(x, y); } int main() { int N; cin >> N; C p0 = inC(); ...
#include <bits/stdc++.h> #define INF 1e9 #define INFLL 1ull<<60u using namespace std; #define REPR(i,n) for(int i=(n); i >= 0; --i) #define FOR(i, m, n) for(int i = (m); i < (n); ++i) #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define ALL(a) (a).begin(),(a).end() #define endl "\n" template<class T>b...
#pragma GCC optimize("Ofast") #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> // ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1000000007; template< typename T > T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; } int main() { int h, w; ci...
#include<bits/stdc++.h> #define _USE_MATH_DEFINES using namespace std; #define ll long long int #define ld double #define pb push_back #define rep(i , j , n) for(ll i = j ; i < n ; i++) #define pre(i , j , n) for(ll i = j ; i >= n ; i--) #define all(x) x.begin(), x.end() typedef pair<int, int> pii; typedef pair<ll...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { long long a, b, c, d; cin >> a >> b >> c >> d; if (b >= c*d) { cout << -1 << '\n'; return 0; } for (int i=0; ; i++) { if ((a + i*b) <= (i*c*d)) { cout ...
#include<bits/stdc++.h> #define ll int #define pii pair<ll,ll> #define debug(a) cout<<a<<'\n' #define maxn 100009 /// I wanna be withma youlu #define MOD 1000000007 #define F first #define S second #define rep(i, a, b) for( ll i = a; i < (b); ++i) #define per(i, b, a) for(ll i = b-1; i>=a ; i--) #define trav(a, x) fo...
#include<bits/stdc++.h> using namespace std; #define GODSPEED ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15); #define f first #define s second #define newl cout<<"\n"; #define pb push_back #define mset(a,x) memset(a,x...
#include<bits/stdc++.h> using namespace std; using ll = long long; using pint = pair<ll,ll>; vector<ll> bipartite(const vector<vector<ll>>& hen) { ll n = hen.size(); vector<ll> col(n, -1); col[0] = 0; stack<ll> st; for(ll i = n - 1; i >= 0; i--) st.push(i); while(st.size()) { ll v = st.top(); st.pop(); /...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; template<typename T> using ve=vector<T>; using ll=long long; using ld=long double; using str=string; using pint=pair<ll,ll>; using vll=ve<ll>; using vd=ve<ld>; using vs=ve<str>; using vll2=ve<ve<ll>>; #define whole(f,x,...
// B - Village of M People #include <bits/stdc++.h> using namespace std; using ll = int64_t; #define rep(i,e) for(int i=0;i<(e);++i) int main(){ int k, n, m; cin>>k>>n>>m; vector<ll> B; vector<pair<ll,ll>> R; ll rest = m; rep(i, k){ ll a; cin>>a; ll b = a*m / n; rest -= b; B.push_back(b); R.emplace_back...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll=long long; int main(){ int n; cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; ll ans=0; rep(i,n){ ll sum=a[i]; int k=i-1; while(0<=k){ if(a[k]<a[i]) break; sum+=a[i]; k--; } ...
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector>...
#include <bits/stdc++.h> #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define pii pair<int,int> #define pll pair<long long, long long> #define inf 1000000000000000001 #define mod 1000000007 #define all(c) c.begin(),c.end() #define mp(x,y) make_pair(x,y) #define mem(a,...
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include <bits/stdc++.h> #define int long long #define loop(i, a, b) for (int i = a; i < b; i++) #define loope(i, a, b) for (int i = a; i <= b; i++) #define bloop(i, a, b) for (int i = a; i >= b; i--) #define FastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \...
#include <bits/stdc++.h> using namespace std; #define flush cout.flush using ll = long long; using ull = unsigned long long; using ld = long double; using pl = pair<ll, ll>; const ll INF = 1e9 + 7; const ll mod = 1e9 + 7; const ll mod2 = 998244353; const ld eps = 1e-9; const ld PI = acos(-1); int main() { ios::...
#include <bits/stdc++.h> #define rep(i,n) for (int i = (0); i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define limit(x,l,r) ma...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)n; i++) #define INF 1e9 const int MAXN=20; int n; int d[MAXN][MAXN]; int dp[1<<MAXN][MAXN]; int rec(int S, int v) { if(dp[S][v] >= 0) return dp[S][v]; if(S==(1<<n)-1 && v==0) return dp[S][v]=0; int tmp=INF; REP(u,n) if(...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7; #define mst(a,b) memset(a,b,sizeof a) #define PII pair<int,int> #define fi first #define se second #define pb emplace_back #define SZ(a) (int)a.size() #define IOS ios::...
#include<bits/stdc++.h> #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> #include<map> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double lb; #define rep(i, f, t) for(int i = f; i <= t; i ++) #define urep(i, f, t) for(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int Maxn = 1000005; char tmp[Maxn]; int n; string A; string B; void Read(string &s) { scanf("%s", tmp); s = tmp; } int main() { cin >> n; Read(A); Read(B); int asum = 0, bsum = 0; int add = 0, neutr = 0; ll res = 0; for (int i = 0; i...
#include<iostream> #include<algorithm> using namespace std; const int N=100010; typedef long long ll; int n; char a[N]; int sum1[N]; int sum2[N]; int main() { cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++) { if(a[i]=='A') { sum1[i]=1; ...
#include<bits/stdc++.h> using namespace std; int main() { double A, B; cin >> A >> B; double f = 0.00; f = B /A; f = 1-f; f=f*100; cout << f << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i) #define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i) #define revrep(i,n) for(ll i=(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 60) -123456789; #define fastio cin.tie(nullptr); ios_base:...
#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> #define INF 1e9 #define INFLL 1ull<<60u using namespace std; #define REPR(i,n) for(int i=(n); i >= 0; --i) #define FOR(i, m, n) for(int i = (m); i < (n); ++i) #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define ALL(a) (a).begin(),(a).end() #define endl "\n" template<class T>b...
#include <bits/stdc++.h> using namespace std; #define ll long long // template <class T = ll> using P = pair< T,T>; template <class T = ll> using V = vector<T>; template <class T = ll> using VV = V<V<T>>; #define rep(i,n) for(int i=0; i<(n);++i) #define repp(i, l, r) for(int i = (l); i < (r); ++i) #define pb push_back ...
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define lowbit(x) (x & (-x)) const LL inf = 1e17+9; const LL mod = 1e9+7; const LL maxn = 3e5+8; LL n, m, a[maxn], bit[maxn]; void add(LL x, LL v) { while (x <= n) { bit[x] += v; x += lowbit(x); } } LL query(LL x) { ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define debug(x) {cerr<<#x<<" = "<<(x)<<endl;} ll ksm(ll a,ll k,ll p) { ll ans=1; while(k) { if(k&1) ans=ans*a%p; k>>=1; a=a*a%p; } return ans; } int sz[10][4] = { {0,0,0,0}, {1,1,1,1}, ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n, x; string s; cin >> n >> x >> s; for (int i = 0; i < n; i++) { if (x > 0 && s[i] == 'x') x--; else if (s[i] == 'o') x++; } cout << x << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> t(N); vector<double> l(N), r(N); for (int i = 0; i < N; i++) scanf("%d %lf %lf", &t[i], &l[i], &r[i]); int Ans = 0; for (int i = 0; i < N - 1; i++) { double l1, r1; if (t[i] == 1) l1 = l[i], r1 = r[i]; else if (t[i] ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pii; typedef tuple<ll, ll, ll> ti; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //using Bint = mp::cpp_int; #define REP(a,b,c) for(l...
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L !...
#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...
#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; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937/*_64*/ rng(chrono::ste...
#include <sstream> #include <iostream> #include <string> #include <vector> #include <deque> #include <numeric> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <list> #include <cassert> #include <cmath> #include <climits> #include <map> #include <queue> #include <functional> #include <cass...
#pragma GCC optimize("Ofast") //Comment optimisations for interactive problems (use endl) #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> using namespace std; #define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(1...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; i < s.size(); i++) { if (s[i] == '6') s[i] = '9'; else if (s[i] == '9') s[i] = '6'; } cout << s << endl; }
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author NikuKyabe */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include<bits/stdc++.h> #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define all(k) k.begin(),k.end() #define INF 1e9 #define repk(i,a,n) for(int i=a;i<=n;i++) #define rep(i,a,n) for(int i=a;i<n;i++) #define rep2(i,a, n) for(int i=a;i<n;i+=2) #define per(i,a,n) f...
/*input 10 165 82 94 21 65 28 22 61 80 81 79 93 35 59 85 96 1 78 72 43 5 12 15 97 49 69 53 18 73 6 58 60 14 23 19 44 99 64 17 29 67 24 39 56 92 88 7 48 75 36 91 74 16 26 10 40 63 45 76 86 3 9 66 42 84 38 51 25 2 33 41 87 54 57 62 47 31 68 11 83 8 46 27 55 70 52 98 20 77 89 34 32 71 30 50 90 4 37 95 13 100 */ //#includ...
#include <bits/stdc++.h> using namespace std; // one-based numbering struct UnionFind { vector<int> data; // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent; UnionFind(int n) { data.resize(n+1, -1); } int find(int x) { if(data[x] < 0) return x; else return data[x] = ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int &it : a) { cin >> it; it %= 200; } vector<int> p(200, -1); if (n > 8) n = 8; for (int m = 1; m < (1 << n); m++) { ...
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++) #define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++) #define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--) #define rreps(i,n) for(int i=((int)(n));i>0;i--) #define repi(i,x) for(a...
#include<bits/stdc++.h> using namespace std; typedef long long int lli; #define all(arr) arr.begin(),arr.end() #define f first #define s second #define debug1(x) cout<<x<<"\n" #define debug2(x,y) cout<<x<<" "<<y<<"\n" #define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" #define nl cout<<"\n"; #define pq priority_queue...
#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(...
//#define _GLIBCXX_DEBUG //#include "atcoder/all" //using namespace atcoder; #include <bits/stdc++.h> #define int long long #define ll long long using ull = unsigned long long; using namespace std; #define Dump(x) \ if (dbg) { \ cerr << #x << " = " <<...
#include <bits/stdc++.h> using namespace std; #define int long long int #define yes cout<<"YES\n"; #define no cout<<"NO\n"; #define fl(n) for(int i=0;i<n;i++) #define flo(n) for(int i=1;i<=n;i++) #define mii map<int,int> #define mci map<char,int> #define V vector<int> #define vp vector<pair<int,int>> #define pb push_ba...
#include <bits/stdc++.h> using namespace std; #define ALL(v) v.begin(), v.end() #define V vector #define P pair using ll = long long; int main() { int n; cin >> n; string s; cin >> s; int q; cin >> q; bool flag = false; for (int i = 0; i < q; i++) { int t, a, b; cin >> t >> a >> b; if(t == 1){ ...
#include<bits/stdc++.h> #define int long long #define rint regester int const int maxn = 1e6 + 10; const int INF = 1e9; using std::ios; using std::cin; using std::cout; using std::max; using std::min; using std::sort; using std::unique; using std::lower_bound; using std::swap; using std::abs; using std::acos; using std...
#include <bits/stdc++.h> using namespace std; void solve(){ string s,ans=""; cin>>s; int n,i,j=-1; n=s.length(); for(i=0;i<n;i++){ if(s[i]=='.'){ j=i; break; } } if(j==0){ cout<<"0"<<endl; return; } if(j==-1){ cout<<s<<endl; return; } for(i=0;i<j;i++) ans=an...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string X; cin >> X; string ans; rep(i, X.size()) { if (X.at(i) == '.') break; ans.push_back(X.at(i)); } cout << ans << endl; }
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i,n) for(int i=0;i<(int)(n);i++) #define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++) #define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(i...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #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> p...
#include <iostream> #include <assert.h> #include <vector> #include <unordered_map> #include <queue> #include <climits> #include <cmath> #include <algorithm> #include <iomanip> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; //cout << std::fixed << std::...
#include <bits/stdc++.h> using namespace std; int main(){ string x; cin >> x; for(int i=0; i<x.length(); i++){ if(x[i]!='.'){ cout << x[i]; }else{ break; } } cout << endl; return 0; }
#include<iostream> #include<cstring> #include<cmath> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<deque> #include <algorithm> using namespace std; #define mem(a,b) memset(a,b,sizeof a) #define PII pair<int,int> #define ll long long #define ull unsigned long long #define ft fir...
#include<iostream> #include<map> #include<vector> #include<algorithm> #include<set> #include<queue> #include<stack> #include<math.h> #include<time.h> #include<deque> #include<cstring> #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define F first #define S second #define mp make_pair ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; 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 (a>b) { a=b; return 1; } return 0; } // dijkstra 蟻本 struct edge {l...
#include "bits/stdc++.h" using namespace std; using ll = int64_t; #define eb emplace_back #define F first #define S second #define ice(i, a, b) for (int (i) = (a); (i) < (b); ++(i)) const ll MOD = 1e9 + 7; vector<vector<pair<int, ll>>> adj(200001); vector<ll> val(200001, 0); void dfs(int n, int m = -1) { fo...
#include<bits/stdc++.h> #define rep(i,N) for(int i=0;i<(N);i++) #define rrep(i, n) for (int i = (int)n-1; i >= 0; --i) #define FOR(i,a,b) for(int i=(a);i<(b);i++) using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e12; const int inf = 1e9; const int mod = 1e9+7; typedef long long ll; typedef pai...
#include<bits/stdc++.h> using namespace std; const int N=110; int n,m,k,a[N],b[N],c[N],d[N]; int vis[N],ans; void dfs(int x){ if(x==k+1){ int sum=0; for(int i=1;i<=m;i++){ if(vis[a[i]]&&vis[b[i]]){ sum++; } } ans=max(ans,sum); return ; } vis[c[x]]++; dfs(x+1); vis[c[x]]--; vis[d[x]]++; dfs(x+...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int mod = 1000 * 1000 * 1000 + 7; const int INF = 1e9 + 100; const ll LINF = 1e18 + 100; #ifdef DEBUG #define dbg(x) cout << #x << " = " << (x) << endl << flush; #define dbgr(s, f) { cout <<...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=1e9+7; const ll N=2e5+5; char s[N]; ll k,len; ll nums[N]; ll dp[N][20][2][2]; ll dfs(ll pos,int st,bool pre,bool limit){ int cnt=__builtin_popcount(st); if(cnt>k) return 0; if(pos>len) return cnt==k&&pre; if(dp[pos][cnt][li...
#include <bits/stdc++.h> using namespace std; const int Maxn = 400004; char tmp[Maxn]; int T; int n; string A, B, C; int nxtA[Maxn][2], nxtB[Maxn][2], nxtC[Maxn][2]; char res[Maxn]; int rlen; void Read(string &S, int nxt[][2]) { scanf("%s", tmp); S = tmp; S = S + S; nxt[S.length()][0] = nxt[S.length()][1] = S.len...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define pb push_back #define all(v) (v).begin(),(v).end() #define fi first #define se second #define sz(x) ((int)(x).size()) using ll=long long; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define MOD 1000000007 const ll INF...
#include<iostream> #include<vector> using namespace std; int main() { /**/ int start_x, start_y, goal_x, goal_y; int cost=0; for (int i = 0; i < 1000; i++) { /*input*/ cin >> start_x >> start_y >> goal_x >> goal_y; /*cul*/ if (start_x - goal_x >= 0) for (int j = 0; j < start_x - goal_x; j++) co...
//GIVE ME AC!!!!!!!!!!!!!!!!! #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include <random> #define ll long long #define rep(i, s, n) for (ll i = s; i < (ll)(n); i++) using namespace std; int main(){ rep(i,0,1000){ ll a,b,c,d; cin>>a>>b>>c>...
// Problem: E - Spread of Information // Contest: AtCoder - AtCoder Regular Contest 116 // URL: https://atcoder.jp/contests/arc116/tasks/arc116_e // Memory Limit: 1024 MB // Time Limit: 3000 ms // // Powered by CP Editor (https://cpeditor.org) #include <bits/stdc++.h> using namespace std; inline int read(){ int s...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i, n) for(int i=0; i<n; i++) #define REPi(i, a, b) for(int i=int(a); i<int(b); i++) #define MEMS(a,b) memset(a,b,sizeof(a)) #define mp make_pair template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=...
#include<bits/stdc++.h> using namespace std; #define res register int #define ll long long //#define cccgift #define lowbit(x) ((x)&-(x)) #define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i) #define per(i,r,l) for(res i=r,_l=l;i>=_l;--i) #define mkp make_pair #define pb push_back #define mem0(a) memset(a,0,sizeof(a)) #define...
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint mod = 1e9 + 7; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) #define rep(i, n) for(int i = 0; i < in...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const int maxn=200020,mod=998244353; #define MP make_pair #define PB push_back #define lson o<<1,l,mid #define rson o<<1|1,mid+1,r #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define ROF(i,a,b) for(int i=(a);i>=(b);i--) #defi...
#include <bits/stdc++.h> using namespace std; #define N 200000 int main() { int n, p, q = 0; vector<bool> u(N+5, 0); scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &p); u[p] = 1; while (u[q]) ++q; printf("%d\n", q); } }
#include <bits/stdc++.h> using namespace std; int dp[1001][1001]; int a[1001], b[1001]; int n, m; int solve(int i, int j) { if (dp[i][j] != -1) { return dp[i][j]; } int & res = dp[i][j]; if (i == n) { res = m - j; return res; } if (j == m) { res = n - i; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++) #define nrep(i, a, b) for (__typeof((b)) ...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mem(a,val) memset(a,(val),sizeof((a))) #define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define decimal(n) cout << fixed ; cout << setprecision((n)); #define mp make_pair #define eb emplace_ba...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) using ll = long long; using P = tuple<ll, ll, int>; int main() { int n; cin >> n; vector<P> ps; rep(i, n) { ll x, y; cin >> x >> y; ps.emplace_back(x, y, i); } vector<bool> pushed(n...
#include <bits/stdc++.h> #define pb push_back #define fst first #define snd second #define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i) #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(),x.end() #define mset(a,v) memset((a),(v),sizeof(a)) #define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) using namespace st...
#include<cstdio> #define mod 998244353 #define N 5001 int f[N],C[N][N]; int main() { int n,m,t; scanf("%d%d",&n,&m); for(int i=0;i<=n;++i) { C[i][0]=1; for(int j=1;j<=i;++j) { C[i][j]=C[i-1][j-1]+C[i-1][j]; if(C[i][j]>=mod) C[i][j]-=mod; } } f[0]=1; for(int i=0;i<=11;++i) { t=(1<<i)<<1; ...
#include <bits/stdc++.h> using namespace std; typedef int_fast32_t int32; typedef int_fast64_t int64; const int32 inf = 1e9+7; const int32 MOD = 1000000007; const int64 llinf = 1e18; #define YES(n) cout << ((n) ? "YES\n" : "NO\n" ) #define Yes(n) cout << ((n) ? "Yes\n" : "No\n" ) #define POSSIBLE(n) cout << ((n) ?...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; #define pb push_back #define mp make_pair const int INF = 0x3f3f3f3f; const int MOD = 1e9+7; const int MAX_N = 2e5+10; const int MAX_K = 19; int n, m; int a[MAX_N],b[MAX_N]; int k; int c[MAX_K]; int dist[MAX_K][MAX_N]; int ...
/*@author Vipen Loka*/ #include <bits/stdc++.h> #define endl '\n' #define ff first #define ss second #define ll long long #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define pii pair<int,int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #defi...
#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<unordered_set> #include<utilit...
#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 Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);} void p...
#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = 998244353; int ans = 0; int next_combination(int sub) { if (sub == 0)return 1001001001; int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } int H, ...
//dhruv #include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ffor(i,n) for(int i = 0;i < (n); ++i) #define fro(i,j,n) for(int i = (j);i < (n); ++i) #define all(v) v.begin(),v.end() #define vi vector<int> #define vvi vector<vi> #define pii pair<int,int> #define vpii vector<pi...
#include<bits/stdc++.h> #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair<int,int> P; const int mod = 1000000007; const int INF = 1001001001; int main() { string s, t; cin >> s >> t; if (s == "Y") { ...
#line 1 "main_b.cpp" #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; const int INF = 1e9; const ll LINF = 1e18; template <class T> void get_uni...
// Copyright 2020 Tsutomu ISHIKAWA // Author: Tsutomu ISHIKAWA #include <bits/stdc++.h> using namespace std; int l; int res; long long a[1010]; long long calcNumOfCombination(int n, int r){ long num = 1; for(int i = 1; i <= r; i++){ num = num * (n - i + 1) / i; } return n...
/* 2021-03-29 14:18:10.721371 Category: combi Rating: ? */ /* #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */ #include<bits/stdc++.h> using namespace std; // // #define fio ios_base::sync_with_stdio(false);cin.ti...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, res = INT_MAX; cin >> n; vector<vector<int>> p(n, vector<int>(3)); for (auto& i : p) { for (auto& j : i) { cin >> j; } } au...
#include<iostream> #include<string> #include<vector> #include<deque> #include<algorithm> #include<stack> #include<iomanip> #include<queue> #include<map> #include<math.h> #include<climits> #include<limits.h> using namespace std; const int N = 17, M = 272144; int x[N], y[N], z[N]; int dp[M][N]; int dis(int f, int s)...
#include <bits/stdc++.h> typedef long long ll ; using namespace std; int main() { int n; cin >> n; vector<int> a(n),b(n),c(n), hash(n,0); for (int i = 0; i < n ; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n; i++) cin >> c[i]; for (int i = 0; i < n ; i++) hash[a[i]-1]+...
// Whatever doesn't kill you simply makes you stronger. // Every single thing is destined, everything is written. #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 #define hii cout << "hii" << endl...
#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 add(a,b) a=((a)+(b))%mod #define mod 998244353 #define Mod 998244351 #define ll long long //#define file using namespace std; int n,i,j,k,l,sum; int a[101]; int f[101][10001]; ll jc[101]; ll ans; ll qpower(l...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int64_t A[n]; for(int i=0; i<n; i++) cin >> A[i]; if(n==1){ cout << A[0] << endl; return 0; }else if(n==2){ cout << (A[0]^A[1]) << endl; } int64_t ans = 1 << 30; for(int64_t i=1; i<(1<<(n-1)); i++){ int j=0; ...
// // Created by Anton Gorokhov // #ifdef lolipop #define _GLIBCXX_DEBUG #endif #include <iostream> #include <cstddef> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <set> #include <map> #include <ctime> #include <unordered_map> #include <random> #include <iomanip> #include <cmat...
#include <stdio.h> int N, Sum; int main() { int i; scanf("%d", &N); for (i = 1; Sum < N; Sum += i, i++); printf("%d", i - 1); return 0; }
#include<bits/stdc++.h> #define AynVul int main() #define ll long long #define task "A" #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 F first #define S second #define all(x) x.begin(), x.end() #define sz(x) (int)(x.size()) #define eb emplace_back #d...
#include<bits/stdc++.h> using namespace std; #define ll long long #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define all(v) v.begin(),v.end() const int mod = 1e9 + 7; ll dp[(1 << 18)][18]; int main (){ fast_io; ll n, m; cin >> n >> m; vector<vector<int> > constr...
#include <iostream> #include <string> #include <vector> #include <cmath> #include <iomanip> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <complex> #include <regex> #define Debug cout << "line: " << __LINE__ << "Debug" << endl;...
#pragma region Macros #include <bits/stdc++.h> // #include <atcoder/all> using std::cin; using std::cout; using std::endl; using std::sort; using std::string; using std::vector; // using namespace atcoder; typedef long long ll; #define int long long #ifdef _DEBUG #define DEBUG(x) cout << #x << ": " << x << endl; #els...
#include <bits/stdc++.h> using i32 = std::int32_t; using i64 = std::int64_t; using u32 = std::uint32_t; using u64 = std::uint64_t; using usize = std::size_t; const i32 INF = 1001001001; const i64 LINF = 1001001001001001; const u32 MOD1 = 1000000007; const u32 MOD2 = 998244353; i64 ntop(i64 x, i64 m) { if(x < 0) ...
#include <bits/stdc++.h> using namespace std; ////////////////////////////////////////////////////////////////////////////<editor-fold desc="macros"> #define endl "\n" #define long long long #define all(v) (v).begin(),(v).end() #define makeset(v) (v).resize(unique((v).begin(),(v).end())-(v).begin()) #define IOS ios::sy...
#include <iostream> #include <string> #include <set> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <array> typedef long long ll; using namespace std; const int logn = 17; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int> > f(n+1, vector<in...
#include <bits/stdc++.h> //#include <cmath> #define int long long #define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define mod 1000000007 //#define lld long double #define mii map<int, int> #define mci map<char, int> #define msi map<string, int> #define pii pair<int, int>...
#include<bits/stdc++.h> #define rei register int #define ll long long #define PLL pair<ll,ll> #define mk make_pair using namespace std; const int N=1e5+100; ll k,n,m; ll a[N],b[N]; priority_queue<PLL>p; int main(){ scanf("%d%d%d",&k,&n,&m); ll sum=0; for(rei i=1;i<=k;++i){ scanf("%d",&a[i]); b[i]=(m*a[i])/n; ...
/* @author: Saurav Sihag */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long #define ff first #define ss second #define lld long double template <class T> void print(vector<T>& v){ for(T x:v) cout<<x<<" "; cout<<"\n"; } void inp(vector<ll>& v, int n){ ...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define gc getchar_unlocked #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long int #define s(x) cin>>x...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define pb push_back #define ppb pop_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll,...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O0") typedef long long ll; typedef long double ld; const ll mod = 1e9+7; const ll INF = 1e18; #define rep(i,n) for (ll i = 0; i < (n); ++i) #define Rep(i,a,n) for (ll i = (a); i < (n); ++i) #define All(a) (a).begin(),(a).end() #define Pi acos(-1) using...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,s,n) for (int i = (s); i < (n); ++i) #define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define len(x) (int)(x).size() #define dup(x,y) (((x)+(y)-1)/(y)) #define pb push_bac...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll = long long; struct Edge { ll to; ll cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; #define mp make_pair #define REP(i, n) for (int i = 0; i < (n);...
#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=3010; const int INF=1e9; int n,a[maxn][5]; int dp[m...
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define c...
//-- In the name of ALLAH -- // We're nothing and you're everything. // Ya Ali! #include<bits/stdc++.h> using namespace std; #define pai acos(-1) #define ff first #define ss second #define ll long long #define pb push_back #d...
/*------------------------------------ .......Bismillahir Rahmanir Rahim..... ..........created by Abdul Aziz....... ------------------------------------*/ #include <iostream> #include <algorithm> #include <stdio.h> #include <cmath> #include <vector> #include <set> #include <utility> #include <list> #include <stack> #i...
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <fstream> #include <array> #include <map> #include <queue> #include <time.h> #include <limits.h> #include <set> #include <stack> #include <random> #include <...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> 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 0; } const int INF=1001001001; const...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define rep(i,n) for (ll i = 0;i<(n);++i) #define all(v) v.begin(),v.end() template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;} template <typename T>bool chmin(T &a, const T& b) {if (a > b) ...
#include "bits/stdc++.h" using namespace std; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); #define pb push_back #define eb emplace_back #define ins insert #define f first #define s second #define cbr cerr<<"hi\n" #define mmst(x, v) memset((x), v, sizeof ((x))) #define siz(x) ll(x.size()) #define all(x) (...
#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> using namespace std ; const int N = 2e3+5 ; int n ,m ,u ,v ; char ch ; vector<int> adj[128][N] ; bool edge[N][N] ; long long dis[N][N] ; long long bfs(){ long long ret = 1e18 ; memset(dis,'?',sizeof dis); queue<pair<int,int>> q ; q.push({1,n}); dis[1][n] = 0 ; while(q.s...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; using std::cout; using std::cin; using std::endl; using ll=long long; using ld=long double; ll I=1167167167167167167; ll Q=1e9+7; #define rep(i,a) for (ll i=0;i<a;i++) template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>; temp...
#include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstdlib> #include <cfloat> #include <cmath> #include <queue> #include <deque> #include <set> #define ll long long #define lp pair<ll, ll> #define max(a,b)((a)>(b)?(a):(b)) #define min(a,b)((a)<(b)?(a):(b)) #define ALL(obj) (ob...
//#undef DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; const ll llinf = (1ll<<61)-1; #define sz(a) int(a.size()) #define all(x) begin(x), end(x) #ifdef DEBUG const int DEBUG_END = 26; #define DOS cout #include <debug.h> #else #define bug(args...) void() #define cbug(a, args...) #endif #defin...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return fa...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int) n; i++) using ll = long long; template <class T> using vt = vector<T>; using vvi = vector<vt<int>>; int main(){ int n, num = 0, t_n; cin >> n; num = pow(2,n); t_n = num; vt<int> a(num); vt<int> tp(num); rep(i,num){ ...
#include <stdio.h> #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include <algorithm> #include <iostream> #include <map> using namespace std; int main(){ int n; scanf("%d", &n); long nNum = 1; for(int i = 0; i < n; i++){ nNum *= 2; } vector<int> viNum(nNum); fo...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <cmath> #include <iomanip> #include <cstdio> #include <set> #include <map> #include <list> #include <cstdlib> #include <queue> #include <stack> #include <bitset> using namespace std; #define MOD 998244353 #define ...
#include <bits/stdc++.h> #define fo(i, k, n) for (ll i = k; i < n; i++) #define ll long long #define ld long double using namespace std; int main() { ios_base::sync_with_stdio(false); int a, b; cin >> a >> b; vector<int> pos(a); vector<int> neg(b); if (a > b) { fo(i, 0, a) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; #define sz(a) int((a).size()) #define pb push_back #define eb emplace_back #define fi first #define se second #define all(...
#include <bits/stdc++.h> using namespace std; #define int long long #define forn(i,a,n) for (int i=a; i<n; i++) signed main(){ ios::sync_with_stdio(false); cin.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); string s; cin>>s; if (s[0]==s[1] && s[1]==s[2]) cout<<"Won"<<endl; e...
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pll pair<ll,ll> #define rep(i,n) for(ll i=0;i<n;i++) #define mod 1000000007 #define INF 10000000000000000 #define F first #define S second #define pb push_back #define lb lower_bound #define ub upper_bound #define pie 3.1415926...
// Always remember that you are absolutely unique, just like everyone else! #include <iostream> #include <vector> using namespace std; // DEBUGGING SECTION void __print(int x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print...
#include<bits/stdc++.h> using namespace std; int a[102],b[102]; int c[20],d[20]; int ans = 0; void solve(int n,int m,bool flag[],int k,int l){ if(l>=k){ int cnt = 0; for(int i=0;i<m;i++) { if(flag[a[i]] == true && flag[b[i]] == true) cnt++; } ans = max(ans,cnt); return ; } bo...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 4e5 + 100; int A[MAXN]; char res[MAXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; vector<pair<int,int>> vect; for(int i = 1 ; i <= 2*N ; i++) { int n; cin...
#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 400005 using namespace std; int n,a[N],c[N],ans[N],sta[N],top;pair<int,int>u[N]; int main(){ scanf("%d",&n);n<<=1; rep(i,1,n)scanf("%d",&a[i]),u[i]=make_pair(a[i],i); sort(u+1,u+n+1); rep(i,1,n/2)c[u[...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef pair<int,int> Pair; typedef tuple<int,int,int> tpl; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c...
#include<cstdio> #include<vector> int w[15]; struct Element{ int l,v; }; struct Edge{ int v,w; Edge(int v,int w):v(v),w(w){} }; std::vector<Edge>g[15]; int f[15]; Element e[100005]; int seq[15]; int vis[15]; int pos[15]; int ans = -1; int dis[1<<10]; void dfs(int p,int n,int m){ if(p==n+1){ for...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int>> pos(n); for (auto &&[x, y] : pos) { cin >> x >> y; } auto judge = [&](double r) -> bool { queue<int> q; for (auto i = 0; i != n; ++i) { if (100 ...
#include <bits/stdc++.h> #define ll long long int #define w(t) int t; cin>>t; while(t--) #define F first #define S second #define pb push_back #define mp make_pair #define pii pair<int,int> #define mii map<int,int> #defin...
#include<bits/stdc++.h> using namespace std; /*#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> is;*/ #define fb find_by_order #define ok order_of_key #define...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <cstdio> #include <cmath> #include <array> #include <queue> #include <stack> #include <map> #include <set> using namespace std; int main() { int N; cin >> N; int v = N * 1.08; if (v == 206) { puts("so...
#include<iostream> #include<math.h> #include<map> #include<vector> using namespace std; int main() { long long int n; cin>>n; long long int ans= n*(n-1)/2; map<long long int ,long long int > count; long long int y; for (long long int i = 0; i < n; i++) { cin>>y; count[y...
#include <vector> #include <iostream> #include <set> #include <map> #include <unordered_set> #include <queue> #include <string> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <iomanip> #include <numeric> #include <math.h> #include <stack> #include <valarray> #include <typeinfo> #include <array> u...