code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b;...
/** * author: Dooloper * created: 22.05.2021 20:55:00 **/ #include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define repp(i,k, n) for(int i = (int)(k); i < (int)(n); i++) #define ALL(a) (a).begin(),(a).end() using ll = long long; using P = pair<int, int>; struct Ed...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <utility> #include <tuple> #define REP(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#include<iostream> using namespace std; int main(){ int n,index; cin>>n; for(int i=1;;i++){ if((i*(i+1))/2 >= n) {index=i; break; } } cout<<index<<endl; }
#include<iostream> using namespace std; typedef long long ll; int main(){ ll n;cin >> n; ll ans = 0; if (n>=1000) ans+=n-999; if (n>=1000000) ans+=n-999999; if (n>=1000000000) ans+=n-999999999; if (n>=1000000000000) ans+=n-999999999999; if (n>=1000000000000000) ans+=n-999999999999999; c...
#include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long #define pb push_back #define vec vector<ll> #define pii pair<ll,ll> #define pr_que priority_queue<pii,vector<pii>,greater<pii> > #define itr(i,x,y) for(ll i=x;i<y;i++) #define mo...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll,ll>; ll solve_sub(ll N, vector<ll>& V) { priority_queue<pii> q; ll ans = 0; for ( int i = 0; i < N; i++ ) { int i2 = 2*N-1-i; q.push(pii(V[i],i)); q.push(pii(V[i2],i2)); ans += q.top().fi...
#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> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a ...
#include <bits/stdc++.h> using namespace std; int main(){ int si, sj; cin >> si >> sj; int t[50][50]; int p[50][50]; for(int i = 0; i < 50; i++) { for(int j = 0; j < 50; j++) { cin >> t[i][j]; } } for(int i = 0; i < 50; i++) { for(int j = 0; j < 50; j++) { ...
#define rep(i,n) for (int i=0;i<n;i++) #include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { unsigned long long n; int a,b; cin >> n; bool torf=false; for(unsigned long long i=0;i<37;i++){ for(unsigned long long j=0;j<25;j++){ //for(k,i) unsigned long long c=1;//=...
#include <bits/stdc++.h> using namespace std; int64_t I=2e18; int main() { int64_t N; cin>>N; vector<int64_t> p={1}; vector<int64_t> q={1}; int A=0,B=0; while(I/3>=p[A]){ p.push_back(p[A]*3); A++; } while(I/5>=q[B]){ q.push_back(q[B]*5); B++; } for(int i=1;i<A;i++){ for(int j=1;j<B;j++){ if(p[i]...
// Author: Pawan Raj // Problem: B - Round Down // Contest: AtCoder - AtCoder Beginner Contest 196 // URL: https://atcoder.jp/contests/abc196/tasks/abc196_b #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)(...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ string x; cin >> x; string ans; for(char c : x) { if(c == '.') break; ans += c; } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; long long C_add = 0; long long C_min = 1e18; long long C_max = -1e18; for (int i = 0; i < N; i++) { long long a, t; cin >> a >> t; if (t == 1) { ...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long #define ll long long #define ld long double using namespace __gnu_pbds; using namespace std; template...
#include <bits/stdc++.h> using namespace std; #define ll long long int main(void){ int h,w; cin >> h >> w; char s[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin.get(s[i][j]); if(s[i][j]=='\n'){ cin.get(s[i][j]); } } } i...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <ios> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #...
#include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n; vector<pair<int,int>> shart(100); vector<pair<int,int>> aadmi(16); int res=0; void fun(int pers, int m, int k, vector<int> coin) { if(pers==k) { bool bartan[101]={}; for(auto x: coin) ba...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(long long i = 0; i < (n) ; ++i) #define orep(i,n) for(long long i = 1; i <= (n); ++i) // one rep #define drep(i,n) for(long long i = (n)-1; i >= 0; --i) // down rep #define srep(i,s,t) for(long long i = (s); i < (t); ++i) // set rep #define rn...
#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; 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 mod 998244353 using namespace std; int main(){ int n; cin >> n; vector<int> a(n); int sig=0; for(int i=0;i<n;i++){ cin >> a[i]; sig+=a[i]; } if(sig%2==1){cout << "0\n";return 0;} vector<vector<int>> dp(n+1,vector<int>(5005)); dp[0][0]=1; for(int i=0;i<n;i++)...
// Problem: E. String Reversal // Contest: Codeforces - Educational Codeforces Round 96 (Rated for Div. 2) // URL: https://codeforces.com/contest/1430/problem/E // Memory Limit: 256 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loop...
#include <bits/stdc++.h> #include <algorithm> using namespace std; #define endl "\n" #define pb push_back #define fo(i, start, end) for (ll i = start; i < end; i++) #define rep(i, start, end, step) for (ll i = start; i < end; i += step) #define print(x) cout << #x << " is " << x << endl #define all(arg) arg.begin(), ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vll = vector<ll>; using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using pll = pair<ll, ll>; using pii = pair<int, int>; using vpii = vector<pii>; using vpll = vector<pll>; const ll LIN...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1000000007; #define mod(x) (x % MOD + MOD) % MOD const int dx[4] = {+1, 0, -1, 0}; const int dy[4] = {0, -1, 0, +1}; struct SegmentTreeRSQ { ll size; vector<ll> dat; const ll INITVAL = 0LL; SegmentTreeRSQ(ll n) ...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef pair<LL,LL> pii; typedef pair<LL,pii> ppi; typedef pair<pii,pii> ppp; #define FOR(i, n) for(int i = 1; i<=n; i++) #define F0R(i, n) for(int i = 0; i<n; i++) #define mp make_pair #define pb push_back #define f first #defin...
#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> using namespace std; int N; long long mod = 1000000007; vector<pair<int, long long>> E[200010]; long long A[200010]; void dfs(int v, int p){ int res = 0; for(int i = 0; i < (int) E[v].size(); i++){ int c = E[v][i].first; if(c == p) continue; long long w = E[v][i].second; A[c] = (...
#include <iostream> #include <algorithm> #include <limits> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <vector> #include <deque> #include <stack> #include <queue> #include <vector> #include <deque> #include <cmath> using namespace std; int n; int a[200010]; long long preSum...
// {{{ by unolight #pragma region #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+...
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << ...
#pragma GCC optimize("Ofast", "unroll-loops") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; #define ll long long using pos = pair<int, int>; bool canMoveWith1Move(const pos& from, const pos& to){ return ( (from.first + from.second == to.first + to.second) || (from.fir...
#include <bits/stdc++.h> using namespace std; typedef long long ll ; #define rep(i,a,n) for(int i=a ; i<n ; i++) #define pb push_back struct ob { unsigned long long t,m ; } ; bool comp(ob a , ob b) { return a.t<b.t ; } int main() { unsigned long long n,c,x,y,z ; cin>>n>>c ; vector<ob> a ; rep(i,0,n) { cin>...
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define sz(v) (v).size() #define all(v) (v).begin(),(v).end() #define REP(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define rep(i,a,b) fo...
// Problem: E - White Pawn // Contest: AtCoder - AtCoder Beginner Contest 203(Sponsored by Panasonic) // URL: https://atcoder.jp/contests/abc203/tasks/abc203_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // Author: abhidot #include <bits/stdc++.h> #define int long long #define IOS std::ios::sync_with_stdio(false);...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define rep(i,s,e) for(int i=s ; i < e ; i++) #define rrep(i,s,e) for(int i=s ; i > e ; i--) #define srep(i,s,e,j) for(int i=s ; i < e ; i+=j) #define tr(i,x) for(auto i : x) #define vinp(a) for(int i=0 ; ...
#include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; using namespace std; #define int long long int #define pb push_back #define vec vector<i...
#include <bits/stdc++.h> using namespace std; int main() { string X; cin>>X; string a=X.substr(0,X.find('.')); cout<<a<<endl; }
#include <bits/stdc++.h> using namespace std; int mod = 998244353; int add(int a, int b) { return a + b - (a + b >= mod) * mod; } int sub(int a, int b) { return a - b + (a - b < 0) * mod; } int mul(int a, int b) { return (1ll * a * b) % mod; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n;...
#include <algorithm> #include <deque> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <utility> #include <vector> #define all(v) v.begin(), v.end() #define rep(i, j) for (ll i = 0; i < j; ++i) #define rep2(i, j, k) for (ll i = j; i <= k; ++i) #define rep...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n,x; cin>>n>>x; string s; cin>>s; for(ll i=0;i<n;i++) { if(s[i]=='x') x--; else x++; if(x<0) x=0; } cout<<x<<endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPR(i, n) for (int i = (n); i >= 0; i--) #define FOR(i, m, n) for (int i = (m); i < (int)(n); i++) #define INF 1000000000 //配列 vector<型> 配列名(要素数, 初期値); //二次元配列 vector...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e3+9; const int MAX=1e2+9; const double ep=1e-4; const double ep1=1e-6; const int mod=77797; const double inf=1e20; const double pi=acos(-1); #define debug1 puts("?"); #define debug(x) cout<<"##"<<(x)<<endl; #define mk make_pair #define ...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <iomanip> #include <set> #include <map> #include <queue> #include <bitset> #include <random> #include <list> #include <array> #include <fstream> #include <chrono> typedef long long ll; typedef long double ld; using na...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+50; int sum[N],a[N]; ll n; ll lowbit(int x) { return x&(-x); } void add(int pos,int val) { while(pos<=n) { sum[pos]+=val; pos+=lowbit(pos); } } ll query(int pos) { ll res=0; while(pos) { res+=sum[pos]; pos-=lowbit(pos); ...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define asort(a,n) sort(a,a+n) #define vsort(v) sort(v.begin(),v.end()) #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 10000000...
#include <bits/stdc++.h> using namespace std; int main(){ int n, m, t; cin >> n >> m >> t; int charge = n, time = 0; int c; c = 1; while(m--){ int a, b; cin >> a >> b; charge -= a - time; if(charge <= 0) { cout << "No"<< endl; return...
// KNOW NOTHING! #include <bits/stdc++.h> #define ll long long int #define F(i,j,k,in) for(int i=j;i<k;i+=in) #define DF(i,j,k,in) for(int i=j;i>=k;i-=in) #define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it) #define fall(a) a.begin(),a.end() #define sz(x) (int)x.size() #define szs(x) (int)x.length() #defi...
#include <bits/stdc++.h> #define ll int #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define deb(x) cout<<#x<<"="<<x<<endl; #define endl '\n' #define M 1000000007 // #define int long long #define F first #define S second #define INF 1e18 #define N 200005 using namespace std; ll n, m; str...
//include <atcoder> #include <iostream> #include <algorithm> #include <cmath> #include <tuple> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #define flush fflush(stdout) #define endl '\n' #define all...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; using ll = long long int; #define ALL(x) (x).begin(), (x).end() #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...
#include <bits/stdc++.h> typedef long long ll; #define PI acos(-1) #define pb push_back #define mp make_pair #define mt make_tuple #define all(a) (a).begin(), (a).end() #define clr(a,h) memset(a, (h), sizeof(a)) #define F first #defin...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<ll> v(2 * n, 0); rep(i, 2 * n) { cin >> v[i]; } ll sum = 0, aoki = 0; rep(i, 2 * n) sum += v[i]; p...
#pragma region Macros #include <bits/stdc++.h> #if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG) #include <atcoder/all> #endif using namespace std; #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i, n) for(int i=(n); i>=0; --i) #define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##...
#include <iostream> #include <cmath> #include <vector> #include <cstdio> #include <iomanip> #include <algorithm> #include <chrono> using namespace std; int main() { long long int t,n; cin>>t>>n; vector<long long int> skip; long long int pre = 1; for(long long int base=1;base<=100;base++){ if(floor(base...
#include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<(int)(n);i++) #define si(c) ((int)(c).size()) #define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++) #define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--) #define all(c) (c).begin(), (c).end() #define D(a) cerr << #a << "=" <<...
#include <bits/stdc++.h> typedef long long int LL; typedef unsigned long long int ULL; using namespace std; // 插入此處 #define D long long #define F double #define mmm(a,b) memset(a,b,sizeof(a)) D read(){ D ans=0; char last=' ',ch=getchar(); while(ch<'0' || ch>'9')last=ch,ch=getchar(); while(ch>='0' && ch<='9')ans=ans*1...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) #define DREP(i,s,n) for(int i = (s); i < (n); i++) template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}ret...
#include <cstdio> #include <algorithm> const int N = 2e5 + 5; int a[N]; int b[N]; int ans[N]; int main() { #ifndef ONLINE_JUDGE freopen("in", "r", stdin); #endif int n; while (~scanf("%d", &n)) { for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); b[a[i]] = i; } int cnt = 0; for (int i = n; i >= 1; -...
/* author : pshishod2645 Created at : 06:05:49 PM, 05 December 2020 */ #include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; typedef long long ll; //#define int long long #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statist...
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #include <cmath> #include <vector> #include <set> #include <map> #include <queue> #include <cassert> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back typedef long long ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) const long double INF = 1e15; int N = 30*30; int L = 30; // (i,j) i個下 , j個右 int ind(int a,int b){ return a*L + b; } int Vi(int v){return v/L;} int Vj(int v){return v%L;} bool in(int i,int j,int ...
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef unsigned long long ull; typedef unsigned uint; typedef long long ll; #define G getchar() int read() { int x=0; bool flg=false; char ch=G; for (;!isdigit(ch);ch=G) if (ch=='-') flg=true; for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48); return ...
/* /\ In The Name Of Allah /\ Author : Jawahiir Nabhan */ #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const char nl = '\n'; const int NM = 2e5 + 10; int dis[NM],order[NM],vis[NM],depth[NM]; int N,cnt = 1; vector <int> g[NM]; void dfs1(int u) { vis[u] = 1; fo...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll = long long; struct Edge { ll to; ll cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; #define mp make_pair #define REP(i, n) for (int i = 0; i < (n);...
//#include<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 <algorithm> #include <array> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define int long long #define ll long long #define INF 1LL << 33 #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define SHOW(p) \ ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;} template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;} #define itn int #define fi first #define se second #def...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string(string(s)); } string to_string(bool b) { return to_string(int(b)); } string to_string(vector<bool>::reference b) { return to_string(int(b)); } string to_stri...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; signed main() { int n; cin >> n; ll a[n]; rep(i, n)...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ long long int x,y,a,b; cin >> x >> y >> a >> b; long long int ans=0; while((double)a*x<=2e18 && a*x<=x+b && a*x<y ){ ans+=1; x*=a; } cout << ans+(y-1-x)/b <<endl; }
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long #define M 1000000007 #define pb push_back #define mp make_pair #define pi 3.1415926536 #define prior priority_queue<int,vector<int>,greater<int>> #define fi first #define se...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fast_io ios_base::sync_with_stdio(0); cin.tie(0) #define MOD 100000007 typedef long long ll; typedef pair<ll, ll> pii; typedef vector<pii> vp; typedef vector<ll> vi; typedef set<ll> s...
#include <iostream> using namespace std; int main(){ int n, c = 0, jud = 0, max = 0; int a[100], b[100], judge[100]; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } for(int i = 0; i < n; i++){ cin >> b[i]; if(b[i] > max){ max = b[i]; } } for(int i = 0; i < max+1; i++){ ...
#include <bits/stdc++.h> using namespace std; #define fs(n) fixed << setprecision(n) using ll = long long; int fact(int x) { return x <= 1 ? 1 : x * fact(x - 1); } int sign(int x){ return (x > 0) - (x < 0); } bool isLeapYear(int y, int m){ return (y % 400 == 0 || (y % 4 == 0 && y % 100)) && m == 2; } vector<...
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;i++) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;i--) #define erep(i,j) for(int i=hd[j];i;i=nxt[i]) inline int read(){ int x=0,f=1;char c=getchar(); while(c<48||c>57){if(c=='-')f=-1;c=getchar();} while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^4...
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <stack> #include <algorithm> using ll = long long int; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = 998244353ll; #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ ...
#include <bits/stdc++.h> using namespace std; int main() { string x; int p; cin >> x; p = x.find("."); if(p == -1){ cout << x << endl; } else{ cout << x.substr(0,p) << endl; } }
#include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <string> #include <stdlib.h> #include <math.h> using namespace std; #define INF 1e9 #define PI 3.141592653589793238 #define N 1000000010 #define mod 1000000007 #define rep(i,n) for(int i=0; i<n; i++) typedef long long ll; int main() { str...
#include <iostream> #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ull unsigned long long #define int long long #define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer //#define mp make_pair #define max3(x,y,z) max(x,max(y,z)) #define ...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll = long long; struct Edge { ll to; ll cost; }; using Graph = vector<vector<ll>>; using P = pair<ll, ll>; #define mp make_pair #define REP(i, n) for (int i = 0; i < (n); +...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; using ll = long long; int main() { int N; cin >> N; string ans; int x = 108 * N / 100; if (x < 206) ans = "Yay!"; else if (x == 206) ans = "so-so"; else ans = ":("; cout << ans << endl; }
#include<bits/stdc++.h> using namespace std; #define FOR(i, x, y) for(int i = (int)(x); i < (int)(y); ++i) #define MP make_pair #define fst first #define snd second typedef pair<int, int> pii; const int maxn = 4e5 + 5; int n, top = 0; int a[maxn], ord[maxn], rev[maxn], stk[maxn]; char s[maxn]; inline bool cmp(cons...
#include <bits/stdc++.h> using namespace std; // For Policy Based DS #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; // --------------------------------------- #define endl "\n" #define ff first #define ss second #define int...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) template <class T> vector<T> make_vec(size_t a, T val) { return v...
#include <bits/stdc++.h> using namespace std; #include<cstdlib> #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) typedef long long ll; int main(){ int n; cin >> n; vector<int> p(n); rep(i,n) cin >> p.at(i); int ans=0; vector<int> check(200005,0); rep(i,n){ check.at(p.at(i))=1; if(ans!=p.at(i)) co...
#include "bits/stdc++.h" #define pb push_back #define ll long long #define ii pair<int, int> #define pll pair<ll, ll> #define ld long double #define vi vector<int> #define vii vector<ii> #define vvi vector<vi> #define vs vector<string> #define vl vector<ll> #define vll vector<vl> #define all(x) x.begin(), x.end() #def...
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; /* struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; */ using Graph = vector<vector<int>>...
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pi pair<int, int> #define endl '\n' #define all(v) (v).begin(), (v).end() #define FIO ios_base::sync_with_stdio(0), cin.tie(0) #define fi first #define se second int fact(int n) { if (n <= 1) return 1; if (n == 2) ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int64_t> A(N); for (int i = 0; i < N; i++){ cin >> A.at(i); } int64_t max = 0; for (int i = 0; i < N; i++){ int64_t counter = 1; for (int j = i - 1; j >= 0; j--){ if(A.at(j...
#include<iostream> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) int main(){ int N; cin >> N; int as[N]; rep(i,N) cin >> as[i]; int ma=0; rep(l,N){ int mi=101000; for(int r=l;r<N;r++){ mi = min(mi, as[r]); ma = max(ma, mi*(r-l+1)); ...
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MAX 510000 #define rrep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep(i, n) for(ll i = 1; i <= (ll)(n); i++) #define dcout cout<<fixed<<setprecision(15); #define mp make_pair #define pb push_back using namespace std; typedef long long int ll; typed...
#include <iostream> #include <functional> #include <fstream> #include <sstream> #include <iomanip> #include <algorithm> #include <numeric> #include <vector> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <climits> #include <cmath> #include <cstring> #include <cassert> #includ...
//Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined) {virtual,upsolve} #include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, les...
#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...
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~**\ * Bismillahir Rahmanir Rahim. * * Imtiaz_rafi * * PCIU, CHITTAGONG * \**~~~~~~~~~~~~~~~~~~~~~~~~~~~**/ #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll>vi; typedef map<ll,ll>mi; typedef pair<ll,ll>pll; typedef v...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using Pl = pair<ll, ll>; int main() { ll N, P; cin >> N >> P; map<ll, ll> dat; for (int i = 0; i < N; i++) { ll A, B, C; cin >> A >> B >> C; dat[A] += C; dat[B+1] -= C; } ll sum = 0, ...
// Jai Shree Ram #include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int i=a;i<n;i++) #define ll long long #define int long long #define pb push_back #define all(v) v.begin(),v.end() #define endl "\n" #define x first #define y ...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <set> #include <tuple> #include <vector> using namespace std; #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define FOR(i, a, b) for (ll i = a; i <= ll(b); i++) #define ALL(x) x.begin(), x.end() typedef long long ll;...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long #define INF 2147483647 #define LINF ((1LL << 62) - (1LL << 31)) #define rep(i, n) for (int i = 0; i < n; i = i + 1) #define lrep(i, n) for (ll i = 0; i < n; i = i + 1) #define array(N, t) (t*)calloc(N, sizeof(t)) #define max(p, q)(...
#include<bits/stdc++.h> #define S std #define f(i, a, b) for(R int i = a; i <= b; i++) #define R register int T(int x) { if(x == 0||x == 1|| x == 8)return x; else if(x == 6)return 9; else if(x == 9)return 6; } int main() { S::string s; S::cin >> s; int l = s.length(); for(int i = l-1; i >= 0; i--) { S::cout<<...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define pii pair<ll,ll> #define inf 1000000000000000000 #define bpc(x) __...
#include <bits/stdc++.h> //#include <atcoder/modint> //using namespace atcoder; //#pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.en...
#include <bits/stdc++.h> #define ll long long int using namespace std; const int nax = 102; ll dp[nax][nax * nax * nax]; int mod; int main() { int n,k; cin>>n>>k; cin>>mod; dp[0][0] = 1; for(int i=1;i<=n;i++) { for(int c=0;c<nax * nax * nax / 2;c++) { if(c < i) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll,ll>; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() const ll INF = 1L...
#include <bits/stdc++.h> #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define PER(i,a,b) for (int i = (b); i >= (a); --i) #define log2(x) (31-__builtin_clz(x)) #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)(x).size() #define mup(x,y) x = std::min(x,y) #define Mup(x,y) x = max(x,y) #define debug(x) cou...
#include<bits/stdc++.h> #define ll long long using namespace std; ll MX=100000000000000000LL; ll ck(vector<ll> a, vector<ll> b) { ll mn=MX; sort(a.begin(), a.end()); sort(b.begin(), b.end()); for(int i=0;i<a.size();i++) { auto it=upper_bound(b.begin(), b.end(), a[i]); if(it!=b.end(...
//Codeforcesで128bit整数を使いたいとき //→__int128_tを使う&GNU C++17 (64)で提出する //インクルードなど #include<bits/stdc++.h> using namespace std; typedef long long ll; //イテレーション #define REP(i,n) for(ll i=0;i<ll(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll(b...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int mx=1e6+5; //考虑括号序列的匹配问题 inline int read() { int x=0,f=1; char c=getchar(); while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();} while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();} return x*f; } struct node{ int x,id; bool operator ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#include <bits/stdc++.h> using namespace std; 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> #define int long long #define ll long long #define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(v) ((v).begin()), ((v).end()) #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#include <bits/stdc++.h> using namespace std; int main() { int A, B; cin >> A; int i = 1; B = 0; while (B < A) { B = B + i; i++; } cout << i - 1; }
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pb push_back #define pob pop_back #define eb emplace_...
#include <iostream> #include <cmath> #include <stdio.h> #include <string.h> #include <bits/stdc++.h> #include <vector> #include <array> #include <tuple> #include <algorithm> using namespace std; int main() { int N; cin >> N; int x[N], y[N]; int a, b, p; p=0; for (int i=0; i<N; i++){ cin >> a >> b; ...
#include <bits/stdc++.h> #define loop(s, e, i) for (int i = s; i < e; ++i) #define print(s) cout << s << endl; #define DIV 1000000007 #define ll long long using namespace std; const int INF = 1e9+7; /* 浮動小数点の入力 cout << fixed << setprecision(9) << endl; */ int main() { cin.tie(nullptr); ios::sync_with_stdio(f...
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 4000000000000000000 //オーバーフローに注意 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; //最大公約数 ll gcd(ll x,ll y){ x = abs(x); y = abs(y); if(x < y){ swap(x,y); } i...
#include <bits/stdc++.h> #define rep(i, n) for (ll i=0; i<n; ++i) #define all(obj) (obj).begin(),(obj).end() using namespace std; typedef long long ll; long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; } int main(){ ll n; cin >> n; if(n<=10){ cout << 0 << endl; return 0;...
#include <bits/stdc++.h> using namespace std; #define all(a)a.begin(),a.end() using ll=long long; const int INF = 1<<30; const ll INFll =1LL<<62; //const int mod= int(1e9)+7; const int mod=998244353; using P = pair<int,int>; using Pl= pair<ll,ll>; using ld=long double; using V=vector<int>; using Vl=vector<ll>; using VV...
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef pair<string,int> psi; typedef pair<int,string> pis; typedef array<int,2> aii; typedef array<int,3> aiii; typedef array<int,4> aiiii; typedef unsigned long long ull; typedef long long int ll; typedef array<ll,2> all; typedef array<ll,3> all...
#include <bits/stdc++.h> using namespace std; #define int long long #define IOS ios_base::sync_with_stdio(0);cin.tie(0) /* start */ signed main(){ IOS; int a, b; cin >> a >> b; for(int i = -1000; i <= 1000; i++) { for(int j = -1000; j <= 1000; j++) { if(i + j == a and i - j == b) { ...
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int main() { int x, y; scanf("%d%d", &x, &y); int a = (x+y)/2; int b = x-a; printf("%d %d\n", a, b); return 0; }
// Author: Harshdeep Sharma , IIT Indore #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define lll __int128 // #define mp std::make_pair #define pii std::pair<int,int> #define pll std::pair<ll,ll> #define pli std::pair<ll,int> #define pil std::pai...
#include<bits/stdc++.h> using namespace std; #define int long long int n,k; int ans; signed main() { cin>>n>>k; for(int i=2;i<=2*n;i++) { int b=i-k; if(b>=2&&b<=2*n) { int l=0; if(i>n) { int cha=i-n; l=(n-cha+1); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T,class U> using P = pair<T,U>; template<class T> using vec = vector<T>; template<class T> using vvec = vector<vec<T>>; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) ll M = 998244353; vector<ll> fac(300001); //n!(mod M) vector<ll> ifac...
#include<bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; #define rep(i,n) for(int i=0;i<(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep1(i,n) for(int i=(n);i>0;i--) #define fore(i_in,a) for (auto& i_in: a) #define sz(x) (int)x....
#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 ...
// atcoder/zone2021/D/main.cpp // author: @___Johniel // github: https://github.com/johniel/ #include <bits/stdc++.h> #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) using namespace std; template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first <...
#include <iostream> #include <algorithm> #include <unordered_set> #include <set> #include <vector> #include <queue> #include <map> #include <numeric> #include <math.h> using namespace std; #define rep(i, n) for (long long int i = 0; i < (long long int)(n); i++) #define irep(i, n) for (long long int i = 1; i <= (long ...
#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; #pragma GCC optimize("Ofast") #define watch(x) cout<<(#x)<<"="<<(x)<<'\n' #define mset(d,val) memset(d,val,sizeof(d)) #define setp(x) cout<<fixed<<setprecision(x) #def...
#include<bits/stdc++.h> using namespace std; using ll=long long; static const ll mod=1000000007; ll H,W; char a[2005][2005]; ll dp[2005][2005]; ll sumx[2005][2005]; ll sumy[2005][2005]; ll sumxy[2005][2005]; int main(){ cin>>H>>W; for(ll i=0;i<H;i++){ string s;cin>>s; for(ll j=0;j<W;j++) a[i][j]=s[j]; }...
#include <iostream> #include <cstdio> #include <vector> using namespace std; typedef long long ll; ll n, m; bool v[1005][1005]; ll cp[2005]; bool v1[2005], v2[2005]; ll cnt1, cnt2; ll fnd(ll p) { if(cp[p] == p) return p; return cp[p] = fnd(cp[p]); } void uni(ll p, ll q) { if(fnd(p) == fnd(q)) return; ...
#include<bits/stdc++.h> #define ll long long int using namespace std; int fib(int n) { if (n <= 1) return n; return fib(n-1) + fib(n-2); } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,tmp=0; cin>>n; ll tm=log10(n); tm/=2; tmp=pow(10,tm-1)-1; ll ...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <complex> #include <queue> #include <set> #include <unordered_set> #include <list> #include <chrono> #include <random> #include <iostream> #in...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> using namespace std; //using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; typedef pair<ll,ll> P; #define PI 3.141592653589793 //#define MOD 1000000007 #define MOD 998244353 #define ALL(obj) (obj).begin(),(obj).e...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MOD int(1e9+7) #define INF int(1e9+7) #define LINF ll(1e18+7) #define PI acos(-1) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll,ll> #define chmax(x,y) (x = max(x,y)) #define chmin(x,y) (x = min(x,y)) vector<int> dp[210...
#include <bits/stdc++.h> using namespace std; template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); } template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> ...
//BISMILAHIRAHMANIR RAHIM #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pb push_back #define ppb pop_back #de...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; #define REP(i,n) for(ll i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;}; template<typename T> b...
#include <bits/stdc++.h> typedef long long ll; typedef std::pair<int, int> PII; const int INF = 1e9; const int MOD = 1e9+7; int main(){ int k; std::cin>>k; int deck[10], ht[10]={}, ha[10]={}; for(int i=1;i<10;++i)deck[i]=k; std::string s, t; std::cin>>s>>t; ll st, sa; st=0; sa=0; ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; void testcase(){ int l, r; cin>>l>>r; int flag = 0; ll count = 0; ll inc = 2; if(r-2*l+1>=1){ ll times = r-2*l+1; count = (times*(times+1))/2; } cout<<count<<endl; } int main(){ ios_base::sync_with_stdio(); cin.tie(NULL); int t...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using Pll = pair<long long,long long>; using vec = vector<int>; using vecll = vector<long long>; using mat = vector<vector<int>>; using matll = vector<vector<long long>>; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #...
// Problem: A - Two Sequences 2 // Contest: AtCoder - KEYENCE Programming Contest 2021 // URL: https://atcoder.jp/contests/keyence2021/tasks/keyence2021_a // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #define fi first #define se...
#include <bits/stdc++.h> #include <vector> #include <iostream> #include<algorithm> #include<string> #include <map> #include <queue> #include <stack> #include<set> //#define DIV 1000000007 #define TE 2e5 using namespace std; using ll = long long; using ldb = long double; int main() { int N; cin >> N; vector<ll...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,s,n) for (int i = (s); i < (n); ++i) #define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define len(x) (int)(x).size() #define dup(x,y) (((x)+(y)-1)/(y)) #define pb push_bac...
#include<bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define fi first #define se second const int MOD = 1000000007; const int MOD1 = 998244353; const int maxn = 100010; const int lim = (int)1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL...
#include <bits/stdc++.h> using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t; using i128 = __int128_t; using u128 = __uint128_t; using isize = std::ptrdiff_t; using usize = std::size_t; class rep { struct Iter { usize itr; constexpr Iter(const u...
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<bitset> #include<cmath> #include<ctime> #include<queue> #include<map> #include<set> #define int long long #define lowbit(x) (x&(-x)) #define mp(x,y) make_pair(x,y) #define lc (x<<1) #define rc (x<<1|1) #define fi first #define se second...
#include<bits/stdc++.h> using namespace std ; // mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); #define MAXN 200007 int n , k ; vector < int > v[ MAXN ] ; int depth[ MAXN ] ; int lst[ MAXN ] ; bool used[ MAXN ] ; int root ; vector < int > ord ; void dfs ( int vertex , int prv ) { ...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); template <typename Arg1> void prn(Arg1&& arg1) { cout<<arg1<<"\n";} temp...
//QwQcOrZ yyds!!! #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include...
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define INF (ll)1e18 #define mod 998244353 #define maxn 110 #define phi ((1 + sqrt(5)) / 2) ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b; vector<ll> rs; void solve(ll a, ll...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep1(i, n) for(int i = 1;i < n+1; i++) #define all(A) A.begin(),A.end() typedef long long ll; int main(){ int n,m; cin >> n >> m; vector<ll> a(n+1); priority_queue<pair<ll,int>> p; rep1(i,n){ cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; int _____asdfwqerqwdcasdfasd = 0; #define debug cout << "debug output " << "number: " << ++_____asdfwqerqwdcasdfasd << endl; #define int long long #define inf 2e18 int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ...
/////home/mohammed/.config/sublime-text-3/Packages/User /*input */ #include <bits/stdc++.h> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <numeric> #include <math.h> #include <sstream> #include <iterator> #include <cstdlib> #include <unordered_map> #include <map> #include <li...
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline") #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; template<typename T> using ordere...
#include <bits/stdc++.h> #define mid(l,r) ((l + r) >> 1) #define lsb(x) (x & (-x)) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define FOR(X,L,R) for(int X=L;X<R;++X) #define endl '\n' #define int long long #define MOD ((int)1e9 + 7) #define INF (0x3f3f3f3f) #define LLINF (0x3f3f3f3f3f3f3f3f...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MOD=1000000007; #define INF 1LL<<30 #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() int main(){ ll N; cin>>N; for(ll i=1;;i++){ if(stoll(to_string(i)+to_string(i))>N){ cou...
// Problem : D - AB // Contest : AtCoder - AtCoder Regular Contest 108 // URL : https://atcoder.jp/contests/arc108/tasks/arc108_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common...
#include <bits/stdc++.h> using namespace std; int main(){ int N; string S; cin >> N; for(int i = 0; i < 4; i++){ char c; cin >> c; S.push_back(c); } long long mod = 1000000007; if(S.at(0) == 'A' && S.at(1) == 'A'){ cout << 1 << "\n"; return 0; } if(S.at(1) == 'B' && S.at(3) == 'B'){ cout << 1 << "...
#include<cstdio> #include<cmath> using namespace std; #define ll long long ll a,b,c,d; int main() { scanf("%lld%lld%lld%lld",&a,&b,&c,&d); if (c*d<=b) printf("-1\n"); else printf("%d",(int)ceil(a*1.0/(c*d-b))); return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double lld; #define mod 1000000007; #define INF 1e18 #define pb push_back #define F first #define S second #define pll pair<ll,ll> #define plll pair<ll,pair<ll,ll>> // pb,mp,F,S,MOD,INF should not be used as variable names for any i...
#include <bits/stdc++.h> #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; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; map<int,int> circle; vector<int> f(n); rep(i,n){ cin >> f[i]; } int cnt = 0; rep(i,n){ m...
#include <bits/stdc++.h> using namespace std; const int P=998244353; vector<int> e[200050]; int n,ans=1; bool v[200050]; void dfs(int u) { v[u]=1; for (int i=0; i<e[u].size(); ++i) if (!v[e[u][i]]) dfs(e[u][i]); } int main() { scanf("%d",&n); for (int i=1,u; i<=n; ++i) { scanf("%d",&u); e[u].push_back(i); ...
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<string> #include<stdio.h> #include<stdlib.h> #include<float.h> #include<tuple> #include<string.h> #include<iomanip> #include<stack> #include<queue> #include<map> #include<deque> #include<math.h> using namespace std; #define ll long long ...
#include<bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';} template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x)...
#include <bits/stdc++.h> #define REP(i,n) for (int i = 0; i < (n); ++i) template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} using namespace std; using ll = long long; using P = pair<in...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #def...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define fast ios_base::sync_with_stdio(false);cin.tie(NULL) #define br cout<<endl; #define pb push_back #define left(x) x.begin(), x.end() #define right(x) x.begin(), x.end(), greater<ll>() #define mp make_pair #define M -1000000005 void solve(){ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; char RPS(char a, char b) { if(a=='R' && b=='S') return a; if(a=='P' && b=='R') return a; if(a=='S' && b=='P') return a; if(a=='R' && b=='P') return b; if(a=='P' && b=='S') return b; if(a=='S' && b=='R') return b; return a; } int main() ...
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here string a; int n; cin>>n; cin>>a; vector<int> C(n), A(n); for(int i=0;i<n;i++) { if(a[i]=='A') A[i]++; else if( a[i]=='C') C[i]++; else if(a[i]=='G') C[i]--; else A[i]--; if(i==0) continue ; A[i]+...
/** * @FileName a.cpp * @Author kanpurin * @Created 2021.05.31 03:48:48 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n,m;cin >> n >> m; vector<bool> dp(min(n,m)*2+1); vector<pair<int,int>> a(m); for (int i = 0; i < m; i++) { cin >> a[i].fi...
#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> #define ll long long int using namespace std; #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define mp make_pair #define fi first #define se second #define pb push_back #define endl "\n" #define maxpq priority_queue<ll> #define minpq priority_queue<ll, vector<ll>, g...
#include <bits/stdc++.h> #define endl '\n' #define fi first #define se second #define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k)) #define forn(i,n) for (int i = 0; i < int(n); i++) #define forr(i,a,b) for (int i = a; i <= b; i++) #define all(v) v.begin(), v.end() #define pb push_back using namespace std; typedef long lo...
#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; int d[1005][1005]; vector<int>g[1005][26]; void solve()...
#include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iomanip> #include <functional> #include <bitset> #include <limits> #include <cstdio> #include <cmath> #include <cassert> #include <ra...
#include<iostream> #include<vector> #include<map> #include<stack> #include<set> #include<queue> #include<stdlib.h> #include<math.h> #include<string> #include<string.h> #include<algorithm> #include<iomanip> #include<sstream> #define endl "\n" #define Doura() ios_base::sync_with_stdio(false),cin.tie(NULL), cout.tie(NULL)...
#include<bits/stdc++.h> #define ll long long #define ld long double #define f first #define s second #define FSD ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; const int mod=998244353; const int maxN=1e6+1; const ll inf=1e18+1; int main(){ int n; cin>>n; int nt = 1.08 *...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define endl "\n" #define f first #define s second #define ar array #define pb push_back #define eb emplace_back #define mp make_pair #define sz(X)...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll i=0;i<(ll)n;i++) #define dump(x) cerr << "Line " << __LINE__ << ": " << #x << " = " << (x) << "\n"; #define spa << " " << #define fi first #define se second #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() using ld =...
#include<bits/stdc++.h> using namespace std; void solve(){ int a,b; cin>>a>>b; cout<<(a/b); } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int T=1; // cin>>T; while(T--){ solve(); } }
// Sky's the limit :) #include <bits/stdc++.h> using namespace std; #define int long long /* w / a */ void run_case() { int a, b; cin >> a >> b; vector<int> primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71 }; int n = b - a + 1; vector<int> b...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) (x).begin(), (x).end() #define ll long long using namespace std; int main() { int n, x; cin >> n >> x; int a[n]; REP(i, n) cin >> a[i]; vector<int> ans; REP(i, n) { if (a[i] == ...
#include <bits/stdc++.h> //#include <atcoder/all> #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using namespace std; //using namespace atcoder; const int mod = 1000000007; int main() { int a,b;cin>>a>>b; int X=(a+b)/2; int Y=(a-b)/2; cout<<X<<" "<<Y<<endl; }
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#i...
#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>; using Graph = vector<vector<int>>; 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; re...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ld eps = 1e-8; #define len(x) ((int)x.size()) #define rep(i,n) for (int i = -1; ++ i < n; ) #define rep1(i,n) for (int i = 0; i ++ < n; ) #define be(a) (a).begin(), (a).end() // #define constexpr(...) (__VA_ARGS__) // D...
#include <iostream> int main() { int m, h; std::cin >> m >> h; if (h % m == 0) { std::cout << "Yes" << std::endl; } else { std::cout << "No" << std::endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define ull unsigned ll #define f first #define s second #define ALL(x) x.begin(),x.end() #define SZ(x) (int)x.size() #define SQ(x) (x)*(x) #define MN(a,b) a = min(a,(__typeof__(a))(b)) #define MX(a,b) a = max(a,(__typeof__(a)...
/* Normie's Template v2.0 */ // Standard library in one include. #include <bits/stdc++.h> using namespace std; // ordered_set library. #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set(el) tree<el,null_type,less<el>,rb_tree_tag,tree_order_...
#include <bits/stdc++.h> using namespace std; template<typename T, typename U> using vp = vector<pair<T,U>>; template<typename T> using pque = priority_queue<T>; template<typename T> using lpque = priority_queue<T,vector<T>,greater<T>>; using ll = long long; using pint = pair<int,int>; using pll = pair<ll,ll>; using ...
#include <bits/stdc++.h> //#define int ll using namespace std; typedef long long ll; const int maxn=1e6+5; const int mod=998244353; void solve() { int a,b,c,d; int sum=0; cin>>a>>b>>c>>d; int x=abs(c-a); int y=abs(d-b); if(x==0&&y==0) { cout<<"0\n"; return; } if(x==y||x+...
// // header_useful.h // c++_acm // // Created by 李弘辰 on 2019/7/23. // Copyright 2019 李弘辰. All rights reserved. // #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <time.h> #include <limits.h> #include <vector> #include <list> #include <set> #include <utili...
#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,5000)); vvl yoko(30, vl...