code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define pll pair<ll,ll> #define ldb double template<typename T>void ckmn(T&a,T b){a=min(a,b);} template<typename T>void ckmx(T&a,T b)...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define eprintf(...) fprintf(stderr, __VA_ARGS__) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) int main() { const int mod = 998244353, i2 = 499122177; int n, k; scanf("%d %d", &n, &k); vector <in...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repx(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++) #define repr(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--) #define reprx(i, x, n) for (ll i = ((ll)(n)-1); i >= (ll)(x); i--) #define all(x) ...
#include <iostream> #include <fstream> #include <iomanip> #include <math.h> #include <limits.h> #include <algorithm> #include <functional> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <string> #include <string.h> #include <sstream> #include...
#include <bits/stdc++.h> #include <iostream> #include <queue> #include <stack> #include <vector> #include <string> #include <set> #include <map> #include <random> #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) #define repl(i,n) for (long long i = 0; i < (n); ++i) #defin...
#include <string> #include <math.h> #include <iostream> #include <iomanip> using namespace std; int main() { int n; cin >> n; long long a = 0; long long b = 0; long long c = 0; long long x; for (long i = 0; i < n; i++) { cin >> x; if (x < 0) x = x * (-1); a = a + x; b = b + x * 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> #define ll long long using namespace std; const int N = 200010, mod = 1e9 + 7; ll dp[N][20], k, num[N]; char s[N]; ll dfs(int pos, bool limit, bool lead, int cnt, ll state, int now){ if(!pos){ //printf("now = %d cnt = %d state = %lld\n", now, cnt, state); return cnt == k; } if(cnt > ...
#include <bits/stdc++.h> #define ll long long int #define ld long double #define endl "\n" #define mp make_pair #define HCF __gcd #define LCM(m,n) (m*n)/__gcd(m,n) #define maxa(v) *(max_element(all(v)) #define mina(v) *...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using vi=vector<int>; using vvi=vector<vi>; using LL=long long; using vL=vector<LL>; using vvL=vector<vL>; int main() { long long n; cin>>n; long long a; map<long long ,long long > Map; for (int i=0 ; i<n ; i++) { cin>>a; ...
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1000000007; template <class T> struct fenwick_tree { vector<T> x; fenwick_tree(int n) : x(n, 0) {} T sum(int i, int j) { if (i == 0) { T S = 0; for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j]; return S; } else retur...
#include<iostream> #include<algorithm> #include<numeric> #include<queue> #include<vector> using namespace std; const int BUF = 400005; int nVal; int val[BUF]; void read() { cin >> nVal; nVal *= 2; for (int i = 0; i < nVal; ++i) { cin >> val[i]; } } void work() { long long sum = accumulat...
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0, length = n; i < length; i++) #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ep emplace #define epb emplace_back #define scll static_cast<long long> #define sz(x) static_cast<int>((x).size()) #define pfll(x) printf("%lld...
#include<bits/stdc++.h> #include<bits/extc++.h> #pragma GCC optimize("Ofast") using namespace std; using namespace __gnu_pbds; template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; } template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t){ while(*sdbg != ',') { ce...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep_up(i, a, b) for (ll i = a; i < b; ++i) #define rep_down(i, a, b) for (ll i = a; i > b; --i) #define P pair<ll, ll> #define Graph vector<vector<ll>> #define fi first #define se second #define vvvl...
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define test int t;cin>>t;while(t--) #define REP(i,n) for (int i = 1; i <= n; i++) #define MOD 1000000007 #define MOD2 998244353 #define ll ...
#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 FOR(i,a,b) for(int i=a;i<b;++i) #define RFOR(i,a,b) f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; const int inf = 1e9; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) using pint = pair<ll, ll>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { int h, w, x,...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, m, n) for (int i = (m); i < (int)(n); i++) using ll = long long; using vl = vector<ll>; using P = pair<ll, int>; ll solve(vl& A, map<P, ll>& m, ll x, int i) { if (i == int(A.size()) - 1) return 1; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0; i<(n); ++i) #define rep1(i,n) for(ll i=1; i<=(n); ++i) #define revrep(i,n) for(ll i=(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 62) -1; #define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false); #define new...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define pii pair<ll,ll> #define inf 1000000000000000000 #define bpc(x) __...
#include<bits/stdc++.h> using namespace std; #define f(i,a,b) for(ll i=a; i<b; i++) #define fr(i,a,b) for(ll i=a; i>=b; i--) typedef vector<int> vi; typedef long long int ll; typedef vector<ll> vll; #define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define PI 3.1415926535 ll Mod = 1e9+7; // ...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using iPair = pair<int,int>; using lPair = pair<ll, ll>; using ivector = vector<int>; using lvector = vector<ll>; using istack = stack<int>; using iqueue = queue<int>; using ivv = vector<vector<int>>; using lvv = vector<vector<ll>>; const int INF =...
#include<bits/stdc++.h> using namespace std; // modpow template<class T> T modpow(T b,T p,T m){ T rt = 1; b %= m; while(p>0){ if(p&1) rt = (rt*b)%m; b = (b*b)%m; p>>=1; } return rt; } // small mod combination // # f,g を次のようにする // - f[i] : i が何回 MOD で割れるか. これを f_pre とする // - g[i] : i の MOD で割れない部分の MOD...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #define ll long long #define nl '\n' #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define vi vector<int> #define pii pair<int, int> #define rep(i, a, b) for(int i = (a); i < (b); i++) using namespace std; vector<s...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i <(n); ++i) using namespace std; using ll = long long; using p = pair<int, int>; int main(){ ll ii, jj, count(0),flor(0); cin >> ii>>jj; rep(i,jj){ count+=i+1; } rep(i,ii){ flor+=i+1; } count =100 * flor * jj + count*...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<cstdint> #include<cstddef> #include<vector> //#include<atcoder/all> //using namespace atcoder; using namespace std; using i32 = int_fast32_t; using i64 = int_fast64_t; using usize = uint_fast64_t; temp...
// Author : ps41 #include <bits/stdc++.h> using namespace std; #define ll int64_t const ll M = 1e9 + 7, N = 2e3 + 5; string a[N]; ll row[N][N], col[N][N], dp[N][N], diag[N][N]; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); ll n, m; cin >> n >> m; for (ll i = 1; i <= n; i++) cin >> a[i], a[i] = "#"...
/* Sat-Chitta-Ananda */ #include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("in.txt", "r", stdin); int x, y; cin >> x >> y; int a; cin >> a; int b; cin >> b; int e = 0; while(x < y) { if(LLONG_MAX/x >= a && x*a <...
// Created by ... #include <bits/stdc++.h> #define db1(x) cout<<#x<<"="<<x<<'\n' #define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n' #define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n' #define vll vector< ll > #define M 100000 #define MD 1000000007 #define pb push_back #define rep(i,a,b) ...
#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; int main() { ll N, K; cin >> N >> K; for (; K; K--) { if (N % 200 == 0) { N /= 200; } else { N = N * 1000 + 200; } } cout << N << endl; }
#include <cstdio> #include <algorithm> #include <cstdlib> #include <cmath> #include <climits> #include <cstring> #include <string> #include <vector> #include <queue> #include <numeric> #include <functional> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <memory> #include <threa...
#include<bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++) #define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--) using namespace std; using ll = long long; using vl = vector<ll>; using vc = vector<char>; using vvl = vector<vl>; ...
#include <iostream> #include <cstdint> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unorder...
#include <bits/stdc++.h> using namespace std; int dx[4] = {0, 1, 0, 1}, dy[4] = {0, 0, 1, 1}; int main(){ int H, W; cin >> H >> W; vector<string> S(H); for(int i = 0; i < H; i++) cin >> S[i]; int ans = 0; for(int i = 0; i < H - 1; i++){ for(int j = 0; j < W - 1; j++){ int cnt...
#include <iostream> #include <cstdio> #include <vector> #include <map> #include <unordered_map> #include <set> #include <algorithm> #include <queue> #include <stack> #include <string> #include <cmath> #include <cstring> #define For(i,x,y) for(int i = (x); i <= (y); i ++ ) #define fori(i,x,y) for(int i = (x); i < (y); i...
#include <iostream> using namespace std; const int N_MX = 1e3; int n; int x[N_MX], y[N_MX]; int ans; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { double grad = double(y[j] - y[i]) / (x[j] - ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;...
// clang-format off #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; #ifndef godfather #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,a...
#include<bits/stdc++.h> using namespace std; #define ull unsigned long long int #define ll long long int #define mp make_pair #define pb push_back #define mod 1000000007 #define mem memset #define ff first #define ss second #define loop0(i,n) for(i=0;i<n;i++) #define loop1(i,n) for(i=1;i<=n;i++) ll dist(pair<ll,ll> p1,...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long int ull; #include <fstream> #define int long long int #define mod 1000000007 #define watch(x) cout<<(#x)<<" is "<<(x)<<"\n" #define watch2(x,y) cout<<(#x)<<" is "<<(x)<<" and "<<(#y)<< " is " <<(y)<<"\n" int powerr(int m,int ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" ll n, m; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; if(m < 0) { cout << -1 << endl; return 0; } if(m == 0) { ll rr = 0; for(int i = 1; i <= n;...
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cctype> #include <cmath> #include <vector> #include <set> #include <bitset> #include <map> #include <stack> #include <queue> #include <ctime> #define _for(i,a,b) for(int i=(a);...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int>A(2*N); vector<pair<int,int>>B(2*N); vector<int>C(2*N); for(int i = 0; i < 2*N; i++) { cin >> A[i]; B[i] = {A[i],i}; } sort(B.rbegin(),B.rend()); for(int i = 0; i < N; i++) { ...
#pragma region RegionDefs #include <bits/stdc++.h> #define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i) #define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i) #define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i) #define all(x) begin(x),end(x) using namespace std; typedef long long ll; const ll INF...
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("l.txt", "r", stdin); freopen("m.txt", "w", stdout); #else #endif ll n,s,d; cin>>n>>s>>d; bool f=false; for(ll i=0;i<n;i++) { ll a,b; cin>>a>>b; if(a<s && b>d) { f=true; } } if(f) ...
#include <iostream> int main() { int a, b, c; std::cin >> a >> b >> c; if ( a > b ) std::cout << "Takahashi" << std::endl; else if ( a < b ) std::cout << "Aoki" << std::endl; else { if ( c == 0 ) std::cout << "Aoki" << std::endl; else std::cout << "Takahashi" << std::endl...
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << "[" << H << "]"; debug_out(T...); } #ifdef dddxxz #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", de...
//#include <atcoder/all> //using namespace atcoder; #include <iostream> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <array> #include <algorithm> #include <utility> #include <numeric> #include <functional> #include <limits> #include <iom...
#include <bits/stdc++.h> #define For(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rFor(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rep(i, n) For((i), 0, (n)) #define rrep(i, n) rFor((i), (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef un...
#include "iostream" #include "algorithm" #include "cstring" #include "cstdio" #include "cmath" #include "vector" #include "map" #include "set" #include "queue" using namespace std; #define MAXN 222 //#define int long long #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for (i...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin>>a; int b; b=100-a%100; cout<<b<<endl; }
#include <iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> #include<stack> #include<queue> #include<math.h> using namespace std; typedef long long ll; #define int long long #define double long double typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; t...
#include <bits/stdc++.h> #include <math.h> #define ALL(a) a.begin(), a.end() #define rep(i, K, N) for(long long int i = K; i < N; i++) #define ll long long int using namespace std; int main(){ ll N, Q; string S, x, y;cin >> N >> S >> Q; bool C = 0; x = S.substr(0, N); y = S.substr(N, N); rep(i, 0, Q){ ...
#include <bits/stdc++.h> using namespace std; //LPFI int main() { int n, q; cin >> n; string s; cin >> s; cin >> q; /*string s1 = s.substr(0, n); string s2 = s.substr(n, 2 * n);*/ string s1, s2; for (int i = 0; i < n; i++) s1 += s[i]; for (int i = n; i < 2 * n; i++) s2 += s[i]; int t, a, b; while(q--) ...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; 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 co(x) cout << (x) << "\n" #define cos...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; } ll a[100005],b[100005],c[1005],d[1005],v[1005],vv[1005]; int main() { ll n,m,k,i,j,flag=0,ansx=0,ansy=0,t,sum1,sum,s,ma,ans,q=0; a[1]=a[2]=2; a[3]=4; ans=0; scanf("%lld",&n); n*=2;...
// #pragma GCC optimize("Ofast") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define int long long int #define ll long long int #define ld long double #define getFaster ios_base::sync_with_stdio(false), cin.tie(n...
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<bitset> #include<set> #include<map> #include<stack> #include<queue> #include<deque> #include<list> #include<iomanip> #include<cmath> #include<cstring> #include<functional> #include<cstdio> #include<cstdlib> #include<numeric> //#include<at...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long int #define f(i,j,n) for(int i=j;i<=n;i++) #define mod 1000000007 int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL); string s; cin>>s; int ans=0; f(i,0,9) f(j,0,9) f(k,0,9...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i<n;i++) #define all(i, v) for(auto& i : v) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; const ll N =...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define m_p make_pair #define sz(x) (int)x.size() #define out(x) cerr<<#x<<" = "<<x<<" ...
#include <bits/stdc++.h> //#include <atcoder/all> #define endl "\n" using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bo...
#include <bits/stdc++.h> using namespace std; const int MAX_NUM = 3e5 + 10; int bit[MAX_NUM]; inline int low(int i) { return i & (-i); } void update(int i, int k) { while (i < MAX_NUM) { bit[i] ^= k; i += low(i); } } int query(int i) { int res = 0; while (i > 0) { res ^= bit...
//ye moh moh ke dhaage,tere ungliyon se ja uljhe #include<bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i,n) for(i=...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long long #define ll long long #define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr)) #define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr)) #define sz(a) sizeof(a) #define deb(a) cerr ...
#include <stdio.h> #include <bits/stdc++.h> int main() { int i, N, A[2][131072]; scanf("%d", &N); for (i = 1; i <= N; i++) scanf("%d", &(A[0][i])); for (i = 1; i <= N; i++) scanf("%d", &(A[1][i])); int j, k, l, r; const long long inf = -(1LL << 60); long long dp[2][131072]; for (i = 0; i <= N; i++) { dp[0]...
#include<bits/stdc++.h> // no of bits to store no 2e5 is 19 // 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai using namespace std; #define int long long #define mod 1000000007 #define MOD 1000000007 #define MAX 1000000000 #define inf ...
#include <iostream> #include <cmath> #include <string> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <tuple> #include <utility> #include <functional> #include <set> #include <map> #include <bitset> #include <list> #include<iomanip> using namespace std; using ll = long long; using UL...
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; char In[1 << 20], *ss = In, *tt = In; #define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++) ll read() { ll x = 0, f = 1; char ch = getchar(); for(; ch < '0' || ch > '9'; ...
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; using ll = long long; using ld = long double; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_nod...
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define f(i,a,n) for(int i=a ; i<n ; i++) #define rf(i,n,a) for(int i=n ; i>=a ; i--) #define F first #define S second #define all(c) (c).begin(),(c).end() #define sz(v) (int)(v).size() #define fast ios::sync_with_stdio(0); cin.ti...
#include<bits/stdc++.h> using namespace std; int main() { long long int n,count=0; cin>>n; for(int i=1;i<=1000000;i++){ string s=to_string(i); string r=s+s; long long int res=stoll(r); count++; if(res>n){ break; } } cout<<count-1<<endl; return 0; }
/*Jai Shree Ram*/ // Never Give Up #include<bits/stdc++.h> #include<unordered_map> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi ...
#include <bits/stdc++.h> using namespace std; #define forn(i, n) for(int i = 0; i < int(n); i++) #define fore(i, l, r) for(int i = int(l); i < int(r); i++) #define pb push_back #define all(x) x.begin(), x.end() #define sz(a) int((a).size()) typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; ...
#include <bits/stdc++.h> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; ll x; cin>>n>>x; vector<ll> a(n); for(int i=0;i<n;i++){ cin>>a[i]; } vector<ll> b(n),c(n); for(int i=n-1;i>=0;i--){ b[i]=x/a[i]; ...
// abc182_f #include <bits/stdc++.h> // #include "../cxx-prettyprint/prettyprint.hpp" // #include <iostream> #ifdef LOCAL #endif using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i)) #define REPN(i, m, n) for (int...
#include <bits/stdc++.h> using namespace std; long long C(int n, int r){ __int128 ans = 1; for(int i=n;i>n-r;i--){ ans=ans*i; } for(int i=1;i<r+1;i++){ ans = ans/i; } return ans; } int main(){ int L; cin >> L; cout << C((L-1),11) << endl; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> #define IOS ios::sync_with_stdio(0), cin...
#include <algorithm> #include <complex> #include <cstdlib> #include <ctime> #include <time.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <numeric> #include <lim...
// #define _GLIBCXX_DEBUG #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <l...
#include <bits/stdc++.h> using namespace std; int main(){ long long N, L = 0; long long ans = 0; cin >> N; vector<long long> vec(N); for (int i = 0; i < N; i++){ int x; cin >> x; vec.at(i) = x; } sort(vec.begin(), vec.end()); for (int i = 0; i < N; i++){ if( vec.at(L) != vec.at(...
using namespace std; #include "bits/stdc++.h" #define len(X) (int)(X).size() #define all(X) (X).begin(), (X).end() #define elif else if #define ceil(x,y) (x + y-1)/y #define int long long int32_t main() { cin.tie(nullptr)->sync_with_stdio(false); int n;cin>>n; map<int,int> m; for(int a,i {}; i < n; ++i) cin>>a,...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; int main(){ int n, q, t, e, x, l, r; cin >> n; vector<vector<int>> g(n); int a[n-1], b[n-1]; rep(i,n-1) { cin >> a[i] >> b[i]; a[i]--; b[i]--; g[a[i]].push_back(b[i]); g[b[i]].push...
#include <bits/stdc++.h> using namespace std; #define ll long long priority_queue < pair < ll, int > > q; int n, m, tot, hd[100005], vis[100005], to[200005], nxt[200005], c[200005], d[200005]; ll dis[100005]; int read() { int x = 0, fl = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') fl =...
// In the name of god #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define debug(x) cerr << #x << " : " << x << '\n' using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; typedef string str; const ll maxn = 105, inf = 2e18; ll n, s[maxn]; ld ans...
//#define _DEBUG #include "bits/stdc++.h" #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,a4,x,...) x #define debug_1(x1) cout<<#x1<<": "<<x1<<endl #define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl #define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl #defin...
#include<bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int tree[4 * N], n, a[N]; void built(int l = 1, int r = n, int pos = 1) { if (l == r) { tree[pos] = a[l]; return; } int m = (l + r) / 2; built(l, m, 2 * pos); built(m + 1, r, 2 * pos + 1); tree[pos] = tree[2 * pos] ^ tree[2 * pos + 1]; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define inf 0x3f3f3f3f #define infll 0x3f3f3f3f3f3f3f3f #define all(x) (x).begin(),(x).end() #define pb push_back #define ii pair<int,int> #define vii vector<ii> #define vi vector<int> #define pi 2*acos(0.0) #define F_OR(i, a, b, s) for (int i=(a); (...
#include<bits/stdc++.h> using namespace std; //typedef typedef unsigned int UINT; typedef unsigned long long ULL; typedef long long LL; typedef long double LD; typedef pair<LL, LL> PLL; typedef tuple<LL, LL, LL> TLL3; typedef tuple<LL, LL, LL, LL> TLL4; typedef set<LL, greater<LL> > setdownLL; #define PQ priority_queu...
// 問題の URL を書いておく // #include <bits/stdc++.h> using namespace std; //#define ENABLE_PRINT #if defined(ENABLE_PRINT) #define Print(v) \ do {\ cout << #v << ": " << v << endl; \ }while(0) #define PrintVec(v) \ do {\ for(int __i = 0; __i < v.size(); ++__i) \ { \ cout << #v << "[" << __i << "]: "...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,x,y) for(ll i=(x);i<(y);i++) #define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--) #define all(x) (x).begin(),(x).end() #define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");} #ifdef LOCAL #define de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<pair<ll,ll> > vpl;//追加はmake_pairを使う typedef long double ld; typedef vector<ll> vl; typedef vector<vl> vvl; typedef priority_queue<ll> pq; typedef priority_queue<ll, vector<ll>, greater<ll> > pqg; //昇順のPriority queue #define rep(i, n) for...
#include <iostream> using namespace std; int main() { int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; if (sy < 0) { if (gy < 0) { gy = -gy; } } else { if (gy > 0) { gy = -gy; } } double a = (double)(gy - sy) / (gx - sx); double b = sy - a * sx; double x = (0.0 - b) / a; pr...
#include <bits/stdc++.h> using namespace std; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; f...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<string.h> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) do {} while (0) #endif #include<cassert> using ...
#include <vector> template <typename T, typename F> class segment_tree { public: segment_tree(int n, const F& f, const T& e) : f(f), e(e) { sz = 1; while (sz < n) { sz *= 2; } dat.assign(2 * sz, e); } void update(int i, const T& x) { i += sz; dat[i] = x; while (i > 1) { i /= 2; dat[i] = f...
#include <bits/stdc++.h> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fod(i,a,b) for(int i=a;i>=b;i--) #define me0(a) memset(a,0,sizeof(a)) #define me1(a) memset(a,-1,sizeof(a)) #define op freopen("in.txt", "r", stdin) #define op1 freopen("C:\\acm\\Cproj\\in.txt","r",stdin); #define pr freopen("C:\\acm\\Cproj\\out.t...
#include<bits/stdc++.h> #define ll long long ll a,b,c,d,s; int main(){ scanf("%lld%lld%lld%lld",&a,&b,&c,&d);s=a+b+c+d; if(a==s-a||b==s-b||c==s-c||d==s-d)puts("Yes"); else if(a+b==s-a-b||a+c==s-a-c||a+d==s-a-d||b+c==s-b-c||b+d==s-b-d||c+d==s-c-d)puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> using namespace std; void solve(){ int n; cin >> n; int a[n]; for(int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); if(n & 1){ cout << "Second\n"; }else{ // 1 2 4 5 // 100 // 101 // 010 // 001 for(int i = 0; i < n; i += 2){ if(a[i] != a[i + 1]){ ...
#include <bits/stdc++.h> using namespace std; long long INF = 1LL<<60; using ll = long long; using vll = vector<ll>; using mll = map<ll, ll>; #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() template<class T>bool chma...
#include <iostream> using namespace std; int main() { int res, matrix[4]; for (auto i = 0; i < 4; i++) { cin >> matrix[i]; } res = matrix[0] * matrix[3] - matrix[1] * matrix[2]; cout << res; return 0; }
#include<bits/stdc++.h> #define fo(i,a,b) for((i)=(a);i<=(b);i++) #define rfo(i,a,b) for((i)=(a);i>=(b);i--) #define inrange(x,y,z) (((x)>=(y))&&((x)<=(z))) #define ALL(vec) (vec).begin(),(vec).end() #define SOR(vec) sort(ALL(vec)) #define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end()) using namespace std; int a,b,...
#include<bits/stdc++.h> using namespace std; #define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); //#define mp make_pair #define pb push_back #define fp first #define sp second typedef long long int ll; typedef pair<ll,ll> pp; #define check(x, i) ((x>>i)&1LL) #define set(x,i) (x|(1LL<<i)) #define unset(x,i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 5; struct Person { int val, id, ok, nxt; }a[maxn], q[maxn]; struct D { int a, b; }; int n, fflag, ansflag = 1; int b[maxn], p[maxn]; vector<D> ans; int cmp(const Person &a, const Person &b) { return a.val > b.val...
#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<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define int long long #define ...
// RAKSHIT KADAM #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> 3 // #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> #warning check the size of arrays!!! // NUMERI...
#include <bits/stdc++.h> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; } template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os <<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll N; cin >> N; unordered_set<ll> s; for(ll a = 2; a * a <= N; a++){ ll x = a * a; while(x <= N){ s.insert(x); x *= a; } } cout << N - s.size() << endl; }
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; typedef long long ll; typedef long double ld; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i,n) for(int i=n; i>-1; --i) #define ALL(a) (a).begin(),(a).end() #define FILL(a,n,x) REP(i,(n)){ (a)...
#include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> ostream& operator<<(ostream &os, vector<T> &v){ string sep = " "; if(v.size()) os << v[0]; for(int i=1; i<v.size(); i++) os << sep << v[i]; return os; } template<typename T> istream& operator>>(istream &is, vector<...
/* Saturday 08 May 2021 05:51:43 PM IST @uthor::astrainL3gi0N */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef std::vector<int> vi; typedef std::pair<int,int> ii; typedef std::vector<ii> vii; typedef std::vector<ll> vl; #define pb push_back #define mp make_pair #define debg(...
/*#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops")*/ #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >=...
#include <stack> #include <queue> #include <bitset> #include <unordered_set> #include <unordered_map> #include <map> #include <set> #include <tuple> #include <cmath> #include <random> #include <algorithm> #include <vector> #include <iostream> #include <fstream> #include <chrono> #include <numeric> #define fio ios_base...
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for(int (i) = 0; (i) < (n); ++(i)) #define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i)) #define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i)) template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long INF = 1LL<<60; const double PI = acos(-1.0); /*const double PI = atan2(0.0,-1.0)*/ template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (...
#include <bits/stdc++.h> using namespace std; int n; int dp[200001][8] ; string s, x ; bool fun(int idx, int num) { if (idx > n) return (num == 0) ; int &ret = dp[idx][num] ; if (ret != -1) return ret ; int cur = 0 ; if (x[idx] == 'A') { cur = fun(idx+1, (num * 10)%7) ; if (cur == 1) cur = fun(idx+...
#ifdef LOGX #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; /*---------macro---------*/ #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = s; i < (int)(n); ++i) #define ALL(a) a.begin(),a.end() #define ...
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define fi first #define se second #define endl '\n' #define MAX INT_MAX #define MIN INT_MIN #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define mod 1000000007 #define pb push_back #define sz(a) ...
#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...
#pragma GCC optimize(2) //#include <bits/stdc++.h> #include <iostream> #include <set> #include <cmath> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <utility> #include <map> #define rush() int T; while(cin>>T) while(T--) #define ms(a,b) memset(a,b,sizeof ...
#include<bits/stdc++.h> using namespace std; #define rep(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() #define pb push_back #define f first #define s second #define nl '\n' typedef long long ll; typedef vector<int> vi; typedef pair<int...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; #define int long long typedef int ll; typedef long double ld; const ll N = 505; char en = '\n'; ll inf = 1e16; ll mod = 998244353; ll power(ll x, ll n, ll mod) { ll res = 1; x %= mod; while ...
#include <bits/stdc++.h> #define mod 998244353 using namespace std; int n,i,x; int a[200005]; long long ans; vector<int> seg; map<int, vector<int>> m; void upd(int stt, int drt, int st, int dr, int p, int val) { if(stt==st && drt==dr) { seg[p]+=val; return; } int mij=(st+dr)/2; ...
#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; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { long long N, K; cin >> N >> K; rep(i, K){ if(N % 200 == 0){ N /= 200; continue; } else{ N *= 1000; N += 200; } } cout << N << endl; }
//ver 8.1 #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; using ll=long long; using P=pair<ll,ll>; template<class T> using V=vector<T>; #define fi first #define se second #define all(v) (v).begin(),(v).end() const ll inf=(1e18); //const ll mod=998244353; const ll mod=1000000007; const vector<int> dy={-1...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil ...
// '-.-' // () __.'.__ // .-:--:-. |_______| // () \____/ \=====/ // /\ {====} )___( // ...
#include <iostream> #include <stdio.h> #include <vector> #include <string> using namespace std; void three(int x, int y, int z,int* hi){ if(x < y){ if(x < z){ return; } hi[0] = z; hi[2] = x; return; } else if(y < z){ hi[0] = y; hi[1] = x...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; bool f(int i, map<char, int> a){ string s = to_string(i); for(auto c : s){ if(a[c] == 0) return 0; else a[c]--; } return 1; } int main() { string s; cin >> s;...
#include <iostream> #include <algorithm> #include <stdio.h> #include <bits/stdc++.h> #include <queue> #include <math.h> #include <bitset> #include <map> #include <vector> #include <cstdio> #include <climits> #define white 0 #define gray 1 #define black 2 #define LIMIT (1<<30) #define MOD 1000000007 #define ll long long...
#include<bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> #define vvi vector<vector<int>> #define pb push_back #define endl '\n' vector<int> vis; vector<vector<int>> g; int dfs(int u){ int ans=1; vi...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<int, string> mountain; for (int i = 0; i < N; i++) { string S; int T; cin >> S >> T; mountain[T] = S; } auto no2 = mountain.end(); advance(no2, -2); cout << no2->second << endl; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a ...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; template<typename T> inline bool chmin(T &a, const T &b) {if(a>b) {a=b; return true;} return false;} int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, X, Y; cin >> N >> M >> X >> Y; X--; Y--; map<int, v...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #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 ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #def...
#include <cstdio> #include <algorithm> using namespace std; int a[300000]; int main() { int n, k, c, i, j; long long ans = 0; scanf("%d %d", &n, &k); for (i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); c = k; for (i = 0, j = 0; ; i++) { int x = 0; ...
#include <iostream> #include <vector> using namespace std; class UnionFind { public: UnionFind(int n) : par(n), rank(n, 0) { for (int i = 0; i < n; ++i) { par[i] = i; } } int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } voi...
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <cmath> #include <iomanip> #include <set> using ll = long long; const double PI = 3.1415926535897932; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> ...
//debug icin gdb kullanmayi dene #include<bits/stdc++.h> using namespace std; #define mods 1000000007 #define pb push_back #define mp make_pair #define st first #define nd second #define rs resize #define pii pair<lint,lint> #define piii pair<lint,pair<lint,lint> > #define inf LLONG_MAX-7 #define vvL vector<vector<li...
#include <cstdio> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; typedef __int128 it; typedef long double ldb; int main(){ ll s,p; scanf("%lld%lld",&s,&p); it sqt=it(s)*s-it(p<<2); // if(p*4<(s*2-1)){ // puts("No"); // return 0; // } ldb tmp=sqrt(ldb(s)*s-(p<<2)); for(it i=max(t...
/* Author: QAQAutoMaton Lang: C++ Code: A.cpp Mail: lk@qaq-am.com Blog: https://www.qaq-am.com/ */ #include<bits/stdc++.h> #define int long long #define debug(...) fprintf(stderr,__VA_ARGS__) #define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__) #define Debug debug("Passing [%s] in LINE %d\n",__FUNCTI...
#line 1 "A.cpp" #include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; #if defined(DONLINE_JUDGE) #define NDEBUG #elif defined(ONLINE_JUDGE) #define NDEBUG #endif template<typename T> std::vector<T> m...
//#include <bits/stdc++.h> #include <iostream> #include <string> #include <map> #include <vector> using namespace std; typedef long long ll; //typedef vector<long long> vll; #define rep(i,n) for(long long(i)=0;(i)<(n);(i)++) #define kiriage(a,b) ((a)+(b)-1)/(b) int main(){ double x,y,z; cin >> x >> y ...
#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...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define ll long long #define u unsigned #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define mod 1000000007 #define f(i,n) for(int i=0;i<n;i++) #define f1(i,n) for(int i=1;i<n;i++) #define in(i,arr) for(auto &i:arr)cin>>i; #defi...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vec = vector<ll>; using mat = vector<vec>; using pll = pair<ll,ll>; #define INF (1LL << 60) #define MOD 1000000007 #define PI 3.14159265358979323846 #define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i)) #define FORR(i,v) for(auto (i...
#include <bits/stdc++.h> #define int long long using namespace std; #define se second #define fi first #define M 1e9+7 #define N 1e9 double dp[102][102][102]; void F(){ int a, b, c; cin >> a >> b >> c; for(int i = 100; i >= a; i--){ for(int j = 100; j >= b; j--){ for(int k = 100; k >= c; k--){ if(i == 100...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define all(x) begin(x), end(x) #define allr(x) rbegin(x), rend(x) using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll INF = 2e18; const...
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; int l = b - a; for (int i = l; i >= 1; i--) { int x = (a+i-1)/i; if (b-x*i>=i) { cout<<i<<endl; return 0; } } cout<<a<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double lf; // #define int ll #define FOR(i, f, t) for (int i = (f), ed##i = (t); i <= ed##i; ++i) #define ROF(i, t, f) for (int i = (t), ed##i = (f); i >= ed##i; --i) #define DBG(x) (cerr << "(dbg) " << #...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, b) for (int i = a; i < (b); i++) int main() { int n, m, q; cin >> n >> m >> q; int x[m]; vector<pair<int, int>> vw(n); rep(i, 0, n) { int w, v; cin >> w >> v; vw[i].first = v, vw[i].second ...
#include <bits/stdc++.h> #define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++) #define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++) #define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--) #define deb(x) std::cout << #x << " " << x << endl; #define debl(x) std::cout << #x << " " << x << " "; using namespace std;...
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back int n,query,i,a[200010],b[200010],dis[200010],c[200010],e,x,s,t; bool vis[200010]; vector<int> adj[200010]; queue<int> q; signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)...
#include<bits/stdc++.h> #define inf 2000000000 #define eb emplace_back #define pb push_back #define fi first #define se second #define fastio ios::sync_with_stdio(false);cin.tie(NULL) #define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) using namespace std; typedef long long ll; typedef pa...
#include <iostream> #include <vector> #include <algorithm> #include<numeric> #include<unordered_map> using namespace std; #define MP make_pair #define PB push_back #define REP(i, L, R) for (int i = L; i < (R); ++i) #define SZ(x) (int)x.size() using ll = long long; using ii = pair<int,int>; struct DSU { int n; ...
#include <bits/stdc++.h> using namespace std; int main(void) { int N, M; cin >> N >> M; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<vector<int>> graph(N); for (int i = 0; i < M; i++) { int X, Y; cin >> X >> Y; X--; Y--; graph[X].push_back(Y); } ...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using n...
#include <bits/stdc++.h> using namespace std; namespace DEBUG { void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << ...
#include<bits/stdc++.h> #define forn(i,s,t) for(register int i=(s);i<=(t);++i) #define form(i,s,t) for(register int i=(s);i>=(t);--i) using namespace std; typedef long long LL; const int N = 1e2+3; const LL INF = 2e18; template<typename T>inline T Max(T A, T B) {return A>B?A:B;} template<typename T>inline T Min(T A, T ...
#include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int N=200010,mod=1e9+7; double f[N][2]; bool vis[N]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= k;i++) { int x; cin...
#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 dup(x,y) (((x)+(y)-1)/(y)) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef pair<int, int> pii; const double EPS = 1e-10; const int INF = 1e9; const l...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ld = long double; using P = pair<ll, ll>; using Pld = pair<ld, ld>; using Vec = vector<ll>; using VecP = vector<P>; using VecB = vector<bool>; using VecC = vector<char>; using VecD = vector<ld>; using VecS = vector<string>; template <class T> using...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #ifdef LOCAL #define Gene template< class #define Rics printer& operator, Gene c> struct rge{c b, e;}; Gene c> rge<c> range(c i, c j){ return {i, j};} struct printer{ ~printer(){cerr<...
#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 <iostream> #include <cmath> #include <utility> #include <algorithm> #include <vector> using namespace std; #define mp make_pair #define x first #define y second typedef pair<int,int> pii; typedef long long ll; typedef pair<ll,int> pl; int arr[400005]; pii a[400004]; vector<int> st; int col[400005]; char s[4...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> pll; const ll inf = 1LL<<60; int main(){ int n; cin >> n; vector<pll> vec(n+1, make_pair(inf, -1*inf)); rep(i, n) { ll x, c; cin >> x >> c; vec[...
#include <bits/stdc++.h> using namespace std; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } s...
/** * 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> using namespace std; typedef long long ll; int main(){ int m,h; cin>>m>>h; cout<<(h%m==0?"Yes" : "No")<<endl; }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define mem0(a) memset(a,0,sizeof(a)) #define mem1(a) memset(a,-1,sizeof(a)) #define memf(a) memset(a,false,sizeof(a)) #define all(v) (v).begin(),(v).end() #define lb lower_bound #define ub upper_bound #define pll pair<ll,ll> #defi...
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, n) FOR(i, 0, n) #define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() #define ALLR(obj) (obj).rbegin(), (obj).rend() #define CEIL(a, b) ((a - 1) / b + 1) void solve() { i...
#include <bits/stdc++.h> using namespace std; int main() { long long s = 0, a, n; map<long long, long long> m; cin >> n; m[0] += 1; for (int i = 0; i < n; i++) { cin >> a; if (i % 2 == 0) s += a; else s -= a; m[s] += 1; } long long count = 0; for (auto i : m) { count += i.second...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #define all(v) v.begin(), v.end() using in = long long; #define rep(i, n) for (in i = 0; i < (in)(n); i++) #define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i+...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int>people_weight(n); vector<int>bag_weight(n); vector<int>has_bag(n); set<pair<int,int>>people_priority; vector<int>has_my_bag(n); for(int i = 0; i < n; ++i){ cin >> people_weight[i]; people...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> A(n), B(n), P(n); copy_n(istream_iterator<int>(cin), n, A.begin()); copy_n(istream_iterator<int>(cin), n, B.begin()); copy_n(istream_iterator<int>(cin), n, P.begin()); for (auto &p: P) p--; ...
#include <bits/stdc++.h> using namespace std; const int N = 15; char str[N][N]; int n, m, ans; struct Res { int x, y; }; bool cmp1(Res a, Res b) { return a.x != b.x ? a.x < b.x : a.y < b.y; } bool cmp2(Res a, Res b) { return a.y != b.y ? a.y < b.y : a.x < b.x; } int main() { // freopen("in.txt", "r", st...
#include<bits/stdc++.h> using namespace std; int main(){ int n, a; cin >> n; string s, t; vector<int> p, q; cin >> s >> t; for(int i = 0; i < n; i++){ if(s[i] == '0') p.push_back(i); if(t[i] == '0') q.push_back(i); } a = 0; if(p.size() != q.size()){ a = -1; } else{ for...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 1e+7; const ld PI = acos(-1); const ld EPS = 1e-8; const ll LINF = 1LL<<60; const int INF = 1LL<<17; #define rep(i, a, b) for(ll i=a; i<(ll)(b); i++) #define rrep(i, a, b) for(ll i=b-1; a<=i; i--) #define ALL(x)...
#include<bits/stdc++.h> using namespace std; #define N 107 #define ldb long double char s[N][N]; int g[N][N],cnt[N],n; bool vis[N]; ldb f[N],cof[N]; void dfs(int v){ cnt[v]++; vis[v]=1; for(int i=1;i<=n;i++) if(g[v][i]&&!vis[i]) dfs(i); } int main(){ //freopen("cpp.in","r",stdin); scanf("%d",&n); for(int i=1;...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //namespace mp=boost::multiprecision; //#define mulint mp::cpp_int //#define mulfloat mp::cpp_dec_float_100 struct __INIT{__INIT(){cin.tie(0);ios::sy...
#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 <bits/stdc++.h> using namespace std; #define int long long using ld = long double; const ld et=1e-9; int32_t main(){ ios::sync_with_stdio(0),cin.tie(0); int n,m,k; cin >> n >> m >> k; vector <ld> p(n+1),e(n+1); int cnt[n+1]={}; p[n]=e[n]=cnt[n]=0; for(int i=0;i<k;i++){ int x;...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++) #define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--) #define all(v) v.begin(), v.end() typedef long long ll; template <class T> using V = vector<T>; template <class T> using VV = vector...
#include <cmath> #include <deque> #include <algorithm> #include <iterator> #include <list> #include <tuple> #include <map> #include <unordered_map> #include <queue> #include <set> #include <unordered_set> #include <stack> #include <string> #include <vector> #include <fstream> #include <iostream> #include <functional> #...
//#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> #include <iostream> #include <algorithm> #include <string> #include <stdio.h> using ll=long long; using namespace std; int main(){ ll n; cin>>n; ll x=1000; ll ans=0; while(n>=x){ ans+=n-x+1; x*=1000; } cout<<ans<<endl; }
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main() { string x; cin >> x; int n = x.find('.'); cout << x.substr(0,n) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll=long long; using vpii=vector<pair<int,int>>; using vpll=vector<pair<ll,ll>>; using Graph_1=vector<vector<int>>; const ll INF=1e18; const int inf=1e9; const double eps=1e-10; const double pi=acos(-1); const ll mod=1e9+7; const ll MOD=998244353; //数学関連 int num_or...
#include<iostream> #include<string> using namespace std; int main() { string s; cin >> s; int t = s.size(); for (int i = 0; i < t; i++) { if (i%2 == 0 && isupper(s[i])) {cout << "No" << endl; return 0;} if (i%2 == 1 && islower(s[i])) {cout << "No" << endl; return 0;} } cout << "...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DU...
#include <cstdio> #include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <chrono> #include <random> #include <cstdlib> #include <cmath> #include <ctime> #include <cstring> #include <iomanip> #define int long long #define pii p...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1005; const int M=1000000007; int n,jc[N],inv[N]; char c[2][2],s[5]; int C(int n,int m){return (ll)jc[n]*inv[m]%M*inv[n-m]%M;} int qpow(int x,int y){int ans=1;for(;y;y>>=1,x=(ll)x*x%M)if(y&1)ans=(ll)ans*x%M;return ans;} int main() { scan...
#include<bits/stdc++.h> using namespace std; const int MN = 1e3 + 5, MOD = 1e9 + 7; int dp[MN][2]; char o(char c) {return c == 'A' ? 'B' : 'A';} int fpow (int base, int exp) { int res = 1; exp = max(exp,0); while (exp) { if (exp & 1) res = (long long)res * base % MOD; base = (long long)base * base % MOD; exp >>...
#include<bits/stdc++.h> using namespace std; using ll=int64_t; #define rep1(i,n) for(ll i=0;i<n;i++) #define rep2(i,x,n) for(ll i=x;i<n;i++) int main(){ ll N;cin>>N; ll counter=0; vector<ll>V; for(ll i=2;i<=1e5;i++){ for(ll j=2;j<=34;j++){ ll number=pow(i,j); if(number<=N...
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; //const int INF = 2e9; //const ll INF = 9e18; void solve(){ ll N; cin >> N; set<ll> st; ll ans = 0; for (ll i=2;i*i<=N;i++){ if (st.find(i)!=st.end()) continue; for (ll j=i*i;j<=N;j*=i){ ...