code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_s...
#include <algorithm> #include <complex> #include <cstdlib> #include <ctime> #include <time.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <numeric> #include <lim...
#include <bits/stdc++.h> using namespace std; void solve(){ int n, s, d; cin>>n>>s>>d; for(int i=0; i < n; i++){ int x, y; cin>>x>>y; if (x < s && y > d) { cout<<"Yes"; return; } } cout<<"No"; } int main(){ #ifdef USE_FILE_IO freopen("input.txt...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define rrep(i,n) for(int i=n-1;i>=0;--i) #define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} #define MAX_N 100001 #define i197 1000000007 using namespace std; typedef long long ll; typedef pair<ll,ll> P1; typedef pair<int,int> Pi; typede...
#include<bits/stdc++.h> //Written by ThiDaiLoc using namespace std; //Team Three Wolves typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll,ll> pll; typedef pair<ll,pll> trp; typedef vector<ll> vi; typedef vector<pll> vp; #define fu(i,a,b) for(ll i=a;i<=b;i++) #def...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1e9; const long long INFLL = 1e18; using ll = long long; ll mat[200000+10][2][2]; ll p[200000+10][2]; ll mix, miy; vector<vector<ll>> cal(ll n, ll p){ vector<vector<ll>> res(2, vector<ll>(2)); if(n == 1){ res[0][0] = 0;...
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL X, Y; map<LL, LL> memo; LL solve(LL y) { if(memo.count(y)) return memo[y]; if(y == 1) return memo[y] = llabs(X-y); if(y % 2 == 1) return memo[y] = min(llabs(X-y), min(solve((y+1)/2) + 2, solve((y-1)/2) + 2)); if(y % 2 == 0) return m...
//#include <atcoder/all> //using namespace atcoder; #include <bits/stdc++.h> using namespace std; typedef long long ll; #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 ALL(v) v.begin(), v.end() #define bit(n) (1LL<<(n)) #define FI...
/* author: Maksim1744 created: 23.05.2021 16:09:04 */ #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics...
#include <bits/stdc++.h> #define rep(i,n) for (ll i = 0; i < (ll)(n); i++) #define repr(i,a,b) for (ll i = (a); i < (ll)(b); i++) #define rng(x) (x).begin(), (x).end() #define rrng(x) (x).rbegin(), (x).rend() #define popcnt(x) __builtin_popcountll(x) #define pb push_back #define eb emplace_back #define MP make_pair #de...
#include <bits/stdc++.h> using namespace std; #define rep(i,t,n) for(int64_t i=t;i<n;i++) #define Sort(a) sort(a.begin(),a.end()) #define rSort(a,n,m) sort(a.begin()+n-1,a.begin()+m) #define Reverse(a) reverse(a.begin(),a.end()) #define rReverse(a,n,m) reverse(a.begin()+n-1,a.begin()+m) #define MOD 1000000007 #define s...
#include <bits/stdc++.h> using namespace std; int main() { long long N,X; cin>>N>>X; long long total=0; long long count=0; bool jud=0; for(long long a=0;a<N;a++){ long long v,p; cin>>v>>p; total+=v*p; count++; if(total>(100*X)){ jud=1; break; } } //cout<<total...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <deque> #include <set> #include <sstream> #include <stack> #include <...
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace chrono; typedef long long int ll; typedef vector<int> vii; typedef vector<ll> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define pb push_back #define odd(x) ((x)&1) #define even(x) (!odd(x)) #define all(v) (v).begin(),(v).e...
#include <bits/stdc++.h> #define ll long long int #define vec vector<ll> #define vecp vector<pair<ll,ll> > #define mapp map<ll,ll> #define mapit map<ll,ll>::iterator #define mapr map<pair<ll,ll>,ll> #define maprit map<pair<ll,ll>,ll>::iterator #define fs first #define sc second #define bg begin() #define en end() #defi...
#include <iostream> #include <string> #include <ctype.h> using namespace std; int main() { string input; cin >> input; bool isDifficult = true; bool odd = true; for ( const auto &c : input ) { if ( odd ) { if( isupper( c ) ) { isDifficult = false; break; } } else { if( islower( c ) ) { isDi...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using _lint = int; #define REP(i, n) for (_lint i = 0; i < (_lint)(n); i++) #define FOR(i, a, b) for (_lint i = (_lint)(a); i < (_lint)(b); i++) #def...
// -------- START : snippet -------- // #include <bits/stdc++.h> using namespace std; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; // -------- START : macro ------...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<ll, ll>; // Sieve of Eratosthenes // https://youtu.be/UTVg7wzMWQc?t=2774 struct Sieve { int n; vector<int> f, primes; Sieve(int n = 1) : n(n), f(n + 1) { f[0] = f[1] = ...
#include <bits/stdc++.h> using namespace std; using ll =unsigned 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 << " = ...
#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; int main(){ int n, m; cin >> n >> m; map<int, vector<int>> mp; rep(i, m){ int x, y; cin >> x >> y; mp[x].push_back(y); } set<int> s; s...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for(int i = n-1; i >= 0; i--) #define all(x) (x).begin(),(x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #d...
#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; } signed main(){ cou...
#include <iostream> using namespace std; int main() { int N; int A[4]; N = 4; int ans; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < N; i++) { if (i == 0) { ans = A[0]; } else { if (ans > A[i]) { ans = A[i]; } } } cout << ans << endl; }
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; typedef long long ll; int main(){ int n;cin>>n; for(int i=0;i<n;i++){ ll r,l;cin>>l>>r; ll res=int(r-2*l); if(res<0)cout<<0<<endl; else { res=(res+1)*(res+2)/2; ...
// #define LOCAL #ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++) #define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--) #define ll long long #define ld long double #define pb push_back #define eb empl...
#include<bits/stdc++.h> using namespace std; #define ll __int128 #define pll pair<ll,ll> #define mp make_pair #define fi first #define se second #define db double #define pb push_back #define N 1000000000 #define inf 10000000000000 char s[65]; ll len,mx,m; inline ll ksm(ll a,ll b){ ll res=1; for(;b;b>>=1,a=a*a){ ...
#include <bits/stdc++.h> using namespace std; template<typename T> struct counting_iterator: public iterator<random_access_iterator_tag, bool>{ T value = 0; counting_iterator(const T &value): value(value){} counting_iterator(const counting_iterator &it): value(it.value){} counting_iterator(){} typename iterator_t...
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ int n,m; cin >> n >> m; vector<vector<int>> g(n); for(int i=0;i<m;++i){ int a,b; cin >> a >> b; a--; b--; g[a].push_back(b); } ll ans=0; for(int i=0;i<n;++i){ vector<int> dist(n,-1); queue<int> qu...
//#include <atcoder/all> #include <bits/stdc++.h> #include <math.h> 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++) typedef long long ll; typedef pair<ll, ll> P; const int MOD = 1000000007; const int INF_32 = 1LL << 30; const int64_t...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; template<int M> class ModInt { public: ll value; constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; } c...
#include <bits/stdc++.h> using namespace std; using ll = long long; using uint = unsigned int; using ull = unsigned long long; #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 per(i,n) for(int i=int(n)-1;i>=0;i--) #define per1(i,n) for(int i=int(n);i>0;i--) #define all(c) ...
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int,int> II; typedef tuple<int,int,int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int,int> MAPII; typedef unordered_set<int> SETI; template<class T> using VV=vector<vector<T>>; // minmax te...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ff first #define ss second #define pb push_back #define mp make_pair #define deb(x) cout<< #x << " " << x << "\n"; #define MAX 9223372036854775807 #define MIN -9223372036854775807 #define setbits(n) __builtin_popcountll(n) #define mkunique(a...
// Link to the Problem // https://atcoder.jp/contests/abc197/tasks/abc197_a /* 飲んだ魔剤で家が建つ。 created at: 2021-04-11 19:20:49 cleared at: */ #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define MOD 1000000007 #define INF 1000000000 long long rtceil (long long x) { ...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <iomanip> #include <climits> #include <functional> #include <cassert> using namespace std; typedef long long ll; typedef pair<int,int>...
#include <bits/stdc++.h> #define F first #define S second #define all(x) x.begin(),x.end() #define endl '\n' using namespace std; using ll = long long; using pii = pair<int, int>; const int INF = 0x3f3f3f3f; const ll INFLL = 0x3f3f3f3f3f3f3f3fLL; const int MOD = 1000000007; const int dx[] = { 0, 0, -1, 1, 1, -1, 1, ...
#include <bits/stdc++.h> using namespace std; #define ll long long template <class T = ll> using P = pair<T,T>; template <class T = ll> using V = vector<T>; template <class T = ll> using VV = V<V<T>>; #define rep(i,n) for(int i=0; i<(n);++i) #define repp(i, l, r) for(int i = (l); i < (r); ++i) #define pb push_back #def...
/** * Author: Sohel Rana * Date: 2020-10-24 23:02:29 * Task: B_Various_distances **/ #include <bits/stdc++.h> #define endl '\n' #define db double #define ld long double #define ll long long #define ull unsigned long long #define sqr(x) (x) * (x) #define gcd(a, b...
#include<bits/stdc++.h> using namespace std; #define res register int #define ll long long //#define cccgift #define lowbit(x) ((x)&-(x)) #define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i) #define per(i,r,l) for(res i=r,_l=l;i>=_l;--i) #define mkp make_pair #define pb push_back #define mem0(a) memset(a,0,sizeof(a)) #define...
#include <iostream> #include <vector> #include <string> #include <array> #include <functional> #include <algorithm> #include <stack> #include <map> #include <set> #include <climits> #include <queue> #include <bitset> #include <cassert> #include <math.h> #include <complex> #include <iomanip> #include <unordered_map> usi...
#include <bits/stdc++.h> #if MYDEBUG #include "lib/cp_debug.hpp" #else #define DBG(...) ; #endif #if __cplusplus <= 201402L template <typename T> T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #endif using LL = long long; constexpr LL ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" #define all(v) begin(v),end(v) #define pb push_back #define fr first #define sc second #define si(s) (int)s.size() #define rep(i,a,b) for(int i=a;i<b;i++) #define pi 3.1415926536 #define dig(a) fixed<<setprecision(a) #define fast ios_...
#include <bits/stdc++.h> #define PRINT(x) cerr<<#x<<'='<<x<<endl #define NL(x) " \n"[(x)] #define sz(x) int((x).size()) #define all(x) begin(x),end(x) #define mid (l+r)/2 #define fi first #define se second #define pb push_back #define endl '\n' #define lld long long #define pii pair<int,int> #define pli pair<lld,int> #...
/*input 10 6 7 5 18 2 3 8 1 6 3 7 2 8 7 7 6 3 3 4 7 12 8 9 15 9 9 8 6 1 10 12 9 7 8 2 10 3 17 4 10 3 1 3 19 3 3 14 7 13 1 */ #include <bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) a.begin(), a.end() #define sz(a) (int)a.size() #define rd() abs((int)rng()) using namespace std; usin...
#include<bits/stdc++.h> #define DONTSYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now! #define TEST unsigned long long T; cin>>T; while(T--) //loop over each testcase #define endl "\n" #define fori(a,start,end) for(in...
#include <iostream> #include <string> #include <algorithm> int main() { std::string input; std::cin >> input; std::reverse(input.begin(), input.end()); for(int i = 0; i < input.length(); ++i) { if(input.at(i) == '6') input.at(i) = '9'; else if(input.at(i) == '9') input.at(i) = '6'; ...
#include <bits/stdc++.h> #define MOD 998244353 using namespace std; typedef long long LL; int main(){ long long i,j,k,l,m,n,t; char a[300010]; cin>>n; getchar(); for(i=0;i<n;i++) { a[i]=getchar(); } if (a[0]!=a[n-1]) { cout<<1; return 0; } for(i=1;i<n-1;i++)...
// {{{ by unolight #include <bits/stdc++.h> #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-function" #define SZ(x) ((int)(x).size()) #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i,a,b) for (int i = a; i <= (int)(b); i++) #define ALL(c) (c).begin(), (c).end...
#include<bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> // #include<ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; //using namespace __gnu_pbds; #define pb push_back #define ins insert #define var auto #define F first #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int sz = 105; int dp[sz][sz][sz], ara[sz], a[sz], bm; int fnc(int n, int k, int m) { if(!n) return 0; int &w = dp[n][k][m]; if(w < 0) { w = fnc(n - 1, k, m); if(k == 1) { if(a[n] == m) w = max(w, ara[n]); } ...
#include<bits/stdc++.h> #define forn(i,s,t) for(register int i=(s);i<=(t);++i) #define form(i,s,t) for(register int i=(s);i>=(t);--i) using namespace std; typedef long long LL; const int N = 1e2+3; const LL INF = 2e18; template<typename T>inline T Max(T A, T B) {return A>B?A:B;} template<typename T>inline T Min(T A, T ...
/* "An anomaly, I'm Muhammad Ali Cause I know one day I'm gonna be the" - Greatest, Eminem */ #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #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; typ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5+10; char s[N],t[N],f[]=" atcoder"; int main() { int T; scanf("%d", &T); while (T--) { scanf("%s", s+1); int n = strlen(s+1); int ook = 0; for (int i=1; i<=min(n,7); ++i) { if (s[i]>f[i]) { ook = 1; break; } if (s[i]<f[i]) { ...
#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 A,B,C; cin >> A >> B >> C; if(C%2==0){ if(abs(A)>abs(B)) cout << ">" << endl; else if(abs(A)<abs(B)) cout << "<" << endl; else cout << "=" << endl; }else{ if(A>B) cout << ">" << end...
#include <bits/stdc++.h> using namespace std; // clang-format off using LL = long long; #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define REP(i,x) for(int i=0;i<(int)(x);i++) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++) #define RFOR(i,c) for(__typeof((...
#include <iostream> using namespace std; int main(){ int N; cin >> N; int a[N], b[N]; for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 0; i < N; i++) cin >> b[i]; long long ans; for (int i = 0; i < N; i++){ ans += a[i] * b[i]; } if (ans == 0)cout << "Yes"; else cout << "No"; }
#include<bits/stdc++.h> using namespace std; #define ll long long int #define ff first #define ss second int main(){ ll t,n,i; cin>>n; vector<ll>arr(n); set<ll>s; for(i=0;i<n;i++) { cin>>arr[i]; s.insert(arr[i]); } while(s.size()>=2) { ll x=*s.be...
#include<bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair #define x first #define y second #define WT int T=read();while(T--) #define NO puts("NO"); #define YES puts("YES"); using namespace std; inline int read() { char c=getchar();int x=0;bool f=0; for(;!isdigit(c);c=getchar())f...
#include<cstdio> using namespace std; #define int long long int n,a[200010],sum[200010],sum2[200010],mx[200010]; signed main(){ scanf("%lld",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); sum[i]=sum[i-1]+a[i]; sum2[i]=sum2[i-1]+sum[i]; mx[i]=(mx[i-1]>a[i]?mx[i-1]:a[i]); } ...
//...Bismillahir Rahmanir Rahim. . . #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; // typedefs... typedef double db; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vect...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <vector> #include <numeric> #include <iostream> #include <random> #includ...
/** * author: shishunze * date: 2021/2/18 **/ #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const int N = 100005; vector<int> e[N]; int n,x,dp[N],sz[N]; void dfs1(int u) { sz[u]=1; for(int i=0;i<e[u].size();i++) { int v = e[u][i]; dfs1(v); sz[u]+=sz[v]; } ...
#include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> v[100000]; pair<int, pair<int, int>> dfs(int x) { int p1 = 0, p2 = 0, sa = 0, sb = 0, f = 0, i; vector<pair<int, pair<int, int>>> w; p1++; f = 1 - f; for (i = 0; i < v[x].size(); i++) { pai...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define scan(any) for(auto &i:any) cin>>i; #define print(any) for(auto i:any) cout<<i<<" "; #define endl '\n' #define pb push_back #define vll vector<ll> #define f(i,x,y) for(i=x;...
#include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #define all(s) begin(s), end(s) #define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sz(s) int(s.size()) #define ENDL '\n' #define vv(type, name, h, ...) vec...
#include <iostream> #include <set> using namespace std; const int max_n = 1000; multiset<int> mst; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, ta; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> ta; mst.insert(ta); } for (int i = 0; i < m; i++) { cin >> ta; mst.insert(...
#include<bits/stdc++.h> using namespace std; #define vec vector<int> #define vecp vector<pair<int,int>> #define ll long long #define ull unsigned long long #define pb push_back #define fr first #define sc second #define fr1(i,a,b) for(int i=a;i<b;i++) #define fr2(i,a,b) for(int i=a;i>=b;i--) #define fr3(i,a,b) for(int ...
#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 <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
//region TEMPLATE #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; #define fastio ios_base::sync_with_stdio(0);cin.tie(NULL); #...
// #pragma comment(linker, "/stack:200000000") // #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") // #pragma GCC optimization("unroll-loops") #include "bits/stdc++.h" #define pb push_back #define mp make_pair #define mt make_tuple #define endl '\n' #define F first #define S second #define IO ios::s...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, s, n) for (int i = (int)s; i < (int)n; i++) #define repr(i, n,...
#include<iostream> using namespace std; int main() { int n,w; cin>>n>>w; int i=1; int t=1; while(t<=n){ t=w*i; i++; } cout<<i-2; }
#include<bits/stdc++.h> #define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++) #define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--) #define ll long long #define ull unsigned long long #define db double #define pii pair<int, int> #define mkp make_pair #define sz(x) ((int) x.size()) #define be(x) x.begin() #d...
#include<bits/stdc++.h> using namespace std; #define ri register int typedef long long ll; int p,q,t,x,y; ll a[3],ans,g,m[3]; template<class T> inline T slow_add(T a,T b,T mod){ while(a>mod-b)a-=mod; return a+b; } template<class T> inline T slow_mul(T a,T b,T mod){ T ret=0; for(;b;a=(a+a)%mod,b>>=1)if(b&1)ret=(ret+...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin(...
#include <bits/stdc++.h> using namespace std; #ifdef __DEBUG__ void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);} #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #d...
// {{{ by unolight #include <bits/stdc++.h> #include <unistd.h> #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-function" #define SZ(x) ((int)(x).size()) #define ALL(x) begin(x),end(x) #define RALL(x) rbegin(x),rend(x) #define REP(i,n) for ( int i=0; i<int(n); i++ ) #define REP...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; ll a[505][505]; ll b[505][505]; const int INF = 1000000000; int dist[1000005]; vector <pair <int, int>> graf[1000005]; int n, m; int hes(int i, int j, int k){ return k*n*m + (i-1)*m+j; } int main(){ ios_base::sync...
#include <bits/stdc++.h> using namespace std; #ifdef BOI #include "debug.h" #else #define debug(args...) #endif typedef long long ll; int main() { ios_base :: sync_with_stdio(0); cin.tie(0); int n; cin >> n; ll k; cin >> k; vector <vector <ll>> a(n, vector <ll>(n)); for (int i =...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<ll mod> struct Mint { ll x; Mint(ll x = 0) : x((x %= mod) < 0 ? x + mod : x) { } Mint& operator+=(Mint rhs) { return (x += rhs.x) >= mod ? x -= mod : 0, *this; } Mint& operator-=(Mint rhs) { return (x -= rhs.x) < 0 ? x += mod :...
#include <bits/stdc++.h> using namespace std; template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;} template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;} // ================= #define f(i, k, n) for (int i = k; i < n; i++) #define ll long long #define pb push_back #define fr first #de...
#include <iostream> #include <cmath> using namespace std; int main(){ int N, a, b; cin >> N; int arr[N], arr1[N]; for(int i = 0; i < N; i++){ cin >> a; arr[i] = a; } for(int k = 0; k < N; k++){ cin >> b; arr1[k] = b; } int result = 0; for(int j...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include <iostream> #include <vector> #include <map> #include <numeric> #include <algorithm> using namespace std; typedef long long ll; int main() { ll n; cin >> n; map<ll, ll> m; vector<ll> v; { ll tmp; while (cin >> tmp) { m[tmp]++; v.push_back(tmp); ...
#include <bits/stdc++.h> using namespace std; int main(){ long long t, N; cin>>t>>N; long long ans; long long nonexistcount=0; long long i=1; while(nonexistcount!=N){ if(i*(double)t/100>=nonexistcount+1){ ans = i+nonexistcount; nonexistcount++; if(nonexistcount==1&&N!=1){ i = i...
#include<bits/stdc++.h> using namespace std; #define _ 0 const int maxn=1e5+5; const int inf=0x3f3f3f3f; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen(".in","r",stdin); //freopen(".out","w",stdout); long long t,n; cin>>t>>n; cout<<(n*100+t-1)/t+n-1<<endl; r...
#include<bits/stdc++.h> using namespace std; // for loop #define rep(i,a,n) for(int i=(a);i<(n);++i) #define repe(i,a,n) for(int i=(a);i<=(n);++i) #define rrep(i,n,a) for(int i=(n);n>(a);--i) #define rrepe(i,n,a) for(int i=(n);n>=(a);--i) // abbreviati #define PB(v) push_back(v) #define MP(A,B) make_pair(A,B) #define...
#include<iostream> #include<cstdio> #include<map> using namespace std; #define N 100012 inline int sgn(int x){return (x==0)?0:((x>0)?1:(-1));} inline int Abs(int x){return (x>0)?x:(-x);} int n,L,a[N],b[N],c[N],la[N];bool fl=true;map<int,int>mp;long long ans=0; inline void Fin(int l,int r) { if(l+1>=r)return;int i,ql=l...
#include <bits/stdc++.h> #define LL long long #define ull unsigned long long #define F(i, j, k) for(int i = j; i <= k; i++) #define DF(i, j, k) for(int i = j; i >= k; i--) using namespace std; template <typename T> inline void read(T &n) { T w = 1; n = 0; char ch = getchar(); while (!isdigit(ch) && ch != EOF)...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define all(a) (a).begin(),(a).end() #define endl "\n" #define yes "Yes\n" #define no "No\n" #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); ll maxn = 1000006; void solve(int test) { vector<l...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = l...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++) #define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--) #define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++) #define ALL(x) (x).begin(),(x).end() // #define MOD 10000...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { int N; scanf("%d", &N); vector<ll> A(N), S(N + 1, 0), M(N + 1, 0); rep(i, N) { scanf("%lld", &A[i]); S[i + 1] = S[i] + A[i]; M[i + 1] = max(M[i]...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int i = 1; int sum = 0; while(true) { sum = sum + i; if (sum >= N) { cout << i << endl; return 0; } i++; } }
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<pair<ll,ll>> vp; #define pb(a) push_back(a) #define mp(a,b) make_pair(a,b) #define mod 1000000007 #define all(a) a.begin(),a.end() #define ral...
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<set> #include<queue> #include<cmath> //#include<bits/stdc++.h> #define int long long #define for0(i, n) for(int i = 0; i < (n); i++) #define for1(i, n) for(int i = 1; i <= (n);i++) #define mp make_pair #define all(x) x.begin(),x.end() #de...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ll> vl; typedef vector<pair<int,int>> vpi; #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++) #define pb push_back #define mp make_pair...
#include <bits/stdc++.h> #define clog(x) std::clog << (#x) << " is " << (x) << '\n'; using LL = long long; int main() { //freopen("in", "r", stdin); std::cin.tie(nullptr)->sync_with_stdio(false); LL n; std::cin >> n; std::vector<LL> F{1, 1}; while (F.back() <= n) F.emplace_back(F[F.size() - 2] + F[F.size() - 1...
/** * Author: Daniel * Created Time: 2021-03-27 20:02:48 **/ // time-limit: 2000 #include <bits/stdc++.h> using namespace std; #define F first #define S second #define ER erase #define IS insert #define PI acos(-1) #define PB pop_back #define MP make_pair #define MT make_tuple #define LB lower_bound #define UB up...
#include <iostream> #include <algorithm> #include <vector> #include <tuple> using namespace std; using p = pair<int, int>; vector<p> d = {p(-1,0), p(1,0), p(0,-1), p(0,1)}; int main() { int h, w, x, y; cin >> h >> w >> x >> y; x--; y--; vector<vector<char>> v(h, vector<char>(w)); for (int i=0; i<h; i++) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> ii; typedef vector<ii> vii; typedef vector<vi> vvi; #define FOR(i,a,b) for(int i=a; i <=(b); i++) #define ROF(i,a,b) for(int i=a; i >=(b); i--) #define loop(i,a) for(int i=0; i < (...
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const ll MAX_N = 1e18 + 2000; int main () { ios::sync_with_stdio(false); ll n; cin >> n; ll on = n; vector<ll> fib = {0, 1}; while (fib.back() < MAX_N) { ll a = fib.back(); ll b = *next(fib...
#include<bits/stdc++.h> using namespace std; #define M 1000000007 #define ll long long #define FIO ios_base::sync_with_stdio(false);cin.tie(NULL) #define ifor(st,lim) for(int i=st;i<lim;i++) #define jfor(stt,llim) for(int j=stt...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define fr(i,n) for(int i=0;i<n;i++) #define pct(i,n) cout<<"Case "<<i<<": "<<n<<endl; #define fast() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define e "\n" int main() { int x,y; cin>>x>>y; if(x==y){ cout<<x<<e...
#include<iostream> using namespace std; int A, B, W; int main(){ cin >> A >> B >> W; W*=1000; int ans_max= W/A; int ans_min= W/B + (W%B!=0); bool IsSatisfiable = false; for(int i=1; i<=1000000; i++){ if(A*i<=W&&W<=B*i){ IsSatisfiable = true; break; } } string S =to_string(ans_min) + ...
//{{ /* * Created at: 06/21/21 17:49:29 * * FB: https://facebook.com/tgbaodeeptry * From Viet Nam with Love :D * */ #include <bits/stdc++.h> using namespace std; #define fast_io() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define REP(i, a, b) for (int i = int(a); i < int(b); ++i...
#include <bits/stdc++.h> using namespace std; #define int long long template <typename T> void print_vec(const vector<T>& v, bool newline = true) { for (int i = 0; i < v.size(); ++i) { cout << v[i] << " "; } if (newline) { cout << "\n"; } } mt19937 rng((uint32_t)chrono::steady_c...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define rrep(i,n) for(int i=int(n-1);i>=int(0);--i) ...
#include<bits/stdc++.h> #define int long long #define N 200000 #define P 1000000009 using namespace std; int T,n,aa,hsh[4][2*N+1],pw2[2*N+1]; //n1[2][2*N+1],n2[2][2*N+1],n3[2][2*N+1],l0,l1,st[2][4]; string s1,s2,s3,ans,ss[4]; //int calmi(string ns){ // for(int i=0;i<ns.size();i++){ // if(ns[i]=='0'){ // int nans=0,n...
#include <bits/stdc++.h> using namespace std; int main() { int n,t; string s; cin >> t; for(int i=0; i<t; i++) { cin >> n >> s >> s >> s; for(int i=0; i<n; i++) cout << 0; for(int i=0; i<n; i++) cout << 1; cout << 0 << endl; } }
/* * @Author: RBQRBQ * @Date: 2020-11-16 10:14:40 * @LastEditors: RBQRBQ * @LastEditTime: 2020-11-16 10:36:16 */ #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii; namespace IO{ template<typename T>inline void read(T &x){ x=0;ll f=1;cha...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int,int>; #define ff first #define se second #define pb push_back #define all(x) (x).begin(),(x).end() const int mod = 1e9+7; const int inf = 1e9; const int mx = 1e6+5; int getsolve(int x){ int ans = 0; for(int i=-200; i<=x;...
#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<queue> using namespace std; typedef long long ll; int main() { ll n,i,j...
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0), cin.tie(0); #ifdef CLION freopen("in.txt", "rt", stdin); freopen("out.txt", "w", stdout); #endif int cnt = 0; int num; cin>>num; while (true){ if(num%...
#include <cstdio> int n; int a[505]; int ans[250005],len; inline void swap(int &a,int &b) { int tmp=a; a=b; b=tmp; } int p=1; void doSwap(int pos) { if(p%2==1) { int x=0; if(2*x+1==pos || 2*x+2==pos) { x^=1; } swap(a[2*x+1],a[2*x+2]); ans[++len]=2*x+1; p++; }else { if(pos==2 || pos==3) { ...
#include <array> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include <stack> #include <list> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #inclu...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ppb pop_back #define make make_pair #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); typedef long long int ll; typedef double dd; #define test int t;cin>>t;while(t--) #define f(i,a,b) for(ll i=a;i<b;i++) #define f...
#include <bitset> #include <iostream> #include <climits> #include <vector> #include <algorithm> #include <cmath> #include <limits> #include <iomanip> #include <bitset> #include <stack> #include <algorithm> #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stdio.h> #include <...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //namespace mp=boost::multiprecision; //#define mulint mp::cpp_int //#define mulfloat mp::cpp_dec_float_100 //#include<atcoder/all> //using namespace...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; const int INF = 1e9; const int MOD = 1000000007; const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1}; // const int dx[] = {-1,-1,-1, 0, 0, 1, ...
#include <algorithm> #include <iostream> #include <stack> #include <queue> #include <math.h> #include <cmath> #include <string> #include <string.h> #include <iterator> #include <map> #include <set> #include <iomanip> #include <vector> #include <cstdint> #include <time.h> using namespace std; using ll = long long; using...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n,m,t; cin>>n>>m>>t; int prev_t = 0; int curr = n; for(int i=0;i<m;i++){ int a, b; cin>>a>>b; curr = max(curr-(a-prev_t)*1,0); if(curr==0){ cout<<"No"<<endl; return 0; } curr = min(curr+(b-a)*1, n ); prev_t = b; ...
#include <iostream> #include <vector> #include <set> using namespace std; using pairint = pair<int, int>; int main(void){ int N, M, Abuf, Bbuf; vector<int> dp; vector<vector<int>> cgroups; vector<pairint> upperbits; vector<int> birank; cin >> N >> M; int numid = 1<<N; upperbits.assign(n...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define loop(i,n) for(ll i=0;i<n;i++) #define loop1(i,n) for(ll i=1;i<=n;i++) #define fast_az_fck ios_base::sync_with_stdio(false);cin.tie(NULL); #define mod 1000000007 struct custom_hash { static uint64_t splitmix64...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll MOD = 1000000007; int main() { int n, m; cin >> n >> m; vector<int> w(n); vector<int> sums(1 << n), mn(1 << n); REP(i, n) cin >> w[i]...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; int main(){ int N, M; cin >> N >> M; vector<int> w(N); for (int i = 0; i < N; i++){ cin >> w[i]; } vector<int> l(M), v(M); for (int i = 0; i < M; i++){ cin >> l[i] >> v[i]; } vector<pair<int, int>> P(M + 1); for (int i...
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define int long long #define F(i, n) for (int i = 0; i < n; i++) #define all(x)(x).begin(), (x).end() #define show(A) for (auto i: A) cout << i << " "; cout << '\n'; #define show_(A, n) F(i, n) { show(A[i]) } using namespace std; using l...
#include<bits/stdc++.h> #include<bits/extc++.h> #pragma GCC optimize("Ofast") using namespace std; using namespace __gnu_pbds; #ifdef DEBUG #define debug(x) {{cerr<<#x<<": "; cerr<<x<<endl;}} #define debugv(x) {{cerr<<#x<<": "; for(auto i:x) cerr<<i<<" "; cerr<<endl;}} #else #define debug(x) #define debugv(x) #define c...
#include <bits/stdc++.h> #define f(i,j,k) for(long long i=j;i<k;i++) #define f2(i,j,k) for(long long i=j;i>=k;i--) #define ll long long using namespace std; int main(){ bool j=true; ll n,m,c,d; cin>>n>>m; ll a[n],b[n],ansa=0,ansb=0; vector <ll>now(n,0); f(i,0,n){ cin>>a[i]; } f(...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; vector<int> a(n + 1); for (auto& e : a) cin >> e; for (int k = *max_element(a.begin(), a.end()); k >= 1; k--) { bool valid = true; for (int i = 0; valid && i < n; i++) { int l1 = a[i] / k, l2, l3; ...
#include <bits/stdc++.h> using namespace std; using Int = long long; #define PUTS(x) std::cout << (x) << endl; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define rep3(i, m, n) for (int i = (int)(m), i##_len = (int)(n); i < i##_len; i++) template <typename T> inline bool chmin(T &a, T b) {...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int maxk = 17; const int maxs = (1 << maxk) + 10; const int INF = 0x3f3f3f3f; int n, m, k; vector<int> E[maxn]; int c[maxk], dis[maxn], a[maxk][maxk], f[maxk][maxs]; void bfs(int x) { memset(dis, 0x3f, sizeof dis); queue<int> Q; Q.push(x)...
#include <iostream> #include <math.h> typedef long double ld; typedef long long ll; using namespace std; const ld eps = 1e-12; int main() { ll n; cin >> n; ll L = 1, R = 2e9; while (L != R) { ll M = (L + R + 1) / 2; ll val = M * (M + 1) / 2; if (val <= n + 1) L = M; else R = M - ...
#include <bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; //typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // #include <ext/rope> // using namespace __gnu_cxx; typedef long long int ll; typedef long double...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vec = vector<ll>; using mat = vector<vec>; using pll = pair<ll,ll>; #define INF (1LL << 60) #define MOD 1000000007 #define PI 3.14159265358979323846 #define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i)) #define FORR(i,v) for(auto (i...
#include <iostream> #include <stdio.h> #include <cstring> #include <cstdio> #include <math.h> #include <algorithm> #include <vector> #include <string> #include <stdlib.h> #include <queue> #include <stack> #include <utility> #include <fstream> //#include <random> #include <map> #include <unordered_map> #include <cstdlib...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define fi first #define se second #define pb push_back #define mp make_pair int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin>>n; vector<ll> t(n),p(n),s(n); ll ans=1e9; ll none=1; for(int i=0; i<n; i+...
#include<bits/stdc++.h> #define INF 7F7F7F7F7F7F7F7F using namespace std; typedef long long ll; int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); clock_t start,end; start = clock(); #endif void wor...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <numeric> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; #define ALL(a) (a).begin(), (a).end() #define min_e(v) *min_element(ALL(v)) #define max_e(v) ...
#include <iostream> #include <cmath> #include <stdio.h> #include <string.h> #include <bits/stdc++.h> #include <vector> #include <array> #include <tuple> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; double p[101][101][101]; for (int i=0; i<=100; i++){ for (int j=0; j<=100; j++){ ...
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) REP(i, 0, n) #define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--) #define sz(x) int(x.size()) #define bitsz(x) int(__builtin_popcount(x)) #define all(x) (x).begin(), (x).end() #define rall(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; ll tt(ll n) { ll res = 1; for(ll i = 0; i < n; i++) { res *= 2; res %= MOD; } return res; } int main() { ll N; cin >> N; char c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4; v...
#include<bits/stdc++.h> #define RG register #define R RG int #define ll long long #define D double #define I inline using namespace std; int main() { ll b,c; scanf("%lld%lld",&b,&c); if(b==0)printf("%lld\n",(c>>1)+(c-1>>1)+1); else if(b>0) { printf("%lld\n",(max(c-2>>1,0ll))+(min((b<<1)-1,(c>>1)+(c-1>>1)))+(c-1>...
#include "bits/stdc++.h" #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int N; vector<int> A,B; int solve(){ int res = 2e5; REP(i,N) res = min(res,A[i]+B[i]); REP(i,N){ REP(j,N){ if(i == j) continue; res = min(res,max(A[i],B[...
#include <iostream> #include <iomanip> #include <vector> #include <array> #include <stack> #include <queue> #include <tuple> #include <algorithm> #include <unordered_set> #include <unordered_map> #include <cmath> #include <map> #include <numeric> #include <cassert> #include <string> #include <list> using ull = unsign...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define all(x) begin(x), end(x) #define ra...
#include "bits/stdc++.h" using namespace std; void solve(){ int a,b,c,d; cin>>a>>b>>c>>d; cout<<a*d-b*c<<'\n'; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; // cin>>t; while(t--){ solve(); } return 0; }
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; typedef long long ll; typedef vector<ll> vint; typedef vector< vector<ll> > vvint; #define rep(i,n) for(ll i=0;i<n;i++) #define repf(i,f,n) for(ll i=f;i<n;i++) #define repr(i,n) for(ll i=n-1;i>=0;i--) #define mp make_p...
// Template Libraries #include <bits/stdc++.h> using namespace std; //Standard input bool checkMod7(int n, int mod){ for(; n > 0; n = n / mod){ if(n % mod == 7) return true; } return false; } int main(){ int N, counter; bool dec_flag, oct_flag; cin >> N; counter = N; for(int i ...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #...
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define mp make_pair #define ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; 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,cc,n) for(int i=cc...
#include<bits/stdc++.h> using namespace std; //#include<atcoder/all> //using namespace atcoder; using ll = long long; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() using P = pair<int, int>; void Main(){ int n, m; cin >> n >> m; vector<vector<P>> path(n); For(i,0,m){ ...
#include <bits/stdc++.h> using namespace std; unsigned long long r,x,y; int main(){ cin >> r >> x >> y; unsigned long long target = x*x+y*y; unsigned long long r2 = r*r; unsigned long long ans = 0; if(target%r2==0){ ans = target/r2; if(sqrt(ans)!=(unsigned long long)sqrt(ans)){ ...
// Author: wlzhouzhuan #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pb push_back #define fir first #define sec second #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = l; i >= r; i--) #define mset(s...
#include <bits/stdc++.h> using namespace std; typedef long long ll; using Graph = vector<vector<ll>>; vector<bool> seen; ll dfs(const Graph &G, ll v, ll cnt) { seen[v] = true; ll res = cnt; for (auto next_v : G[v]) { if (seen[next_v]) continue; res = dfs(G, next_v, res)+1; } return...
/*{{{*/ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<set> #include<map> #include<queue> #include<bitset> #include<vector> #include<limits.h> #include<assert.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).be...
#include <bits/stdc++.h> #define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i) #define rep(i,l,r) for (int i=l;i<=r;++i) #define per(i,r,l) for (int i=r;i>=l;--i) #define ll long long #define pb push_back using namespace std; const int N=5e3+3,P=998244353; int dp[N][2],pw[N]; void upd(int x,int &y,int c){ y=(y+(ll)x*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> #define pb push_back #define mk make_pair #define mk make_pair #define ll long long #define ss second #define ff first #define mod 1000000007 #define w(x) ll x; cin>>x; while(x--) #define ps(x,y) fixed<<setprecision(y)<<x; #define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in) #define re(i, j) fo(i,...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef pair <int, int> pin; const int N = 2e5 + 5; const ll P = 998244353LL; int n, tot, head[N], ans[N], dis[N], fa[N], diaSon[N]; bool vis[N], inDia[N]; vector <int> son[N]; struct Edge { int to, nxt; } e[N << 1]; inline v...
#include <bits/stdc++.h> using namespace std; string sdouble(string s) { int n = s.size(); string s2(n*2,'a'); for (int i = 0; i < n; i++) { s2[i*2] = s[i]; s2[i*2+1] = s[i]; } return s2; } string ssign(string s) { int n = s.size(); string s2(n*2,'a'); for (int i = 0; i < n; i++) { if (s[i...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define INF 1000000007 using namespace std; int main(){ long n; cin >> n; vector<long> ans; for(int i=1;i<sqrt(n)+1;i++){ if(n%i==0){ ans.push_back(i); if(i*i != n)ans.push_back(n/i); } } sort(ans.begin(), ans.end()); rep(i...
#include <iostream> #include <algorithm> #include <bits/stdc++.h> using namespace std; int main() { long long int n,i; cin >>n; set<long long int> s; for(i=1;i<=sqrt(n);i++){ if(n%i==0){ s.insert(i); s.insert(n/i); } } for(auto it=s.begin();it!=s.end();it++){ cout<<*it<<endl; } r...
/*** author: yuji9511 ***/ #include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; using lpair = pair<ll, ll>; using vll = vector<ll>; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);...
#include<bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x){ x=0;char ch=getchar();bool f=false; while(!isdigit(ch)){if(ch=='-'){f=true;}ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} x=f?-x:x; return ; } template <typename T> inline void write(T x){ if(x<0)...
#include <bits/stdc++.h> using namespace std; int main() { int numa, numb; cin >> numa >> numb; cout << numa* 2 + 100 - numb; return 0; }
#include <iostream> #include<bits/stdc++.h> #define pb(x) push_back(x) #define ll long long #define fr(i, n) for(int i=0; i<n; i++) #define fr1(i, a, b) for(int i=a; i<=b; i++) #define fr2(i, a, b) for(int i=a; i>=b; i--) #define srt(a) sort(a.begin(), a.end()) #define frit(it, m) for(auto it=m.begin(); it!=m.end(); i...
#include <bits/stdc++.h> using namespace std; int main(){ int x,y; cin>>x>>y; if(x>y){ if(y+3>x) cout<<"Yes"; else cout<<"No"; } else if(y>x){ if(x+3>y) cout<<"Yes"; else cout<<"No"; } }
#include<bits/stdc++.h> #define ll long long int #define mii map<int,int> #define qi queue<int> #define pqi priority_queue<int> #define pqgi priority_queue<int,vector<int>,greater<int>> #define si set<int> #define vi vector<int> #define vll vector<long long int> #define vii vector<pair<int,int>> #define mii map<int,int...
#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> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main() { int n; cin >> n; vector<P> x(n); bool ok = false; rep(i, n) cin >> x[i].first >> x[i].second; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,f,n) for(ll i=(f); (i) < (n); i++) #define repe(i,f,n) for(ll i=(f); (i) <= (n); i++) #define repc(i,f,n) for(char i=(f); (i) <= (n); i++) #define PI 3.14159265359 #define debug(x) cout<<#x<<" :: "<<x<<"\n"; #define debug2(x,y) cout<<#x<<"...
#include<bits/stdc++.h> typedef uint64_t u64; typedef int64_t i64; typedef long double f128; using namespace std; template<u64 mod> class modint{ public: u64 val; constexpr modint(const u64 x=0) noexcept:val(x%mod){} constexpr u64 &value() noexcept{ return val; } constexpr const u64 &value() const noexce...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); string S[3]; cin >> S[0] >> S[1] >> S[2]; map<ch...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (ll i = s; i < e; i++) #define rrep(i, s, e) for (ll i = s; i > e; i--) int main() { ll A, B, W; cin >> A >> B >> W; W *= 1000; ll cnt_a = W / A, cnt_b = W / B; if (cnt_a != cnt_b) cout << cnt_b + (W % B != 0) << " "...
#include <iostream> #include <string> #include <vector> #include <cmath> #include <map> #include <numeric> #include <iomanip> #include <algorithm> using namespace std; string rus; int point = 0; void move(vector<vector<int>> &mdata, vector<vector<int>> &pdata, vector<int> cdata,int x,int y,int p,int dir, string sdata...
#include <bits/stdc++.h> using namespace std; template<class t> inline t read(t &x){ char c=getchar();bool f=0;x=0; while(!isdigit(c)) f|=c=='-',c=getchar(); while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar(); if(f) x=-x;return x; } template<class t> inline void write(t x){ if(x<0) putchar('-'),wr...
#include <bits/stdc++.h> using namespace std; // typedef using ll = long long; using str = string; using PL = pair<ll, ll>; using P = pair<int, int>; using VL = vector<ll>; using VI = vector<int>; using VS = vector<str>; using VP = vector<P>; using VPL = vector<PL>; using VVL = vector<VL>; using VVI = vector<VI...
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <complex> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #include <queue> #define INF 1010101010LL #define INFLL 101...
// WIP #include <bits/stdc++.h> using namespace std; #define ALL(X) (X).begin(), (X).end() #define FOR(I, X, Y) for (int I = (X); I < (Y); I++) using ll = int64_t; using ull = uint64_t; namespace std { template<class ...Ts> istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >...
#include <cstdio> using ll = long long int; int cnt[405]; int N; int main(){ scanf("%d",&N); for(int i=0;i<N;i++){ int tmp; scanf("%d",&tmp); cnt[tmp+200]++; } ll ans=0ll; for(int i=0;i<=400;i++){ for(int j=i+1;j<=400;j++){ ll diff=j-i; /...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pl; using Graph = vector<vector<int>>; const ll INF = 1LL << 62; const double PI = acos(-1); const ll mod = 998244353; const ll MOD = 1000000007; template<clas...
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> // #include <atcoder/all> /* cd $dir && g++ -std=c++17 -Wall -Wextra -O2...
#include <bits/stdc++.h> #define ll long long #define ld long double #define V vector<long long> #define VV vector<vector<long long>> #define VVV vector<vector<vector<long long>>> #define P pair<ll,ll> #define rep(i,n) for(ll (i)=0;(i)<(n);++(i)) #define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i)) #ifdef LOCAL #define debu...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FO...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair <int, int> #define vi vector<int> #define FOR(i, a, b) for (int i=a; i<b; i++) #define FORd(i, a, b) for (int i=a-1; i>=b; i--) #define F0Rd(i, a) for (int i=a-1; i>=0; i--) #define F0R(i, a) for (int i=0; i<a; i...
#include<bits/stdc++.h> using namespace std; long long ans; void noanswer() { puts("-1"); exit(0); } int a[100005], b[100001]; struct info { int cnt, p; }; info seq[100001]; int tot; void solve(int l, int r) { int p = l-1; while (p < r && a[p+1] > b[p+1]) ++p; for (int i = p+1; i <= r; i++) if (a[i] > b[i]) noa...
#include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define mp make_pair #define fi first #define se second #define REP(i,j) for(int i=0;i<j;i++) #define REPA(i,j) for(int i=1;i<=j;i++) #define FORN(i,j,k) for(int i=j;i<k;i++) #define vi vector<int> #define vvi vector<vi > #define p...
#include<bits/stdc++.h> using namespace std; long long b,c,x,y; unsigned long long ans=0; int main(){ scanf("%lld%lld",&b,&c); if(c==1){ if(b==0)printf("1"); else printf("2"); return 0; } if(b==0)printf("%lld",c); else if(b>0){ x=c%2; y=c/2; if(y>=b)ans=2*b+1; else if(x)ans=2*y+2; else ans=2*y+1; ...
#include <bits/stdc++.h> using namespace std; const int MAX = 10000; int main() { int n, m; cin >> n >> m; vector<int> cnt(MAX); for (int i = 0; i < n + m; i++) { int x; cin >> x; ++cnt[x]; } for (int i = 0; i < MAX; i++) { if (cnt[i] == 1) { cout <...
#include <bits/stdc++.h> #include<iostream> using namespace std; typedef long long ll; int keta(ll n) { return log10(n)+1; } ll f() { for (int i = 0; i< 10;i++) {} for (int j = 0; j< 10;j++) {} ll p = 3* 2e18; vector<ll> vec; vec.push_back(0); vec.back(); vec.pop_back(); for_each(...
// header {{{ // header {{{ using namespace std; #include <bits/stdc++.h> #define CPP_STR(x) CPP_STR_I(x) #define CPP_CAT(x, y) CPP_CAT_I(x, y) #define CPP_STR_I(args...) #args #define CPP_CAT_I(x, y) x##y #define ASSERT(expr...) assert((expr)) using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = ...
#include <bits/stdc++.h> using namespace std; using LL = long long; const int int_inf = 1e9; const LL ll_inf = 1e18; const int mod = 1000000009; template <class T> void sort(T &v) { std::sort(v.begin(), v.end()); } template <class T> void rsort(T &v) { std::sort(v.rbegin(), v.rend()); } int main() { ios::sync_w...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<(int)(n);++i) #define ALL(v) (v).begin(),(v).end() #define debug(x) cerr<<#x<<": "<<(x)<<endl using namespace std; using llong = long long; using vi = vector<int>; using vvi = vector<vi >; using vvvi = vector<vvi >; using pii = pair<int,int>; constexpr i...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; int main(){ int n; ll k; cin >> n >> k; vector<pair<ll,ll>> friends(n); for(int i=0;i<n;i++){ ll a,b; cin >> a >> b; friends[i] = make_pair(a,b); } sort(friends.begin(), friends.end()); ll...
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define all(x) (x).begin(), (x).end() #define F first #define S second #define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define pb push_back using namespace std; // DEBUG TEMPLATE void __print(int x) {cout << x;} void...
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0 ; i < (n); ++i) using namespace std ; typedef long long ll ; const int mod=1000000007; const int N=1e3 ; void solve(){ int n,k; cin>>n>>k ; vector<int> a(n) ; rep(i,n){ cin>>a[i] ; } map<int,int> mp ; for(int i=0;i<n;i++){ mp[a[i]]++ ; } int mn=...