code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<bits/stdc++.h> using namespace std; using i64 = long long; using u64 = unsigned long long; struct debug { ~debug(){cerr << endl;} template<class c> debug& operator<<(c x) {cerr << x; return *this;} template<class c, class d> debug& operator<<(pair<c, d> x) {*this << "(" << x.first << ", " << ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long long, long long>; constexpr char ln = '\n'; constexpr long long MOD = 1000000007; //constexpr long long MOD = 998244353; constexpr long long INF = 1000000000 + 100; constexpr long long LINF = 1000000000000000000 + 100; #define al...
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; if(a+b>=15&&b>=8) { cout<<1; return 0; } else if(a+b>=10&&b>=3) { cout<<2; return 0; } else if(a+b>=3) { cout<<3; return 0; } else { c...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long #define lld long double #define inf 1000000000 #define pii pair<int,int> #define fi first #define se second #define pb push_back #define mod 1000000007 #define mod2 998244353 #define all(x) ...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i ) typedef std::pair<int,int> pint; using namespace std; typedef long long ll; int main(){ int N; cin >> N; vector<pint> p(N); rep(i,N){ cin >> p[i].first >> p[i].second; } int count = 0; for(int i = 0;i < (N - 1)...
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <cmath> #include <string> #include <iomanip> #include <deque> #include <queue> #include <stack> #include <set> #include <complex> #include <ctime> #include <bitset> // #include <atcoder/all> #include <fstream> #include <random> #include ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define MOD 1000000007 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ...
///Bismillahir Rahmanir Rahim #include "bits/stdc++.h" #define ll long long #define int ll #define fi first #define si ...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define pi (acos(-1.0)) #define fff ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; int main() { fff; long long r, x, y; cin>>r>>x>>y; long double d = sqrt(x*x*1.0 + y*y*1.0); long long dd= ceil(d/r); ...
#include <bits/stdc++.h> #define ll long long int #define uu first #define vv second #define pii pair<int,int> #define pll pair<ll,ll> #define tp tuple<int,int,int> #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) using namespace std; const int ...
#include<bits/stdc++.h> using namespace std; #define PI 3.14159265 #define seive_len 10000001 typedef long long int lli; vector<bool> seive(seive_len, true); const int MOD = 1000000007; lli primeSeive[seive_len]; lli gcd(lli a, lli b) { if(b == 0) return a; return gcd(b, a%b); } lli lcm(lli a, lli b) { ...
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<map> #include<stack> #include<queue> #include<set> #include<vector> #define inf 0x3f3f3f3f using namespace std; typedef long long ll; const ll mod = 1e9+7; const ll maxn = 200010; ll a[200010],b[200010],ans[200010]; struc...
/* dont stick to an approach */ #include <iostream> #include <iomanip> #include <cmath> #include <string> #include <algorithm> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> #include <numeric> #include <cstdlib> using namespace std; typedef l...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) int a, b; int main(){ scanf("%d%d", &a, &b); if((a+b) >= 15 && b >= 8){ puts("1"); }else if((a+b) >= 10 && b >= 3){ puts("2"); }else if((a+b) >= 3){ puts("3"); }else puts("4"); }
#include<iostream> #include<string> #include<queue> #include<map> #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef long long ll; ll split(ll n) { ll i, j, te, x, xlen; for (i = 1, xlen = 0; (te = i * (i - 1) / 2) < n; i++) { x = n - te; if (x % i == 0) { ...
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0);ios_base::sync_with_stdio(0); string to_string(string s) { return '"' + s + '"';} string to_string(char s) { return string(1, s);} string to_string(const char* s) { return to_string((string) s);} string to_string(bool b) { return (b ? "true" : "fa...
#pragma GCC optimize("O3") // #include <atcoder/all> // using namespace atcoder; #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; // gp_hash_table<int, int> mapka; using namespace std; #define PB push_back #define MP make_pair #define LL long long #define int LL #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mp make_pair #define fr first #define sc second template<class T> T T_INF(){ return 1000000000000000000; } template<> int T_INF<int>(){ return 1000000000; } template<int MOD> struct modint{ ull val; modint(...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<int> x(n); vector<int> y(n); vector<int> posx(n, 0); vector<int> posy(n, 0); iota(posx.begin(), posx.end(), 0); iota(posy.begi...
#include <iostream> #include <algorithm> #include <utility> using namespace std; pair<int, int> p[400009]; int st[800009], lz[800009]; void lazy(int tn, int s, int e) { if (lz[tn] != 0) { st[tn] += lz[tn]; if (s != e) { lz[tn * 2] += lz[tn]; lz[tn * 2 + 1] += lz[tn]; } lz[tn] = 0; } } void update(in...
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #incl...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using P = pair<ll,ll>; #define pb push_back int main(){ vvl tate(29, vl(30,0)); vvl yoko(30, vl(29...
/* stuff you should look for * int overflow, array bounds, uppercase/lowercase * special cases (n=1?) * do sth. instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */ #include<cstdio> #include<string> #include<iostream> #include<map> char s[15]; std::map<int,std::string> mp; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct sa{ string nam; int gd; }a[1005]; int n; bool cmp(sa x,sa y){ return x.gd<y.gd; } int main(){ cin>>n; for(int i=1;i<=n;++i){ cin>>a[i].nam>>a[i].gd; } sort(a+1,a+n+1,cmp); cout<<a[n-1].nam; return 0; ...
#include <bits/stdc++.h> using namespace std; int k, n, dep[200010]; char vis[200010]; vector <int> gl[200010]; int check(const int &u, const int &d, int &cnt); int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif scanf("%d%d", &n, &k); for (int i = 1; i < n; ++i) { int u, v; scanf("%d%d", &u, &v);...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <vector> #include <algorithm> using namespace std; const int LOG = 22; vector<int> G[200010]; int parent[25][200010]; int d[200010]; void dfs(int s, int p){ parent[0][s] = p; for(int v:G[s]){ ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int x[2010]; int y[2010]; int main() { int n,t,li,ri,ans; cin >> n; rep(i,n){ cin >> t >> li >> ri; li*=2; ri*=2; if(t==2)ri--; if(t==3)li++; if(t==4){ li++; ri--; } x[i]=li; y[i]=ri; } ans...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll INF = 1e9+7; int main(){ ll n; cin >> n; double t, a, b; vector<pair<double, double>>v; for(ll i=0; i<n; i++){ cin >> t >> a >> b; if(t == 1) v.push_back(make_pair(a, b)); else if(t == 2) v.push_back(make_pair(a, b-0.5)...
#pragma GCC optimize("O3") #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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> // find_by_order(k): It returns to ...
#include<bits/stdc++.h> #define int long long using namespace std; #define rep(i, n) for(int i=0;i<(n);++i) typedef pair<int, int> pii; const int INF = 1l << 60; int N, M; vector<pair<int, pii>> G[100010]; int dist[100010]; //時刻tかそれ以降にCi=c,Di=dの道の通行を始めるとき、最短で到着する時刻 int earliest(int c, int d, int t) { int T = sqr...
#include<iostream> #include<math.h> #include<bits/stdc++.h> #include<queue> #include<cstdio> #include<vector> #include <algorithm> #include<map> #define rep(i,n) for (int i=0;i<(n);++i) using ll = long long; using namespace std; using P = pair<int,int>; #define INF 1000000000 int main(){ map<char,ll> mp; vector<stri...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // Common file // #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update // #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; //using namespace __gnu_pbds; #define pb push_back #define INF 1000000000 #d...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { string s; string tmp = "110"; int n; cin >> n; cin >> s; ll ans = 0; for (int i = 0; i < 3; i++) { bool ok = 1; for (int j = 0; j < n; j++) if (s[j] != tmp[(i + j) % 3]) ...
#include<bits/stdc++.h> using namespace std; const int64_t MAX = 10000000000; int64_t is_valid(string &S, string &T){ int64_t ret = -1; for(int i=0; i<S.size() - T.size()+1; i++){ bool flag = true; for(int j=0; j<T.size(); j++){ if(S[i+j] != T[j]){ flag = false; } } if(flag){ ...
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <vector> 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...
#include <cmath> #include <iostream> #include <map> #include <utility> #include <vector> #define LOOP(n) for (int _i = 0; _i < (n); _i++) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = (n); i >= 0; --i) #define FOR(i, r, n) for (int i = (r); i < (n); ++i) using namespace std; using ll ...
#include<bits/stdc++.h> using namespace std; bool _DD = false; #define _D(a)if(_DD)cout<<#a<<':'<<a<<" | "; #define DBG(a){_D(a);if(_DD)cout<<'\n';} #define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';} #define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';} #define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n'...
#include <iostream> int a[100]; int b[100]; int used[200]; int main() { int n; std::cin >> n; for (int i = 0; i < n; ++i) { std::cin >> a[i] >> b[i]; if (a[i] != -1) ++used[a[i] - 1]; if (b[i] != -1) ++used[b[i] - 1]; if (a[i] != -1 and b[i] != -1 and a[i] >= b[i]) { ...
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <numeric> #include <ctime> #include <comple...
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> divisors (ll n) { vector<ll> dest; for (ll i = 1; i < floor(pow(n, 0.5) + 1); i++) { if (n % i == 0) { dest.push_back(i); if (floor(n / i) != i) { dest.push_back(floor(n / i)); } } } sort(dest.begin...
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; int n; vector<int>v; string s; int cache[20][200]; int dp(int i, int s...
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include<iterator> #include<complex> #in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; //bool vis[1000]; //int x[]={1,-1,0,0}; //int y[]={0,0,1,-1}; //int f=0; //"''; ll a,b,k; ll util(ll a,ll b){ ll dp[a+b+1][a+b+1]; memset(dp,-1,sizeof(dp)); for(int i=0;i<=a+b;i++){ for(int j=0;j<=i;j++){ if(j==0|...
#include<bits/stdc++.h> 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> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long #define inf 1000000000 #define pii pair<int,int> #define fi first #define se second signed main(){ fastio int t; //cin>>t; t=1; while(t--){ int v,t,s,d; c...
#include <bits/stdc++.h> using namespace std; #define int long long #define ull unsigned long long #define si(x) int x;cin>>x; #define w(x) si(x); while(x--) #define fo(i,n) for(int i=0 ; i<n ; i++) #define rea(a,n) int a[n];fo(i,n){cin>>a[i];} #de...
#include <bits/stdc++.h> using namespace std; #include <algorithm> #define ll long long int #define pb push_back #define fo(i, n) for (int i = 0; i < n; i++) #define vct vector<long long int> const ll INF = 1e18; const ll NINF = -1e18; #define f first #define s second int main() { ios_base::sync_with_stdio(false);...
#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 <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 <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long int #define pb push_back #de...
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; int main() { int A, B; cin >> A >> B; cout << (A + B)...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll=long long; using ld=long double; //using mint = modint1000000007; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) #define PI acos(-1) #define oo 2e18 template<typename T1, typename T2> bool ...
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <string> #include <iomanip> #define _USE_MATH_DEFINES #include <math.h> using namespace std; #define rep(i,n) for(i=0;i<n;i++) #define repl(k,n) for(k=0;k<n;++k) int main() { long long int n; cin >> n; long long int half = (long ...
#include<iostream> using namespace std; int sum(int x) { int ans=0; for(int j=2;j<x;j++) { int s=0; if(x%j==0) { while(x%j==0) x/=j,s++; } ans+=s; } if(x>1) ans++; return ans; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { if(n==1) cout<<"1"; else { cout<<" "<<sum(i)+1; } } }
#include "bits/stdc++.h" #define rep(i,n) for(int i=0;i<(n);++i) #define reps(i,cc,n) for(int i=cc;i<(n);++i) #define dreps(i,cc,n) for(int i=cc;i>(n);--i) #define llreps(i,cc,n) for(long long i=cc;i<(n);++i) #define ALL(v) begin(v),end(v) #define rALL(v) rbegin(v),rend(v) using namespace std; using ll = long long; us...
#include <bits/stdc++.h> using namespace std; #define ll long long int #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> #define ld long double #define ff first #...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second #define mp make_pair #define scan(a) scanf("%d", &a) #define scanl(a) scanf("%lld", &a) #define scand(a) scanf("%lf", &a) #define ...
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); for(auto& a : A) cin >> a; int mx = 0, ans; for(int i = 2; i <=1000; i++){ int cnt = 0; for(int j = 0; j < N; j++){ i...
#include<bits/stdc++.h> using namespace std; #define int long long int read(){ int x = 0, f = 1; char ch; while(!isdigit(ch = getchar())) (ch == '-') && (f = -1); for(x = ch ^ 48 ; isdigit(ch = getchar()) ; x = (x << 3) + (x << 1) + (ch ^ 48)); return x * f; } const int N = 1e6 + 9, p = 998244353; int ...
/* dont stick to an approach */ #include <iostream> #include <iomanip> #include <cmath> #include <string> #include <algorithm> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> #include <numeric> #include <cstdlib> #include <chrono> using namespa...
// #pragma GCC optimize("Ofast") #include <vector> #include <iostream> #include <utility> #include <cmath> #include <set> #include <algorithm> #include <queue> #include <string> #include <utility> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> vll; typedef vector<int> vi...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; #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 REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n) - 1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define sz(v) (int)v.size() co...
#include <bits/stdc++.h> #include <bits/extc++.h> #define double long double #define rbtree __gnu_pbds::tree<int,__gnu_pbds::null_type,less<int>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> #define int ll #define IOS ios_base::sync_with_stdio(false);cin.tie(0); #define pb push_back #define ALL...
#include <algorithm> #include <cassert> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #include <limits.h> using namespace std; typedef long long ll; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } ...
#include<bits/stdc++.h> using namespace std; void __print(int x){cout<<x;}void __print(long x){cout<<x;} void __print(long long x){cout<<x;}void __print(unsigned x){cout<<x;} void __print(unsigned long x){cout<<x;}void __print(unsigned long long x){cout<<x;} void __print(float x){cout<<x;}void __print(double x){cout<<x...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Vi = vector<ll>; int main () { int L, R; cin >> L >> R; Vi num(R + 10, 0); bool db[1000100]; for (int i = 0; i <= R; i ++) { db[i] = true; } ll ans = 0; for (int i = 2; i <= R; i ++) { if (db[i]) { ll kj = (R / i) - ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vc<vc<T>>; template<class T> using vvvc = vc<vvc<T>>; template<class T> using vvvvc = vvc<vvc<T>>; template<class T> using PQ = priority_queue<T>; template<class T> using invPQ = pri...
#include<bits/stdc++.h> using namespace std; int N; long long a; int t; int Q; long long x; long long mi=0x3f3f3f3f3f3f3f3f; long long ma=0xcfcfcfcfcfcfcfcf; long long add; int main() { scanf("%d",&N); while(N--) { scanf("%lld %d",&a,&t); if(t==2) { ma=max(ma,a); ...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x){ x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();} while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();} x *= f; } inline void write(int x){if (x > 9) write(x/10); putchar(x%...
//#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<st...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; using ll=long long; int main(void){ int n,m; cin >> n >> m; if(m==0){ cout << 1 << endl; return 0; } vector<int> a(m); rep(i,m){ cin >> a[i]; a[i]--; } sort(a.begin(),a.end()); //set<int> s; vector<i...
#include <iostream> #include <algorithm> using namespace std; int a[500005]; int main(int argc, char** argv) { int n,m; cin >> n >> m; for(int i=1;i<=m;i++) cin >> a[i]; sort(a+1,a+m+1); a[m+1]=n+1; int mn=1e9; for(int i=1;i<=m+1;i++) if(a[i]-a[i-1]-1) mn=min(mn,a[i]-a[i-1]-1); int ans=0; for(int i=1;i<=m+...
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c)) #define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c)) #defin...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #d...
#include<bits/stdc++.h> #define ll long long int #define mk make_pair #define pb push_back #define INF (ll)6e18 #define pii pair<ll,ll> #define mod 1000000007 #define f(i,a,b) for(ll i=a;i<b;i++) #define fb(i,a,b) for(ll i=a;i>b;i--) #define ff first #define ss second #define srt(v) if(!v.empty())sort(v.begin(),v.end(...
#include <stdio.h> #include <vector> #define cm (1 << 17) char cn[cm], *ci = cn + cm, ct; inline char getcha() { if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; } return *ci++; } inline int getint() { int A = 0; while ((ct = getcha()) >= '0') A = A * 10 + ct - '0'; return A; } int main()...
#include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(int 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 pl(x) pri...
#pragma region #include <bits/stdc++.h> #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define prec fixed<<setprecision(9) #define all(x) x.begin(),x.end() using ll = long long; using namespace std; int mod = 1e9+7; string to_string(string& s) {return '"'+s+'"';...
/*pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops")*/ #include <bits/stdc++.h> using namespace std; 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 >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define r...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define yes() cout << "Yes" << endl #define no() cout << "No" << endl using ll = long long; using ld = long double; using P = pair<int,int>; int main() { int a,b,c; cin>>a>>b>>c; if(a*a+b*b<c*c)yes(); else no(...
// Create by JJL #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <unordered_map> #include <set> #include <queue> #define fi first #define se second using namespace std; typed...
#include<iostream> #include<cstring> #include<cctype> using namespace std; const int BUF = 200005; const int MOD = 1000000007; int add(int a, int b) { return (a + b) % MOD; } int mul(int a, int b) { return 1LL * a * b % MOD; } string N; int K; void read() { cin >> N >> K; } int ch2v(char ch) { i...
#include <iostream> #include <fstream> #include <string> #include <vector> #include <list> #include <map> #include <set> #include <unordered_set> #include <unordered_map> #include <algorithm> #include <cmath> #include <functional> #include <utility> #include <tuple> #include <numeric> #include <queue> #include <cstring...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <utility> #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <limits> #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; template<clas...
#include <bits/stdc++.h> #include <string> #define ll long long #define ld long double #define iter vector<ll>::iterator #define mp make_pair #define pb push_back #define all(x) x.begin(),x.end() #define rep(i,n) for(ll i=0;i<n;i++) #define rep1(i,n) for(ll i=1;i<=n;i++) #define frep(i,a,b) for(ll i=a;i<=b;i++) #defi...
#include <bits/stdc++.h> using namespace std; int main() { int N; string S; cin >> N >> S; int ans = 0; for (int i = 0; i < N; ++i) { int c1 = 0, c2 = 0; for (int j = i; j < N; ++j) { if (S[j] == 'A') c1++; else if (S[j] == 'T') ...
#include <bits/stdc++.h> //#include <atcoder/modint> //#include <atcoder/math> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ...
#include<bits/stdc++.h> using namespace std; #define hi ios_base::sync_with_stdio;cin.tie(NULL);cin.tie(NULL); typedef long long int ll; typedef long double ld; typedef long long unsigned llu; #define test int test; cin>>test; while(test--) #define loop(i,n,k) for(int i=n;i<k;i++) #define rloop(i,n,k) for(int i=...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理} using namespace std; using ll = long long; using P = pair<int, int>; #include <unordered_set> int main() { ll n,count=1, sum=0; cin >> n; vector<ll> v(n); rep(i,n) cin >> v[i]; sort(v.begin(), v.end()); for (int i=0; i...
#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 <iostream> #include <sstream> #include <vector> #include <algorithm> #include <numeric> #include <cmath> #include <utility> #include <map> #include <list> #include <climits> #include <set> #include <deque> #include <queue> #include <stack> #include <unordered_map> #include <unordered_set> #include <iomanip> #i...
#include <bits/stdc++.h> #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif using namespace std; #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 Clear(a) a = decltype(a)() #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define v...
#include<bits/stdc++.h> #define ll long long #define fr(i,j,k) for(int i=j;i<k;i++) #define f(n) fr(i,0,n) #define f1(n) fr(i,1,n+1) #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() const int mod = 1e9+7; using namespace std; vector<int>v[200005]; vector<int>g[200005]; int dep[200...
#include <iostream> #include <vector> using namespace std; const int INF = (1u<<31) - 1; int main() { int n; cin >> n; long long max_thr = INF, min_thr = -INF; long long max_v = INF, min_v = -INF; for (int i = 0; i < n; i++) { long long a, t; cin >> a >> t; if (t == 1) { max_v += a; min_v += a; } el...
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define ll long long int #define pb push_back using namespace std; const int N = 1e6 + 5; const int MOD = 1e9 + 7; int n, m, ans1, k; vector<pair<int, int> > v, vv; vector<int> ans; int solve(int i){ if(i >= k){ ...
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,m,a[110],b[110],c[110],x[110],y[110],k,ans; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]); scanf("%d",&k); for(int i=1;i<=k;i++) scanf("%d%d",&x[i],&y[i]); for(int i=0;i<=(1<<k)-1;i+...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; #define BOOM ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<pair<int, int>, int> ppi; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector...
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<stack> #include<map> #define ll long long #define MAXN 1000005 #define uns unsigned #define INF 0x3f3f3f3f using namespace std; inline ll read(){ ll x=0;bool f=1;char s=getchar(); while(...
#include<bits/stdc++.h> using namespace std; #define int long long #define For(i,a,b) for(register int i=a;i<=b;++i) #define Down(i,a,b) for(register int i=a;i>=b;i--) #define reg register namespace yspm{ inline int read(){ int res=0,f=1; char k; while(!isdigit(k=getchar())) if(k=='-') f=-1; while(isdigit(k)) re...
#include <iostream> #include <vector> #include <queue> #include <stack> #include <map> #include <algorithm> #include <bitset> #include <string> #include <cstdio> #include <cmath> #include <climits> #include <fstream> #include <functional> #include <time.h> using namespace std; const long long INF = 1LL << 60; const lo...
#include <bits/stdc++.h> #define F first #define S second #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) #define bck(i, a, b) if ((i) >= (a) && (i) < (b)) #define trav(x, a) for (auto &x : (a)) #define sz(a) (int)(a).size() #define all(x) (x).begin(), (x).end(...
#include<bits/stdc++.h> #define ll long long #define ljc 998244353 #define bit __builtin_popcount using namespace std; #define gc getchar inline ll read(){ register ll x=0,f=1;char ch=gc(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();} while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();} return (f==1...
#include "bits/stdc++.h" using namespace std; //shorthands #define ll long long #define ld long double #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define mkp make_pair #defin...
#include <stdio.h> #include <queue> #include <set> #include <iostream> using namespace std; typedef long long int llint; llint n; priority_queue<llint> que; int main(){ long n; cin >> n; set<long> ans; for(long d=1;d*d<=n;d++){ if(n%d==0){ ans.insert(d); ans.insert...
/* C++ */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll,ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for(ll i = ll(0); i < ll(n); i++) #define Rep(i, n) for(ll i = ll(1); i < ll(n); i++) #define ALL(a) (a).begin(),(a).e...
//#include<math.h> #include<algorithm> #include<stdlib.h> #include<time.h> #include<stdio.h> #include<string.h> #define un unsigned #define srd srand(time(0)) #define ll long long #define con continue #define gtc getchar() #define ptc putchar #define dou double #define eps 0.00000000001 #define opr operator #define cl(...
#include <bits/stdc++.h> #define rei register int using namespace std; int qpow(int x,int p,int mod){ int res = 1; while(p){ if(p & 1) res = 1ll*res * x % mod; x = 1ll*x * x % mod; p >>= 1; } return res; } bool vis[11]; int main(){ int A,B,C; cin >> A >> B >> C; int mod = 1,now = 1; vis[1] = 1; while(1){ now = ...
#include <bits/stdc++.h> using namespace std; int main() { string n; cin>>n; int d = n.size()-1; int count = 0 , c= 0; for(int i = d;i>=0; i-- ){ if(n[i]=='0')c++; else break; } for(int i = 0;i<c; i++ ){ n = '0'+n; } d = d + c ; for(int i = 0 ; i <= d/2 ;i++ ){ if(n[i]!=n[d-i])count=2; } ...
#include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <bitset> #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); i++) using namespace std; int main() { string s; cin >> s; if (s == string(s.rbegin(), s.rend())) { cout << "Yes" << endl; }...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define N 200100 #define MOD 1000000007 //998244353 #define ll long long #define rep(i, n) for(int i = 0; i < n; ++i) #define rep2(i, a, b) for(int i = a; i <= b; ++i) #define rep3(i, a, b) for(int i = a; i >= b; --i) #define eb emplace_back #def...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i,n) for (int i = 0; i < (int)(n) ; i++) #define rep2(i,a,b) for (int i = (a); i < (int)(b); i++) #define repR(i,n) for (int i = (int)(n)-1; i >= 0; i--) #define ENDL '\n' #define pb push_back #define SIZE(a) (int)(a...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; using std::cout; using std::cin; using std::endl; using ll=long long; using ld=long double; ll I=1167167167167167167; ll Q=1e9+7; #define rep(i,a) for (ll i=0;i<a;i++) template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>; temp...
// #define _GLIBCXX_DEBUG // for STL debug (optional) #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex...
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define POPCOUNT(x) __builtin_popcount(x) template <typename T> void chmin(T &a, const T &b) { a = min(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
//全力以赴 #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define PI 3.141592653L #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const ll INF = (ll)1e18; const int N = 3e5 + 5; const ll MOD = 1e9+7; int parent[N]; const int dx[4] = {+1, 0, -1, 0}; const int dy[4] ...
// I've done my sentence but committed no crime #pragma GCC optimize("Ofast") #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define mod (int)(1e9+7) #define flush fflush(stdo...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vll = vector<vl>; using Pll = pair<ll, ll>; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define Rep(i,j,n) for (ll i=(ll)(j);i<=(ll)(n);++i) #define all(v) v.begin(), v.end() #define sz(x) ((int) x.si...
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<stack> #include<bitset> #include<cstdlib> #include<cmath> #include<set> #include<list> #include<deque> #include<map> #include<random> #include<ctime> #include<queue> using namespace std; typedef long lon...
/*Lucky_Glass*/ #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef int ll; const int N=10,M=1e5+10; int n,m; int wei[N],id[N]; ll f[N]; pair<int,int> bri[M]; //(limit,length) inline int Read(int &r){ int b=1,c=getchar();r=0; while(c<'0' || '9'<c) b=c=='-'? -1:b,c...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, k, n) for (int i = k; i < (int)(n); i++) #define repd(i, n) for (int i = n-1; i >= 0; i--) #define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--) #define all(x) (x).begin(),(x).end() #define chmax(x,y...
#include <bits/stdc++.h> using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; typedef long double ldbl; typedef pair<int, int> pii; typedef pair<uint, uint> puu; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<double, double> pdd; typedef vector<int> vi...
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; int dp[2][100005],dpp[2][100005],a[100005]; int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); dp[0][n]=dp[1][n]=1; dpp[0][n]=a[n]; dpp[1][n]=(-a[n]+mod)%mod; for(int i=n-1;i>=1;i--){ dp[0][i]=(dp[1][i+1]+dp[0][i+1])%mod;...
#include <iostream> using namespace std; int main(void){ // Your code here! int a,b,c,d; cin >> a >> b >> c >> d; int ans = a * d - b * c; cout << ans; }
//#include <atcoder/maxflow.hpp> #include <memory> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <sstream> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #include <limits> #include <unordered_map> #include <...
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i,x,n) for(int i = x; i<=n; i++) #define FORO(i,n) for(int i = 0; i<n; i++) #define nl "\n" #define sp " " #define MOD 1000000007 #define pb push_back int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll a,b,c; cin>>a>>b>>c; ...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#include <bits/stdc++.h> using i64 = long long; constexpr int P = 1000000007; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<int> a(n); std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(2)); std::vector<std::vector<int>> cnt(n +...
#include <bits/stdc++.h> //#include <atcoder/modint> //#include <atcoder/math> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for(int i = 0; i < n; i++) #define REPP(i, n) for(int i = 1; i <= n;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,ll> #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1e9; const int MOD = 1...
#include <bits/stdc++.h> #define lol long long #define INF 998244353 using namespace std; int main(){ int a,b; char c; cin>>a>>b; for(int i=0;i<a;i++){ cin>>c; if(c=='o') b++; else if(b!=0) b--; } cout<<b<<"\n"; return(0); }
#include <bits/stdc++.h> #define f(a, n) for (int a = 0; a < n; a++) #define F(a, n) for (int a = 1; a <= n; a++) using namespace std; int main(){ int n, x; string s; cin>>n>>x>>s; f(i, n){ if (s[i] == 'o'){ x++; } else{ if (x > 0) x--; } } cout<<x<<endl; }
#include <iostream> #include <vector> #include <numeric> #include<cstdlib> #include <map> #include <set> #include <algorithm> // std::random_shuffle #define INF (1<<30) #define ll long long #define MAXX 800*800 using namespace std; int A[888][888]; int B[888][888]; int cumul[888][888]; bool Can(int N,int K) { ...
#include <bits/stdc++.h> #include <cassert> typedef long long int ll; using namespace std; // #include <atcoder/all> // using namespace atcoder; // @@ !! LIM(f:>>) // ---- inserted function f:>> from util.cc template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.s...
// #pragma GCC optimize("O3") // #pragma comment(linker, "/stack:200000000") // #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace ::std; // clang-format off template<typename T...
#include<bits/stdc++.h> #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() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (n); i++) #define REP(i, s, n) for (long long i = (s); i <= (n); i++) #define repr(i, n) for (long long i = (n - 1); i >= 0; i--) #define REPR(i, s, n) for (long long i = (s); i >= (n); i--) #define all(v) (v).begin(), (v).end() ...
// Template begins #include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <stdio.h> #include <math.h> #include <iomanip> #include <queue> #include <string.h> #include <string> using namespace std; #define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #defi...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdio> #include <cmath> #include <tuple> #define int long long #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int n, T; int a[40];...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define __ ios_base::sync_with_stdio(0);cin.tie(0); #define fi first #define se second #define pb push_back #define all(x) x.begin(),x.end() #define forn(i,a,n) for(int i=a; i < n; i++) typedef long long int lli; typedef long double Double; typedef pair<in...
#include <bits/stdc++.h> using namespace std; namespace hy { typedef long long LL; typedef vector<int> VI; typedef vector<vector<int> > VVI; typedef pair<int, int> PII; typedef pair<double, double> PDD; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define PB push_back #define SZ(x) ((int)(x).size()) #define ...
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <iomanip> #include <string> #include <cmath> #include <algorithm> #include <vect...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using lint = long int; using llint = long long int; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, k, m; cin >> n >> k >> m; vector<int> points(n - 1); rep(i, n) cin >> points[i]; ...
// Problem: B - Sign of Friendship // Contest: AtCoder - ZONe Energy Programming Contest // URL: https://atcoder.jp/contests/zone2021/tasks/zone2021_b // Memory Limit: 1024 MB // Time Limit: 2000 ms #include <bits/stdc++.h> using namespace std; int main() { int n, D, H; cin >> n >> D >> H; double ans = 0; while (...
#include<bits/stdc++.h> using namespace std; inline int read(){ int res=0; char c; bool zf=0; while(((c=getchar())<'0'||c>'9')&&c!= '-'); if(c=='-')zf=1; else res=c-'0'; while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0'; if(zf)return -res; return res; } const int maxn=1e5...
#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 <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <type_traits> #include <unordered_set> #include <utility> #include <vector> u...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=(n)-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue<x...
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime>...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0); #define mod 1000000007 #define decimal(n,k) cout<<f...
#include <bits/stdc++.h> using namespace std; using ll=long long; using vb=vector<bool>; using vvb=vector<vb>; using vd=vector<double>; using vvd=vector<vd>; using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; using pii=pair<int,int>; using pll=pair<ll,ll>; using tll=tuple<ll,ll>; usi...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b){ ll m = max(a,b); ll n = min(a,b); if(n == 0) return m; else return gcd(n, m%n); } ll extgcd(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 1; y = 0; return a; } ll gcd = extgcd(b, a % b, x, y); l...
#include<bits/stdc++.h> using namespace std; double k; double a,b,c,d,s,p; double f(double x) { return -b/k+a; } int main() { cin>>a>>b>>c>>d; b=-b; k=(b-d)/(a-c); s=f(0); printf("%.10lf",s); return 0; }
#include<bits/stdc++.h> #include<iostream> #include<string> #include<vector> #include<iomanip> using namespace std; int main() { double x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; double t = (((x1 * y2) + (x2 * y1))/(y1 + y2)); cout <<fixed << setprecision(10) <<t << endl; }
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<iomanip> #include <string> #include <math.h> using namespace std; int main(){ int x,y,z; cin>>x>>y>>z; for(int i=0;;i++){ if(y*z<=x*i){ cout<<i-1<<endl; break; } } return 0; }
#include<bits/stdc++.h> using ll = long long int; using namespace std; #define sync ios_base::sync_with_stdio(false); cin.tie(NULL) using ld = long double; #define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1] #define mod 1000000007 #define F first #define S second #include <ext/pb_ds/assoc_container.hpp> #include...
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FIO ios_base::sync_with_stdio(false); cin.tie(0); #define trav(x,a) for (auto& x: a) #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define endl "\n" #define c...
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = (int)1e9+7; signed main(){ cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<int>arr(n+1); for(int i = 1; i<=n; i++){ cin >> arr[i]; } vector<vector<int>>dp(n+1,vector<int>(n+1));// current ans as we iterate thr...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i = 0; i < (long long)(n); i++) typedef long long ll; const long long MOD=1e9+7; int main(){ int n; cin>>n; n*=108; n/=100; if(n<206)cout<<"Yay!"<<endl; else if(n==206)cout<<"so-so"<<endl; else cout<<":("<<endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<pll> vpll; typedef vector<bool> vbl; typedef vector<vector<bool>> vvbl; void INX(){} template<typename Head, typename... Tail> vo...
#include <bits/stdc++.h> using namespace std; int main() { int a,N; string b; cin>>N; vector<pair<int, string>> p(N); for (int i = 0; i < N; i++) { cin>>b>>a; p.at(i)=make_pair(a,b); } sort(p.begin(), p.end()); // tie(a,b) = data; cout<<p.at(N-2).second<<endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll,ll> int main(){ int a,b; cin>>a>>b; cout<<2*a+100-b<<endl; }
#line 2 "header.hpp" //%snippet.set('header')% //%snippet.fold()% #ifndef HEADER_H #define HEADER_H // template version 2.0 using namespace std; #include <bits/stdc++.h> // varibable settings template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1; #define _overload3(_1, _2, _3, name, ...) name #define ...
#include <bits/stdc++.h> using namespace std; #define ffor(i, a, b) for (int i = a ; i <= (int) b ; i++) #define rfor(i, a, b) for (int i = (int) a ; i >= b ; i--) #define vec vector #define PB push_back #define MP make_pair #define MT make_tuple #define F first #define S second using ll = long long int;...
/* * 答え見た * https://atcoder.jp/contests/keyence2021/submissions/19465975 */ #include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; i++) #define debug(x) cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl #define debugvec(v) rep(i, v.size()) cerr << "L" << __LINE_...
#include <bits/stdc++.h> #define int long long using namespace std; const int MAX = 5005, MOD = 998244353; int m, n, k, f[MAX][MAX]; char a[MAX][MAX]; int mul(int x, int k) { if (k == 0) return 1; int tmp = mul(x, k / 2); if (k % 2 == 0) return tmp * tmp % MOD; return tmp * tmp % MOD ...
// SMOKE SHISHA PLAY FIFA // #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define pll pair<ll,ll> #define MP make_pair #define ff first #define ss second #define PB push_back #define mo...
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define MAXN 110000 #define MOD using namespace std; int T,n,m; LL a[MAXN]; int sum[MAXN]; LL work(LL x) { LL L=1,R=2e18; while(L!=R) { LL mid=(L+R)/2; int loc = upper_bound(a+1,a+n+1,mid) - ...
#include <bits/stdc++.h> #define pii pair<int,int> #define S second #define F first using namespace std; const int maxn=2e5+5; struct node{ int x,id; }a[maxn]; bool cmp(node a,node b){ return a.x<b.x; } vector<pii> ans; int n,b[maxn],p[maxn],Id[maxn],cnt; main(){ ios::sync_with_stdio(0),cin.tie(0); cin>...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn #define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa #define db(x) cout << #x << " = " << x << endl #define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用 #define all(x) (x).begin(), (...
#include <bits/stdc++.h> #define err(args...) {} #ifdef DEBUG #include "_debug.cpp" #endif using namespace std; using ll = long long; using ld = long double; template <typename T> using lim = numeric_limits<T>; template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; ...
#include<bits/stdc++.h> int main(){ using namespace std; unsigned long N, M, K; cin >> N >> M >> K; const auto unavailable{[&N, &M, &K]{ vector<unsigned long> unavailable(N + 1); vector<unsigned long> ban; for(unsigned long i{0}, a; i < K; ++i){ cin >> a; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl "\n" ll mod=1000000007; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int main() { IOS; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #end...
#include <vector> #include <complex> #include <unordered_map> #include <unordered_set> #include <iostream> #include <random> #include <queue> #include <algorithm> #include <climits> #include <map> #include <set> #include <stack> #include <sstream> #include <cstring> #include <bitset> #include <deque> using namespace s...
#pragma region Macros #include <bits/stdc++.h> using namespace std; using ll = long long; #define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i) #define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i) #define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME #define REP(...) GET_MACRO_...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> ii; #define DEBUG freopen("in.txt", "r", stdin); struct fastio { fastio() { ios::sync_with_stdio(false); cout << setprecision(10) << fixed; cin.tie(0); } }; fastio _fast_io; const int N = 2...
#include <bits/stdc++.h> using namespace std; #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() #define SIZE(x) ll(x.size()) template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chm...
#include<bits/stdc++.h> using namespace std; int main() { long long n,w;cin>>n>>w; long long a[200001]={},i,j,x,y,z; for(i=0;i<n;i++) { cin>>x>>y>>z; a[x]+=z; a[y]-=z; } for(i=1;i<=200000;i++) { a[i]+=a[i-1]; } for(i=0;i<=200000;i++) { if(a[i]>w) break; } if(i==200...
using namespace std; #include <cstdio> #include <cstring> #include <algorithm> #define N 105 int n; char s[N]; int e[N][N]; int main(){ scanf("%d",&n); for (int i=1;i<=n;++i){ scanf("%s",s+1); for (int j=1;j<=n;++j) e[i][j]=s[j]-'0'; } for (int i=1;i<=n;++i) e[i][i]=1; for (int k=1;k<=n;++k) for (int i=...
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define finf -0x3f3f3f3f #define scNO printf("NO\n"); #define scNo printf("No\n"); #define scno printf("no\n"); #define sc0 printf("0\n"); #define sc1 printf("1\n"); #define scf1 printf("-1\n"); #define scz1 printf("1\n"); #define scYES printf("YES\n")...
#include <bits/stdc++.h> using namespace std; // BEGIN LIB #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() typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<ll> vll; typedef pair<int,...
#include <bits/stdc++.h> using namespace std; template<typename T> void debug(vector<T> item) { for (auto& i : item) { cout << i << " "; } cout << endl; } int64_t dfs(int n, vector<vector<int>>& neb, vector<bool>& vis) { if (vis[n]) return 0; vis[n] = true; int64_t ret = 1; for (int nxt : neb[n]) { i...
#define _USE_MATH_DEFINES #include <iostream> #include <sstream> #include <string> #include <list> #include <vector> #include <queue> #include <algorithm> #include <climits> #include <cstring> #include <cmath> #include <stack> #include <iomanip> #include <tuple> #include <functional> #include <cfloat> #include <map> #i...
// Created at 2021/02/07 22:38 // {TODO}WA, {TODO}min, {TODO}diff // goal: {TODO}min #include <bits/stdc++.h> //#include <atcoder/all> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define rep(i, n) for (lint i = 0, i##_len = n; i < i##_len; i++) #define rep2(i, n) for (lint...
#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; template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } vector<int> table(2500); vector<...
#include <bits/stdc++.h> const long long INF = 1e9; const long long MOD = 1e9 + 7; //const long long MOD = 998244353; const long long LINF = 1e18; using namespace std; #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIB...
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "lin...
#include <bits/stdc++.h> using namespace std; //UnionFindテンプレ class UnionFind { // まとめる 判定 サイズを知る public: // Aから見た親の番号を格納する。rootだったら-1*その集合のサイズ。 vector<int> Parent; // 初期化 UnionFind(int N) { Parent = vector<int>(N, -1); } // Aのrootを調べる int root(int A) { if (Parent[...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #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 = (...
/** * author: shu8Cream * created: 18.04.2021 12:10:02 **/ #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<ll,ll>; using vi = vector<ll>; using vvi = vector<vi>; template<typename T> struct BIT{ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include <bits/stdc++.h> #define mk make_pair #define fs first #define sc second using namespace std; typedef long long ll; typedef long double ld; // please, read the question correctly (do you need set or multiset)??? const int N=510; //check the limits, dummy int a[N][N], b[N][N]; int n, m; int mem[N][N][2]; struct ...
#include<bits/stdc++.h> typedef long long ll; using namespace std; const int N = 2e5 + 5; const int mod = 998244353; void solve() { int n; cin >> n; vector<ll> a(n), sum1(n), sum2(n); for (int i = 0; i < n; i++) { cin >> a[i]; if (!i) { sum1[i] = a[i]; sum2[i] = a[i] * a[i]; } else { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, start, n) for (int i = start; i < (n); i++) using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); ll st1, st2, st3; ll sum1 = 0; // sum(A) ll sum2 = 0; // sum(A^2) rep(i,0,N) { cin >> A.at(i); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> ii; typedef vector <int> vi; #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ff first #define ss second #define f(i,a,b) for(int i = a; i < b; i++) #define fa(i,a,b) for(int i = a; i >= b; i--) co...
#include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false);cin.tie(nullptr) #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define mkp make_pair #define lc(x) ((x)<<1) #define rc(x) (((x)<<1)|1) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef do...
#include <bits/stdc++.h> using namespace std; #define int long long #define quickread \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define hii cout << "Hii there Sparky! \n" #define endl '...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define mp make_pair #define pb push_back #define lp(i,s,f) for(ll i = s; i < ll(f); i++) #define inF freopen("input.in", "r", stdin); #define outF freopen("output.in", "w", stdou...