code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
//@Author: KeinYukiyoshi // clang-format off #include <bits/stdc++.h> //#pragma GCC optimize("Ofast") //#pragma GCC target("avx") #define int long long using namespace std; #define stoi stoll #define fi first #define se second #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++) #define rep2(i, a, b) for (int i...
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string> #include <cstring> #include <map> #include <stack> #include <set> #include <bits/stdc++.h> using namespace std; #define lson 2*i #define rson 2*i+1 #d...
#include <bits/stdc++.h> #define loop(s, e, i) for (int i = s; i < e; ++i) #define print(s) cout << s << endl; #define DIV 1000000007 using namespace std; typedef long long ll; typedef unsigned long long ull; const int INF = 1e9+7; ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ ll floordiv(ll a, ll b) { retu...
#include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <queue> #include <string> #include <math.h> #include <functional> #include <iomanip> #include <set> #include <map> #include <numeric> #include <cstdint> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) using ll = long lon...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<(int)(n); i++) #define rep1(i, n) for(int i=1; i<=(int)(n); i++) #define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++) typedef long long ll; typedef vector<int> vi; typedef vector<vi> wi; typedef vector<ll> vl; const ll inf=1LL<<60; templ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; #define FOR(i, a, b) for (int i = a; i <= (b); i++) #define F0R(i...
#include "bits/stdc++.h" #define int long long int #define mp make_pair #define pb emplace_back #define F first #define S second using vi = std::vector<int>; using vvi = std::vector<vi>; using pii = std::pair<int, int>; using vpii = ...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include...
/** * Author: dhruv_gheewala * Problem: __________ * Date: 19.12.2020 * Time: 17:37:15 **/ #if __has_include("debug.h") #include "debug.h" #else #include<bits/stdc++.h> using namespace std; #define fundri 108 #define debug(...) 1729 #endif #define endl '\n' #define int int64_t...
#include <bits/stdc++.h> using namespace std; #define for0(i, n) for (int i = 0; i < (n); ++i) #define cinb(a, b) cin >> a >> b; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } using ll = long long; #define p(ans) cout << ans << endl; ll n, m, k; ll ab[110][...
#include<bits/stdc++.h> using namespace::std; long long n; int m; long long add(long long a, long long b, long long mod){ return (a + b) % mod; } long long mul(long long a, long long b, long long mod){ long long r = 0; while(b > 0){ if(b & 1) r = add(r, a, mod); a = add(a, a, mod); b >>= 1; } return r; } ...
#include <iostream> using namespace std; typedef long long ll; #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)<(y)?(y):(x)) ll comb(ll n, ll k){ if (k == 0 || k == n) return 1; if (k == 1 || k == n-1) return n; return comb(n-1,k)+comb(n-1,k-1); } int main(){ ll n,k;cin >> n >> k;--k; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#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; } int n,m,X[100010],Y[100010],c[110]; vector<int> g[110]; int ans[11...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using vpii = vector<pii>; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; using db = long double; using pl = pair<ll, ll>; using vpl = vector<pl>; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; usin...
#include <bits/stdc++.h> #define ll long long #define ii pair<int, int> #define pll pair<ll, ll> #define dd pair<double, double> #define vi vector<int> #define vl vector<ll> #define vd vector<double> #define vii vector<ii> #define vll vector<pll> #define vdd vector<dd> #define vvi vector<vi> #define vvl vector<vl> #de...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define FOR(i,s,n) for(int i = (s); i < (n); i++) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n); i >= 0; i--) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() #define ATYN(n) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int sz = 2e5+5; ll a[sz], b[sz], ans[sz]; int main() { int n; cin >> n; for(int i=1; i<=n; i++) scanf("%lld", &a[i]), a[i] = max(a[i-1], a[i]); for(int i=1; i<=n; i++) scanf("%lld", &b[i]); for(int i=1; i<=n; i++) { ans[i] ...
#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; template<typename T>inline T Max(T A, T B) {return A>B?A:B;} template<typename T>inline T Min(T A, T B) {return A<B?A:B;} inline bool pd(char *...
#include <bits/stdc++.h> #define ios ios::sync_with_stdio(false), cin.tie(0); #define et cout<<endl; using namespace std; typedef pair<int, int> PII; typedef long long ll; typedef unsigned long long ull; inline int read() { int x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();} ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; char s[2010][2010]; long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; }...
#include <bits/stdc++.h> using namespace std; const int64_t MOD = 1e9+7; void add(int64_t& a, int64_t b){ a = (a+b) % MOD; } void mul(int64_t& a, int64_t b){ a = a*b % MOD; } int64_t power_mod(int64_t num, int64_t power){ int64_t prod = 1; num %= MOD; while(power > 0){ if(power&1) prod = p...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll a,b,c,ans,n; cin >> n; b = 0LL; ll two = 1LL; ans = 1e18; while(two <= n) { c = n % two; a = n / two; ans = min(ans, a+b+c); ...
#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> bool chmax(T...
#include "bits/stdc++.h" #ifdef FFS #include "debug.h" #else #define debug(args...) #endif using namespace std; const int N = 6 + 9 + 4e5; vector <int> gr[N]; signed main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; int x = INT_MAX, y = INT_MIN; for(int i = 0, a, b; i < n; ++...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define REP(i,n) for (ll i = 0; i < n; ++i) #def...
#include <bits/stdc++.h> using namespace std; int main(){ int N, count = 0; double tmp; cin >> N; vector<int> x(N), y(N); for(int i = 0; i < N; i++) cin >> x.at(i) >> y.at(i); for(int i = 0; i < N; i++){ for(int j = i+1; j < N; j++){ tmp = (double)y.at(i) - y.at(j); ...
#include <iostream> #include <vector> #define rep(i,a,b) for(int i=a;i<b;i++) using namespace std; int main() { int n; cin >> n; vector<int> x(n), y(n); rep(i, 0, n) { cin >> x[i] >> y[i]; } int dx, dy, cnt = 0; double t; rep(i, 0, n - 1) rep(j, 0, n) { if (i < j) { dx = x[j] - x[i]; dy = y[j] - y[...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int main() { double ans; int N; double D, H; double delta; double dN, hN; cin >> N >> D >> H; ans = 0; rep(i, N){ cin >> dN >> hN; delta = (H - hN) / (D - dN); ans = max(ans, (H - de...
#include <bits/stdc++.h> using namespace std; int d[105],h[105]; int main() { int N,D,H; double max=-1; cin>>N>>D>>H; for(int i=0;i<N;i++) { scanf("%d%d",&d[i],&h[i]); double x1=D,y1=H,x2=d[i],y2=h[i]; double b=y1-((x1*y1-x1*y2)*1.0/(x1-x2)); if(b>=0) { if(b>max) { max=b; } } } if(max==-...
#ifdef _LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; ld solve(ll n) { ld res = 0; for(int i = 1; i < n; i++) { res += (ld)n / (ld)i; } return res; } #ifndef _LOCAL int main() { ll n; cin >> n; cout <...
#include <iostream> #include <cmath> #include <cstring> #include <map> #include <set> #include <vector> #include <algorithm> #include <bitset> #include <complex> #include <numeric> #include <string> #include <utility> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; using ll = long long; u...
#include <bits/stdc++.h> using namespace std; using ll =long long; typedef pair<ll,ll> P; #define SORT(a) sort((a).begin(),(a).end()) #define REV(a) reverse((a).begin(),(a).end()) #define For(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define rep(i, n) For(i, 0, n) #define debug(x) cerr << #x << " = " << (x) ...
/* author : Aryan Agarwal, IIT KGP created : 06-February-2021 18:04:32 IST */ #include <bits/stdc++.h> using namespace std; #define int long long const int mxn = 2000; const long long INF = 2e18; const int32_t M = 1000000007; /*more than 1e9 */ /*7 + 1e9*/ // const int32_t M = 998244353; /*less than 1e9 */ ...
#include <bits/stdc++.h> using namespace std; int T,n,m,p,k; char s[100010]; int main(){ scanf("%d%s",&n,s+1); if(s[1]!=s[n]) return puts("1"),0; for(int i=2;i<n-1;i++) if(s[i]!=s[1]&&s[i+1]!=s[n]) return puts("2"),0; puts("-1"); }
/*{{{*/ #include "bits/stdc++.h" using namespace std; #define MT make_tuple #define all(x) begin(x), end(x) #define putchar(x) cout << (x) static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }(); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); tem...
/* Stay motivated and keep working hard */ #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 int long long #define pb push_back #define cntbit __builtin_popcount #define fr first #define mem(arr, val) m...
#include<bits/stdc++.h> using namespace std; int main() { int n,i,e,j; //e=1;; //while(e--) { cin>>n; long a[n],b[n],c[n],max,d; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) cin>>b[i]; c[0]=0; max=a[0]; for(i=1;i<n;i++) { if(a[i]>max) { max=a[i]; c[i]=i; } else c[i]=c[...
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful ----- #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 > stru...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (ll i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define pb push_back using ll = long long; using ld=long double; using vin=vector<int>; using v...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v...
#include <bits/stdc++.h> #define endl "\n" #define int long long #define ll long long using namespace std; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int,int> pii; template<typename T> void printv(vector<T> v) { for (auto e : v) { cout << e << " "; } cout << endl; } template<typ...
#include <bits/stdc++.h> typedef long long ll ; #define int ll const int MAX=2e5+10; const int modn=1e9+7; const int INF=0x3f3f3f3f3f3f; #define endl '\n' #define cwk freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout) using namespace std; int n,m,k,x; bool vis[MAX];...
#include <bits/stdc++.h> #define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) begin(x), end(x) using namespace std; using ll = long long; constexpr ll Mod = 998244353; constexpr ll mod = 1e9 + 7; constexpr ll inf =...
#include<iostream> using namespace std; int main(){ long long a,b; cin>>a>>b; if(a+b>=15&&b>=8)cout<<1<<endl; else if(a+b>=10&&b>=3)cout<<2<<endl; else if(a+b>=3)cout<<3<<endl; else cout<<4<<endl; }
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); #define cerr if(1) cerr #define ll long long #define fp cout<<fixed<<setprecision(9); #define loop(var,s,n) for(ll var=s ;var<n;var++) #define rloop(var,s,n) for(ll var=s ;var>=n;var--) #define pb push_back #define endl '\n' #define ...
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n, s) for (int i = (s...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define ff first #define ss second #define d(x) cout<<x<<" " #define nl cout<<endl #define rep(var,init_val,final_val) for(int var = init_val; var < final_val; ++var) #define tt ll t;cin>>t;while(t--) #defin...
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(v) (v).begin() , (v).end() #define vi vector <ll> #define vii vector <pair<ll,ll>> #define ii pair<ll,ll> #define sz(v) ((int)((v).size())) #define Forr(i,s) for(auto &i:s) #define lp(i...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll MOD = 1000000007; ll INFL = 1ll << 60; ll INF = 1 << 28; // ==================================================================== int main() { int n, m, t; cin >> n >> m >> t; vector<int> a(m), b(m); for (int i = 0; i < m; i++) cin >>...
#include<iostream> #include <cassert> #include <algorithm> #include <map> #include <set> #include <queue> #include <vector> #include <cstring> using namespace std; const int N = 3e5 + 123; char a[200][200]; int n, m, x, y; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> x >> ...
#include<bits/stdc++.h> #define inf 1e18 #define endl "\n" #define mp make_pair #define pb push_back #define loop(i,x,y) for(int i = x; i < y ; i++ ) #define all(x) (x).begin(),(x).end() #define in(n) int n; cin>>n; #define inarr(arr,n) vector<int>arr(n); for(int i = 0; i < n ; i++){cin>>arr[i];} #define maploop(...
//#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; int main(){ int N; cin >> N; vector<pair<int, int>> A(N); for(auto& [x, y] : A) cin >> x >> y; int ans = 0; for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) { auto [x1, y1] = A[i]; auto [x2, y2] = A[j]; ...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; // typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define scn(n)...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; using P = pair<int, int>; using ll = long long; bool solve(string s){ int n = s.size(); if(n == 1) return s == "8"; if(n == 2){ if(stoi(s)%8 == 0) return 1; swap(s[0],s[1]); return stoi(s)%8 == 0; ...
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<long long> a, nxt; long double solve(); bool check(long double e); int main() { cin >> n >> m >> k; a.resize(k); for (auto &p : a) cin >> p; cout << fixed << setprecision(10); auto res = solve(); if (res < 0) cout << "-1" << endl; el...
#include <bits/stdc++.h> #include <variant> #define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++) #define rep(i,n) rep2(i,0,n) #define all(x) begin(x),end(x) #ifdef ENV_LOCAL #define dump if (1) cerr #else #define dump if (0) cerr #endif using namespace std; using namespace std::string_literals; using i32 = int32_t...
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define F first #define S second #define PB push_back #define MP make_pair using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; ...
#include<bits/stdc++.h> #define dbug printf("I am here\n"); #define Fast ios_base::sync_with_stdio(false); cin.tie(0); #define vs v.size() #define ss s.size() #define sot(v) sort(v.begin(),v.end()) #define all(v) (v).begin(), (v).end() #define rev(v) reverse(v.begin(),v.end()) #def...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int N; cin >> N; vector<int> A(N); for (auto& x : A) cin >> x; ll res = 0; map<ll, int> a; ll s = 0; ++ a[0]; for (int i = 0; i < N; ++ i) { if (i % 2) { s += A[i]; res += a[s]; ++ a[s]; } else { s -= A[i]; res ...
# include <bits/stdc++.h> # define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) # define reps(i, n) for(int i=1, i##_len=(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 ALL(x) (x).begin(), (x).end() # define SZ(x) ((int)(x...
#include<iostream> #include<string> using namespace std; int main() { int T,N; cin >> T; string s1,s2,s3; int i,j; for(i=0;i<T;i++) { cin >> N >> s1 >> s2 >> s3; cout << "0"; for(j=0;j<N;j++)cout << "1"; for(j=0;j<N;j++)cout << "0"; cout << endl; } }
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { int n; cin>>n; vector<int>a(n),b(n),c(n); for(int i=0;i<n;i++) { cin>>a[i]; if(i)a[i]=max(a[i],a[i-1]); } for(int i=0;i<n;i++) cin>>b[i]; for(int i=0;i<n;i++) { c[i]=a[i]*b[i]; if(i)c[i]=max(c[i],c[i-1]); } for(int i...
#include <iostream> #include <iostream> #include <utility> #include <vector> #include <algorithm> #include <iomanip> #include <tuple> #include <math.h> #include <set> #include <cassert> #include <stack> #include <bitset> #include <map> #include <queue> #include <random> #include <unordered_set> #include <unordered_map>...
#include <stdio.h> #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <...
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int dp[5005][5005]; char s[5005][5005]; int main(){ int inv = 332748118; int h, w, k; scanf("%d%d%d", &h, &w, &k); for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) s[i][j] = '.'; for(int i=1;i<=k;i++){ int h, w; char...
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1000000010 #define EPS 1e-9 #define F first #define S second #define debug(x) cout<<x<<endl; #define repi(i,x,n) for(int i=x;i<n;i++) #define rep(i,n) repi(i,0,n) #define lp(i,n) repi(i,0,n) #define repn(i,n) for(in...
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=400010; int a[N]; const int mod=3; int n; ll qmi(ll a, ll k){ ll res = 1; while(k){ if(k & 1) res = res * a % mod; a = a * a % mod; k >>= 1; } return res; } ll C(ll a, ll b, ll p){ if(b > a) return 0; ll res = 1; for(int i = 1, ...
#include<bits/stdc++.h> using namespace std; void solve(int TestCase) { int n, k, m; cin >> n >> k >> m; n--; vector<int> A(n); for(auto& x : A) cin >> x; int sum = 0; for(auto x : A) sum += x; int need = m * (n+1) - sum; if(need > k) cout << -1 ...
#include <iostream> #include <stdio.h> #include <string> #include <math.h> #include <iomanip> #include <vector> #include <algorithm> #include <cassert> #include <utility> #include <numeric> #include <cstring> #include <map> #include <set> #include <cmath> #define rep(i,n) for (int i=0; i<(n); ++i) using namespace std;...
#include<bits/stdc++.h> using namespace std; using ll = long long; /*-----for personal-----*/ #define rep(i,a,b) for(int i=(a);i<(b);++i) #define repn(i,n) rep(i,0,n) 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 >...
//............Created by:- Arth Raj...........................// #include <string.h> #include <cstdio> #include <cstdlib> #include <cmath> #include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <bitset> #include <list> #include <stack> #include <queue> #include <algorithm> #inclu...
#include <bits/stdc++.h> #define fo(i, k, n) for (ll i = k; i < n; i++) #define rfo(i, k, n) for (ll i = k; i >= n ; i--) #define ll long long #define ld long double #define que queue #define pb push_back #define mp make_pair #define vi vector<int> #define vl vector<ll> #define gcd(m,n) __gcd( m, n) #define sq(x) ...
//clear adj and visited vector declared globally after each test case //check for long long overflow //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod; //Incase of close mle change language to c++17 or c++14 /**#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unro...
//wtrl,everybody hangbeat me #pragma GCC optimize(3) #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctim...
#include <iostream> using namespace std; int main() { string s; cin >> s; if (s[0] == s[1]) { if (s[1] == s[2]) { cout << "Won"; return 0; } } cout << "Lost"; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define rep(i,n) for(ll i=0;i<ll(n);i++) #define REP(i,k,n) for(ll i=k;i<ll(n);i++) #define all(a) a.begin(),a.end() #define eb emplace_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bound(all(v),k)-v.begin()) #de...
#include <bits/stdc++.h> using namespace std; //#define int long long template <int mod = 1000000007> struct modint{ int x; modint(int y = 0) : x((y % mod + mod) % mod) { } friend modint operator^(modint a, long long b) { modint r = 1; for(; b; b >>= 1, a *= a) if(b & 1) r *= a; ...
#include <bits/stdc++.h> using namespace std; // vtqi6hy80o@email.edu.pl #define rep(i, a, b) for(lli i = a; i < b; i++) #define lli long long int #define ld long double #define all(v) v.begin(), v.end() #define hell 1000000000000000 #define pb push_back #define pf push_front #define vi vector<lli> #define vip vector<p...
#include <bits/stdc++.h> using namespace std; const int maxn=112345; const long long mod=1000000007; int n; long long res,dp[maxn]; inline long long go(int x) { if (x<=0) return 1; return dp[x]; } int main() { dp[0]=1; dp[1]=2; for (int i=2;i<maxn;++i) dp[i]=(dp[i-1]+dp[i-2])%mod; scanf(...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; const long long int big = 2999999999999999999; const long long int small = -2999999999999999999; #define ll long long int #define pb(a) push_back(a) #define vll vector<long long int> #define loop(i, n) for(long long int i=1;i<=n;i++) ...
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) int main(){ int n,m; cin>>n>>m; vector<int>a(n+2); a[0]=0; a[n+1]=0; int maxa=0; rep(i,n){ cin>>a[i+1]; maxa=max(maxa,a[i+1]); } set<int>is[maxa+2]; rep(i,n+2){ is[a[i]].insert(i); ...
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf LLONG_MAX #define int long long #define mod 998244353 int a[1500005]; int x[1500005]; s...
#pragma warning(disable: 4996) #include <string> #include <vector> #include <iostream> #include <cstdio> #include <sstream> #include <fstream> #include <math.h> #include <algorithm> #include <map> #include <bitset> #include <queue> using namespace std; typedef long long ll; #define rep(i,n) for (int i = 0; i < (n); i+...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template<typename T> void fin(T a){ cout<<a<<endl; exit(0); } signed main(){ int n;cin>>n; vector<int> v(n); REP(i,n)cin>>v[i]; REP(i,n)v[i]--; set<int> rem; REP(i,n-1)if(v[i]>i&&v[i...
#include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long int akaPow(int e, int p) { int ans = 1; while (p > 0) { if (p & 1) ans = ans * e; e = e * e; p >>= 1; } return ans; } int32_t main() { IOS; #if...
#include<bits/stdc++.h> #define f first #define s second #define pb push_back #define M (L+R)/2 #define N 500009 #define inf 99999999999 #define ll long long #define mod 1000000007 #define sz size(); using namespace std; int main(){ ios::sync_with_stdio(0); int V, T, S, D; cin>>V>>T>>S>>D; if(D>=T*V && D<=V*...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr long long INF = numeric_limits<long long>::max() / 2; constexpr int MOD =1000000007; using Graph = vector<vector<int>>; signed main() { cin.tie(nullp...
//x<<y=x*2^y,x>>y=x/2^y //1e5+3 is prime //a+b=(axorb)+2*(a&b) // in a matrix, all elements of a primary diagonal have constant diff of coordinates // and a secondary diagonal has constant sum of coordinates //use ll() for using an integer in self-built fn //(x&-x) bitwise and of (x and its 2's complement) returns (las...
#include <bits/stdc++.h> #define mp make_pair #define sc second #define fr first #define pb push_back #define pii pair<int, int> #define Nmax 100005 using namespace std; vector <pii> v[Nmax]; int t[Nmax], s[Nmax], viz[Nmax], n, m; int tata(int x) { if(x!=t[x]) t[x]=tata(t[x]); return t[x]; } void uneste(int x,...
#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) constexpr int INF = 1e9; //constexpr ll INF = 1LL << 61; constexpr int mod = 1e9+7; struct Edge{ in...
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; #define endl "\n" #define fi first #define se second #define For(i,a,b) for(ll i=a;i<b;i++) #define RFor(i,b,a) for(ll i = b;i>=a;i--) #define sz size() #define PQ ...
#include <bits/stdc++.h> using namespace std; typedef long long lint; #define rep(i,n) for(lint (i)=0;(i)<(n);(i)++) #define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++) #define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--) #define INF (1ll<<60) #define all(x) (x).begin(),(x).end() //const lint MOD =1000000007; const lint ...
// Problem: D - Logical Expression // Contest: AtCoder - AtCoder Beginner Contest 189 // URL: https://atcoder.jp/contests/abc189/tasks/abc189_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp...
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<queue> #include<stack> #include<math.h> #include<map> typedef long long int ll; using namespace std; #define maxn 0x3f3f3f3f #define INF 0x3f3f3f3f3f3f3f3f const int mm=2e5+100; ll d[mm]; ll n; string s[1000]; int main() { ll n,i,j,...
#include <bits/stdc++.h> using namespace std; const long long INF = 10000000000000007; const long long mod = 1000000007; typedef long long ll; typedef pair<int, int> P; int main() { int n; cin >> n; cout << setprecision(10); vector<double>dp(n+1); dp[1] = 0; for (int i = 1; i < n; i++) { dp[i+1] = dp...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i = 0; i < (n); ++i) using ll = long long; using P = pair<ll,ll>; using vec = vector<ll>; using vecp = vector<P>; using mat = vector<vec>; using matp = vector<vecp>; const ll MOD = 998244353; const ll INF = 1e18; #define all(v) v.begin(), v.e...
#include<bits/stdc++.h> using namespace std; typedef long long int lli; typedef long double ld; /* #include <chrono> using namespace std::chrono; #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using nam...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> T(N); int sum = 0; for(int i = 0; i < N; i++){ cin >> T[i]; sum += T[i]; } int ave = (sum+1)/2; vector<vector<int>> dp(101, vector<int>(1000001, 0)); for(int i = 0; i < N; i++){ ...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string S; cin >> S; string T; bool rev = false; string revT; for (int i = 0; i < S.length(); i++){ if (S[i] == 'R') { rev = !rev; } else { if (rev) revT += S[i]; else T += S[i]; }...
#include <bits/stdc++.h> using namespace std; using ll= long long; #define rep(i,n) for(ll i=0;i<n;i++) int main(){ string S; cin >> S; ll N = S.length(); deque<char> dq; ll rr[N] = {}; rep(i, N){ if(i == 0){ if(S[i] == 'R'){ rr[i] = 1; } ...
#include<bits/stdc++.h> using ll = int_fast64_t; using P = std::pair<ll,ll>; using PP = std::pair<ll,P>; #define REP(i,b,e) for(int i=b; i<e; i++) #define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");} #define fi first #define se second const int MOD = 1e9+7; int dx[] = {0, 1, 0, -1, 1, 1, -1, ...
#include<bits/stdc++.h> using namespace std; #define int long long #define fo(i,a,b) for(int i = a; i<b ; i++) #define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define pb push_back #define M 1000000007 int mod(int x){ return ((x%M + M)%M); } int add(int a,int b){ return mod(mod(a)+mod(b)...
#pragma GCC optimize ("O2") #pragma GCC target ("avx") //#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 co(...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <sstream> #include <vector> #include <set> #include <map> #include <stack> #include <cmath> #include <iterator> #include <queue> #define ll long long int using namespace std; int main() { ll n,q; cin>>n>>q; v...
#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 <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; //using mint = modint1000000007; //using mint = modint998244353; template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; } template <typename T> bool chmin(T &u, const T z) {...
#include <iostream> #include <iomanip> #include <cmath> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <tuple> #include <string> #include <list> using namespace std; long long min(long long int a,long long int b){ if(a>b){ return b; }else{ return a; } } l...
#include <bits/stdc++.h> using namespace std; int main() { int64_t N; cin >> N; vector<int64_t> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<int64_t> B(N); int64_t sum = 0; for (int i = 0; i < N; i++) { sum = sum + A[i]; B[i] = sum; } vecto...
/** * author: tomo0608 * created: 27.02.2021 21:15:09 **/ #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; typedef pair<int,int> pii; typedef pair<long long, l...
#include <bits/stdc++.h> using ll = long long; #define rep(i,n) for(int i = 0;i < (int)(n); i++) using namespace std; int main() { int A, B, C, D; cin >> A >> B >> C >> D; if (C * D - B == 0)cout << -1; if (C * D - B < 0)cout << -1; if (C * D - B > 0){ int N = A / (C * D - B); if (A % (C * D - B) != 0)cout <<...
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <fstream> #include <iomanip> #include <iostream> #include <istream> #include <map> #include <math.h> #include <numeric> #include <ostream> ...
#include <iostream> using namespace std; int main() { int A, B; cin >> A >> B; if (A+B >= 15 && B >= 8) { cout << 1 << endl; } else if (A+B >= 10 && B >= 3) { cout << 2 << endl; }else if (A+B >= 3) { cout << 3 << endl; }else { cout << 4 << endl; } }
#include<bits/stdc++.h> using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a, b, sum = 0; while(cin >> a >> b){ sum += a + b; if(sum >= 15 and b >= 8) cout << "1\n"; else if(sum >= 10 and b >= 3) cout << "2\n"; else if(sum >= 3) cout << "3\n"; else ...
#include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<algorithm> #include<queue> #include<vector> #include<cstring> #include<map> #include<set> #include<cstdlib> #include<bitset> using namespace std; #define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef long long ll; ll a[66]; ll n; i...
#include<iostream> #include<vector> #include<string> #include<cstdio> #include<algorithm> #include<iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; const ll LLMAX = (1llu<<(sizeof(ll)*8-1)) - 1; const int IMAX = (1llu<<(sizeof(int)*8-1)) - 1; int N; string s[100]; ull dp[100][2];...
//Time to take charge! #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define MAX 200110LL #define MOD 1000000007LL #define INF 1000000000000000000LL ll modularExp(ll x, ll n) { x %= MOD; if (n == 0) { return 1; }else if (n & 1) { return (x * (mo...
#include<bits/stdc++.h> #define int long long using namespace std; const int maxn = 200010, mod = 1000000007; int read() { int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w; } struct Seg{ int tot,s[maxn*1...
#include<bits/stdc++.h> #define LL long long using namespace std; LL a[9]; template<typename T> inline void read(T &x) { x=0;T w=1;char c=getchar(); while(!isdigit(c)){if(c=='-')w=-1; c=getchar();} while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0'; c=getchar();} x*=w; } int main() { for(LL i=1;i<=4;++i) read(a[i]); sort(...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <cstring> #include <utility> #include <numeric> using namespace std; int main(){ int N; cin >> N; vector<int> A(2 * N); for(int i = 0; i < 2 * N; i++){ cin >> A[i]; } vector<pair<in...
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for...
/** * CODE * BY * VIKAS VERMA * * $$Always Check for Constraints */ #include <bits/stdc++.h> using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) #define Fo(i, n) for (int i = 1; i <= n; i++) #define fr(i, n) for (ll i = n - 1; i >= 0; i--) #define REP(l, r) for (int i = l; i < r; i++) #define printc...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i)) #define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i)) #define ALL(x) std::begin(x), std...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; using vv = vector<vector<int>>; const int INF = (int)1e9; const LL LINF = (LL)1e18; string path(int si, int sj, int ti, int tj){ int di = ti - si, dj = tj - sj; string s; ...
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define eb emplace_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define a first #define b second #d...
#include <iostream> #include <vector> using namespace std; #define ll long long vector<int> primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}; int main() { std::ios::sync_with_stdio(false); ll a, b, sol = 0; cin >> a >> b; vector<ll> dp(1 << 20); dp[0] = 1;//the empty set ...
#include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; const ull maxn=800005; ull w[maxn]; const ull mod=1e9+7; ull head[maxn], to[maxn], nex[maxn], val[maxn], cnt, dep[maxn]; void add(ull i, ull j, ull w){ cnt++; to[cnt]=j; val[cnt]=w; nex[cnt]=head[i]; head[i]=cnt; } void df...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<ll,ll,ll> using Graph = vector<vector<Pr>>; ll mod = 1000000007; int main() { //GraphInput ll N; cin >> N; Graph G(N+1); rep(i,N-1){ ll a,b,c...
#include <bits/stdc++.h> using namespace std; // template {{{ #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1) #define whole(f, x, ...) ([&](decltype((x)) container) { return (f)( begin(container), end(container), ## ...
#include<iostream> #include<algorithm> #include<vector> using namespace std; int N_MAX = 501; int M_MAX = 250000; typedef long long ll; typedef pair<ll,int> P; template<class T> void chmin(T &a, T b){if(a>b){a=b;}} int p[501],id[501],res[250000]; void sw(int m){ swap(p[res[m]],p[res[m]+1]); id[p[res[m]]]=res[m]; ...
#include<bits/stdc++.h> using namespace std; using P = pair<int, int>; using ll = long long; template<class T> inline bool chmax(T &a, T b) {if(a < b){a = b; return true;} return false;} template<class T> inline bool chmin(T &a, T b) {if(a > b){a = b; return true;} return false;} #define rep(i,n) for(int i = 0; i < (n)...
#include <iostream> #include <cmath> #include <string> #include <vector> #include <queue> #include <unordered_set> #include <map> #include <algorithm> using namespace std; using ll = long long; #define rep(i, n) for(int i=0;i<(int)n;i++) struct Edge { int to; // 隣接頂点番号 long long w; // 重み Edge(int to, long long w...
#include <iostream> #include <vector> #include <map> using namespace std; const int maxn = 1e2 + 10; const int maxm = 1e4 + 10; int n, m; int c[maxn]; bool visited[maxn]; string ans[maxm]; vector<int> G[maxn]; vector<pair<int, int>> edge; map<pair<int, int>, int> edge_ind; void dfs(int v){ visited[v] = true; for(int...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; typedef unsigned long long ull; constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/ #de...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (int)(n); i++) #define REP(i,n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define debug(var) do{cout << #var << " : "; view(var);}while(0) template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;ret...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back // g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o const int nax=2e5+5; int par[nax],sz[nax]; map<int,int>adj[nax]; int get(int a){ return (par[a]==a)?a:get(par[a]); } void Union(i...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define lb lower_bound #define ub upper_bound #define fe(x) (*(x.begin())) #define le(x) (*(x.rbegin())) #define pb ...
//@formatter:off #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 rep2(i,s,n) for (int i = int(s); i < int(n); ++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back #de...
#include<bits/stdc++.h> using namespace std; int main() {int a,b,c,d; cin>>a>>b>>c>>d; int ans=-1000000; for(int i=a;i<=b;i++){ for(int j=c;j<=d;j++){ ans=max(ans,i-j); }} cout<<ans; }
#include<iostream> #include<iomanip> #include<limits> #include<vector> #include<algorithm> #include<bitset> #include<string> #include<queue> #include<tuple> #include<cmath> #include<unordered_set> #include<iterator> #include<sstream> #include<set> using namespace std; #define endl "\n" typedef long long ll; typedef st...
#include <iostream> #include <algorithm> using namespace std; int main() { int a, b; cin >> a >> b; for (int g = b; b > a; g--){ if(b/g-(a-1)/g >=2){ cout << g << endl; return 0; } } }
#include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define vi vector<int> #define vl vector<ll> #define vvi vector<vector<int> > #define ss second #define ff first #define ll long long #define int ll #define popcount(x) __builtin_popcountll(x) #define pii pair<int , int> #define ar...
#include<bits/stdc++.h> using namespace std; int main(){ double sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy; gy*=-1; double a=(sy-gy)/(sx-gx); cout<<fixed<<setprecision(10)<<sx-sy/a<<endl; }
#include<bits/stdc++.h> // #pragma GCC target("fpmath=387") // Turns on excess precision using namespace std; const int p = 31; const int m = 998244353; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef int in; #define ar array #define ff first #define ss second #include<ext/pb_ds/as...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ string reorigin; cin >> reorigin; string origin = reorigin; reverse(origin.begin(), origin.end()); if (origin.compare(reorigin) == 0){ printf("Yes"); } else{ int size = origin.size(); ...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 7; const double PI = 3.14159265358979; #define ALL(x) x.begin(),x.end() bool isPal(string s){ bool ret = true; for(int i = 0; i < s.size()/2; i++){ if(s.at(i) != s.at(s.size()-1-i)){ ...
#pragma GCC optimize("Ofast") //#pragma GCC target("avx2") #pragma GCC optimize("unroll-loops") #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 mulflo...
#include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long #define rep(i,j,n)...
#include<bits/stdc++.h> using namespace std; int main() { char ch[1010]; int len,i,x; cin>>ch; len=strlen(ch); for(i=0;i<len;i++){ x=i+1; if(x%2==0){ if(ch[i]>=97 && ch[i]<=122){ cout<<"No"<<"\n"; return 0; } } ...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define rng(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i) #define per(i, b) gnr(i, 0, b) #define all(obj) begin(obj), end(obj) #define allr(ob...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for(ll i = 0; i < (ll)(n); ++i) #define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i) 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=...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <sstream> #include <numeric> #include <map> #include <set> #include <unordered_set> #include <unordered_map> #include <queue> #include <vector> using namespace std; typedef pair<int, int> II; int solve(int N, int ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string s; cin >> s; string s2 = s; reverse(s2.begin(), s2.end()); if(s == s2){ cout << "Yes"; return 0; } int index = 0; while(ind...
#include<iostream> #include<string> using namespace std; int ten(int num){ int digit = 0; while(num!=0){ num/=10; digit++; } return digit; } int main(void){ int num; cin >> num; while(num > 0){ if(num %10 == 0){ num /= 10; }else{ break; } } int num2 = 0; int digit = ...
//#include "bits/stdc++.h" #define _USE_MATH_DEFINES #include<cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <deque> #include <algorithm> #include <functional> #include <iostream> #include <list> #include <map> #include <array> #include <unordered_map> #include<unordered_set> #include <numeric...
#include <bits/stdc++.h> #pragma GCC optimize(2) #include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<cmath> #include<cstring> #include<bitset> #include<stack> #include<time.h> #define X first #define Y second #define PB push_b...
#include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { int n;cin>>n; string s;string t;cin>>s>>t; int prev=-1; queue<int>q; int ans=0; for(int i=0;i<n;i++) { if (t[i] == '1') q.push(i); if (s[i] == '1') { if (prev != -1) {...
#include<bits/stdc++.h> #define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++) #define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--) #define pii pair<int,int> #define fi first #define se second #define PB push_back #define ll long long #define ull unsigned long long #define y1 orzkcz using namespace std; const int N...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int K = 305; const int N = 200010; const int MOD = 998244353; const ll INV = 1 + MOD >> 1; int n, k; ll a[N], pwr[N], sum[K], two[K], comb[K][K]; int main() { cin >> n >> k; for (int i = 0; i <= k; ++i) comb[i][0] = 1; for (int i = 1; ...
#include<bits/stdc++.h> using namespace std; typedef long long ll;typedef double db; typedef pair<int, int> pii;typedef pair<ll, ll> pll; typedef pair<int,ll> pil;typedef pair<ll,int> pli; #define Fi first #define Se second #define _Out(a) cerr<<#a<<" = "<<(a)<<endl const int INF = 0x3f3f3f3f, MAXN = 1e6 + 50; const ll...
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <string> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <ctime> #include <cassert> #include <fstream> #include <stack> #include <random> #include <i...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #define dumpv(...) #endif #define rep(i, n) for (int i = 0; i < (n); i++) #define mins(x, y) (x = min(x, y)) #define maxs(x, y) (x = max(x, y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; us...
#include <iostream> #include <iomanip> #include <vector> class union_find { const int N; // the number of nodes int M; // the number of trees std::vector<int> parent, sz; public : union_find(const int& n) : N(n), M(n), parent(n, -1), sz(n, 1) {} const int& root(const int& k) {return ((parent[k] == -1)?k:(parent[...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll INF = 9223372036854775807; const ll MOD = 1000000007; const long double PI = acos(-1); #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define o0(a) cout<<a<<" " #define o1(a) cout<<a<<"\n" #d...
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> #include <set> #include <map> #include <queue> #include <deque> #include <bitset> #include <math.h> #include <random> #include <chrono> #include <assert.h> using namespace std ; using...
// URL #include <iostream> #include <vector> using namespace std; #define loop(i, a, b) for (int i = a; i < b; i++) #define mp make_pair #define pb push_back #define sz size #define rsz resize typedef long long LL; const char NL = '\n'; const char SP = ' '; const char HB[] = "HOBA"; const LL llinf = 9e18; const int ii...
//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>>; ...
#include <bits/stdc++.h> using namespace std; // For Policy Based DS #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; // --------------------------------------- #define endl "\n" #define ff first #define ss second #define int...
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define rep1(i,n) for (int i = 1; i <= (n); ++i) #define bit(n,k) ((n>>k)&1) //nのk bit目 #define vec(T) vector<T> #define vvec(T) vec(vec(T)) using ll = long long; using P = pa...
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define watch(x) cout << (#x) << " is " << (x) << endl #define debug cout << "hi" << endl #define maxn 3e5+50 using namespace std; typedef long long ll; typedef unsi...
#include <bits/stdc++.h> using namespace std; const int N=1e5+5; int MOD=1e9+9; long long n,a[N],b[N]; int solve() { cin>>n; string s,str1="",str2=""; cin>>s; for(int i=0;i<2*n;i++) { if(i<n) str1+=s[i]; else str2+=s[i]; } bool cur=0; int q; c...
#include<iostream> #include<vector> #include<algorithm> #include<random> #include<map> long long int realOdometer = 0; long long int manhattanOdometer = 0; long long int generalAverage = 0; using namespace std; int main(){ pair<int, int>s, t; map<pair<pair<int, int>, pair<int, int>>, pair<int, int>>distance; int ...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i<n; i++) #define repx(i, l, n) for(int i=l; i<n; i++) #define all(v) v.begin(), v.end() #define show(x) cout << #x << ": " << x << endl; #define list(x) cout << #x <<...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; using namespace __gnu_pbds; #define endl "\n" #define fi first #define se second #define pb push_back...
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define pb push_back #define pf pus...
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e3 + 5; long long mod = 1e9 + 7; const int lim = 700; const int lg = 19; const long double eps = 1e-6; ll a[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "...
#include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #pragma GCC optimize("Ofast") using namespace std; //#define int long long #define double long double #define fast ios_base::sync_with_stdio(false); cin.tie(NULL...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define pb(x) push_back(x) #define vll vector<long long> #define pll pair<long long, long long> #define mll map<long long, long long> #define sz(v)...
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; if(n%2==0) cout<<"White"<<endl; else cout<<"Black"<<endl; }
#include <bits/stdc++.h> using namespace std; template <class c> struct re { c b, e; }; template <class c> re<c> range(c i, c j) { return re<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { #ifndef ONLINE_JUDGE ~debug() { cerr << endl; } t...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() ll ans = 0; char battle(char a, char b){ if(a == b) return a; else{ string s = ""; s.push_back(a); s.push_back(b); sort(s.begin(), ...
#include <bits/stdc++.h> 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 ld = long double; using pi = pair<int, int>; using pl = pair<ll, ll>; template <typename T> bool ckmin(T &a, const T &b) ...
#include <bits/stdc++.h> #include <chrono> #include <math.h> using namespace std; #pragma GCC optimize("-O3") #define endl "\n" #define mp make_pair #define st first #define nd second #define pii pair<int, int> #define pb push_back #define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(12)...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int(i)=0;i<(n);i++) int main(){ int h,w,ans=0; vector<string> s(11); cin>>h>>w; REP(i,h) cin>>s.at(i); REP(i,h) REP(j,w){ if(s.at(i).at(j)=='#'){ int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1}; bool f[4]={0,0,0,0}; REP(k,4){ ...
#include"bits/stdc++.h" using namespace std; #define int long long #define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define endl '\n' #define mod 1000000007 int power(int n, int k) { if (k == 0) { return 1; } int curr = power(n, k / 2); if (k % 2 == 0) { return ((curr ...
#include<bits/stdc++.h> #define pb push_back #define pf push_front #define f1 first #define f2 second #define ll long long #define pii pair<int,int> #define fastio() cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) //no scanf #define fileio(code) freopen("code.in","r",stdin);freopen("code.out","w",stdou...
#include<bits/stdc++.h> using namespace std; int main(){ long double n;cin>>n; long double ans=0; for(int i=1;i<n;i++)ans+=n/i; cout<<setprecision(16)<<ans<<endl; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #incl...
#include<bits/stdc++.h> #define pi 3.141592653589793238 #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #defin...
#include <bits/stdc++.h> using namespace std; template<int M> struct static_mint { static_assert(0 < M, "Module must be positive"); int val; static_mint(): val() {} static_mint(long long x) : val(x % M) { if (val < 0) val += M; } static_mint pow(long long n) const { static_mint ans = 1, x(*this); while (n) { if ...
#include<bits/stdc++.h> #define int unsigned long long #define all(x) begin(x), end(x) #define SZ(x) ((int)(x).size()) #define EB emplace_back #define PB push_back #define PP pop_back #define MP make_pair #define F first #define S second #define de(x) if(x && x == MODE) #define MODE 1 using namespace std; typedef pai...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define lowbit(x) ((x)&(-(x))) #define mid ((l+r)>>1) #define lson rt<<1, l, mid #define rson rt<<1|1, mid+1, r #define fors(i, a, b) for(int i = (a); i < (b); ++i) #define all(vec) vec.begin(),vec.end() using namespace std; const int maxn = 1e5 + 5; int...
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = std::vector<int>; using Vl = std::vector<ll>; using Pii = std::pair<int, int>; using Pll = std::pair<ll, ll>; constexpr int I_INF = std::numeric_limits<int>::max(); constexpr ll L_INF = std::numeric_limits<ll>::max(); templ...
#include<bits/stdc++.h> using namespace std; #define int long long int #define vi vector<int> #define pb push_back #define ff first #define ss second #define ppi pair<int,int> #define forn(i,n) for(int i=0;i<n;i++) #define M 1000000007 #define all(x) x.begin(), x.end() #define fastio ios_base::sync_with_stdio(false);ci...
#include<bits/stdc++.h> using namespace std; int main() { int a; cin>>a; cout<<a-1; }
#include <bits/stdc++.h> using namespace std; int main() { char A,B,C; cin>>A>>B>>C; if (A==B&&B==C) cout <<"Won" << endl; else cout<<"Lost"<< endl; }