code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
//This Code was made by Chinese_zjc_. #include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <bitset> #include <cmath> #include <queue> #include <stack> #include <string> #include <cstring> #include <cstdio> #include <cstdlib> #include <map> #include <set> #include <time.h> // #include<w...
/*#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 #define doublecout(a) cout<<setprecision(16)<<a<<endl; using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける u...
#include <bits/stdc++.h> using namespace std; int cnt[26]; int main() { string s; cin >> s; reverse(s.begin(), s.end()); long long ans = 0; vector <int> all; for (int i = 0; i < s.size(); i++) { int j = i; while (j < s.size() && s[i] == s[j]) j++; if (j - i >= 2) { ans += i - cnt[s[i] - 'a']; memset(...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #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--) #define all(v) v.begin(), v.end() void c...
#include<bits/stdc++.h> using namespace std; int f(int x) { int ans=0; while(x) { if(x&1)ans++; x>>=1; } return ans; } int ksm(int a,int b) { int ans=1; while(b) { if(b&1)ans*=a; a*=a; b>>=1; } return ans; } int main() { int n,m; cin>>n; m=ksm(2,n)-1; cout<<m<<"\n"; for(int i=1;i<=m;i++) { ...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); ++i) #define FOR(i, c) for(__typeof((c).begin()) i = (c...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { map<char, int> ch; string s, t, w; cin >> s >> t >> w; for (char c : s) ch.emplace(c, 0); for (char c : t) ch.emplace(c, 0); for (char c : w) ch.emplace(c, 0); if (ch.size() > 10) { cout << "UNSOLVABL...
#include <bits/stdc++.h> using namespace std; int main() { int h, w, x, y; cin >> h >> w >> x >> y; bool arr[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { arr[i][j] = false; } } for (int i = 0; i < h; i++) { string s; ...
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; for(int i=1;i<=n;i++){ cout<<(i+1)/2<<" "<<(n+i+1)/2<<endl; } }
#include <cstdio> int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ printf("%d %d\n",(i<<1)%n+1,(i<<1|1)%n+1); } return 0; }
#include <bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ #define pii pair<int,int> #define fi first #define pb push_back #define si second #define int long long #define mod 998244353 #define fast ios_base::sync_with_stdio(false); cin....
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin>> #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeo...
#include <cstring> #include <iostream> using namespace std; using ll = long long; const int MAXN = 102; const int MAXC = 122505; ll k, mod, table[MAXN][MAXC], ret[MAXN]; int n, now; void calc() { memset(table, 0, sizeof(table)); table[0][0] = 1; for (int i = 1; i <= n; ++i) { int c = (k * (i + 1...
/*Lucky_Glass*/ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=101,M=125001; #define ci const int & int n,m,MOD; int f[N][M]; inline int Add(ci a,ci b){return a+b>=MOD? a+b-MOD:a+b;} inline int Sub(ci a,ci b){return a-b<0? a-b+MOD:a-b;} inline int Mul(ci a,ci b){return int(1l...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; string S, X; cin >> S >> X; vector<int> pow_10(N); int tmp = 1; for (int i=N-1;i>=0;i--) { pow_10[i] = tmp; tmp = tmp*10%7; } ...
//#pragma GCC optimize(2) #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false);cin.tie(nullptr) #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define mkp make_pair #define lc(x) ((x)<<1) #define rc(x) (((x)<<1)|1) using namespace std; typedef long long ll; typedef unsigned ...
/* _(┐「ε:)_ */ #include <bits/stdc++.h> using namespace std; #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define er equal_range #define spc(x, y) setprecision(y) << fixed << x #define slc(x, w, c)...
#include "bits/stdc++.h" using namespace std; #define int long long #define forn(i,n) for(int i = 0; i < n; i++) #define pb push_back #define sz(x) ((int)(x).size()) #define dbg(x) cerr << #x << "->" << x << "\n"; #define prnt(x) cerr<<"{ ";for(auto i:x)cerr<<i<<" ";cerr<<"}\n"; void solve() { int N; cin >> N; vecto...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; typedef unsigned long long ull; constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/ #de...
#include <iostream> using namespace std; //#define int long long const int maxm=1e3+5; int g[maxm][maxm]; int mark[maxm]; int a[maxm]; int b[maxm]; int c[maxm]; int ans[maxm]; int n,m; void dfs(int x){ mark[x]=1; for(int i=1;i<=n;i++){ if(g[x][i]){ g[i][x]=0; if(!mark[i]){ ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; using V = vector<ll>; using VV = vector<V>; using M = map<ll, ll>; using Q = queue<ll>; using PQ = priority_queue<ll>; using ST = stack<ll>; using Graph = vector< vector<ll> >; using VP = vector<P>; #define rep(i, n) for(...
#define _CRT_SECURE_NO_WARNINGS 1 #define _CRT_DECLARE_NONSTDC_NAMES 0 // for using y1 as variable name #include <iostream> #include <cstdio> #include <utility> #include <algorithm> #include <vector> using namespace std; using ll = long long int; constexpr ll MOD = 1000000007; int n; vector<int> d; ll res; int main...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <typename T> inline bool chmax(T &current, const T &test){ if (current < test){ current = test; return true; } return false; } template <typename T> inline bool chmin(T &curr...
#include<bits/stdc++.h> using namespace std; int mod=1e9+7; const int N=2e5+5; int32_t main() { int ans=0; int n; cin>>n; vector<vector<int> > a(n,vector<int> (5)); vector<vector<int> > dp(5); for(int i=0;i<n;i++) { for(int j=0;j<5;j++) { cin>>a[i][j]; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define f(i,a,b) for( ll i = a; i < b ; i++ ) #define af(i,a,b) for( ll i = a; i >= b ; i--) #define rep(i,a,b,k) for(ll i = a; i < b ; i+= k ) #define arep(i,a,b,k) fo...
#include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <bitset> #include <iomanip> #include <cmath> #include <set> #include <unordered_set> #include <functional> #include <map> #include <unordered_map> #include <string> #include <tuple> using namespace std; using ll = long...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define rep(i,a) for(ll i=0; i< a; i++) #define rep1(i,a) for(ll i = 1; i< a; i++) #define foi(i, a, b) for(ll i = a; i<b ; i++) #define fod(i, a, b) for(ll i = a; i>=b ; i--) #define max3(a, b, c) max(max(a, b), c) #defin...
#include <bits/stdc++.h> using namespace std; int main() { int N = 0 ,A = 0 ,B = 0; cin >> N >> A >> B; cout<< N - A + B << endl; }
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #include<ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; #define forn(i,x1,n) for(int i=x1;...
#include<bits/stdc++.h> #define LL long long using namespace std; const int mn=2e6+6,mod=1e9+7; int n,m,k; LL fac[mn],inv[mn]; LL qpow(LL a,LL b) {LL ans=1;while(b) {if(b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;} void init() { fac[0]=inv[0]=1; for(int i=1;i<mn;++i) fac[i]=fac[i-1]*i%mod; inv[mn-1]=q...
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define pii pair<int,int> #define fastIO ios_bas...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<math.h> #define ll long long using namespace std; int main() { string s; cin>>s; if(s[0]==s[1]&&s[1]==s[2]) cout<<"Won"<<endl; else { cout<<"Lost"<<endl; } }
#include<bits/stdc++.h> // #include<atcoder/all> // #include<boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace atcoder; // using bint = boost::multiprecision::cpp_int; using ll = long long; using ull = unsigned long long; using P = pair<int,int>; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #de...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define PI acos(-1) #define pb push_back #define int long long #define ld long double #define sp fixed<<setprecision #define bp __builtin_popcountll #define all(x) x.begin(),x.end() #define pii pair<long long,long long> #define FAST ios_ba...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 main() { ll x,y,a,b,ans=0; cin>>x>>y>>a>>b; while(1) { if(x>=1e9) { break; } else { if((a-1)*x<b) { ...
#include<bits/stdc++.h> #include<vector> #include<map> #include<unordered_set> #include<set> using namespace std; #define flush #define pb push_back #define ed endl #define cout1(a) cout<<a #define cout2(a,b) cout<<a<<b #define cout3(a,b,c) cout<<a<<b<<c #define ll long long #define ld long double #define db double #de...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if ...
#include <bits/stdc++.h> using namespace std; const int O = 2e5 + 1; vector <int> c, dp, g[O], Max; int t = 1; bool how_sort(int x, int y){ return Max[x] < Max[y]; } int dfs(int u, int par = 0){ Max[u] = 0; for (int v : g[u]){ if (v == par) continue; dp[v] = dp[u] + 1; Max[u] =...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} int dx[4]={0,1,0,-1}, dy[4]={1,0,...
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace chrono; typedef long long int ll; typedef vector<int> vii; typedef vector<ll> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define pb push_back #define odd(x) ((x)&1) #define even(x) (!odd(x)) #define all(v) (v).begin(),(v).e...
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <numeric> #include <functional> using namespace std; typedef long long ll; typedef...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; int V[400005]; vector<int> A; vector<int> B; int main(){ int N; scanf("%d", &N); long long ans = 0; for(int i = 0; i < 2*N; i ++){ scanf("%d", &V[i]); ans += V[i]; } for(int i = 0; i < N; i ++){ ...
#include <bits/stdc++.h> //#include <iostream> //#include <vector> using namespace std; int main(){ int a,b,c; cin >> a >> b >> c; cout << 21-(a+b+c); return 0; }
#include <bits/stdc++.h> //#include <atcoder/all> #define rep(i, n) for (int i=0; i < (n); i++) using namespace std; //using namespace atcoder; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> P; const int INF = 1 << 30; const ll LINF = 1LL << 61; const int NIL = -...
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define rep(i, n) FOR(i,0,n) #define irep(i, n) IFOR(i,0,n) #define all(v) begin(v), end(v) using namespace std; using ll = long long; using ull = unsigned long long; using P ...
#include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <set> #include <map> #include <math.h> #include <string> #include <numeric> #include <queue> #include <cstdio> #include <cstring> #define ll long long #define rep(i,n) for(ll i=0;i<n;++i) #define rep1(i,n) for(ll i=1;i<n;++i) #define...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> #include<cstring> #include<algorithm> 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 ...
#include <stdio.h> #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include <algorithm> //#include <atcoder/All> using namespace std; //using namespase atcoder; int main(){ const long nPrime = 1000000007; int t; scanf("%d", &t); for(int iCount = 0; iCount < t; iCount++){ long n,a...
/** * author: pankaj_m05 * created: 06.02.2021 17:35:00 **/ #include<bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); int v, t, s, d; cin >> v >> t >> s >> d; if (d < v * t || d > v * s) { cout << "Yes"; } else { cout << "No"; } ...
#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...
/************************************************************************* > File Name: F.cpp > Author: Bran > Mail: 1811161330@qq.com > Created Time: 2020/12/19 23:11:30 ************************************************************************/ #include <bits/stdc++.h> #define all(x) x.begin(), x.en...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; //https://algo-logic.info/segment-tree/#toc_id_3_2 template <typename X> struct SegTree { using FX = function<X(X, X)>; // X•X -> X となる関数の型 int n; FX fx; const X ex; vector<X> dat; SegTree(int n_, F...
#include<bits/stdc++.h> #define ll long long #define N 200005 using namespace std; int read() { int x=0,f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} return x*f; } int n,m,K,cnt,h[N],c[N],fp[N]; struct Edge { int to,next; }a[N*2]; void Add(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>; void chmin(int& x, int y) { x = min(x,y);} int main() { int n, m; cin >> n >> m; vector<vector<int>> to(n); rep(i,m) { int a, b; cin >> a >> b; --a; --b; ...
//x<<y=x*2^y,x>>y=x/2^y //1e5+3 is prime // in a matrix, all elements of a primary diagonal have constant diff of coordinates // and a secondary diagonal has constant sum of coordinates //use ll() for using an integer in self-built fn //(x&-x) bitwise and of (x and its 2's complement) returns (last set bit) //eg if x=1...
#include <bits/stdc++.h> using namespace std; #define rep(i,n)for(int i=0;i<(n);i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back #define int ll using ll = long long; using P = pair<int, int>; using int128 = __int128_t;//cin coutはできない const int mod = 998244353; s...
#include <bits/stdc++.h> using namespace std; //basic input and data type #define ll long long #define loop(a,b) for(ll int i=a;i<b;i++) #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi(x) printf("%d\n",x) #define pl(x) printf("%lld\n",x) #define ps(s) printf("%s\n"...
#include<bits/stdc++.h> using namespace std; int const maxn=2e5+10; int noded=0,tot,cou,son[maxn],head[maxn],n,m,deep[maxn],fa[maxn],ans[maxn]; struct edge{ int v,nxt; }e[maxn<<1]; void build(int x,int y){ e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot; } void getans(int x){ ans[x]=++cou; for(int i=hea...
#include "bits/stdc++.h" using namespace std; typedef long long ll; ll num[200100]; int mi = 100099; bool cmp(int a,int b){ return a > b; }; int main() { // ios::sync_with_stdio(0); // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // memset(s1, 0, sizeof(s1)); // memset(s2, 0, s...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i,x,n) for(int i = x; i < n; ++i) #define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it) typedef long long ll; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n...
#include<bits/stdc++.h> using namespace std; const int MAX = 3010; bool dp[MAX][4][32]; void init(){ for(int i=0; i<MAX; i++){ for(int j=0; j<4; j++){ for(int k=0; k<32; k++){ dp[i][j][k] = false; } } } dp[0][0][0] = true; } int main(){ int N; cin >> N; vector<vector<int>> vec(...
#include<bits/stdc++.h> //#pragma GCC optimize "trapv" //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define fast_az_fuk ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll int #define lll __int128 #define ull unsigne...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> #define MOD 1000000007 #define INF 1000000000 #define ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) ll n,k; vector<string> s(101); char a; int main(){ cin>>n>>k>>s[0]; rep(i,k){ rep(j,n)s[i].push_back(s[i][j]); rep(j,n){ if(s[i][2*j]==s[i][2*j+1])a=s[i][2*j]; else if((s[i][2*j]=='R' ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < n; ++i) using ll = long long; using P = pair<int,int>; // auto mod int const int mod = 1000000007;//998244353; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);...
/** * Written by : Ujjawal Pabreja [cuber_coder] * Email : ujjawalpabreja99@gmail.com */ #include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ld long double #define endl "\n" const int mod = 1e9 + 7; const int MAX = 2e5 + 1; ll power(ll x, ll p) { ll ans = 1; while...
#include <iostream> #include <algorithm> #include <string> #include <complex> #include <vector> #include <set> #include <cmath> #include <queue> #include <map> #include <stack> #include <bitset> #include <numeric> //lcm #include <iomanip> //double精度 setprecision #include <chrono> #include <random> #include <cassert> ...
#include<bits/stdc++.h> using namespace std; #define ll long long bool decimal(ll n) { while(n) { int r=n%10; if(r==7) return true; n/=10; } return false; } bool octal(ll n) { while(n) { int r=n%8; if(r==7) return true; n/=8; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<stack> #include<string> #include<map> #include<set> #include<tuple> #include<cmath> #include<iomanip> using namespace std; typedef long long ll; typedef vector<ll> v; typedef vector<vector<ll>> vv; #define MOD 1000000007 #define INF 10...
#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 codeWizard ios_base::sync_with_stdio(0);cin...
#include<bits/stdc++.h> using namespace std; int mod=1e9+7; const int N=2e5+5; int32_t main() { int ans=0; int n; cin>>n; vector<vector<int> > a(n,vector<int> (5)); vector<vector<int> > dp(5); for(int i=0;i<n;i++) { for(int j=0;j<5;j++) { cin>>a[i][j]; ...
#include <sys/time.h> #include <iostream> #include <iomanip> #include <algorithm> #include <utility> #include <cmath> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <utility> #include <cctype> #include <cstdlib> #include <typeinfo> /* #inc...
#include <iostream> #include <string> #include <array> #include <vector> #include <set> #include <map> #define INI_1(N) N #define INI_5(N) N, N, N, N, N #define INT_10(N) INT_5(N), INT_5(N) #define INT_20(N) INT_10(N), INT_10(N) #define INT_50(N) INT_10(N), INT_20(N), INT_20(N) #define INT_100(N) INT_50(N), INT_50(N) ...
#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>; bool solve(int v, int c, vector<vector<int>>& G, vector<int>& color) { if (color[v] != -1) { if (color[v] != 2 && color[v] != c) { color[v] = -2; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> adj(n); for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; --u, --v; adj[u].push_back(v); adj[v].push_back(u); } vector<...
#include<bits/stdc++.h> #define endl '\n' #define ll long long #define ld long double #define ull unsigned long long using namespace std; struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io; const ll mod=10; int g=0; int a[100000][2]; ld cmp(ld a,ld b){ return a>b; } ll qpow(ll a,ll b){ ll ans=1,x=a,y=...
///ShzFahad #include<bits/stdc++.h> using namespace std; #define ll long long int #define ld long double int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; map<string,ll>mp; while(n--) { string s; cin >> s; mp[s]++; } for(auto it=mp....
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { const ll INF = 1e18; ios_base::sync_with_stdio(0); cin.tie(0); int n; ll x; cin >> n >> x; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; // number of possible values of y // y, y-x u...
//Author: Fuadul Hasan(fuadul202@gmail.com) //BSMRSTU,Gopalganj //#include<bits/stdc++.h> #define _USE_MATH_DEFINES #include <set> #include <map> #include <list> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <cstdio> #include <string> #include <vector> #include <bitset> #include <random> ...
#include <bits/stdc++.h> using namespace std; class Node { public: int x; int y; int cost; Node() {} Node(int _x, int _y, int _cost) { x = _x; y = _y; cost = _cost; } }; class Point { public: int x; int y; Point() {} Point(int _x, int _y) { x = _x; ...
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <stack> #include <cassert> #include <map> #include <numeric> #include <cstring> #include <set> #include <ctime> #include <queue> #include <cmath> #include <iomanip> #include <iterator> using namespace std; class InputReader { publi...
/* In the name of ALLAH Author : Raashid Anwar */ #include <bits/stdc++.h> using namespace std; #define int int64_t #define mod 1000000007 int power(int a,int b) { int r=1; while(b) { if(b&1) r=(r*a)%mod; a=(a*a)%mod; b>>=1; } return r; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int N,K,M; cin >> N >> K >> M; int sum=0; for(int i=0; i<N-1; i++) { int ai; cin >> ai; sum += ai; } for(int i=0; i<=K; i++) { if((sum + i)/N >= M) { cout << i << endl; return 0; } } pu...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define int long long #define ll long long #define pi (3.141592653589) #define mod 1000000007 #define float double #define pb push_back // #define mp make_pair #define ff first #define ss second #define all(c) c.begin(), c.end() #define min3(a, b, c) min(c...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i) #define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i) #define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 60) -123456789; #define fastio cin.tie(0); ios_base::s...
#include<bits/stdc++.h> using namespace std; #define DONTSYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now! #define TEST unsigned long long T; cin>>T; while(T--) //loop over each testcase #define endl "\n" #define for...
#pragma region header #include <bits/stdc++.h> using namespace std; #define rep(i,n)for(int i=0;i<(n);i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back #define int ll #define each(i, a) for (auto &&i : (a)) using ll = long long; using ld = long double; using vi = v...
//#include <atcoder/all> #include <bits/stdc++.h> using namespace std; //using namespace atcoder; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector<ll>; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector<vector<pair<ll, ll>>>; Graph G; vll dist; vector<bool> se...
#include <bits/stdc++.h> using namespace std; #define e1 first #define e2 second #define pb push_back #define mp make_pair #define boost {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } #define eb emplace_back #define OUT(x) {cout << x; exit(0); } #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define scanf...
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; int A[200010]; int X[200010]; for(int i = 1; i <= N; i++){ cin >> A[i]; X[A[i]] = i; } vector<int> op; for(int i = 1; i <= N; i++){ if(A[i] == i) continue; int a = X[i]; ...
#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 lli long long int #define double long double #define all(x) x.begin(),x.end() #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); const int mod=1e9+7; int n,ans=0; cin>>n; vector<long long>sum(n+1); vector<vector<int> >lst(n+1,vector<int>(n+1)),dp(n+1,vector<int>(n+1)); for(int i=1;i<=n;i++) { long long ...
#include<bits/stdc++.h> typedef uint64_t u64; typedef int64_t i64; typedef long double f128; using namespace std; template<typename T> void scan(T& n){ cin>>n; } void scan(){} template<typename T,class... Args> void scan(T& n,Args&... args){ scan(n); scan(args...); } template<typename T> void scanall(T start,...
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/ /*:::::::::::::J A I S H R E E R A M::::::::::::::::*/ /*::::::::::::::::::::::::::::::::::::::::::::::::::::*/ #include <bits/stdc++.h> using namespace std; #ifdef LUCTIVUD #include <buggyBaby.hpp> pretty:: PrettyPrinter NonIterable; #define cerr ...
/** * author: Hritik Raj * created: 06-06-2021 17:33:26 **/ #include <bits/stdc++.h> using namespace std; #define int long long void solve(){ int n; cin>>n; int ans = 0; for(int i=0;i<n;i++){ int x; cin>> x; ans += max(0LL, x-10); } cout<<ans<<"\n"; } int32_t main(){...
#include<cstdio> const int mod(1e9+7); long long f(int x) { long long res=1; for(int i=1;i<=x;i++) res=(res*i)%mod; return res; } long long pow(long long x,int p) { long long res=1; while(p) { if(p%2) res=(res*x)%mod; p/=2; x=(x*x)%mod; } return res; } long long c(int n,int m) { return ((f(n)*pow(f(m...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<vi> vvi; typedef vector<pll> vll; typedef vector<vl> vvl; #define fori(i, n) for (in...
#include <bits/stdc++.h> using namespace std; #define int long long int #define double long double #define pb push_back #define fi first #define se second #define vi vector<int> #define pii pair<int,int> #define vpii vector<pii> #define pqi priority_queue<int> #define test int tcase; cin>>tcase; for(int tc = 1; tc <=...
#include<bits/stdc++.h> #define ll long long using namespace std; template <typename T, typename TT> void print(T c, TT a,int n){ vector<int> r; for(int i=0;i<n;i++) r.push_back(a[i][0] - c[0]); int mi = *min_element(r.begin(), r.end()); if(mi<0){ for(auto &x:r) x+=abs(mi); for(auto &x:c) x-=abs(mi)...
#include<iostream> #include<cstdio> #include<vector> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int p=1e9+7; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n,k; cin>>n>>k; while(k--){ if(n%200==0) n/=200; else n=n*1000+200; } cout<<n; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define fi(a,b) for(int i=(a);i<(b);i++) #define fj(a,b) for(int j=(a);j<(b);j++) #define pb(n) push_back(n) string ts(int a){ string q=""; while(a!=0){ q+=a%10+48; a/=10; } return q; } int main(){ string s; ll n,k; cin>>s>>k; istringstream ...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; a=(a*a)+(b*b); c=a-(c*c); if(c<0) cout<<"Yes"<<endl; else cout<<"No"<<endl; }
/* Ashraful Islam Paran 24-April-2021 18:03:40 */ #include <bits/stdc++.h> using namespace std; #define int long long #define f(n) for (int i = 0; i < n; i++) #define show(x, y) cout << x << " " << y << "\n" #define fo(i, x, n) for (int i = x; i < n; i++) #define fb(i, x, n) for (int i = n - 1...
#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); #define m_p make_pair #define x first #define y second using namespace std; using LL=long long; using ULL=unsigned long long; using LD=long double; using P=pair<int,int>;...
// Code for B - Many 110 #include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++) #define MOD 1000000007 #define mod(x) ( (x) % MOD + MOD ) % MOD #define debug(var) do{std::cout << #var << " : ";view(var);}while(0) ...
#include <bits/stdc++.h> using namespace std; int main(){ int H,W; cin >> H >> W; vector<string> S(H); for(int i=0; i<H; i++){ cin >> S.at(i); } int count = 0; //横 for(int i=0; i<H; i++){ for(int j=0; j<W-1; j++){ if(S.at(i).at(j)=='.' && S.at(i).at(j+1)=...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < n; ++i) using ll = long long; using P = pair<int,int>; int main() { int h,w;cin>>h>>w; vector<string> v; string last(w+1,'#'); rep(i,h){ string s;cin>>s; v.push_back(s); v[i].push_back('#'); } int ans=...
#include <algorithm> #include <complex> #include <cstdlib> #include <ctime> #include <time.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <numeric> #include <lim...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int inf=0x3f,INF=0x3f3f3...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < n; i++) #define rep2(i, s, n) for (int i = (s); i < n; i++) #define sort(A) sort(A.begin(),A.end()) #define reverse(A) reverse(A.begin(),A.end()); #define vecint(A, n) vector<long long int> A(n); #define vecint2(A, n, m) vector<vector<long long>> A(n,...
#include<bits/stdc++.h> #define ll long long using namespace std; int read() { int a=0,f=1,c=getchar(); while(!isdigit(c)) { if(c=='-')f=-1; c=getchar(); } while(isdigit(c)) { a=a*10+c-'0'; c=getchar(); } return a*f; } const int K=1e5+10; int k; int n,m; ll a[K],L[K],R[K]; bool check(ll d) { ll ...
#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, m, t; cin >> n >> m >> t; int lt = 0; int battery = n; bool ok = true; rep(i, m) { int a, b; cin >> a >> b; battery -= a - lt; if (battery <= 0) { ...
#include <iostream> using namespace std; long long s[1006], e[1006]; int main() { long long n, m, t; cin >> n >> m >> t; for (int i=0; i<m; i++) { cin >> s[i] >> e[i]; } long long count; count=n; count-=s[0]; for (int i=0; i<m; i++) { if (count<=0) { ...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18; void print0() {} template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);} void p...
#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() constexpr ll MOD=1000000007; constexpr ll INF=2e18; ll power(ll x, ll y){ x%=MOD; ll ret=1; w...
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<string> #include<unordered_map> #include <iomanip> using namespace std; #define intmax INT_MAX #define lmax LON...
/////////////////////////////////TEST CASES//////////////////////////////////// /* */ /////////////////////////////////////CODE////////////////////////////////////// //#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 998244353; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) <<...
#include <iostream> #include <string> #include <vector> #include <queue> #include <stack> #include <algorithm> #include <numeric> #include <map> #include <set> #include <cstring> #include <cmath> #include <iomanip> #include <cassert> #include <random> const int32_t MOD = 998244353; int32_t dfs(int32_t x, std::vector<...
#include<cstdio> using namespace std; typedef long long LL; const int maxn=100,maxm=499950; int n,K,MOD,f[maxn+5][maxm+5],F[maxn+5]; int main(){ scanf("%d%d%d",&n,&K,&MOD);f[0][0]=1; for (int i=1,sum=i*K;i<=n;i++,sum+=i*K){ for (int j=0;j<i;j++) F[j]=0; for (int j=0;j<=sum;j++){ F[j%i]=(F[j%i]+f[i-1][j])%MOD...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long N; long long A[1 << 18]; long long dp1[1 << 18][2]; long long dp2[1 << 18][2]; int main(){ cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; dp1[1][0] = 1; dp2[1][0] = A[1]; for (int i = 2; i <= N; i++) { for (int j = 0; j ...
#include <iostream> #include <string> #include <vector> #include <list> #include <map> #include <queue> #include <stack> #include <algorithm> #include <fstream> #include <sstream> #include <iomanip> #define ll long long using namespace std; long long MOD = 1000000007; struct info{ ll num; ll cost; }; bool o...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define INF LONG_MAX/3 //#define DIV 1000000007 //#define DIV 998244353 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, ...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define pii pair<int,int> #define INF 1000000000 #define all(x) (x.begin(), x.end()) #define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0) typedef vector<int> vi; void testcases() { #ifndef ONLINE_J...
#include <bits/stdc++.h> std::vector<std::string> split(const std::string& source, const char delim); struct Node{ explicit Node(const int nodeId) :node_id(nodeId){ }; int addNode(const std::shared_ptr<Node>& nodeSptr){ child_node_sptr_list.emplace_back(nodeSptr); return 0; }; ...
#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 endl '\n' #define f first #define s second #define ub upper_bound #define lb lower_bound #define pb push_back #define all(c) (c).begin(), (c).end() #define ...
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<cstdlib> #include<cmath> #include<map> #include<queue> #include<stack> #include<set> #include<iomanip> #include<iterator> #include<sstream> using namespace std; int main() { long long n,a,b,ta,ao,i,k,l; vector<pair<lon...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define pop_b pop_back #define pf push_front #define pop_f pop_front #define mt make_tuple #define eb emplace_back #define sf(x) sizeof(x) #define len(x) x.length() ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpii ve...
#include <bits/stdc++.h> using namespace std; using ll = long long ; int main() { string S, small, large ; cin >> S ; small="abcdefghijklmnopqrstuvwxyz" ; large="ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; int size_S=S.size(), size_small=small.size(), size_large=large.size() ; for(int i=0;i<size_S;i++){ if(i%2==0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "...
#include <bits/stdc++.h> using namespace std; int main() { size_t N; long long K, M; cin >> N >> K >> M; vector<vector<long long>> dp(N + 1, vector<long long>(N / 2 * (N / 2 + 1) / 2 * K + (N + 5), 0)); dp[0][0] = 1; for (size_t i = 1; i <= N; i++) { vector<long long> sum(i, 0); ...
#include <iostream> #include <iomanip> #include <algorithm> #include <array> #include <cassert> #include <optional> #include <utility> #include <vector> //#include <atcoder/all> template <class InputIterator> std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_ar...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() using ll = long long; using P = pair<ll, ll>; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; string char_to_string(char val) { return string(1, val); } int ...
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int N; cin >> N; vector<long long> A; A.push_back(0); for (int i = 1; i <= N; i++) { long long a; cin >> a; A.push_back(a); } vector<long long> max_move, move; max_move.resize(N + 1...
#include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int c = 0; map<int,int> m; for(int i = 2; i*i <= n; i++) { int x = i*i; if(m[i] == 1) continue; while(x <= n) { m[x] = 1; c++...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define ld long double #define mod 1000000007 #define pb push_back #define mp make_pair #define pf push_front #define ff first #define ss second #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b)) #define vl vector<lli> #define vl...
#include <bits/stdc++.h> using namespace std; #define int long long int #define vi vector<int> #define ff first #define ss second #define pb push_back #define MOD 1000000007 //const int nax = 1e6+5; #define inf 4e18 #define display(v) for(int i =0;i<(int)v.size();++i)cout << v[i] << " " #define all(v) v.begin(),...
#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>; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const...
#include<iostream> #include<cassert> using namespace std; typedef long long ll; template <int N> struct modInt { long long val; modInt(ll v){ this->val = v%N; } int toInt(){ return this->val; } void operator=(const ll other){ this->val = other%N; } }; template<int ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define deb(...) #endif #define endl "\n" #define pb push_back // #define int long long #define ll long long #define pii pair<int,int> #define F first #define S second #define all(c) c.begin(),c.end() #define read(v) for(auto &it:v) cin...
#include <bits/stdc++.h> #define rep(i,n) for (ll i = 0; i < n; ++i) using namespace std; using ll = long long; int main(){ ll n; cin >> n; vector<ll> a(n); vector<ll> p(n); vector<ll> q(n); rep(i,n){ cin >> a[i]; if(i==0){ p[i] = a[i]; q[i] = p[i]; ...
#define _DEBUG #include "bits/stdc++.h" #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,a4,x,...) x #define debug_1(x1) cout<<#x1<<": "<<x1<<endl #define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl #define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl #define ...
#include <bits/stdc++.h> using namespace std; ////////////////////////////////////////////////////////////////////////////<editor-fold desc="macros"> //#define mod 9999991 long mod=9999991; #define endl "\n" #define long long long #define all(v) (v).begin(),(v).end() #define makeset(v) (v).resize(unique((v).begin(),(v...
#include <iostream> #include <iomanip> #include <vector> #include <set> #include <string> #include <queue> #include <algorithm> #include <map> #include <cmath> #include <numeric> #include <list> #include <stack> #include <cstdio> #include <cstdlib> #include <cstring> #include <tuple> #include <deque> #include <complex>...
#include <bits/stdc++.h> #define eprintf(args...) fprintf(stderr, args) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) const int mxn = 2e5 + 5; int n, a[mxn], b[mxn]; std::map <int, std::vector <int> > oa, ob; int s[mxn]; void update(int x, int v) { for (++ x; x < mxn; x += x & -x) s[x] += v; } int query(i...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; deque<char> t; int n = s.size(); int rev = 0; for (int i = 0; i < n; ++i) { if (s[i] == 'R')rev = 1 - rev; else { if (rev == 0) { if (t.size() > 0 && t.back() == s[i]) t.pop_b...
#include<bits/stdc++.h> #include<string> using namespace std; const int N=1e3+10; typedef long long ll; int n,k,q,m,h,w; const ll mod=998244353; int a[N]; int b[N]; map<int,map<int,int> > mp; set<int> se; string s; stack <int> st; int X[]={-1,-1,-1,0,0,1,1,1}; int Y[]={-1,0,1,-1,1,-1,0,1}; int main() { int A,B,...
#include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int long long #define mod 1000000007 #define pb push_back #define endl "\n" #define fi first #define se second #define ll long long #define inf 9000000000000000000 #define PI 3.14159265359 ...
/* written by Pankaj Kumar. country:-INDIA Institute: National Institute of Technology, Uttarakhand */ #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 long long ll ; typedef unsigned long long ull...
#include <bits/stdc++.h> using namespace std; /* ループ処理 0からnまで*/ #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, M; cin >> N >> M; std::vector<int> v = {}; rep(i, N) { int temp; cin >> temp; v.push_back(temp); } rep(j, M) { int temp; cin >> temp; auto itr...
#include <bits/stdc++.h> #define Fast cin.tie(0), ios::sync_with_stdio(0) #define All(x) x.begin(), x.end() #define louisfghbvc int t; cin >> t; while(t--) #define sz(x) (int)(x).size() using namespace std; typedef long long LL; typedef pair<LL, LL> ii; typedef vector<int> vi; template<typename T> istream& operator>>...
/*input 2 4 1 2 4 */ #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>; // p[i][j] = (-1: do not pair, 0: ok, 1: fixed) int p[205][205]; int main() { int n; cin >> n; int n2 = n*2; // type[i] = (0: either, -1: start, ...
// #pragma GCC optimize(2) // #include <random> // #include <windows.h> // #include <ctime> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cstdio> #include <cctype> #include <bitset> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack> #include...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++i) #define per(i, a, b) for (int i = (a) - 1, i##end = (b); i >= i##end; --i) #define REP(i, a) rep(i, 0, a) #define PER(i, a) rep(i, a, 0) namespace IO { const int MAXIOSIZE = 1 << 24 | 1; unsigned char...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int N; vector<vector<int>> es; vector<int> A, B; vector<int> depth; vector<ll> dp; void DepthDFS(int a, int d) { depth[a] = d; for (int next : es[a]) { if (dept...
#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); } template <typename T> class Dijkstra { private: struct edge { int to; T cost; }; vector<ve...
#include <bits/stdc++.h> using namespace std; #define DEBUG #ifdef DEBUG inline void debug_print() { cerr << endl; } template <typename T1, typename... T2> void debug_print(const T1 a, const T2 &... b) { cerr << a << ' '; debug_print(b...); } #define debug(...) cerr << __LINE__ << ": [" << #__VA_ARGS__ << "] = " , deb...
// C - Large RPS Tournament #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) char not_loser(char a, char b){ char w = a; if(a=='R' && b == 'P') w = b; if(a=='P' && b == 'S') w = b; if(a=='S' && b == 'R') w = b; return w; } int main(){ int N, K; string S; cin>>N>>K>>S; while(K...
#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; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { printf("%d %d\n", (i + 1) / 2, i + (n - i + 1) / 2); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef pair<int,int> Pair; typedef tuple<int,int,int> tpl; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c...
/* Code written by Talant I.D. */ #include <bits/stdc++.h> //~ #include <ext/pb_ds/assoc_container.hpp> //~ using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; //~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_s...
#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) for (int i = n - 1; i >= 0; --i) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define len(x) (int)(x).size() #define pb push_back #define em emplace_back #define ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; //const ll INF = numeric_limits<ll>::max() / 4; //const int INF = numeric_limits<int>::max() / 4; int main() { // ll N; ll K, N, M; cin >> K >> N >> M; vector<ll> A(K,0); for(int i = 0; i < K; i++) cin >> A[i]; v...
#include <map> #include <set> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <numeric> #include <sstream> ...
#include<bits/stdc++.h> int main(){ using namespace std; long x; cin >> x; cout << max(x, 0L) << endl; return 0; }
#include <bits/stdc++.h> //#include <atcoder/all> //#include "Z:\2_Src\31_Luzhiles_s.git\template\template.cpp" using namespace std; //using namespace atcoder; template<typename T> using ve=vector<T>; using ll=long long; using ld=long double; using str=string; using pint=pair<ll,ll>; using vll=ve<ll>; using vd=ve<ld>...
//author: .rod. //#include <bits/stdc++.h> #include <iostream> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <chrono> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio>...
#include <stdio.h> int main(){ char c[3]; scanf("%c%c%c", &c[0], &c[1], &c[2]); if(c[0] == c[1] && c[1] == c[2]){ printf("Won"); return 0; } printf("Lost"); }
#include <bits/stdc++.h> using namespace std; #define rep(i, start, n) for (int i = start; i < (n); i++) using ll = long long; int main() { int V, S, T, D; cin >> V >> S >> T >> D; if(V*S <= D && D <= V*T) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> #define i64 long long #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b) - 1; i >= (a); --i) using namespace std; const int N = 1e5 + 1; int n, sp[N]; vector<int> prime; bool vis[N]; vo...
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; cout <<n-1; return 0; }
#include<bits/stdc++.h> using namespace std; #define INF 1e15 #define EPS 1e-9 #define MOD 1000000007 #define Pi 3.14159265358979323846264338327950288419716939937510 #define umap unordered_map #define uset unordered_set #define fi first #define se second #define l...
#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; #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif #define int long long #define mp make_pair #define mt make_tuple #define pb push_back #define ppb pop_back...
#include <bits/stdc++.h> #define ll long long using namespace std; vector <int> vis; void DFS(int x, vector <vector <int> > & g) { vis[x] = 1; for (auto to: g[x]) if (!vis[to]) DFS(to, g); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; map <int, vector <pair <int, i...
#include<bits/stdc++.h> using namespace std ; using ll = long long ; using vll = vector<ll> ; int main(){ int n,m ; cin >> n >> m ; vll a(n) ; for(auto &i:a) cin >> i ; vector<pair<ll,ll>> b(m) ; for(auto &i:b) cin >> i.second >> i.first ; sort(b.begin(),b.end()) ; b.emplace_back(1e10,0...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mp make_pair #define Fast_IO ios::sync_with_stdio(false); #define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__) //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #de...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author NikuKyabe */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include <bits/stdc++.h> #define MOD 998244353 using namespace std; int main() { int n; cin>>n; long long a[200010]; for(int i=0;i<n;i++){ cin>>a[i]; } sort(a,a+n); long long x=a[0]; long long pow=1; for(int i=1;i<n;i++){ x=(x+pow*a[i])%MOD; pow=(pow*2)%MOD; } cerr<<x<<endl; long long sum=(x*a[0])%M...
#include <bits/stdc++.h> using namespace std; #define N 200000 #define mo 998244353 #define fo(i, x, y) for(int i = x; i <= y; i ++) #define fd(i, x, y) for(int i = x; i >= y; i --) void read(int &x) { char ch = getchar(); x = 0; while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9'...
#include <bits/stdc++.h> using namespace std; typedef long long ll; //typedef pair<ll, ll> P; typedef pair<int, int> i_i; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define ALL(v) v.begin(), v.end() #define SZ(x) ((int)(x).size()) template<class T> inline bool chmin(T& a, T b) { if (a ...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define fi first #define se second #define all(v) v.begin(),v.end() #define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0); #define mod 1000000007 #define decimal(k) cout<<fixed<<setprecision(k)<<e...
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; vector<vector<array<int, 2>>> A(N + 1); for (int i = 0; i < M; i++) { int X, Y, Z; cin >> X >> Y >> Z; A[X].push_back({Y, Z}); } vector<int64...
#include "bits/stdc++.h" using namespace std; int main() { int a, b; cin >> a >> b; int c = 2 * a + 100; cout << ((c - b) > 0 ? c - b : 0) << endl; return 0; }
#include <iostream> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair <int,int> pii; typedef pair<ll,ll> pll; /*bool compare_function(const pair<int, int> a, const pair<int, int> b...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll N; cin >> N; vector<ll> A(N); rep(i,N) cin >> A[i]; rep(i,N) if(i & 1) A[i] = -A[i]; vector<ll> s(N + 1, 0); rep(i,N...
#pragma GCC optimize ("O2") #pragma GCC target ("avx") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(...
#include<bits/stdc++.h> using namespace std; #define ll long long #define int long long #define inf 0x7f7f7f7f #define MAX_SIZE 1000001 #define debug(x) cout<<#x<<" "<<x<<"\n" #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define file freopen("input.txt","r",stdin);freopen("output.txt","w"...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <cstdio> #include <cmath> #include <array> #include <queue> #include <stack> #include <map> #include <set> using namespace std; int M[2001][2001]; int H, W; vector<vector<int>> dp(2001,vector<int>(2001, -1)); int...
#include<cmath> #include<cstdio> #include<vector> #include<cstring> #include<utility> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int M=25,N=(1<<18)+10; int n,m,a[M]; vector<pair<int,int> > e[M]; ll dp[N]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { int ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; const int INF = 1e9; const ll LINF = 1e18; template <class T> bool chmax(T...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n,x; scanf("%d %d",&n,&x); string s; cin>>s; for(int i = 0;i<s.size();i++){ if(s[i] == 'o')x++; else if(s[i] == 'x'){ if(x>0)x--; } } printf("%d",x); return 0; }
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define pf push_front #define ins insert #define len(s) s.length() #define forp(i, a, b) for (int i = a; i <= b; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define ren(i, n) for (int i = n - 1; i >= 0; i--) #define forn(i, a, b) fo...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var <= (end); var++) #define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--) #define REP(var, length) FOR(var, 0, length - 1) #define RREP(var, length) RFOR(var, length - 1, 0) #de...
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <cmath> #include <queue> #include <string> #include <utility> using namespace std; using ll = long long int; using pii = pair<int,int>; using pll = pair<ll,ll>; int main(){ int K; cin >> K; ll ans = 0; for(int c=1;c<...
//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; // (POLICY BASED DS) // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<typename T> // using ordered_set=tree<T,null_type,less<T>,...