code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <stdio.h> #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <...
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m; cin >> n >> m; vector<string> g(n); for (int i = 0; i < n; ++i) cin >> g[i]; int ans = 0; for (int i = 1; i < n; ++i) for (int j = 1; j < m; ++j) { int cnt = 0; cnt += g[i][j] == '#'; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vc<vc<T>>; template<class T> using vvvc = vc<vvc<T>>; template<class T> using vvvvc = vvc<vvc<T>>; template<class T> using PQ = priority_queue<T>; template<class T> using invPQ = pri...
#include<bits/stdc++.h> using namespace std; int b[2000000] = {0}; struct node{ int x, y, id; }; node a[200010]; bool cmp1(node x, node y) { return x.x < y.x; } bool cmp2(node x, node y) { return x.y < y.y; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i].x, &a[i].y); ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string(string(s)); } string to_string(bool b) { return to_string(int(b)); } string to_string(vector<bool>::reference b) { return to_string(int(b)); } string to_stri...
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(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...
#include<bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define OUT(V) for(int i=0;i<(int)V.size();++i){cout<<V[i]<<" ";}cout<<endl; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll MOD = 1000000007; int main() { int N; cin >> N; vector<...
#include <bits/stdc++.h> #define f(i,j,k) for(long long i=j;i<k;i++) #define f2(i,j,k) for(long long i=j;i>=k;i--) #define ll long long using namespace std; const long long mod=1e9+7; const long long mod2=998244353; const long long INF = (1 << 29); void chmin(int& a, int b){ if(a > b) a = b; } void chmax(int& a, int b...
#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_a...
#include <iostream> #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iterator> #include <list> #include <map> #include <memory> #inclu...
#pragma region Macros #include <bits/stdc++.h> #if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG) #include <atcoder/all> #endif using namespace std; #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i, n) for(int i=(n); i>=0; --i) #define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##...
#include <iostream> #include <sstream> #include <iomanip> #include <vector> #include <deque> #include <list> #include <set> #include <map> #include <stack> #include <queue> #include <bitset> #include <string> #include <numeric> #include <algorithm> #include <functional> #include <iterator> #include <cstdio> #include <c...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); float a,b,discount,res; cin>>a>>b; discount=(a-b)/a; res=discount*100; cout<<res<<"\n"; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> ii; typedef vector<ii> vii; const int mod = 1e9+7; const int N = 1e5+2; #pragma region Debugger void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __...
#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp" #include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i < n; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define REV(i, n) for (int i = n - 1; i > ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+5; const int mod=1e9+7; int n,m; int C[17][17]; char s[N]; int a[N]; int w[200]; inline int po(int x,int k){ int ret=1; while(k){ if(k&1) ret=1ll*ret*x%mod; x=1ll*x*x%mod; k>>=1; } return ret; } inline int calc(int f,int c){ i...
#include<cstdio> #define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i) using namespace std; const int N=3005; template<typename T>void read(T &x) { bool neg=false; unsigned char c=getchar(); for(;(c^48)>9;c=getchar())if(c=='-')neg=true; for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48); if(neg)x=-x; } int n,a[N...
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include ...
#include <cstdio> #include <cmath> #include<iostream> #include <cstring> #include <algorithm> #define space putchar(' ') #define enter putchar('\n') #define debug(a) cout<<#a<<"="<<a<<endl; using namespace std; typedef long long ll; template <class T> void read(T &x){ char c; bool op = 0; while(c = getchar(...
/** * author: souravrax * created: 30.05.2021 19:53:53 **/ #include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define len(x) int((x).size()) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } ...
#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をaからn #define db(x) cout << #x << " = " << x << endl #define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用 #def...
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef pair<int,int>pint; typedef long double db; using vll=vector<ll>; using vs=vector<string>; #define b2e(v)v.begin(),v.end() #define p2a(v, p) v[p.first][p.second] ll solve1(db x, db y, db r) { ll ct...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lb; #define rep(i, j, n) for (ll i = j; i < (n); i++) #define repr(i, j, n) for (ll i = j; i >= (n); i--) #define each(i, mp) for (auto &i : mp) #define all(x) (x).begin(), (x).end() #define CLR(mat, f) memset(mat, f, sizeof(mat)) ...
#include <bits/stdc++.h> using namespace std; //#define endl '\n' #define pb push_back #define ll long long #define int ll #define FF first #define SS second #define f(a,b,c) for(int a=b;a<=c;a++) #define fd(a,b,c) for(int a=b;a>=c;a--) #define fspr(X) fixed<<setprecision(X) int mod = 1000000007; ll mod_pow(ll ...
#include<bits/stdc++.h> #define pb push_back #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define f first #define s second #define int long long #define sz(x) (ll)(x.size()) using namespace std; const int mod = 1e9+7; in...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> using namespace std; using ll = long long int; const ll MOD = 1000000007; int main(){ int t; cin >> t; for(int i = 0; i < t; i++){ ll n, a, b; cin >> n >> a >> b; if(n < a+b){ c...
#include <bits/stdc++.h> #define pb push_back #define fr first #define sc second #define bg begin() #define ed end() #define all(x) x.bg, x.ed #define sz(x) int(x.size()) #define vi vector<int> #define vl vector<long long> #define vvl vector<vector<long long> > #define vvi vector<vector<int> > typedef long long ll; ...
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; void fun(vector<ll>v,ll n,ll m) { v.pb(n+1); ll prev=0; vector<ll>temp; for(ll val:v) { if(val-prev-1>0) { temp.pb(val-prev-1); } prev=val; } sort(temp.begin(),...
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") #include <bits/stdc++.h> #include<set> #include <array> using namespace std; #define ll long long #define endl '\n' #define mod 1000000007 #define pb push_back #define ff first #define ss second #define con continue #define ub upper_bound #define lb lower_...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++) #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<ll,ll,ll> using Graph = vector<vector<Tp>>; ll mod = 1000000007; int main() { ll N,M,X,Y; cin >> N >> M >> X >> Y; Graph G(N+1); rep(i,M){ ll a,b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long long int lli; typedef vector<ll> vl; #define pb push_back #define mp make_pair #define ff first #define ss second #define SQR(x) ((x) * (x)) #define loop(i, y) for (int i = 0; i < int(y); i++) #define FOR...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 char p[1000005],q[1000005]; ll pre[1000005]={0},ans=0,pre2[1000005]={0},n; ll solve(ll le,ll ri,ll pos) { if(pos==0) return 0; if(le>=ri) return 0; if(le==ri-1) { ans+=1;return 0; } ll pos1,pos2; if(pos==1) { ...
//ye moh moh ke dhaage,tere ungliyon se ja uljhe #include<bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i,n) for(i=0...
#include <bits/stdc++.h> using namespace std; int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0)); using Int = long long; vector<int> divisor(int n) { vector<int> ans; for (int t = 1; t * t <= n; t++) { if (n % t != 0) continue; if (t * t == n) { ans.push_...
#include<bits/stdc++.h> #define pb push_back #define pl pair<ll,ll> #define pll pair<ll,pair<ll,ll>> #define ll long long #define vl vector<ll> #define fastio ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = (1<<30)-1; const ll LINF = (1LL<<60)-1; #define rep(i, n) for (int i = 0; i < n; i++) #define sz(a) (int)(a.size()) template<class T> bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;} template<class T> bo...
#include <iostream> #include <cmath> #include <vector> #include <map> #include <stack> #include <queue> #include <set> #include <algorithm> #include <iomanip> #include <string.h> #include <bitset> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() typedef lo...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr double eps = 1e-9; double o; double pi2 = 2 * acos(-1); struct P { bool operator!=(const P &p) const { double z = t - p.t - o; z = z - round(z / pi2) * pi2; return !(abs(z) < eps && r2 == p.r2); } bool op...
#include<cstdio> #include<iostream> #include<cmath> using namespace std; int n; struct point{ int x,y; }a[110],b[110]; double dx[110],dy[110]; double abss(double x){return (x<0)?-x:x;} int main() { scanf("%d",&n); if (n==1) {printf("Yes");return 0;} for (int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y); for (int ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6 + 10; vector <pair <int, int>> a; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a, b, x, y; cin >> a >> b >> x >> y; int ans = 0; if (a > b) { --a; } y = min(y, x + x); ...
#include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fast ios_base::sync_with_stdio(0);ci...
// #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 endl '\n' #define all(x) (x).begin(),(x).end() template<typename T1,typename T2> bool chmin(T1 &a,T2 back){if(a<=back)return 0; a=back; return 1...
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; if(s[0] != s[1]) cout<<"Lost\n"; else if(s[1] != s[2]) cout<<"Lost\n"; else cout<<"Won\n"; return 0; }
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for...
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n; int a[N]; map<int , int> mp; int main() { // freopen(".inp","r",stdin); // freopen(".out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1 ; i <= n ; ++i) cin >> a[i]; ...
#include <bits/stdc++.h> #define PB push_back #define MP(x,y) make_pair(x,y) #define F first #define S second #define LOOP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define lp(i,n) LOOP(i,0,n) using namespace std; typedef long long int lli; typedef pair<int,int> pii; char grid[2005][2005]; int dp[2005][2005]; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}; int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b; cin >> a >> b; vector<ll> dp((1 << 20), 0); dp[0] = 1; for (ll i = a; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ub upper_bound #define lb lower_bound #define endl "\n" #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) const int N = 2e5 + 5; vector<int> adj[N], dept...
#include <bits/stdc++.h> #define ll long long #define V vector<long long> #define VV vector<vector<long long>> #define VVV vector<vector<vector<long long>>> #define P pair<ll,ll> #define rep(i,n) for(ll (i)=0;(i)<(n);++(i)) #define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i)) #define all(x) (x).begin(),(x).end() using names...
#include <bits/stdc++.h> #include <iostream> #include <fstream> #include <numeric> #define ll long long #define mod 1000000007 #define mod1 998244353 using namespace std; //vector<int>adj[200000+1]; int cnt=0; vector<int>cand; int prime[1000001]; void SieveOfEratosthenes(int n) { memset(prime, 0, sizeof(p...
#include<bits/stdc++.h> using namespace std; long long arr[1000000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); long double x,a,b,c; cin>>a>>b; x=(a-b)*100; x=x/a; cout<<x<<endl; }
#include<bits/stdc++.h> #define gc getchar #define pc putchar #define N 200005 #define ll long long using namespace std; template<class T>void read(T&x) { T f=1;x=0;char c=gc(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=gc();} while('0'<=c&&c<='9'){x=x*10+c-'0';c=gc();} x*=f; } template<class T>void print(T x,char c) { ...
#include<bits/stdc++.h> #define int long long using namespace std; int n,q; int p[200010],in[200010],out[200010],dep[200010],cnt; int ver[200010],nxt[200010],head[200010],tot; vector<int> g[200010]; bool cmp(int x,int y) { return in[x]<in[y]; } template<typename Tp> void read(Tp &x) { x=0;int f=1;char c=getchar()...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <unordered_set> ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; using vll = vector<ll>; using vvll = vector<vll>; template <typename T> constexpr int inof(const T x) { return static_cast<int>(x); } template <typename T> constexpr ll l...
//g++ t.cpp -o t && t < p.txt //d>p.txt&&t<p.txt&&t2<p.txt #include <iostream> // プログラムの耳と口 #include <vector> // 超有能配列秘書 #include <algorithm> // みんな大好きソートと二分探索 #include <queue> // きゅーちゃん、だいすき #include <string> // to_string #include <functional> // 関数を変数に入れる子 #include <set> // 値の取得・挿入・削除を高速に #include <map> // setの妹 これま...
#include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); ++i) typedef long long ll; const int nQuery = 1000; int main(void) { REP(iQuery, nQuery) { int r1, c1, r2, c2; scanf("%d%d%d%d", &r1, &c1, &r2, &c2); --r1; --c1; --r2; --c2; while(r...
// https://atcoder.jp/contests/abc203/editorial/2008 #include <bits/stdc++.h> using namespace std; #define N 805 #define MAX_A 1000000000 #define rep(i, n) for(int i = 0; i < n; ++i) int main(void) { int n, k, lim; int a[N][N]; int s[N][N]; rep(i, N) { s[i][0] = 0; s[0][i] = 0; } int ng = -1; int ok = MA...
#include<iostream> #include<iomanip> #include<vector> #include<algorithm> using namespace std; int main() { int a, b, as = 0, bs = 0; cin >> a >> b; as += a / 100; bs += b / 100; a = a % 100; b = b % 100; as += a / 10; as += a % 10; bs += b / 10; bs += b % 10; if (as > bs) cout << as; else cout << b...
#include <iostream> #include <vector> using namespace std; typedef long long LL; LL process(vector<pair<int, LL>>& a, int n) { if (n == 2) { return min(a[0].second, a[1].second) == a[0].second ? a[0].first : a[1].first; } for (int i = 0, j = 0; i < n - 1; i += 2, j++) { a[j] = max(a[i].second, a[i + 1]...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define square(x) pow(x,2.0) #define all(x) (x).begin(),(x).end() #define F first #define S second #define max_queue(x) priority_queue<x> #define min_queue(x) pr...
/*NEVER GIVE UP*/ /*First try brute force and check if it is in the range of time complexity*/ /*Then try to solve the problem in mathematical form*/ /*Then try to imagine how the final ans will look like*/ /*Write on paper if still not able to get*/ /*Try to think diff. algorithms and data structures that could solve ...
//------------------------------------------ // C++ templete //------------------------------------------ #include <bits/stdc++.h> #define int long long using namespace std; //type //------------------------------------------ using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector...
#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>; ll ll_pow(ll a, ll n) { ll ans = 1; for(ll i = 0; i < n; i++) ans *= a; return ans; } ...
#include<bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define pd push_back #define sort(v) sort(v.begin(),v.end()) #define Sort(v) sort(v.begin(),v.end(),greater<int>()) #define display(s) for(auto val:s) cout<<val<<" "; cout<<endl; #define displayMap(mymap) for(auto val:mymap) cout<...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <map> #include <queue> #include <iomanip> #include <set> #include <tuple> #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define mp make_pair typedef long long int ll; vector<ll> v[200000+5],par(200000+5),val(200000+5,0); ll vis1[200000+5]={0}; ll vis[200000+5]={0}; void pdfs(int p){ vis1[p]=1; for(auto i:v[p]){ if(vis1[i]...
/* “The only way that we can live is if we grow. The only way we can grow is if we change. The only way we can change is if we learn. The only way we can learn is if we are exposed. And the only way that we are exposed is if we throw ourselves into the open.” *************************************** *************...
#pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define ll long long // const ll p = 998244353; const ll nax = 100001; ll gcd (ll a, ll b, ll & x, ll & y) { if (a == 0) { x = 0; y = 1; return b; } ll x1, y1; ll d = gcd (b%a, a, x1, y1); ...
#include <bits/stdc++.h> using namespace std; typedef bool boool; typedef long long ll; #define vl vector<ll> #define vb vector<boool> #define vs vector<string> #define vp vector<pair<ll, ll>> #define vvl vector<vector<ll>> #define vvp vector<vector<pair<ll, ll>>> #define mod 1000000007 #define all(x) x.begin(), x.end(...
// E - Akari #include <bits/stdc++.h> using namespace std; using vi = vector<int>; #define rep(i,n) for(int i=0;i<n;++i) // bitでフラグ管理 enum Flag{ NONE = 0b000, // なし BRIGHT = 0b001, // 明るい BULB = 0b010, // 電球 BLOCK = 0b100, // ブロック }; int main(){ int H, W, N, M; cin>>H>>W>>N>>M; vector<vi> grid(H, vi(W)); ...
//#include<bits/stdc++.h> #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; #define pb push_back typedef long long ll; typedef unsigned long long ull; const int inf=0x3f3f3f3f; const int mod=1e9+7; const int seed=233; const int N=4e4+10; char win[200][200]; int main() ...
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i=a; i<=b; i++) #define trav(a, x) for(auto& a : x) #define all(x) begin(x), end(x) #define sz(x) (int) x.size() #define pb push_back #define f first #define s second #define nl "\n" typedef long long ll; typedef pair<int, int> pii; typedef vec...
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector <int> vi; typedef vector <ll> vll; typedef vector <string> vS; typedef vector <vector <int>> vv; typedef map<int, int> mi; typedef map<string, int> ms; typedef map<char, int> mc; ty...
#include<algorithm> #include<cstdio> #define MaxN 200005 using namespace std; struct Data{int u,v;}ans[MaxN]; int tot; bool vis[MaxN]; int a[MaxN],b[MaxN],p[MaxN]; int st[MaxN],tn; bool cmp(int A,int B) {return a[A]>a[B];} void solve(int u) { st[tn=1]=u; for (int v=p[u];v!=u;v=p[v])st[++tn]=v; sort(st+1,st+tn+1,c...
#include<iostream> #include<stdio.h> #include<algorithm> #include<math.h> #include<bits/stdc++.h> #include<stack> #include<queue> #include<list> #include<vector> #include<bitset> #include<unordered_map> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define fio ios_base::sync_with_stdio(...
///Given threee color R,G,B .Now find the number of ways of coloring the n nodes and m edges graph using these color ///where no adjacent nodes can be same color ///Here n<=10 ///Idea : As n<=10 so ideal backtracking can be done complexity:3*(2^10) #include<bits/stdc++.h> using namespace std; #define ll long long in...
#include <iostream> #include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define ll long long #define forn(i,a,n,b) for(ll i=a;i<n;i+=b) #define forr(i,a,n,b) for(ll i=a;i>=n;i-=b) #define MOD 1000000007 #define vll vector<ll> using namespace std; int main() { fas...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #pragma region macros using str=string; using ll=long long; using vl=vector<ll>; using vc=vector<char>; using pl=pair<ll,ll>; using ml=map<ll,ll>; using sl=set<ll>; template<class T> using V=vector<T>; template<class T,class U...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int t=1; // cin>>t; while(t--) { int a,b,x,y; cin>>a>>b>>x>>y; cout<<(b-x)<<endl; } return 0; }
// written by c++(gcc) // -*- cording: utf-8 -*- #include <stdio.h> // 最大値を返す関数 int max(int a, int b){ int maxNum; if(a < b){ maxNum = b; }else{ maxNum = a; } return maxNum; } int main(void){ int a, b, c, d; int ans; scanf("%d %d", &a, &b); scanf("%d %d", &c, &d)...
#include <iostream> #include <set> #include <string> #include <random> #include <unordered_map> #include <vector> using namespace std; int main(){ int N, M; cin >> N >> M; set<string> Set; unordered_map<string, int> count; unordered_map<string, bool> done; int Lmin = 10000, Lmax = 0; while(...
/* /\ In The Name Of Allah /\ Author : Jawahiir Nabhan */ #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const char nl = '\n'; const int NM = 3e6 + 10; ll dp[4][NM]; int main() { ll N,K; cin>> N >> K; dp[0][0] = 1; for (ll i = 0; i < 3; i++) { for ...
#include <bits/stdc++.h> using namespace std; typedef int_fast32_t int32; typedef int_fast64_t int64; const int32 inf = 1e9+7; const int32 MOD = 1000000007; const int64 llinf = 1e18; #define YES(n) cout << ((n) ? "YES\n" : "NO\n" ) #define Yes(n) cout << ((n) ? "Yes\n" : "No\n" ) #define POSSIBLE(n) cout << ((n) ?...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int price = n * 1.08; if (price < 206) { cout << "Yay!" << endl; } else if (price == 206) { cout << "so-so" << endl; } else { cout << ":(" << endl; } }
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 0x3f3f3f3f #define swap(a, b) (a ^= b ^= a ^= b) #define max(x,y) ((x)>(y)?(x):(y)) // #define min(x,y) ((x)<(y)?(x):(y)) #define endl '\n' const int maxn = 1e6 + 5; inline int pow(int a, int b, int mod) { int ans = 1;while (b) { if (b & 1)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define endl '\n' #define all(x) (x).begin(),(x).end() #define mp(x,y) make_pair(x,y) const int INF=1000000000+5; const int N=100+5; const ll oo=1e18+5; const ll mod=1e9+7; double dp[N][N][N]; double solve(int a,int b,...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; if(N%2==1){ cout<<"Black"<<endl;} else{cout<<"White"<<endl;} }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; if(s[0]==s[1]&&s[1]==s[2]) cout << "Won" << endl; else cout << "Lost" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) using ll = long long; int main(){ int n,k,ans=0; cin>>n>>k; int grid[n][n]; rep(i,n)rep(j,n) cin>>grid[i][j]; vector<int> v; rep(i,n) v.push_back(i+1); do { ll loop = 0; rep(i,n-1){ loop += grid[v[i]-1]...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll = int64_t; using ull = uint64_t; 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 print() { pri...
/* AUTHOR:SOURABH CREATED:11:10:20 */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> #define ll long long int #define ld long double #define fi first #define s...
#include <bits/stdc++.h> using namespace std; // clang-format off /* accelration */ // 高速バイナリ生成 #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") // cin cout の結びつけ解除, stdioと同期しない(入出力非同期化) // cとstdの入出力を混在させるとバグるので注意 struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(fals...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int64_t i = 0; i < (n); ++i) using Matrix = vector<vector<int64_t>>; int main() { int64_t n; cin >> n; vector<pair<int64_t, int64_t>> piece(n); for (auto &[x, y] : piece) cin >> x >> y; int64_t m; cin >> m; Matr...
#include<cstdio> #define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i) #define G(i,a,b,c) for(long long i=(a+c-1)/c*c;i<b;i+=c) using namespace std; typedef unsigned long long ull; const int N=80,P[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71}; template<typename T>void read(T &x) { bool neg=false; uns...
// Created by Kshitij Anand NSIT #include <bits/stdc++.h> //#include <ext/numeric> //using namespace __gnu_cxx; using namespace std; #define int long long #define pb push_back #define P pair<int,int> #define F first #define S second #define vi vector<int> #define vc vector<char> #define vb vector<bool> #define all(...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, k, n) for (int i = k; i < (int)(n); i++) #define repd(i, n) for (int i = n-1; i >= 0; i--) #define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--) #define all(x) (x).begin(),(x).end() #define chmax(x,y...
/* In the name of Anton */ /* * Motto :) * * * * * */ #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define repa(i,a,n) for(int i=a;i<=n;i++) #define repb(i,a,n) for(int i=a;i>=n;i--) #define trav(x,a) for(auto &x: a) #define all(x) x.begin(),x.end() #define sz(x) (int)(x).size()...
#include <algorithm> #include <numeric> #include <iomanip> #include <iostream> #include <string> #include <vector> #include <cmath> #include <numeric> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n'; #define PRINTVEC(x) for (int...
#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 INF = 1001001001; int main() { int n, m; cin >> n >> m; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> dp(n, 2*INF); vector<vector<int>>...
/// Down with The Sickness #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimization ("unroll-loops") #include "bits/stdc++.h" using namespace std; using ll = long long; using ii = pair<int, int>; #define pb push_back #define F first #define S second #defin...
#include <stdio.h> #include <iostream> #include <vector> // #include <bits/stdc++.h> #include <queue> #include <algorithm> #include <string> #include <iomanip> #include <cmath> using namespace std; typedef long long ll; #define rep(i,k,n) for(ll i=k; i<(ll)(n); i++) int main(){ ll n; cin >> n; ll a,b; l...
#include <bits/stdc++.h> #include<algorithm> #include<cstring> #include<cmath> #include<cstdlib> #include<string.h> using namespace std; #define pb push_back #define all(v) v. begin(),v. end() #define rep(i,n,v) for(i=n;i<v;i++) #define per(i,n,v) for(i=n;i>v;i--) #define ff first #define ss second #define pp pair<l...
#include <bits/stdc++.h> #include <vector> #include<math.h> #include<string.h> using namespace std; #define MAX 300005 #define MOD 998244353 #define SMOD 998244353 #define ROOT 512 #define GMAX 20 #define INF 2000000000000000 #define EPS 0.000000001 #define NIL 0 #define FASTIO ios_base::sync_with_stdio(false);cin.tie(...
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #includ...
#include <iostream> using namespace std; double a,d=1.0; int b, c; int main() { cin>>b>>c; a= c; a/=b; a= a*100; a=100-a; cout<<a; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ull = uint64_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using pii = pair<int, int>; using ld = double; #define X first #define Y second #define FWRITE namespace io { #ifndef FWRITE #include <unist...
#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; #include <ext/rope> using namespace __gnu_cxx; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; //less_equal f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1000000007; // const int MOD = 998244353; struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() { return mint(-x); } mint operator+=(mint rhs) { x += rhs.x; if (x >= MOD) x -= MOD; return *this; } ...
/*First,solve the problem then write the code:);)*/ #include<bits/stdc++.h> using namespace std; #define ll long long #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define test ll t;cin>>t;while(t--) #define sets(a) memset(a, -1, sizeof(a)) #define clr(a) memset(a, 0, sizeof(a)) #define...
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<(n);++i) using ll=long long; using namespace std; int main(){ ll c,b,ans,ml,mr,pl,pr; cin>>b>>c; ans=c/2+(c-2)/2+1+(c-1)/2+(c-1)/2+1; ml=-b-(c-1)/2; mr=-b+(c-1)/2; pl=b-c/2; pr=b+(c-2)/2; if(pl<=mr) {//ダブ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define print(a) \ for (auto x : a) \ cout << x << " "; \ cout << endl #define print_upto(a, n) \ for (ll i = 1; i <= n; i++) \ cout << a[i] << " "; \ cout << endl #define take(a, n) ...
#include <iostream> #include <vector> #include <algorithm> #include <climits> #include <unordered_map> #include <unordered_set> #define ll long long #define mod 1000000007 using namespace std; int main() { int N; ll X; cin >> N >> X; vector<int> a(N); ll ans=X; for (auto &e : a) { cin >> ...
#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...
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") // warning: pragmas don't work on USACO and just set to O0 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //gp_hash_table<T, U, chash>; #include <ext/pb_ds/tree_policy.hpp> //tree<T, U, cmp, rb_tre...
#include <bits/stdc++.h> #define ll long long #define endl "\n" #define pb push_back #define ms(v,x) memset(v,x,sizeof(v)) #define ff first #define ss second #define td(v) v.begin(),v.end() #define rep(i,a,n) for (int i=(a);i<(n);i++) #define re(v) {for(auto &_re : v) cin >> _re;} #define pr(v) {for(auto _pr : v) cout ...
#include <bits/stdc++.h> #include <iostream> //#include <algorithm> // #include <iomanip> #define ll long long #define map unordered_map #define set unordered_set #define l_l pair<ll, ll> #define vll vector<ll> #define mll map<ll, ll> #define mp make_pair using namespace std; const ll MOD = 1000000007LL; const ll IN...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define reps(i, s, n) for (int i = (s); i < (int)(n); ++i) #define ZERO {puts("0"); return 0;} #define NO {puts("No"); return 0;} #define ALL(obj) begin(obj), end(obj) #define pb push_back templat...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; #define pb push_back #define mp make_pair const int INF = 0x3f3f3f3f; const int MOD = 1e9+7; const int MAX_N = 103; int N,M,Q; int W[MAX_N],V[MAX_N]; int X[MAX_N]; int L[MAX_N],R[MAX_N]; void solve() { vector<pair<int,int>...
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<set> using namespace std; inline int read(){ int x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){if(c == '-')f = -1; c = getchar();} while(c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0'; c = getchar();} return x ...
#include<bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(),(v).end() using namespace std; using ll=long long; using ld=long double; using pii=pair<int, int>; using vi=vector<int>; using vii=vector<vector<int>>; const ll LINF=1LL<<60; const int INF=1<<29; const int MOD=1e9+7; template<typename T> boo...
#include <bits/stdc++.h> using namespace std; bool less_size(string ls, string rs) { return ls.size() < rs.size(); } int main() { int N, M; cin >> N >> M; vector<string> s(M); for (int i = 0; i < M; i++) { cin >> s[i]; } sort(s.begin(), s.end(), less_size); int j = 0; for (int i = 0; i < N; i...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_poizcy.hpp> typedef long long ll; typedef long llu; #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define mem(a,h) memset(a, (h), sizeof(...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; long long f[1010], pw[1010]; int main () { f[0] = 1, f[1] = 2, pw[0] = 1, pw[1] = 2; for (int i = 2; i <= 1005; i++) { f[i] = (f[i - 1] + f[i - 2]) % mod; pw[i] = pw[i - 1] * 2 % mod; } int n; cin >> n; char AA, AB, BA, BB; cin >> AA ...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define FULL(x,y) memset(x,y,sizeof(x)) using namespace std; const int N=100005; int n,p; vector<int> G[N]; int f[N],sz[N]; void dfs(int x) { int sum=0; vector<int> vec; int len=G[x].size(); for(int i=0;i<len;i++) { int v=G[x][i]; dfs(v); sz[...
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") #include <bits/stdc++.h> #include<set> #include <array> using namespace std; #define ll long long #define endl '\n' #define mod 1000000007 #define pb push_back #define ff first #define ss second #define con continue #define ub upper_bound #define lb lower_...
#include <bits/stdc++.h> #define ll long long #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; ll n; bool ada = false; ll binexp(ll a, ll b){ ll res = 1; while(b > 0){ if(b & 1) res *= a; a *= a; b >>= 1; } return res; } int main() { fa...
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define MOD 1000000007LL #define MXN 10005 #define INF 1e9 #define EPS 1e-8 #define endl '\n' #define lowbit(x) (x&-x) using namespace std; mt19937 gen(time(0)); ll n; bool isprime[MXN]; bool v[MXN]; ll ans[MXN]; ll factor[] = {6,10,15}; vector<l...
#include <bits/stdc++.h> using namespace std; #define LL long long #define r 1000000007 #define pb push_back #define pf push_front #define loop(i,a,b) for (LL i = a; i < b; i++) #define numberOfOnes(n) __builtin_popcountll(n) #define parity(n) __builtin_parityll(n) // = 1 when numberOfOnes(n) is odd #def...
#include "bits/stdc++.h" using namespace std; int main(){ string s; cin>>s; int cnt = 0; for(int i = 0; i<=9999; i++){ vector<bool>a(10); int pss = i; for(int j = 0; j<4; j++){ a[pss%10] = 1; pss /= 10; } bool ok = 1; for(int k = 0; k<10; k++){ if(s[k]=='o'&&!a[k])ok = 0; if(s[k]=='x'&&a[k])...
#include <bits/extc++.h> using namespace std; using ll = long long; #define REP(i,n) for(int i=0;i<int(n);i++) #define FOR(i,a,b) for(int i=a;i<=int(b);i++) #define ALL(x) x.begin(),x.end() #define MOD (ll)1000000007 set<ll> ans; vector<pair<ll, ll>> xy; signed main() { ll n; int m; cin >> n >> m; ans.insert(n...
#include<bits/stdc++.h> using namespace std; #define Mod(x) (x>=P)&&(x-=P)||(x<0)&&(x+=P) #define rep(i,a,b) for(ll i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(ll i=a,i##end=b;i>=i##end;--i) #define erep(i,a) for(ll i=hd[a];i;i=nxt[i]) typedef long long ll; void Max(ll &x,ll y){(x<y)&&(x=y);} void Min(ll &x,l...
#include <iostream> #include <cmath> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) using ll = long long; int in(){///値を丸める double x; cin >> x; x *= 10000; return round(x); } bool ok(ll dx,ll dy,ll z){//円のうちなら1 return dx*dx + dy*dy <= z*z; } ll f(ll x,ll y,ll z,ll lim){ int l=0,r=1; ll re...
#include <bits/stdc++.h> #define rep(i, begin, end) for (i=begin;i<end;i++) #define printint(i0, i1) printf("%d %d\n", i0, i1) #define MAX_N 1000 using namespace std; typedef long long int ll; const int inf = 1000000000; const int mod = 1000000007; const int nil = -1; ll i, j, n, m, k, ans; ll c[500][500]; ll a[500], ...
#pragma GCC optimize("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif void d_err() { c...
/* #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") */ #include<bits/stdc++.h> #define ALL(x) (x).begin(),(x).end() #define ll long long #define db double #define ull unsigned long long #define pii_ pair<int,int> #define mp_ make_pair #define pb push_back #define fi first #define se second #define rep(i...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pld pair<long double, int> #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define ff first #define ss second #define SZ(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() mt19937 rng(chrono::steady_clock::now().t...
#include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<n;++i) #define rrep(i, n) for(ll i=n-1;i>=0;--i) #define rep1(i, n) for(ll i=1; i<=n; ++i) #define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();++itr) #define ALL(a) (a).begin(),(a).end() template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}} ...
#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 = 1001001001; const ll INF_LL = 1001001001001001001LL; vector<int> BFS(vector<vector<int>> &Graph,int iv,int n){ vector<int> dist(n,-1); queue<int> q; dist[iv]=0; q.push(iv); whil...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int N, M; map<int, vector<int>> G; void get_input(); void solve(); void dfs(vector<bool> &seen, int v); /** * @brief メイン処理. * * @return int 0 */ int main() { // 標準入力を取得 get_input(); // 求解処理 solve(); return 0; } /** * @b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; //bool vis[1000]; //int x[]={1,-1,0,0}; //int y[]={0,0,1,-1}; //int f=0; //int t[500000]; //int ll[500000]; //"''; int main(){ ll n,w; cin>>n>>w; vector<ll> v(300000,0); for(int i=0;i<n;i++){ l...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ULL; #define endl "\n" #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back void read(vector<int> &a, int n) {for (int i = 0; i < n; i++)cin >> a[i];} void read(v...
#include "bits/stdc++.h" using namespace std; using LL = long long; constexpr int N = 1e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = s.size(); int cnt[26]; memset(cnt, 0, sizeof cnt); LL res = 0; for (int i = n - 1; i > 0; i--) { if (s[i] == s[i - 1...
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #include<string.h> using namespace std; #define pb push_back #define all(v) v.begin(),v.end() #define ya cout<<"Yes"<<endl; #define no cout<<"No"<<...
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for(int i = (a); i <= (b); i++) #define PER(i, a, b) for(int i = (a); i >= (b); i--) #define rep(i, a, b) for(int i = (a); i < (b); i++) #define all(S) (S).begin(), (S).end() #define pb push_back #define mk make_pair #define S second #define F first t...
#include <bits/stdc++.h> using namespace std; //const long nPrime = 1000000007; //const long nPrime = 998244353; long GCD(const long n, const long m){ long a = abs(n), b = abs(m); if(a<b){ swap(a,b); } while (b > 0) { long t = a / b; a -= t * b; swap(a, b); } ret...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define e "\n" #define fl(x,n) for(ll i=x;i<=n;i++) #define fl2(x,n) for(ll i=x;i>=n;i--) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,Max,Min,x; cin >> n; cin >> Max; ...
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define ll long long #define endl "\n" #define rep(X,Y) for(X=0;X<Y;X++) #define rep1(X,Y) for(X=1;X<=Y;X++) #define rrep(X,Y) for(X=Y-1;X>=0;X--) #define rrep1(X,Y) for(X=Y;X>=1;X--) #define ml l...
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; struct edge { int v,w,k; edge(){} edge(int _v, int _w, int _k) { v = _v; w = _w; k = _k; } }; const int N = 1e5 + 5; const long long oo = 1e18; vector <edge> adj[N]; long ...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; //#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define rep(i,a,b) for(ll i=a;i<b;i++) #define rev...
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n);i++) #define Graph vector<vector<int>>; #define iterG(next_v, G, v) for(auto next_v : G[v] #define ALL...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; using ll = long long; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define _...
#include <bits/stdc++.h> using namespace std; #define co(n) cout<<n<<endl; const double eps=1e-10,pi=3.1415926535898; const int mod=998244353,maxn=5e3+10; int T,n,m,k,x,y; long long dp[maxn][15],vis[maxn][15]; long long fac[maxn]={1,1},inv[maxn]={1,1},fac_inv[maxn]={1,1}; void init() { for (int i=2;i<maxn;++i) { ...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using vi = vector<int>; constexpr char newl = ...
#include <iostream> #include <cmath> #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 <cassert> #in...
#include <bits/stdc++.h> #define ll long long using namespace std; template <typename T> void read(T &x) { x = 0; char c = getchar(); int f = 0; for (; !isdigit(c); c = getchar()) f |= c == '-'; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ '0'); if (f) x = -x; } template <typename T> void write(T x, char...
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> #define double long double using namespace std; typedef long long ll; const int N_MAX = 200005; int n, m, k; bool trap[N_MAX]; double dp[N_MAX]; double solve (double answ...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
/** * author: avoas * created: 02.03.2021 18:53:30 **/ #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i = 0; i < (n); i++) #define all(x) (x).begin(),(x).end() #define int long long constexpr double EPS = 1e-12; signed main() { ios::sync_with_stdio(fals...
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define POPCOUNT(x) __builtin_popcount(x) template <typename T> void chmin(T &a, const T &b) { a = min(...
#include <stdio.h> #include <stdbool.h> int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n]; for (int i = 0; i < n; i++) a[i] = ri(); int b[n]; for (int i = 0; i < n; i++) b[i] = ri(); int res = 0; for (int i = 1; i <= 1000; i++) { bool ok = true; for (int j = 0; j < n; j+...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define rep(i,j,n) for(int i=j;i<n;i++) #define readvec(v,n) for(int i=0;i<n;i++){cin>>v[i];} #define MOD 1000000007 vector<vector<ll>> dp; ll rec(int x,int y) { if(dp[x][y]!=-1)return dp[x][y]; dp[x][y]=0; if(x>0)dp[x][y] += rec(x-1,y); if(y...
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n, k, pw[N]; char s[N]; int dp[N][N]; char tp(int x){ if(x==0)return 'R'; if(x==1)return 'S'; return 'P'; } int id(char c){ if(c=='R')return 0; if(c=='S')return 1; return 2; } int win(int x,int y){ if((x+1)%3==y)retur...
#include <bits/stdc++.h> #define i64 long long using namespace std; int n,k; string s; char Win(char a,char b){ if(a==b) return a; if(a=='R' && b=='S') return a; if(a=='P' && b=='R') return a; if(a=='S' && b=='P') return a; return b; } int main(){ ios::sync_with_stdio(false); cin.tie(0); #ifdef ...
#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> constexpr int DEBUG = 0; using namespace std; using int64 = long long; struct Edge { int s, t; Edge(int s, int t) : s(s), t(t) {} }; vector<vector<Edge>> ReadUndirectedGraph(int n, int m, int offset) { vector<vector<Edge>> graph(n); for (int i = 0; i < m; i++) { int v1, v2; cin >>...
#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 = 2e5; int n, k, f[N]; vector<int> G[N]; int dfs(int u, int...
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << e...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin>>n; int d=(n/100)*100+100; cout<<d-n<<endl; }
#include <iostream> #include <string> #include <iomanip> #include <vector> #include <algorithm> #include <numeric> #include <cmath> #include <stack> #include <queue> #include <set> #define mod 1000000007 #define mp make_pair #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define _GLIBCXX...
#include <bits/stdc++.h> // #include <atcoder/all> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for(int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; // using namespace atcoder; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}e...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e2 + 10; int n, a[N]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int mi = INT_MAX; for (int i = 1; i < (1 << n); i++) { bitset<25> st(i); int sum = 0, tot = 0; for (int j = 0; j < n; j++) { ...
//#include <bits/stdc++.h> #include <vector> #include <iostream> #include<algorithm> #include<string> #include <map> #include <queue> #include <stack> #include<set> #include<math.h> //#define DIV 1000000007 #define TE 5e5 using namespace std; using ll = long long; using ldb = long double; int main() { ll N; cin >> N...
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int count = 0; while (true) { int a = s.find("ZONe"); if (a == std::string::npos) { cout << count; return 0; } s = s.substr(a + 4, s.length() -...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; vector<int64_t> A(N+1); vector<int64_t> M(N+1); for (int i = 1; i <= N; i++) { cin >> A[i]; A[i] += A[i-1]; M[i] = M[i-1]; M[i] = max(M[i], A[i])...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n; int p[N]; int sz[N]; vector<int> edges[N]; int dfs(int u) { sz[u] = 1; vector<int> evens; vector<int> odds; for (int v : edges[u]) { int val = dfs(v); sz[u] += sz[v]; if (sz[v] & 1) { odds.emplace_back(val); } ...
#include <bits/stdc++.h> using namespace std; int main(){ long k, n, m, p, c; cin >> k >> n >> m; p = m; long a[k], b[k] = {}; for(int i = 0; i < k; i++) cin >> a[i]; priority_queue<pair<long, long>, vector<pair<long, long>>, less<pair<long, long>>> q; for(int i = 0; i < k; i++){ b[...
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define maxn 300005 #define inf 1e9 #define ins insert #define pb push_back #define rep(i,a,b) for(int i=a;i<=b;i++) #define per(i,a,b) for(int i=a;i>=b;i--) using namespace std; inline int read() { int x=0,w=1; char c=getchar(); while(c<'0'||c>...
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long int N, M; vector<pair<int, int> > g[2020], h[2020]; int dist[2020]; int Dijkstra(int S) { memset(dist, 0x3f, sizeof(dist)); priority_queue<pair<int, int> > pq; pq.push({0, S}); dist[S] = 0; while(!pq.empty()) { int d = -p...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; #if DEBUG && !ONLINE_JUDGE ifstream input_from_file("input.txt"); #define cin input_from_file #else #endif const int MAXN = 5e6; vector<int> aa[MAXN]; vector<int> ww[MAXN]; int H, W; vector<vector<char>> gr...
#include<bits/stdc++.h> using namespace std; int main(){ string S; cin >> S; int len = S.size(); if(len == 1){ int n = S.at(0) - '0'; if(n % 8 == 0){ cout << "Yes" << endl; }else{ cout << "No" << endl; } return 0; } if(len == 2){ int a = S.at(0) - '0'; int b = S.a...
#include <algorithm> #include <chrono> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define all(c) c.begin(), c.end() #define rall(c) c....
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(NULL); priority_queue <string> a, b; int n; cin >> n; for (int i = 0; i < n; i++) { string c; cin >> c; i...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define mp make_pair #define F first #define S second #define pll pair<int , int> #defin...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> P; const int maxn = 1000 + 10; const int INF = 0x3f3f3f3f; struct HH { string name; int h; bool operator < (const HH &b) const { return h > b.h; } }arr[maxn]; void solve() { int n, h; cin >> n; ...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,a[300001],memo[300001] = {},ans = 0,tmp,cnt = 0; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } memo[0] = a[0]; memo[n] = 0; for(int i = 1; i < n; i++){ memo[i] = a[i] - memo[i - 1]; ...
#include<bits/stdc++.h> using namespace std; #define f(i,a,b) for(register int i=a;i<=b;++i) #define ll long long inline ll read(){ll x;scanf("%lld",&x);return x;} ll Abs(ll x){if(x<0)return -x;return x;} int main() { ll n=read(); __int128 L=0,R=n+1; while(L<R){ __int128 Mid=(L+R+1)>>1; if((__int128)(1+Mid)*Mid...
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ld long double #define ll long long #define pb push_back #define ff first #define ss second #define all(x) x.begin(), x.end() #define mp map<ll, ll> #define um unordered_map<ll, ll> #define st set<ll> #define us unordered_set<ll> #define vt v...
/*Jai Shree Ram*/ // Never Give Up #include<bits/stdc++.h> #include<unordered_map> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi ...
#include <bits/stdc++.h> #define for0(i, n) for (int i = 0; i < (ll)(n); ++i) #define for1(i, n) for (int i = 1; i <= (ll)(n); ++i) #define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i) #define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (ll)(n); i >= 1; --i) #define pb ...
#include<iostream> using namespace std; int main() { int a,b,p=2,sum=0; cin>>a>>b; if(a>=b) { while(a--) { cout<<p<<" "; sum+=p; p+=2; } p=-2; while(b>1) { cout<<p<<" "; sum+=p; p-=2; --b; } } else { p*=-1; while(b--) { cout<<p<<" "; sum+=p; p-=2; } p=2; wh...
#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #define rep(i,n) for(ll i=0;i<(n);++i) #define rep2(i,n) for(ll i=1;i<=(n);++i) #define rep3(i,i0,n) for(ll i=i0;i<(n);++i) #define rrep(i,n) for(ll i=((n)-1); i>=0; --i) #define rrep2(i,n) for(ll i=(n); i>0; --i) #define pb push_back #define mo...
// とりあえず, // a[i] = x[i], b[i] = y[i], c[i] = x[i] + 1, d[i] = y[i] + 1 // として,面積 1 の正方形で囲むことにする。 // まずは入力形式の確認。 #include <bits/stdc++.h> #ifdef DEBUG #define PRINT(x)\ cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl; #define PRINTA(a,first,last)\ cout<<"func "<<__func__<<": line "<<_...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <queue> template <class T> inline void read(T &x) { x = 0; int f = 0; char ch = getchar(); while (!isdigit(ch)) { f |= ch == '-'; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x...
#include<bits/stdc++.h> #define pb push_back #define mk make_pair #define ll long long #define ss second #define ff first #define mod 1000000007 #define w(x) ll x; cin>>x; while(x--) #define ps(x,y) fixed<<setprecision(y)<<x; #define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in) #define re(i, j) fo(i, 0, j, 1) #define pi ...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(x) (x).begin() , (x).end() #define sz(x) ((int)(x).size()) template<class T>bool chmax(T &a, const T &b) { if (a<b) {a=b; return 1; } return 0;} template<class T>bool chmin(T &a, const T &b) { if (b<a) {a=b; retur...
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define BUFF ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define IO freopen("in.txt","r",stdin),freopen("out.txt","w",stdout) #define P(x) cout<<x<<endl #define P2(x,y) cout<<x<<' '<<y<<endl #define P3(x,y,z) cout<<x<<' '<<y<<' '<<z<<endl #define P4(...