code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < int(n); i++) using namespace std; using ll = long long; const int INF = (1<<30)-1; const long long LINF = (1LL<<62)-1; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; retur...
/*pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops")*/ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define r...
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <vector> #include <algorithm> #include <cmath> #include <map> #include <set> #include <string> #include <bitset> #include <complex> #include <deque> #include <functional> #include <limits> #include <list> #include <numeric> #inclu...
#include <iostream> #include <string> #include <vector> #include <cmath> #include <iomanip> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <complex> #include <regex> #define Debug cout << "line: " << __LINE__ << "Debug" << endl;...
#include<bits/stdc++.h> using namespace std; template <typename T> inline void read(T& A){T x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();A=x*f;} template <typename T> inline void read(T& A,T& B){read(A),read(B);} template <type...
/* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //*/ #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "<<x<<endl; #define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" ...
#include <iostream> #include <algorithm> using namespace std; int main() { int x; cin>>x; if (x>=0)cout<<x; else cout<<0; return 0; }
#include <bits/stdc++.h> #define M 1000000007 #define ll long long #define ld long double #define P pair<int, int> #define PL pair<ll, ll> #define F first #define S second #define vc vector<int> #define vcl vector<ll> #define vcb vector<bool> #define vt vector #define pb push_back #define ha cout << "YES"; #define na c...
#pragma region templates //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using db = double; using ld = long double; t...
#include <bits/stdc++.h> using namespace std; #define int long long int #define yes cout<<"YES\n"; #define no cout<<"NO\n"; #define f0(n) for(int i=0;i<n;i++) #define f1(n) for(int i=1;i<=n;i++) #define mii map<int,int> #define mci map<char,int> #define V vector<int> #define vp vector<pair<int,int>> #define pb push_bac...
//2*10^9 -- int //9*10^18 -- long long int //10^38 -- __int128_t //we also have long double /*A better way to compare floating point numbers is to assume that two numbers are equal if the difference between them is less than ε, where ε is a small number.(ε=10−9) */ #include<bits/stdc++.h> using namespace std; ...
#include <bits/stdc++.h> #define LL_MAX 1e18 using ll = long long; using namespace std; int main(){ int dx[4]={0,0,-1,-1}; int dy[4]={-1,0,-1,0}; int h,w; cin>>h>>w; vector<string> s(h); for(int i=0; i<h; i++) cin>>s[i]; int ans=0; for(int i=1; i<h; i++){ for(int j=1; j<w; j++){ ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long INF = 1LL<<60; 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; } #define rep(i, n) for ...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for(int i=0; i<n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vect...
#include <bits/stdc++.h> using namespace std; template<typename T> struct BIT { int n; vector<T> dat; BIT(int n=0){ initialize(n); } void initialize(int nin){ n = nin; dat.assign(n, 0); } T sum(int i){ T s = 0; while(i >= 0){ s += dat[i...
#include<bits/stdc++.h> #define int long long const int N=1000050; using namespace std; int n,ans,to[N]; struct node{ int w,p; bool operator <(node b)const{return w==b.w?p<b.p:w<b.w;} }a[N],b[N]; int s[N]; void add(int k){ while(k<=n)s[k]++,k+=k&-k; } int sum(int k){ int ans=0;while(k) ans+=s[k],k-=k&-k; retu...
#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...
/** * Coded by : lucky_21 * --------Lokesh Singh **/ #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace ...
#include <map> #include <set> #include <queue> #include <cmath> #include <vector> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define LL long long template <typename T> void read (T &x) { x = 0; T f = 1; char ch = getchar (); while (ch < '0'...
#include <bits/stdc++.h> using namespace std; #define tcase int _; cin >> _; while(_--) #define ll long long #define endl '\n' const int INF = 2e9; const int MAX = 2e5+100; void solve() { ll n; cin >> n; vector<int> arr(n); for(int &x : arr) cin >> x; vector<int> uf(MAX), w(MAX); for(int i=0; ...
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <cstring> #include <bitset> #include <array> using namespace std; typedef long long ll; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); co...
#include<bits/stdc++.h> using namespace std; bool _DD = false; #define _D(a)if(_DD)cout<<#a<<':'<<a<<" | "; #define DBG(a){_D(a);if(_DD)cout<<'\n';} #define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';} #define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';} #define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n'...
#include<bits/stdc++.h> using namespace std; typedef long long li; typedef long double ld; typedef pair<int,int> pt; typedef pair<ld, ld> ptd; typedef unsigned long long uli; #define SORT(vec) sort(vec.begin(), vec.end()) #define loop(i,a,n) for(int i=a;i<n;i++) #define pb push_back #define mp make_pair #define mset(a...
#include<bits/stdc++.h> using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define imod(a , n) (a % n + n ) % n #define fastio ios_base::sync_with_stdio(false);cin.tie(0); #define inF freopen("file.txt","r",stdin ); #define outF freopen("perimeter.out" , "w" , stdout ) ; #define...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define Rep(i,n) for(int i = 1; i <= n; i++) #define sz(a) int(a.size()) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define debug(a) { cerr << #a << ':' << a << endl; } #define endl '\n' #define fi first...
#include<bits/stdc++.h> #define int long long using namespace std; const int N=55; int n,a[N],X[N],x; int dp[N][2]; int calc(int i,int carry) { if(i==n+1) return carry^1; int &res=dp[i][carry]; if(res!=-1) return res; int lim=a[i+1]/a[i]; int cur=X[i]+carry; if(cur==lim) res=calc(i+1,1); e...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#include<bits/stdc++.h> #include<tuple> typedef long long ll; #define INF 99999999999999 #define mod 1000000007 #define eps 1e-9 using namespace std; typedef pair<ll,ll> du; ll n; string s,x; ll dp[200005]; int main(){ ios::sync_with_stdio(0); cin>>n>>s; cin>>x; dp[n]=1; //cout<<s[0]-'0'<<endl; ...
#include <bits/stdc++.h> #include <cassert> typedef long long int ll; using namespace std; // #include <atcoder/all> // using namespace atcoder; // @@ !! LIM() int main(/* int argc, char *argv[] */) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(20); ll N; cin >> N; ll p = 1; ...
#include <bits/stdc++.h> #define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) begin(x), end(x) using namespace std; using ll = long long; constexpr ll Mod = 998244353; constexpr ll mod = 1e9 + 7; constexpr ll inf =...
/*input 3 3 5 2 3 D 1 3 D 2 1 D 1 2 X 3 1 R */ #include<bits/stdc++.h> using namespace std; #define ll long long int const ll mod = 998244353,N = 5005; ll H,W,K; vector<vector<char>> mat(N,vector<char> (N,'.')); vector<vector<ll>> dp(N,vector<ll> (N,-1)),row(N,vector<ll> (N,0)),col(N,vector<ll> (N,0)); vector<ll>...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second const int N = 2e5 + 5; const int INF = 2e9; const ll LINF = 9e18; struct query { int T, X, Y; }; int n, m, q; int a[N], b[N]; ll tree[4][N << 2]; // 0 = Sum_A, 1 = Sum_B, 2 = Freq_A, 3 = Freq_B void update(int...
#include <bits/stdc++.h> using namespace std; const int N = 200010; const int INF = 0x3f3f3f3f; int n, L[N], R[N]; long long dp[N][2]; int main() { memset(L, 0x3f, sizeof(L)); memset(R, -0x3f, sizeof(R)); scanf("%d", &n); for (int i = 0, x, c; i < n; ++i) { scanf("%d%d", &x, &c); L[c] = min(L[c], x); R[c]...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; #define X real() #define Y imag() // 内積 |a||b|cos(theta) double dot(P a, P b) { return a.X * b.X + a.Y * b.Y; } // 外積 |a||b|sin(theta) double cross(P a, P b) { return a.X * b.Y - a.Y * b.X; } int main() { int N; cin >> N; vector<P>...
#include <string> #include <queue> #include <stack> #include <vector> #include <sstream> #include <algorithm> #include <deque> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <list> #include <cstdio> #include <iostream> #include <cmath> #include <climits> #include <bitset> #incl...
#include <bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; long double n , m , cnt, ans , sum; ll x , y , z; ll a , b , c; string s , s1; char ch; map<char , int>mp; int main(){ cin >> n >> a >> b >> m; if( m / n >= a and m / n <= b ) cout << "No"; else ...
//I still luve you Kashish <3 #include<bits/stdc++.h> using namespace std ; #define int long long #define pb push_back #define F first #define S second #define P push #define nl "\n" #define vvi vector<vecto...
//Hoang Vu - CVA-BD High School for Gifted Student #include <bits/stdc++.h> using namespace std; //ifstream f1("test.inp"); //ofstream f2("test.out"); //#define cin f1 //#define cout f2 #define fu(i,a,b) for(ll i=a;i<=b;++i) #define fd(i,a,b) for(ll i=a;i>=b;i--) #define FastIO ios_base::sync_with_stdio(NULL);cin.tie(N...
#include <bits/stdc++.h> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type)) #define memarray(array, value) memset(array, value, sizeof(array)) #define fillarray(array, value, begin, end) fill((array) + (begin), (array) +...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #include...
#include<bits/stdc++.h> using namespace std; const int mn=5005; int cnt[mn][5],ans; int main() { int n;cin>>n; char c; for(int i=1;i<=n;++i) { for(int j=1;j<=4;++j) cnt[i][j]=cnt[i-1][j]; c=getchar(); while(c!='A'&&c!='G'&&c!='C'&&c!='T') c=getchar(); if(c=='A') cnt[i][1]++...
// RAKSHIT KADAM // rax_coder #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> 3 // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree< int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> #warning check the size of arrays!...
#include<bits/stdc++.h> using namespace std; #define int long long int signed main(){ int t = 1; //cin >> t; while(t--){ int n,k; cin >> n >> k; int time[n+1][n+1]; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) cin >> time[i][j]; vector<int>...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef std::vector<long long> vll; typedef std::vector<std::vector<long long>> vvll; typedef std::vector<bool> vb; typedef std::vector<std::vector<bool>> vvb; #define INF 1999999999 #define MODA 1000000007 #define rep(i,n) for (long long i = 0; i < (...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) #define ll long long using namespace std; using P = pair<int, int>; struct E { int to, co; E(int to=0, int co=0): to(to), co(co) {} }; int main(){ int n, m; cin >> n >> m; vector<vector<E>> g(n); rep(i, m){ int a...
// author : sharad12arse #include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define INF LONG_LONG_MAX #define gcd __gcd const long mxN=2001; const ll ax=1e12; ll n,m; vector<pair<ll,ll> > adj[mxN]; vector<ll> vst(mxN),dst(mxN); ll bfs(ll x){ priority_queue<pair<ll,ll...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; int n,m,k; vector<pair<int,int>> v; vector<pair<int,int>> item; int dish[105]; int ans = 0; void chk(){ int result = 0; for(int i=0;i<m;i++){ if(dish[v[i].first]>0&&dish[v[i].second]>0) result++; } a...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // Common file // #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update // #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; //using namespace __gnu_pbds; #define pb push_back #define INF 1000000000 #d...
#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> #inc...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mii map <int, int> #define mll map <ll, ll> #define pii pair <int, int> #define pll pair <ll, ll> #define vi vector <int> #define vd vector <double> #define vll vector <ll> #define fi first #define se second #define si set ...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a + b >= 15 && b >= 8) { cout << 1 << endl; } else if (a + b >= 10 && b >= 3) { cout << 2 << endl; } else if (a + b >= 3) { cout << 3 << endl; ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i,n) for(int i = 0; i < (n); i++) int s(int n) { int res = 0; while(n) { res += n%10; n /= 10; } return res; } int main() { int a, b; cin ...
#include<bits/stdc++.h> using namespace std; #define PI double(2 * asin(1.0)) #define ll long long #define MOD 1000000007 #define INF 1e15 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; ll a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; a[i] %= 200; } unordered_map<int...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn #define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa #define db(x) cout << #x << " = " << x << endl//デバッグ用 #define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用 #define all(x) (x).beg...
#include <bits/stdc++.h> using namespace std; #define clear(a) memset(a, 0, sizeof(a)) #define full(a) memset(a, 0x3f, sizeof(a)) #define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i]) #define mset(a, b) memset(a, b, sizeof(a)) #define Rep(i, a, b) for(int i = (a); i <= (b); ++i) #define dRep...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; int n; int p[201]; vector<pair<int,int> > v; map<pair<int, int>, int > mp; bool sol...
#include<bits/stdc++.h> using namespace std; const long long maxn=330; long long n,f[maxn][maxn]={}; int main(){ scanf("%lld",&n); f[0][0]=1;for(long long i=1;i<=n;i++){f[i][0]=1;for(long long j=1;j<=i;j++)f[i][j]=f[i-1][j-1]+f[i-1][j];} printf("%lld",f[n-1][11]); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <climits> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
#include<bits/stdc++.h> using namespace std; using ll=long long; using uint=unsigned int; using ull=unsigned long long; const ll LL_MAX=LLONG_MAX; class union_find{ private: vector<ll> par; vector<ll> siz; public: union_find(ll n) : par(n),siz(n,1LL){ for (ll i=0;i<n;i++) par[i]=i; } ll root(ll x)...
///In the name of GOD //#pragma GCC optimize("O2") #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MXN = 3e5 + 10; ll n, cnt; string s, t; int main(){ ios::sync_with_stdio(0);cin.tie(0); cout.tie(0); /* cin >> n >> s >> t; for(int i = 0; i < n; i ++){ cnt += (s[i] ==...
#include<bits/stdc++.h> template <typename _Tp>void read(_Tp &x){ char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar(); x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar(); if(f)x=-x; } template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) begin(v), end(v) using namespace std; using P = pair<int,int>; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using Graph = vector<vector<int>>; ll ll_pow(ll a, ll n) { ll ans = 1; for(ll i = 0; i < ...
#include<bits/stdc++.h> #define ll long long int #define pll pair<ll,ll> #define vpll vector< pll > #define mpll map<ll,ll> #define MOD 1000000007 #define all(v) v.begin(),v.end() #define s(v) v.size() #define test ll t;cin>>t;while(t--) #define vec vector<ll> #define read0(v,n) for(int i=0;i<n;i++)cin>>v[i]; #define r...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> using namespace std; #define MOD @ #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD) typedef long long i64; typedef vector<int...
#include "bits/stdc++.h" #include <chrono> #include <random> #define lli long long int using namespace std; #define mod 1000000007 #define mod1 998244353 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define INF 1000000000 #define common cout << "Case #" << w+1 << ": " #define maxn 10...
#include<bits/stdc++.h> using namespace std; #define ll long long #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define all(v) v.begin(),v.end() const int mod = 1e9 + 7; int main (){ fast_io; int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) a[i] ...
# include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0;i<ll(n);i++) signed main() { ll N, K; cin >> N >> K; rep(i,K) { if(N % 200 == 0) { N /= 200; } else { string s = to_string(N) + "200"; ...
#include <iostream> #include <bitset> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <cassert> #include <funct...
#include <bits/stdc++.h> using namespace std; int main() { int64_t N; cin >> N; vector<string> S(N); for (string& s : S) { cin >> s; } vector<int64_t> reached_num(N, 0); for (int64_t i = 0; i < N; i++) { //iからスタートして到達できるところに到達回数+1をしていく vector<bool> curr_reach(N, fal...
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ms(s, n) memset(s, n, sizeof(s)) #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...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<n; i++) #define reps(i,s,n) for(int i=s; i<n; i++) #define per(i,n) for(int i=n-1; i>=0; i--) #define pers(i,n,s) for(int i=n-1; i>=s; i--) #define all(v) v.begin(),v.end() #define fi first #define se second #define pb push_back #define si(v) int(v.size()) #defin...
#include<bits/stdc++.h> using namespace std; #define ll long long // memo fixed setprecision(20); using vvll = vector<vector<ll>>; ll mod =1e9+7; /*"itob" int to "N"base */ template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";s...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; pair<int, int> l, r; for (int i = 0; i < (1 << (n - 1)); ++i) { int a; cin >> a; l = max(l, make_pair(a, i)); } for (int i = 0; i < (1 << (n - 1)); ++i) { int a; cin ...
#include<bits/stdc++.h> //#include <atcoder/all> #define rep(i, n) for(int i = 0; i < (n); ++i) #define DEBUG #ifdef DEBUG #define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0) #define DEBUG_VAL(a, b) do{std::printf("%s:...
/*...................................................................* *............___..................___.....____...______......___....* *.../|....../...\........./|...../...\...|.............|..../...\...* *../.|...../.....\......./.|....|.....|..|.............|.../........* *....|....|.......|...../..|....|.....
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define ll long long using namespace std; using namespace __gnu_pbds; ll int mod=1e9+7; typedef tree<ll int, null_type, less<ll int>, rb_tree...
#include<bits/stdc++.h> // no of bits to store no 2e5 is 19 // 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai using namespace std; #define int long long #define mod 998244353 #define MOD 998244353 #define MAX 1000000000 #define inf ...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mp make_pair #define pb push_back #define eb emplace_back #define test(x) cout << "Line(" << __LINE__ << ") " #x << ' ' << x << endl #define printv(x) {\ for (auto i : x) cout << i << ' ';\ cout << endl;\ } #define pii pair <int, int> #de...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MAXN = 60 + 5; int n; ll m; char s[MAXN]; bool chk(ll base) { ll cur = 0; for(int i=1; i<=n; ++i) { if(cur > m / base + 1) return 0; cur = cur * base + s[i] - '0'; if(cur > m) return 0; } return cur <= ...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; #define endl "\n" #define eb emplace_back #define mem(a, b) memset(a , b , sizeof(a)) const ll INF = 0x3...
#include <bits/stdc++.h> #define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++) #define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--) #define pb push_back #define mp make_pair #define pll pair<ll,ll> #define endl "\n" using ll=long long; using ld=long double; using namespace std; ll mod= 1e9+7; ll GCD(ll a, ll b) { return b ? GCD(b...
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ALL(x) x.begin(), x.end() #define chmax(x, y) x = max(x, y...
#include<iostream> #include<algorithm> #include<functional> #include<cmath> #include<string> #include<vector> #include<stack> #include<queue> #include<map> #include<set> #include<deque> using namespace std; #define ll long long const int mod = 1000000007; const int MOD = 998244353; const ll INF = 1000000000000000000; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, a, ans; int main() { cin >> n >> ans; for(int i = 1; i < n; ++i) cin >> a, ans = __gcd(ans, a); cout << ans << endl; return 0; }
#include<bits/stdc++.h> #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstream> #include<algorithm> #define...
#include <bits/stdc++.h> using namespace std; #define maxn 200005 #define ll long long int ll n, q, x; ll a, t, low, high, add; int main(){ cin >> n; low = -1000000000; high = 1000000000; add = 0; for(int i = 0; i < n; i++){ cin >> a >> t; if(t == 1){ low += a; high += a; add += a; }else if(t =...
#include <iostream> int main() { int a, b, c, d; std::cin >> a >> b >> c >> d; std::cout << b - c << std::endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::en...
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const int maxn = 1e6 + 5; const ll mod = 998244353; ll fac[maxn], ifac[maxn], inv[maxn]; ll nck(ll n, ll k) { //cout...
#include<bits/stdc++.h> #define ll long long int #define pll pair<ll,ll> #define vpll vector< pll > #define mpll map<ll,ll> #define MOD 998244353 #define all(v) v.begin(),v.end() #define s(v) v.size() #define test ll t;cin>>t;while(t--) #define vec vector<ll> #define read0(v,n) for(int i=0;i<n;i++)cin>>v[i]; #define re...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; for (int i = 0; i < N; i++){ cout << i * 2 % N + 1 << ' ' << (i * 2 + 1) % N + 1 << endl; } }
#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...
/*** 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> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #pragma GCC optimize ("Ofast") #pragma GCC optimization ("unroll-loops, no-stack-protector") #pragma GCC target ("avx") #pragma GCC target ("avx2") #pragma GCC target ("fma") #define fastio ios_bas...
#include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <utility> #include <algorithm> #include <cmath> #include <climits> #include <iomanip> #include <queue> #include <stack> #include <ctype.h> using namespace std; typedef long long ll; const int INF = (1<<30)-1; const ll LINF...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } r...
#include <bits/stdc++.h> using namespace std; typedef long long ll; //int:2*10**9 typedef long double ld; typedef pair<ll,ll> P; #define REP(i,n) for(ll i = 0; i<(ll)(n); i++) #define FOR(i,a,b) for(ll i=(a);i<=(b);i++) #define FORD(i,a,b) for(ll i=(a);i>=(b);i--) #define vec2(name,i,j,k) vector<vector<ll>> name(i,vect...
#include <bits/stdc++.h> #define ll long long const int INF = 1000000000; using namespace std; const int MAX = 105; int edgeDir[MAX * MAX], c[MAX], used[MAX]; vector<pair<int, pair<int, int> > > g[MAX]; void dfs(int u) { used[u] = 1; for(auto e : g[u]) { int v = e.first; int eId = e.second.first; int reverte...
#include <iostream> #include <vector> //#include <string> #include <algorithm> //#include <math.h> #include <queue> //#include <stack> //#include <iomanip> // sometimes used //#include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; //t...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long int #define double long double #define F first #define S second #define pb push_back #d...
/* NAME : RISHABH SINGH INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY */ #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 pii pair<int, int> #define bi __builtin_inf() #define ll long ...
#include <iostream> #include <string> #include <vector> #include <deque> #include <queue> #include <algorithm> #include <iomanip> #include <set> #include <map> #include <bitset> #include <cmath> #include <functional> using namespace std; #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define REV(i,n) for(ll (i) = (...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define chmin(x,y) x = min((x),(y)); #define chmax(x,y) x = max((x),(y)); using namespace std; using ll = long long; using P = pair<int,int>; using pll = pair<long long,long long>; const int INF = 1e9; const long long LINF = 1e18; const int MOD = 100...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DU...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() const long long MOD = 1000000007; struct mint { long long int value; mint() : value(0) {} explicit mint(long long int value) : value((value ...
#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--) using namespace std; const int N = 400005; int n, b[N]; pair<int, int> a[N]; stack<int> s; char ans[N]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n; rep(i, 1, 2 * n...
/* _ _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ ...
#include <bits/stdc++.h> #include <set> #define ll long long #include <string> #define pb push_back #define mp make_pair #define pi 3.14159265358979323846 #define mod 1000000007 #define INF 1e18 // typedef pair<ll, ll> pi; #define rep(i,n) for(i=0;i<n;i++) #define repk(i,k,n) for(i=k;i<n;i++) #include <ext/pb_ds/assoc_...
//HEADER FILES AND NAMESPACES #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 ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <ty...
#include <bits/stdc++.h> using namespace std; int main(){ int takahashi_num,aoki_num,C; // 条件数 cin >> takahashi_num >> aoki_num >> C; if(C==0){ if(takahashi_num<=aoki_num){ cout << "Aoki" << endl; }else{ cout << "Takahashi" << endl; } }else{ ...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<int>>; int INF=1000000000; const double PI =...
/* -----------------AUTHOR----------------------- --------------Parth Mangal-------------------- ---------------------------------------------- */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout....
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int64_t a[N]; for(int i=0; i<N; i++){ cin >> a[i]; } for (int i=0; i<N; i++){ if (a[i]<0){ a[i] = (-1) * a[i]; } } int64_t M=0; for(int i=0; i<N; i++){ M+=a[i]; } int64_t x=0; double E; for(int...
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<vector> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<deque> #include<iomanip> #include<tuple> #include<cassert> #include<set> #include<complex> #include<numeric> #include<functional> using namespace std; typede...
#include<iostream> using namespace std; #define int long long int n,m,mod=998244353,ans; int p[5001][5001]; int power(int a,int b) { if(p[a][b])return p[a][b]; if(!a)return 0; if(!b)return 1; int tmp=power(a,b/2); tmp=tmp*tmp%mod; if(b&1)tmp=tmp*a%mod; return p[a][b]=tmp; } signed main() { cin>>n>>m; if(m==1) ...
#include<bits/stdc++.h> #define vi vector<int> #define vb vector<bool> #define vs vector<string> #define vvi vector<vector<int>> #define vpi vector<pair<int,int>> #define pb push_back #define mp make_pair #define int long long...
// Jai Shree Ram #include<bits/stdc++.h> typedef long long int ll; #define pb push_back #define max2(a,b) (a>b)?a:b #define mi2(a,b) (a<=b)?a:b #define fori(i,n) for(ll i=0;i<(ll)n;i++) #define ford(i,n) for(ll i=n;i>=0;i--) #define pll pair<ll,ll> #define MOD 998244353 #define ff first #define ss second using namespac...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <iomanip> #include <random> #include <cstdio> #include <cmath> #include <map> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (int) n; i++) int main() { int n,k,m; cin >> n >> k >> m; int s...
#include <iostream> using namespace std; int main(){ int n,k,m; cin >> n >> k >> m; int Score[n-1],sum=0; for(int i=0;i<n-1;i++){ cin >> Score[i]; sum += Score[i]; } //主処理 int TargetScore = m*n; //すでに目標点を超えている場合 if(TargetScore <= sum){ cout << 0 << endl; } //下回っている場合 else{ if...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using matrix = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define REP(i,n) for (ll i = 0; i < (n); ++i) #...
#include<bits/stdc++.h> using namespace std; #define MAXN 200005 #define lowbit(x) (x&-x) #define reg register #define mp make_pair #define fir first #define sec second typedef long long LL; typedef unsigned long long uLL; const int INF=0x3f3f3f3f; const int mo=1e9+7; const int iv2=5e8+4; const int lim=1000000; const i...
#include <bits/stdc++.h> #define Ri register int #define ll long long #define db double #define FOR(i, j, k) for(Ri i = j; i <= k; i++) #define DEC(i, j, k) for(Ri i = j; i >= k; i--) using namespace std; const int maxn = 2e5 + 100; int n; vector<int> g[maxn]; int mx, xm; int d[maxn]; inline void dfs(int u, int fa) {...
#include<cstdio> using namespace std; const int mod=998244353; int n,m,k; int res; int pow(int x,int t) { int r=1; while(t) { if(t&1) { r=1ll*r*x%mod; } t>>=1,x=1ll*x*x%mod; } return r; } int main() { scanf("%d%d%d",&n,&m,&k); if((n==1)||(m==1)) { res=pow(k,n==1?m:n); } else { for(int i=1;i<=k;++i) ...
#include<bits/stdc++.h> using namespace std; #define author "Sihare0riginals" #define ss string #define lli long long int #define ld long double #define f first #define s second #define all(v) v.begin(),v.en...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n; ll a[100005],f[100005][2],g[100005][2],p; int main(){ scanf("%d",&n); p=1e9+7; for (int i=1;i<=n;i++) scanf("%lld",&a[i]); g[0][1]=1; for (int i=1;i<n;i++){ g[i][0]=g[i-1][1]%p; g[i][1]=(g[i-1][1]+g[i-1][0])%p; f[i][0]=(f[i-1][1]+(a[i]...
#include <bits/stdc++.h> #define fi first #define se second #define DB double #define U unsigned #define P std::pair #define LL long long #define LD long double #define pb emplace_back #define MP std::make_pair #define SZ(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define CLR(i,a) memset(i,a,sizeof(i)) #defin...
#include <bits/stdc++.h> using namespace std; typedef int int2; #define int long long #define pi pair<int, int> #define pb push_back #define mp make_pair #define eb emplace_back #define f first #define s second const int inf = 1e18; const int B = 450; int t; int2 main() { ios::sync_with_stdio(0); cin.tie(0...
#include <bits/stdc++.h> #define int long long int #include <time.h> using namespace std; signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin>>n; vector <int> v1; vector <int> v2; for(int i = 1;i<= n;i++){ int z; cin>>z; v1.push_back(z); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; using Pld = pair<ld, ld>; using Vec = vector<ll>; using VecP = vector<P>; using VecB = vector<bool>; using VecC = vector<char>; using VecD = vector<ld>; using VecS = vector<string>; using Graph = vector<V...
#include<bits/stdc++.h> #define LL unsigned long long using namespace std; const int N=5e5+100; const LL P=1e9+7; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(LL x){ if(...
// #define LOCAL #define _USE_MATH_DEFINES #include <array> #include <cassert> #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> #incl...
#include<iostream> using namespace std; double eps=1e-7; double a[100005]; int n; double gtval(double x){ double sum=0; for(int i=1;i<=n;i++){ sum+=x+a[i]-min(a[i],x*2); } return sum; } int main(){ double mx=0; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; mx=max(mx,a[i]); } double l=0,r=mx,ml,mr; while(r-l...
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <stdint.h> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include <list> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #in...
#include<bits/stdc++.h> #define re register #define int long long using namespace std; int n,m,a,b,c,d; char s[1000002]; inline int read(){ re int t=0;re char v=getchar(); while(v<'0')v=getchar(); while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar(); return t; } const int M=1e9+7; inline void add(re int &x,re int y){(x+=y...
#include<bits/stdc++.h> using namespace std; const int N = 5e5 + 10; char s[N], t[N]; stack<int> S, T; int main() { int n; long long ans = 0; scanf("%d", &n); scanf("%s%s", s + 1, t + 1); for (int i = 1; i <= n; i++) { if (t[i] == '1') T.push(i); if (s[i] == '1') { if (!S.empty()) ans += i - S.top(), S.po...
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; using ll=long long; using P=pair<ll,ll>; template<class T> using V=vector<T>; #define fi first #define se second #define all(v) (v).begin(),(v).end() const ll inf=(1e18); //const ll mod=998244353; const ll mod=1000000007; const vector<int> dy={-1...
#include <iostream> using namespace std; int main(void) { int a, b; cin >> a >> b; int bp = b - a; int p = bp; int d = a % p ? p - a % p : 0; while (d + p > bp) { p--; d = a % p ? p - a % p : 0; } cout << p << endl; }
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define w(t) int t;cin>>t;while(t--) #define int long long #define fr(i,a,b) for(int i=a;i<=b;i++) #define rep(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define ppb pop_back #define mp make_pair #define all(x) x.begin(),x.end() #define f...
#include <bits/stdc++.h> #define int long long using namespace std; const int inf = 1e18+9; const int mod = 1e9+7; const int maxn = 2e5+8; int n, m; void solve() { int i, j; map<int, int> mp; cin >> n; for (int x = 3, i = 1; x < n; i++, x *= 3) mp[x] = i; for (int x = 5, i = 1; x < n; i++, x *=...
#include <iostream> using namespace std; // a^p uint64_t my_p(uint64_t a, int p) { uint64_t ans = 1; for (int i = 0; i < p; ++i) { ans *= a;} return ans; } int main() { uint64_t N; cin >> N; for (int i = 1; i < 38; ++i) { for (int j = 1; j < 26; ++j) { uint64...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (n); i++) #define all(a) a.begin(), a.end() using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vv = vector<vi>; using Graph = vector<vector<int>>; template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; r...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; string t = ""; for (auto c : s) { t.push_back(c); while (t.size...
#include <bits/stdc++.h> using namespace std; using ll = long long; // -------------------------------------------------------- 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) { ...
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; string ans = s.substr(1, s.size() - 1); ans.push_back(s[0]); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() struct P{int to,idx;}; vector<vector<P>> edge; vector<int> a,b; vector<string> ans; const string R="->",L="<-"; vector<int> used; bool dfs(int from,int idx,int goal,int num){ used[idx]=num; for(...
#include <bits/stdc++.h> using namespace std; struct edge{ int to, id, orientation; }; vector<vector<edge>> graph; vector<int> ans; void DFS(int v){ for(edge e : graph[v]){ if(ans[e.id] != 0) continue; ans[e.id] = e.orientation; DFS(e.to); } } int main(){ int n, m; cin >> n >...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) using ll = long long; int solve() { int n; cin >> n; string s; cin >> s; if(s.front() != s.back()) return 1; char a = s.front(); for(int i = 1; i < n - 2; ++i) { if(s[i] != a && s[i + 1] != a) ret...
#include<iostream> #include<cstdio> #include<cstring> #define re register #define X first #define Y second #define mp std::make_pair #define pb push_back #define ohh(hhh...) fprintf(stderr,hhh) typedef long long ll; typedef unsigned long long ull; typedef std::pair<int,int> pii; template<class T1> inline bool cmax(T1 &...
// // // Radmanシ // // // #include<iostream> #include<vector> #include<algorithm> #include<map> #include<set> #include<stack> using namespace std; //#define int long long typedef pair<int,int> pii; typedef pair<pii,int> ppi; typedef pair<int,pii> pip; #define F first #define ...
#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> #inclu...
#include<bits/stdc++.h> using namespace std; typedef long long ll; //ifstream in("cowsignal.in"); //ofstream out("cowsignal.out"); void solve(){ map<ll, ll> cntJ; ll n; cin >> n; ll a[n], b[n], c[n]; for (int i = 0; i < n; i++){ cin >> a[i]; } for (int i = 0; i < n; i++){ cin >> b[i]; ...
#include<bits/stdc++.h> using namespace std; typedef long long int lli; #define all(arr) arr.begin(),arr.end() #define f first #define s second #define debug1(x) cout<<x<<"\n" #define debug2(x,y) cout<<x<<" "<<y<<"\n" #define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" #define nl cout<<"\n"; #define pq priority_queue...
#include <iostream> using namespace std; int main(void){ long long n, k; cin >> n >> k; for (int i = 0; i < k; i++){ if (n % 200 == 0){ n = n / 200; } else { string nn = to_string(n); nn += "200"; n = stoll(nn); } } ...
#include <iostream> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <utility> #include <string> #include <sstream> #include <algorithm> #include <random> #include <cstdio> #include <cstdlib> #in...
#include<bits/stdc++.h> #define sf1(n) scanf("%d",&n) #define sf2(n,q) scanf("%d %d",&n,&q) #define f first #define ss second #define pb push_back #define lli long long #define mem(ar,false) memset(ar,false,sizeof(ar)) #define mpr make_pair #define endl "\n" #define mod 1000000007 #define inf 900000000000000LL #define...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { bool ok = true; for (int x = i; ok && x; x /= 10) { ok &= (x % 10) != 7; } for (int x = ...
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define ll long long #define MOD 1000000007LL //#define MOD 998244353LL using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける cons...
#define _GLIBCXX_DEBUG #include<bits/stdc++.h> #include<algorithm>//next_permutation #define rep(i,n) for (int i = 0;i < (n);i++) #define all(v) v.begin(),v.end() #define dec(n) cout << fixed << setprecision(n); #define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define small "abcdefghijklmnopqrstuvwxyz" using namespace std; u...
#include <iostream> using namespace std; int main() { char a,b,c; cin>>a>>b>>c; cout<<b<<c<<a; return 0; }
#include<stdio.h> int main () { int g,j,i,h; scanf("%d %d\n%d %d",&g,&h,&i,&j); printf("%d",g*j-h*i); return 0; }
#include <iostream> #include <fstream> #include <set> #include <map> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <functional> #include <algorithm> #include <climits> #include <cmath> #include <iomanip> using namespace std; #define ll long long int #define rep(i,n) for...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define lli long long int #define pb push_back #define mp make_pair #define pii pair<int,int> #define plli pair<lli,lli> #define vi vector<int> #define vlli vector<lli> #define vpi vector<pii> #de...
#include <iostream> #include <cstdio> #include <cmath> #include <ctime> #include <cstdlib> #include <cassert> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <string> #include <algorithm> #include <utility> #include <complex> ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <utility> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <functional> using nam...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using i64 = long long; #define forn(a, e) for (i64 a = 0; a < (i64)(e); a++) #define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++) #define fore(e, a) for (auto& e : a) #ifdef LOCAL #define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e <...
#include<bits/stdc++.h> #define M 400005 using namespace std; int n; pair<int,int> A[M],B[M],md; int cnt[2]; char S[M]; int main(){ scanf("%d",&n);n*=2; for(int i=1;i<=n;i++){ scanf("%d",&A[i].first); A[i].second=i; B[i]=A[i]; } sort(B+1,B+n+1); md=B[n/2]; for(int i=1;i<=n;i++){ int t=(A[i]<=md); if(cnt...
#include<iostream> #include<string> using namespace std; int main(){ long long N; cin >> N; int ans = 0; for(long long i=1; ; i++){ if(stoll(to_string(i)+to_string(i))<=N) ans += 1; else break; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); /*long long a,b,c; if(a==0 or a==1 or a==5 or a==6){ cout<<a<<"\n"; }else{ }*/ string memo; cin>>memo; long long th=memo.size(); map<char,long long> save; long long sum=th,ans=0,con,k,i; for(i=th-1,con=0;i>=0;...
#include <iostream> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <map> #include <set> #include <random> #include <queue> #include <stack> #include <bitset> #include <cassert> #include <unordered_map> #include <iomanip> #define int long long #define double long double #define rep(i,...
#include <iostream> #include <iomanip> #include <algorithm> #include <bitset> #include <string> #include <cmath> #include <complex> #include <numeric> #include <cassert> #include <vector> #include <array> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <utility> #define PI 3....
/* By: Anurag Rai CF: Raag07 CC: call_me_raag */ #include<bits/stdc++.h> #define FIO std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define REP(it, a, b) for(int it = a; it < b; ++it) #define all(X) (X).begin(), (X).end() #define int long long int #define ff first #define ss second #de...
#include<bits/stdc++.h> using namespace std; #define N 107 #define ldb long double char s[N][N]; int g[N][N],cnt[N],n; bool vis[N]; ldb f[N],cof[N]; void dfs(int v){ cnt[v]++; vis[v]=1; for(int i=1;i<=n;i++) if(g[v][i]&&!vis[i]) dfs(i); } int main(){ //freopen("cpp.in","r",stdin); scanf("%d",&n); for(int i=1;...
#pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define double long double using pii = pair<int, int>; template<typename T> using Prior = std::priority_queue<T>; template<typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>; #define ...
#include <iostream> #include <string> using namespace std; int main(){ int ans=0, i; string s; cin >> s; while ( s.find("ZONe")<s.size() ){ i=s.find("ZONe"); s.erase(i,4); ans++; } cout << ans; }
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> 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) <...
#include <bits/stdc++.h> using namespace std; const int MAXN = 400010; char s[MAXN]; const int MOD = 3; int cnt3[MAXN], pref_cnt3[MAXN]; int fac[MAXN]; int nck_brute (int n, int k) { long long ans = 1; for (int i = n; i > n - k; i--) ans *= i; for (int i = 1; i <= k; i++) ans /= i; return ans % 3; } int nck(int n, ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #pragma region Macros #define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i, n) FOR(i, 0, n) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a,...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX = 2e5 + 10; ll qian[MAX] , hou[MAX] , w[MAX] , h[MAX]; int N , M; int main() { cin >> N >> M; register int i; for(i = 1;i <= N; ++i) cin >> h[i]; for(i = 1;i <= M; ++i) cin >> w[i]; sort(h + 1 , h + N + 1); for(i = 2; i <= N; i...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define fi first #define se second #define unused [[maybe_unused]] #define tempT template<class T> #define pcnt(x) __builtin_popcountll(x) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> nds; #define pb push_back #define mk make_pair #define ff first #define...
#include <cstdio> int a[1005]; int b[1005]; int f[1005][1005]; int vis[1005][1005]; int max(int a,int b){ return a>b?a:b; } void solve(int i,int j){ vis[i][j] = 1; if(i==0 || j==0) f[i][j] = max(i,j); else{ if(!vis[i-1][j]) solve(i-1,j); if(!vis[i][j-1]) solve(i,j-1); if(!vis[i-1][...
// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator) #include <bits/stdc++.h> #define overload3(_1, _2, _3, name, ...) name #define rep1(i, n) for(i64 i = 0LL; i < (n); ++i) #define rep2(i, a, b) for(i64 i = (a); i < (b); ++i) #define rep(...) overload3(__VA_ARGS__, rep2, rep1)(...
/* 我的心脏怦怦跳,监管者就在附近 name: Algorithm: writer:Lxs(cdx) place: nothing is impossible */ #pragma GCC optimize(3,"Ofast","inline") #include<bits/stdc++.h> #include<string> #include<iostream> #include<cmath> #include<set> #include<stack> #include<queue> #include<unistd.h> #include<stdio.h> #include<cstring> #define random(a,b...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; cout << max(0, (2 * (a) + 100) - b) << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll, vl, greater<ll>> pql; typedef set<ll> sl; typedef pa...
#include <bits/stdc++.h> using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; typedef long double ldbl; typedef pair<int, int> pii; typedef pair<uint, uint> puu; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<double, double> pdd; typedef vector<int> vi...
#include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define chmin(x,y) x = min((x),(y)) #define chmax(x,y) x = max((x),(y)) #define popcount(x) __builtin_popcount(x) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; const int INF = 1e9; const ...
#include <iostream> using namespace std; int main() { int n; cin>>n; if(n%2==0){ cout<<"White"; } else{ cout<<"Black"; } return 0; }
//BY: YASH JAIN, CF: yashjain0333 #include <bits/stdc++.h> using namespace std; #define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(x) (x).begin(), (x).end() #define rall(v) v.rbegin(),v.rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i...
#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <climits> #include <cctype> #define rg register #define Fo(i,a,b) for(int i=(a);i< (b);++i) #define Fr(i,a,b) for(int i=(a);i<=(b);++i) #define Fl(i,a,b) for(int i=(a);i>=(b);--i) #define Fill(x,n) memset((x),(n),sizeof(x)) using name...
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0, length = n; i < length; i++) #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ep emplace #define epb emplace_back #define scll static_cast<long long> #define sz(x) static_cast<int>((x).size()) #define pfll(x) printf("%lld...
#include <bits/stdc++.h> using namespace std; typedef long long i64; typedef unsigned long long ui64; typedef vector<i64> vi; typedef vector<vi> vvi; typedef pair<i64, i64> pi; #define pb push_back #define sz(a) i64((a).size()) #define all(c) (c).begin(), (c).end() #define REP(s, e, i) for(i=(s); i < (e); ++i) inlin...
#include <bits/stdc++.h> using namespace std; string ans[20]; void output(); void init(); bool yokoni_dekirudake_umeru(); void yokoni_umeru(int,int); int n,m; int used_m; string next_s(); vector<string> s; int main(){ //2,3は無視でいいんじゃないか? init(); bool filled = false; while(used_m < m && !filled){ fill...
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl '\n' #define Endl '\n' #define cont continue #define gcd(a,b) __gcd(a,b) #define lcm(a,b) a*b/__gcd(a,b) #define pb push_back #define mp make_pair ...
/* これを入れて実行 g++ code.cpp ./a.out */ #include <iostream> #include <cstdio> #include <stdio.h> #include <vector> #include <string> #include <cstring> #include <queue> #include <deque> #include <stack> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <unordered_set...
#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; 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.14159265358979323846264338327950ll #define debug(x) cout<<#x<<" :: "<<x...