code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; const int maxn=1e5; typedef long long ll; int main(){ ll a,b,c,d; cin>>a>>b>>c>>d; ll x=max(a,b); ll y=min(c,d); ll ans=x-y; cout<<ans<<endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << b-c << endl; return 0; }
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long #define double long double #define setbits(x) __builtin_popcountll(x) #define zrobits(x) ...
#include <bits/stdc++.h> using namespace std; #define FORI(i, a, b) for (int i = (int)a; i <= (int)b; i++) #define FORD(i, a, b) for (int i = (int)a; i >= (int)b; i--) #define PB push_back #define ALL(v) v.begin(),v.end() #define OJ \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #def...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ int N,M,i,j,n=0; cin >> N >> M; int hurui[1001]; hurui[0]=0; for(i=1;i<=1000;i++){ hurui[i]=0; } int A[N],B[M]; for(i=0;i<N;i++){ cin >> A[i]; hurui[A[i]]++; } for(i=0;i<M;i++){ cin >>...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int N,M; cin >> N >> M; vector<int> A(N),B(M); for(int n=0;n<N;n++) cin >> A[n]; for(int m=0;m<M;m++) cin >> B[m]; vector<int> ans(0); int cnt = 0; for(int n=0;n<N;n++){ bool found1 = fa...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define x first #define y second using namespace std; typedef long long ll; int mas[200005]; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; #define rep(i,a,b) for(ll i=a;i<b;i++) #define rrep(i,a,b) for(lint i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() ///#pragma GCC optimize ("-O3") ll input(){ ...
/* Author : $%U%$ Time : $%h%$:$%m%$:$%s%$, $%D%$/$%M%$/$%Y%$ */ #include <bits/stdc++.h> using namespace std; using ll = long long; using db = long double; // or double, if TL is tight using str = string; // yay python! using pi = pair<int,int>; using pl = pair<ll,ll>; using pd = pair<db,db>; using vi = vector...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 200005; int seg[4*N],h; void update(int idx,int p=1,int s=0,int e=h) { if(s==e) { seg[p] = 1; return; } int mid = (s+e)>>1; if(idx<=mid) update(idx,2*p,s,mid); else update(idx,2*p+1,m...
#include <bits/stdc++.h> using namespace std; signed main() { int a,b; cin >> a >> b; b = a-b; double tmp = 1.0*b/a; printf("%f",tmp*100); return 0; }
#include <bits/stdc++.h> using namespace std; //UnionFindテンプレ class UnionFind { // まとめる 判定 サイズを知る public: // Aから見た親の番号を格納する。rootだったら-1*その集合のサイズ。 vector<int> Parent; // 初期化 UnionFind(int N) { Parent = vector<int>(N, -1); } // Aのrootを調べる int root(int A) { if (Parent[...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,srt,end) for(ll i = (srt); i < (ll)(end); i++) //ll MOD=1000000007; //ll mod=998244353; //int inf=1000001000; //ll INF=1e18+5; //cout << std::fixed << std::setprecision(15) << y << endl; // For debug // Ref: https://qiita.com/ysuzuki19/i...
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdi...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = pair<ll, ll>; using tp = tuple<ll, ll, ll>; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; #define all(hoge) (hoge).begin(), (hoge).end() #...
/* >>>>>Shwetal<<<<< */ #include <bits/stdc++.h> #define int long long #define f(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define inputArray(arr) f(i, 0, arr.size()) cin >> arr[i] #define printArray(arr) f(i, 0, arr.size()) cout <...
#include <bits/stdc++.h> using namespace std; #define rep(i, c) for (int i = 0; i < (int)c; i++) using ll = long long; // 入力のときに10000倍して四捨五入する関数 int in() { double x; cin >> x; x *= 10000; return round(x); } // x^2 * y^2 = r^2 bool ok(ll dx, ll dy, ll z) { return dx * dx + dy * dy <= z * z; } // 円の上半分を...
// D - Circle Lattice Points #include <bits/stdc++.h> using namespace std; using ll = int64_t; using dbl = long double; int main(){ ll scale = 1e4; dbl x, y, r; cin>>x>>y>>r; ll X = round(x*scale); ll Y = round(y*scale); ll R = round(r*scale); ll r2 = R*R; ll ans = 0; for(ll i=0; i<=2*R+scale; i+=scale){ ll ...
#include <algorithm> #include <cassert> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #include <limits.h> using namespace std; typedef long long ll; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } ...
#include<bits/stdc++.h> using namespace std; #define GODSPEED ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15); #define f first #define s second #define newl cout<<"\n"; #define pb push_back #define mset(a,x...
//#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; #define eps 1e-8 //#define eq(x,y) (fabs((x)-(y)) < eps) using namespace std...
#include "bits/stdc++.h" using namespace std; // 定義 typedef long long ll; typedef pair<ll, ll> P; #define ALL(x) (x).begin(),(x).end() #define REP(i, n) for(ll i = 0 ; i < (ll)n ; ++i) #define REPN(i, m, n) for(ll i = m ; i < (ll)n ; ++i) #define VL vector<ll> #define...
// Problem : A - Three Dice // Contest : AtCoder - AISing Programming Contest 2021(AtCoder Beginner Contest 202) // URL : https://atcoder.jp/contests/abc202/tasks/abc202_a // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #pragma GCC optimize("Ofast") #pr...
/* in the name of Anton */ /* Compete against Yourself. Author - Aryan Choudhary (@aryanc403) */ #ifdef ARYANC403 #include "/home/aryan/codes/PastCodes/template/header.h" #else #pragma GCC optimize ("Ofast") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize ("...
#include <bits/stdc++.h> using namespace std; long long s,p; int main() { cin>>s>>p; for(int i=1;i<=sqrt(p);i++){ if(!(p%i)){ if(i+p/i==s){ cout<<"Yes"; return 0; } } } cout<<"No"; return 0; }
#include <bits/stdc++.h> #define ll long long //int n; cin>>n; int i,a[n]; for(i=0;i<n;i++) cin>>a[i]; using namespace std; int main(void){ // Your code here! int t; t=1; while(t--) { ll s,p,m,n,i;cin>>s>>p; string ans="No"; for(i=1;i*i<=p;i++) if(i*(s-i)==p) ...
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <math.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define ll long long using namespace std; unsigned int factorial(unsigned int n){ if (n==0) return 1; else return n*factorial(n-1); } int binary_search(vector<int> v,int k...
#include <bits/stdc++.h> using namespace std; int main(){ int N; long long ans = 0; string S; cin >> N >> S; int A, T, C, G; for(int i = 0; i < N; i++){ A = 0; T = 0; C = 0; G = 0; for(int j = i; j < N; j++){ if(S.at(j) == 'A') A++; if(S.at(j) == 'T') T++; if(S.at(j) =...
#include <bits/stdc++.h> using namespace std; int main(){ long long N; cin >> N; set<long long> A,B,C; vector<vector<long long> > BB; vector<long long> v0; vector<long long> Ac,Cc; for(long long i=0; i<N; i++){ Ac.push_back(0); BB.push_back(v0); Cc.push_back(0); ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define lb lower_bound #define ub upper_bound #define fe(x) (*(x.begin())) #define le(x) (*(x.rbegin())) #define pb ...
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int H,W;cin>>H>>W; vector<vector<char>>S(H,vector<char>(W)); for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>S[i][j]; } } vector<vector<int>>dp(H,vector<int>(W,0)); for(int i=0;i<H;i++){ for(int j=0;j<W;j++)...
#include <bits/stdc++.h> int main() { using std::cin; using std::string; using std::vector; int h, w; cin >> h >> w; vector<string> s (h); for (int i = 0; i < h; i++) cin >> s[i]; int ans = 1; for (int i = 0; i <= h + w - 2; i++) { int b_ok = 1, r_ok = 1; for (int j = std::max(0, i - w + 1); j <= std::mi...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; int main() { int N, M; cin >> N >> M; vector<vector<vector<int>>> G(N, vector<vector<int>>(26)); vector<vector<bool>> adj(N, v...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) void chmin(ll& a, ll b) { if (a > b) a = b; } int main() { int N, M; cin >> N >> M; ll H[N]; rep(i, N) { cin >> H[i]; } sort(H, H+N); vector<ll> left(N/2), right(N/2); rep(i, ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<array<int, 2>> a(n); int res = INT_MAX; for(int i = 0;i < n;i ++) { cin >> a[i][0] >> a[i][1]; } for(int i = 0;i < n;i ++) { for(int j = 0;j < n;j ++) { if(i == j) { ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using pint = pair<int,int>; using p = complex<double>; void f(vector<p>& B) { int N = B.size(); double x = 0, y = 0; for(auto u : B)x += u.real(), y += u.imag(); x /= N, y /= N; for(auto&u : B) { u = {u.real() - x, u.imag() - y}; } sort(B.be...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define reps(i, c, n) for(int i = c; i < n; i++) #define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i] #define MOD 1000000007 #define INF 1e7 #define LINF 1e15 typedef long long ll; typedef long double ld; using Graph = vect...
#include <iostream> using namespace std; int main() { int v, t, s, d; cin >> v >> t >> s >> d; if (d >= v * t && d <= v * s) { cout << "No"; } else { cout << "Yes"; } return 0; }
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__) #else #define DEBUG(...) 6 #endif template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";} template<typename C, typen...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef long int li; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define test ll t; cin >> t; while(t--) const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,n) for(ll i=0; i<n; i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rrep(i,n) for(ll i=n-1; i>=0; i--) #define fi first #define se second #define pcnt __builtin_popcountll typedef long long ll; typedef unsigned long lon...
//W4P3R #include<bits/stdc++.h> #define inf 1e9 #define eps 1e-6 #define mp make_pair #define pb push_back #define re register ll #define fr first #define sd second #define pa pair<ll,ll> #define FOR(i,a,b) for(re i=a;i<=b;i++) #define REP(i,a,b) for(re i=a;i>=b;i--) #define MEM(a) memset(a,0,sizeof(a)) #define N 20001...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = b; i >= a; i--) using namespace std; const int N = 200111; int n, s, t, sub[N], ans[N], e = 1; vector<int> g[N]; pair<int, int> dfs(int v, int p) { pair<int, int> a = {0, v}; for (auto u : g[v]) { if (...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; using namespace std; int main(){ char s,t; cin>>s>>t; if(s=='Y')t= toupper(t); cout<<t<<endl; }
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define ALL(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<int,int>; int main(){ int n , s , d; cin >> n >> s >> d; rep(i,n){ int x , y; cin >> x >> y; if(x >= s || y <= d){ continu...
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here int n,m,k,x,sum=0; cin>>n>>k>>m; for(int i=0;i<n-1;i++) { cin>>x; sum+=x; } int target = n*m; if(sum>target) cout<<0<<endl; else if(abs(target-sum)>k) cout<<-1<<endl; else { cout<<abs(target-sum)<<endl; } return 0; ...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <vector> #include <numeric> #include <iostream> #include <random> #include <map...
/** * author: yuya1234 * created: 17.10.2020 20:15:10 **/ #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);i--) #defin...
#define _CRT_SECURE_NO_WARNINGS #include<bits/stdc++.h> //#include <Windows.h> #include<unordered_map> //#include"testlib.h" using namespace std; //<DEFINE> void Fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void File() { #ifndef ONLINE_JUDGE /* HWND Stealth; AllocConsole(); Stea...
#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>; using Graph = vector<vector<int>>; template<class T> void chmax(T& a, T b){ if(a < b){ a = b; } } template<class T> void chmin(T& a, T b){ if(a > b){ a ...
//#include <stdio.h> #include<bits/stdc++.h> #define ll long long using namespace std; int main(){ int n; cin>>n; int a[n+5],b[n+5]; int min=0; int max=10000; for(int i=0; i<n; i++){ cin>>a[i]; if(min<a[i]) min=a[i]; } //cout<<min<<"\n"; for(int i=0; i<n; i++){ ...
#include <bits/stdc++.h> using namespace std; int a[100][100]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w; cin >> h >> w; int mn = 1e9, total = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> a[i][j]; mn = min(mn,...
#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...
#include<bits/stdc++.h> #define ll long long #define mod 1000000007 #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,a[N],vst[17],tot; char s[N]; ll f[N][17]; int m...
#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; using ll=long long; using db=double; ///***************************************************** CONSTANTS ******************************************************/// int c...
#include <bits/stdc++.h> using namespace std; typedef long long ll; double dp[101][101][101]; double funct(int a, int b, int c){ if(dp[a][b][c]) return dp[a][b][c]; if(a == 100 || b == 100 || c == 100) return 0; double ans = 0; ans += (funct(a + 1, b, c) + 1)*a/(a + b + c); ans += (funct(a, b +...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) #define rep2(i,a,b) for(int i=(a);i<(b);++i) template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;} template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;} //v...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
#pragma GCC optimize("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ld> vld; typedef pair<ll,ll> Pll; ...
#define rep(i, n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector<pair<ll,int>> X(n),Y(n); rep(i,n){ ll x,y; cin>>x>>y; X[i...
#include <bits/stdc++.h> using namespace std; pair<int,int> solve(int x,int y) { if(x > y) { swap(x,y); } return {x,y}; } int main() { int N; cin >> N; vector<pair<pair<int,int>,int>>tmp(N); for(int i = 0; i < N; i++) { cin >> tmp[i].first.first >> tmp[i].first.second; ...
#include <bits/stdc++.h> using i64 = long long; using u32 = unsigned; using u64 = unsigned long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); i64 n; std::cin >> n; std::string s, t; std::cin >> s; std::cin >> t; std::vector<int> a, b; for (int i = 0; i <...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; template<typename T>inline bool ch...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, j, n) for (int i = (j); i < (n); ++i) #define mp make_pair using ll = long long; using ld = long double; typedef pair<int, int> P; typedef pair<P, int> COST; #define repl(i, n) for (ll i = 0; i < (n); ++i) #defi...
#include <bits/stdc++.h> #define ll long long int using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ll N, K, r, m, n; cin >> N >> K; N--; ll sum = N * 3, zero = 0, one = 1, tmp = 0; for (r = 0; r <= sum; r++){ tmp = 0; if (r <= N) tmp = (r + 1) * (r + 1) - (r ...
#include<bits/stdc++.h> using namespace std; #define MAXN 200005 #define lowbit(x) (x&-x) #define reg register #define mkpr make_pair #define fir first #define sec second typedef long long LL; typedef unsigned long long uLL; const int INF=0x3f3f3f3f; const int mo=998244353; const LL jzm=2333; const int iv2=499122177; c...
#include<iostream> #include<string> #include<cstring> #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; #def...
#include<bits/stdc++.h> using namespace std; long long n,a[39],b[31]; int main() { cin>>n; a[0]=b[0]=1ll; for(int i=1;i<=38;i++) a[i]=a[i-1]*3; for(int i=1;i<=26;i++) b[i]=b[i-1]*5; // for(int i=1;i<=30;i++) // cout<<a[i]<<endl; // for(int i=1;i<=30;i++) // cout<<b[i]<<endl; for(int i=1;i<=38;i++) for(i...
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <list> #include <cmath> #include <algorithm> #include <assert.h> using namespace std; template <typename input_type> input_type input() { input_type inp; cin >> inp; return inp; ...
#include <bits/stdc++.h> #pragma GCC diagnostic warning "-std=c++11" #define ll long long #define pb push_back #define pi acos(-1.0) #define maxn 1000009 #define sorted(s) sort(s.begin(),s.end()) #define sl(n) scanf("%lld", &n) #define pb push_back #define fr first #define sc second #define all(a) a.begin(),a...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); //b int n; cin >> n; string t; cin >> t; string s = ""; while ((int) s.size() <= n) { s += "110"; } s += s; const int long long SN = 3e10; long long ans = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); long long m = 998244353; vector<long long> min_sum(n); min_sum.at(0) = a.at(0); if (n > 1) { for (int i = 1; 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 endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } r...
#include <stdio.h> #include <algorithm> #include <vector> #define MN 100000 int n; std::vector<int> e[MN+5]; void add(int u,int v){ e[u].push_back(v); } struct state{ int c,f,s; }s[MN+5]; void dfs(int u){ s[u].c = 1; s[u].f = 1; s[u].s = 0; std::vector<int> ve[2]; for(auto v:e[u]){ dfs(v); s[u].c += s[v...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define rep(i,s,e) for(int i=s ; i < e ; i++) #define rrep(i,s,e) for(int i=s ; i > e ; i--) #define srep(i,s,e,j) for(int i=s ; i < e ; i+=j) #define tr(i,x) for(auto i : x) #define inp(a) for(int i=0 ; i...
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;i++) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;i--) inline int read() { int x=0,f=1;char c=getchar(); while(c<48||c>57){if(c=='-')f=-1;c=getchar();} while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f; } using namespac...
#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 <iostream> #include <algorithm> #include <vector> #include <string> #include <utility> #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <limits> #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; template<clas...
#include <iostream> #include <algorithm> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <string.h> #include <vector> #include <queue> #include <cmath> #include <complex> #include <functional> #include <numeric> #include <iomanip> #include <cassert> #include <random> #include ...
#include <stdio.h> #include <algorithm> #include <vector> using namespace std; typedef long long ll; ll n, f[200111]; ll ck[200111], step[200111]; ll dfs(ll x, ll color, ll curstep = 1) { ck[x] = color; step[x] = curstep; ll nx = f[x]; if (ck[nx] == 0) { return dfs(nx, color, curstep + 1); } if (ck[nx] == ...
#include <bits/stdc++.h> #define ss second #define ll long long #define mod 1000000007 #define ff first #define pb push_back #define pll pair<ll,ll> #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) #defin...
// Problem: E - Train // Contest: AtCoder - AtCoder Beginner Contest 192 // URL: https://atcoder.jp/contests/abc192/tasks/abc192_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <clim...
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define FastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define read() freopen("...
#include <bits/stdc++.h> using namespace std; template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); } template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); } int main(){ ios::sync_with_stdio(false); cin.tie...
#define LOCAL #ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++) #define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--) #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define All(x) x...
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <tuple> #include <utility> #include <vector> #define rep(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#include <iostream> #include <vector> #include <string> #include <array> using namespace std; string s, t; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n >> s >> t; vector<array<int, 7>> dp(n + 1); for (int i = 0; i < 7; i++) dp[n][i] = (i != 0); for(int i = n - 1; i >= 0; i--) ...
#include <bits/stdc++.h> #ifdef LILY #include "./Debug.h" #else #define var(...) (0) #define dbg(...) (0) #endif using int32 = int; using int64 = long long; using namespace std; class Solution { #define int int32 #define sfor(i, n) for (int i = 1; i <= (n); ++i) #define tfor(i, n) for (int i = 0; i < (n); ++i) in...
#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 vector<vector<int>> pass; vector<vector<int>> tour; vector<pair<int, int>>inout; int depth = 0; int p...
#include<bits/stdc++.h> using namespace std; const int mod=998244353; int add(int a,int b) {return a+b>=mod?a+b-mod:a+b;} int dec(int a,int b) {return a<b?a+mod-b:a-b;} int mul(int a,int b) {return 1ll*a*b%mod;} void Add(int &a,int b) {(a+=b)>=mod?a-=mod:0;} void Dec(int &a,int b) {(a-=b)<0?a+=mod:0;} void Mul(int &a,i...
//------------------------------------------ // C++ templete //------------------------------------------ #include <bits/stdc++.h> #define lint long long int using namespace std; //typedef //------------------------------------------ typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; typedef ...
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") //#include <immintrin.h> //#include <emmintrin.h> #include <bits/stdc++.h> using namespace std; #define rep(i,h,t) for (int i=h;i<=t;i++) #define dep(i,t,h) fo...
#include<bits/stdc++.h> using namespace std; typedef long long ll;typedef double db; typedef pair<int, int> pii;typedef pair<ll, ll> pll; typedef pair<int,ll> pil;typedef pair<ll,int> pli; #define Fi first #define Se second #define _Out(a) cerr<<#a<<" = "<<(a)<<endl const int INF = 0x3f3f3f3f, MAXN = 1e2 + 3,MAXV=1e3+4...
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int N = 100 + 5; int mod, k, dp[N][N], a[N]; string s; int add(int a, int b){ return (a + b) % mod; } int mul(int a, int b){ return 1ll * a * b % mod; } int fp(int b, int p){ if(p == 0) return 1; int re...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,f,n) for(ll i=(f); (i) < (n); i++) #define repe(i,f,n) for(ll i=(f); (i) <= (n); i++) #define repc(i,f,n) for(char i=(f); (i) <= (n); i++) #define PI 3.14159265358979323846264338327950ll #define debug(x) cout<<#x<<" :: "<<x...
#include<bits/stdc++.h> #include<cmath> #define pb push_back #define ld long double #define mp make_pair #define vl vector<ll> #define vd vector<double> #define vld vector<long double> #define ll long long int #define pl pair<ll, ll> #define all(a) a.begin(), a.end() #define forr(i, n) for(ll i=0; i<n; i++) #define f...
#include <bits/stdc++.h> //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //#include <atcoder/all> using namespace std; #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a; i > -1; --i) #define REP(i, a, b) for (int i = (int)a; i ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll N=1e6+5,inf=1e18,mod=1e9+7; #define test ll testcases;cin>>testcases; while(testcases--) #define pb push_back #define mp make_pair #define pf push_front #define ff first #define ss second #define vll vector<ll> #define v...
#include <sys/time.h> #include <algorithm> #include <array> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #inclu...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 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; return 1; } return 0; } ...
#include <iostream> #include <vector> #include <queue> #include <stack> #include <cmath> #include <algorithm> #include <set> #include <map> #include <iomanip> using namespace std; #define rep(i, N) for (int i = 0; i < N; i++) #define repi(i, ini, N) for(int i = ini; i < N; i++) #define chmax(i, j) i = max(i, j) #defin...
#include <bits/stdc++.h> #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++) using namespace std; int main() { int N; cin >> N; vector<int> used(2 * N); auto out = []() { cout << "No" << endl; exit(0); }; REP(i, N) { int A, B; cin >> A >...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using Graph = vector<vector<ll>>; const ll INF = 1LL << 60; const double pi = acos(-1); ll mod = 1000000007; // ...
/* * @Author: kabbo * @Date: 2020-06-24 08:40:07 * @Last Modified by: kabbo * @Last Modified time: 2020-06-24 08:49:58 */ #include<bits/stdc++.h> using namespace std; #define pii pair<long long,long long> #define endl '\n' #define ull unsigned long long #define ll int64_t #define ar array // http://www.open-std.org...
#include <bits/stdc++.h> using namespace std; int main(){ char s, t; cin >> s >> t; if(s == 'Y'){ if(t == 'a'){ cout << "A"; }else if(t == 'b'){ cout << "B"; }else{ cout << "C"; } }else{ cout << t; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string S,T; cin>>S>>T; if(S=="Y"){ if(T=="a"){ T = "A"; } if(T=="b"){ T = "B"; } if(T=="c"){ T = "C"; } } cout<<T<<endl; }
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rrep(i,n) for(int i=(n)-1; i>=0; i--) #define FOR(i,a,b) for(int i=(a); i<(b); i++) #define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define UNIQUE(v) v....
#include<bits/stdc++.h> using namespace std; int main(){ int m,h; cin >> m >> h; if (h%m==0){ cout << "Yes" << endl; } else{ cout << "No" << endl; } }
//#include<bits/stdc++.h> #include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #include<vector> #include<map> #include<stack> #include<queue> #include<cstring> #include<string> #include<set> //#include<unordered_map> using namespace std; #define rep(i,a,b) for(int i=a;i<=b;i++) #define dep(i,b,a) for...
#include<bits/stdc++.h> using namespace std; //#include<atcoder/all> //using namespace atcoder; using ll = long long; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() struct edge{ int to; char c; }; void Main(){ int n, m; cin >> n >> m; vector<vector<edge>> graph(n); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i, n) FOR(i,n,0) #define OF64 std::setprecision(40) const ll MOD = 1000000007; const ll INF = (ll) 1e15; ll N; ll A[200005]; ll T[200005]; ll func(ll val...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <numeric> #include <math.h> #include <map> #include <queue> #include <set> #define say(s) cout << s << endl #define rep(i, n) for(int i=0; i<(int)(n); i++) #define vec vector using namespace std; using ll = long long int; using P = ...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll = long long; const ll INF = 9e18; void print() { cout << endl; } template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);} void print0() {} template<typename Head,typen...
#include <bits/stdc++.h> #include <bits/extc++.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)...
#include <algorithm> #include <cmath> #include <vector> #include <functional> #include <cstdlib> #include <map> #include <set> #include <ctype.h> #include <climits> #include <queue> #include <iostream> #include <string> #define rep(i,n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; // us...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define int long long int #define popcount(x) __builtin_popcountll(x) #define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define sc second #define pb push_back #define fr first #define all(a) (a).begin(),(a).end() #define mem0(a) memse...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,n) for(ll i=0; i<n; i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rrep(i,n) for(ll i=n-1; i>=0; i--) #define fi first #define se second long long mo = 1000000007; typedef long long ll; typedef long double ld; typedef ...
#include <bits/stdc++.h> using namespace std; int main() { int a,b,c,f=0; string g="Yes"; cin>>a>>b>>c; int h=a; vector<int> d(b),e(b); for(int i=0;i<b;i++){ cin>>d.at(i)>>e.at(i); } for(int i=0;i<b;i++){ a-=d.at(i)-f; f=d.at(i); if(a<=0)g="No"; a+=e.at(i)-f; if(h<a)a=h; f=e...
#include <iostream> #include <string> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; typedef long long ll; string intToA(int n,int radix){ string ans=""; do{ int t=n%radix; if(t>=0&&t<=9)ans+=t+'0'; else ans+=t-10+'a'; n/=radix; }while(n!=0); ...
#include<iostream> #include<algorithm> #include<cmath> #include<numeric> #include<vector> #include<map> #include<climits> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); for(auto &e: a) cin >> e; int ans = INT_MAX; for(int i = 0; i < 1 << n; i++){ int xored = 0, ored...
#include <bits/stdc++.h> using namespace std; const int N = 101; int dp[N][N * N * N], cnt[N]; int n, k, mod; void upd(int & var, int val) { var += val; if (var >= mod) var -= mod; } int main() { scanf("%d %d %d", &n, &k, &mod); dp[0][0] = 1; int sum = 0; for (int x = 1; x <= n; ++x) { memset(c...
// Author: Muhesh Kumar #include<bits/stdc++.h> using namespace std; using ll = long long; using db = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<db>; using ...
#include <bits/stdc++.h> #define LL long long #define ull unsigned long long #define F(i, j, k) for (int i = j; i <= k; ++i) #define DF(i, j, k) for (int i = j; i >= k; --i) using namespace std; template <typename T> inline void read(T &n) { T w = 1; n = 0; char ch = getchar(); while (!isdigit(ch) &&...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define rep1(i,n) for(int i=1;i<=(int)n;i++) #define sp(n) cout << fixed << setprecision(n) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b...
//DUEL #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define pii pair<int,int> #define pb push_back #define eb emplace_back #pragma GCC optimize("unroll-loops") #define shandom_ruffle(a, b) shuffle(a, b, rng) #define vi vector<int> #define vl vector<ll> #define popcn...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define eprintf(...) fprintf(stderr, __VA_ARGS__) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) int fa[200005]; ll sz[200005]; int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); } void ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; int from[MAXN], to[MAXN]; int dp[2 * MAXN]; int r = 0; int N; int valid(int l, int r) { if (r % 2 == l % 2) return 123456; //cerr << "check " << l << " " << r << endl; int len = r - l + 1, m = (l + r) / 2; vector<bool> can(len / 2, false); for (in...
#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; typedef long long ll; const int N = 55; int n, a[N]; ll mem[N][1<<17]; vector<int> primes; bool check(int x) { for(int i = 2; i*i <= x; ++i) if(!(x % i)) return 0; return 1; } void init() { memset(mem, -1, sizeof mem); for(int i = 2; i <= 50; ++i) { if(check(i))...
#include <bits/stdc++.h> //#include <chrono> #pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll X, Y; cin >> X >> Y; ll ans = (6-X-Y)%3; return ans; } int main() { auto ans = solve(); cout << ans << "\n"; return 0; }
// #pragma GCC optimize("Ofast,unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include <bits/stdc++.h> #define ll long long int #define vi vector<int> #define vvi vector<vector<int>> #define vll vector<long long> #define vs vector<string> #define vc vector<char> #de...
#include "bits/stdc++.h" using namespace std; #define pb push_back const int maxx = 100005; int n , c[maxx]; vector<int> edge[maxx]; int asd[maxx]; multiset<int> s; vector<int> ans; void dfs(int u) { s.insert(c[u]); asd[u] = 1; for(int i : edge[u]) { if(!asd[i]) { if(!s.count...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define V vector #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define mp make_pair #define sz(x) int(x.size()...
#include<iostream> #include<vector> #include<map> #include<unordered_map> #include<unordered_set> #include<string> #include<cmath> #include<set> using namespace std; int main() { int i ; cin >> i ; if(i % 2 == 0){ cout << "White" << endl; } else{ cout << "Black" << endl; } }
#include<bits/stdc++.h> #define ull unsigned long long #define ll long long #define F first #define S second #define pss pair<string,string> #define pcc pair<char,char> #define pll pair<ll,ll> #define pii pair<int,int> #define piii pair<int,pii> #define vi vector<int> #define vii vector<pii> #define pb push_back #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ //freopen("D://input.txt", "r", stdin); int n, m; cin >> n >> m; vector<int> v(n); vector<int> x(2, 0); for(int i = 0; i < n; i++){ string s; cin >> s; int total = 0; int bit_count...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; int main(int argc, char const *argv[]) { int n; cin >> n; vector<int> a(n); vector<int> b(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; int cnt = 0; for (int i = 0; i <= 1000; ++i) { b...
#include <iostream> using namespace std; int main() { int a,b,c,d; cin>>a>>b>>c>>d; cout<<(a*d-b*c); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; const int mxn = 1e6+10; bool mt[20][20]; int h, w,a , b; ll ans = 0; void rec(int i=0, int j=0, int a0=0) { //cout << "[" << i << ", " << j << ", " << a0 << "]\n"; if(a0>a or i>=h or j>=w) return; if(i==h-1 and j==w-1) { if(a=...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> pi; #define f first #define s second #define FAST ios_base::sync_with_stdio(0); cin.tie(0); #define all(x) x.begin(),x.end() typedef pair<int, pi> pii; const int maxn = 10000; const int INF = LLONG_MAX/2; int n,K,mod; int dp[110...
#include <bits/stdc++.h> const long long INF = 1e9; const long long MOD = 1e9 + 7; //const long long MOD = 998244353; const long long LINF = 1e18; using namespace std; #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIB...
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include <cassert> #include <climits> #include <ctime> #include <numeric> #include <vector> #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <iomanip> #include <complex> #include <deque> #include <functional> ...
/* * Author : Andrew J */ #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) x.begin() , x.end() #define rall(x) x.rbegin() , x.rend() #define vz(x) x.size() using ll = long long; using ii = pair <int , int>; void in(int &x); // con...
#include<bits/stdc++.h> #define ls rt << 1 #define rs rt << 1 | 1 #define lson l , mid , rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define lr2 (l + r) >> 1 using namespace std; typedef long long ll; const int maxn = 4e5 + 50; ll sum[maxn << 2], lazy[maxn << 2]; int L[maxn], R[maxn]; void push_up(int rt){ sum[rt]...
#include<bits/stdc++.h> using namespace std; bool _DD = false; #define _D(a)if(_DD)cout<<#a<<':'<<a<<" | "; #define DBG(a){_D(a);if(_DD)cout<<'\n';} #define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';} #define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';} #define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n'...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using ll = int64_t; using ull = uint64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<...
//================code===================// //#define TLE #ifdef TLE #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #include <random> #include <ctime> #define ci(t) cin>>t #define co(t)...
#include <bits/stdc++.h> using namespace std; using ll= long long; // #define double long double #define sz(x) (int)x.size() #define all(x) (x).begin(),(x).end() #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define _set(x) __builtin_popcount(x) #define _setl(x) __builtin_popcountll(x) #de...
#include<bits/stdc++.h> #define ll long long using namespace std; int main() { double v,t,s,d; cin>>v>>t>>s>>d; double x = d/v; if(x<t||x>s)puts("Yes"); else puts("No"); return 0; }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define vll vector<ll> #define pll pair<ll,ll> #define vpll vector<pll> #define ub upper_bound #define lb lower_bound #define all(v) ((v).begin()),((v).end()) #define allr(v) ((v).rbegin()),((v).rend()) #define...
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define pf push_front #define ppf pop_front #define ppb pop_back #define ff first #define s(num) to_string(num) #define ss ...
#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 <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int X; cin >> X; cout << 100 - X % 100 << endl; return 0; }
// RioTian 21/03/15 #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 10; int dp[N][7]; int main() { ios_base::sync_with_stdio(false), cin.tie(0); int n; string s, t; cin >> n >> s >> t, s = " " + s, t = " " + t; dp[n][0] = 1; for (int i = n; i >= 1; --i) { ...
#include<bits/stdc++.h> using namespace std; const int N=2e5+10; bool f[N][7]; int X[N]; char op[N]; int n; int qpow(int p,int q){ int ans=1; while(q){ if(q&1)ans=ans*p%7; q>>=1; p=p*p%7; } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>n; char cc; for(int i=1;i<=...
#include "bits/stdc++.h" using namespace std; int func(int a, int b, int c, int d) { if (a >= b) { if (a >= c) { if (a >= d) { return 0; } else { return 3; } } else { if (c >= d) { return 2; } else { return 3; } } } else { if (b >= c) { if (b >= d) { return 1...
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <cmath> #include <ctime> #include <cassert> #include <cstdio> #include <queue> #include <set> #include <map> #include <fstream> #include <cstdlib> #include <string> #include <cstring> #include <algorithm> #include <numeric> using namespace std; #d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define all(x) (x).begin(),(x).end() template<typename A, size_t N, typename T> void...
#include <algorithm> #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> using ll = long long; using namespace std; ll dp[51][51] = {0}; int main(int argc, char *argv[]) { ll N, M, Q; cin >> N >> M >> Q; vector<pair<ll, ll>> wv_org(N); vector<pair<ll, ll>> wv(N); ...
///Bismillahir Rahmanir Rahim #include "bits/stdc++.h" #define ll long long #define int ll #define fi first #define si ...
//#define _GLIBCXX_DEBUG //#include "atcoder/all" //using namespace atcoder; #include <bits/stdc++.h> #define int long long #define ll long long using ull = unsigned long long; using namespace std; #define Dump(x) \ if (dbg) { \ cerr << #x << " = " <<...
#include<bits/stdc++.h> using namespace std; //common file for PBDS #include<ext/pb_ds/assoc_container.hpp> // including tree_order_statistics_node_update #include<ext/pb_ds/tree_policy.hpp> //namespace using namespace __gnu_pbds; //#define int long long //macro definition #define ordered_set tree<pair<int,int>, null...
//----AUTHOR: eeshan_deo_iitkgp----/ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll long long #define ld long double #define pb push_back #define ppb pop_back #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vb vector<bool> #define vd vecto...
#include <bits/stdc++.h> using namespace std; int main(){ long long N; cin >> N; vector<int> ans; long long INF = 1000000000000000000; vector<long long> fib(87, INF); fib[0] = 1; fib[1] = 1; for(int i = 2; i < 87; i++){ fib[i] = fib[i - 1] + fib[i - 2]; } vector<int> ind;...
#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 H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>...
#include<iostream> #include<string> #include<algorithm> #include<cmath> #include<ctime> #include<map> #include<vector> #include<math.h> #include<stdio.h> #include<stack> #include<queue> #include<tuple> #include<cassert> #include<set> #include<bitset> #include<functional> #include <fstream> //#include<bits/stdc++.h>...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N,Q; vector<ll> A; vector<ll> K; int main(){ cin >> N >> Q; A.resize(N); rep(i,N) cin >> A[i]; rep(i,N) A[i] -= i; K.resize(Q);...
//@formatter:off #include<bits/stdc++.h> #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #defi...
#include <iostream> constexpr int N = 5005; constexpr int p = 998244353; int add(int x, int y) { return (x += y) >= p ? x - p : x; } int sub(int x, int y) { return (x -= y) < 0 ? x + p : x; } int mul(int x, int y) { return (long long)x * y % p; } int n, m; int f[N], g[N]; int main() { std::ios::sync_with_stdio(...
#include <bits/stdc++.h> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; const int N = 105; const int MOD = 1e9 + 7; const long long INF = 5e18; const double PI = 2 * acos(0.0); #define debug(x) cerr << #x << " :: " << x << '\n'; //t...
#include <bits/stdc++.h> using namespace std; int main() { string X; cin >> X; for(int i = 0; i < X.size(); i++){ if(X.at(i) == '.') break; cout << X.at(i); } cout << endl; }
#include <iostream> #include <iomanip> #include <algorithm> #include <assert.h> #include <complex> #include <utility> #include <vector> #include <string> #include <stack> #include <queue> #include <tuple> #include <cmath> #include <bitset> #include <cctype> #include <set> #include <map> #include <unordered_map> #includ...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define mp make_pair #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 LL_MAX LLONG_MAX #define ub(v,x) upper_b...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define repn(i,n) for(int i=1;i<=n;++i) #define LL long long #define pii pair <int,int> #define pb push_back #define fi first #define se second #define mpr make_pair using namespace std; const LL MOD=1e9+7; int main() { int a,b; cin>>a>>b; if(a==b...
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios::sync_with_stdio(0),cin.tie(0); int n,m,q; cin >> n; int x[n],y[n]; for(int i=0;i<n;i++) cin >> x[i] >> y[i]; cin >> m; vector <pair <int,int> > op,ans; vector <pair <int,int> > qry[m]; for(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define forn(i,x,n) for(int i = x;i <= n;++i) typedef pair<int,int> pii; #define x first #define y second const int N = 3,_N = 2e5 + 7; struct mat { ll m[N][N]; }; pii a[_N]; mat op[_N]; mat mul(mat A,mat B,int len) { mat c;memset(c.m,0,sizeof...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main(){ int n, k; int ans = 0; cin >> n >> k; for (int i = 100; i <= n * 100; i += 100) { for (int j = 1; j <= k; j++) { ans += i + j; } } cout << ...
#include<bits/stdc++.h> using namespace std; using namespace std::chrono; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define int long long #define rep(i,a,b) for(int i=a;i<b;i++) #define repn(i,a,b) for(int i=a;i>=b;i--) #define F first #define S second #define pii pair<int,int>...
#include <cstdio> int n; int main(){ scanf("%d", &n); printf("%d\n", (1 << n) - 1); for(int i = 1; i < (1 << n); ++i){ for(int j = 0; j < (1 << n); ++j) if(__builtin_popcount(i & j) & 1) putchar('A'); else putchar('B'); puts(""); } return 0; }
#include<iostream> #include<algorithm> #include<math.h> #include<cstring> #include<queue> #include<vector> #include<map> #include<set> #include<stack> #include<string.h> using namespace std; long long int a[300001]; long long int b[300001]; long long int amax[200001]; string func0(string s); string func1(string s); str...
#include <bits/stdc++.h> using namespace std; long long int MOD = 1000000007; long long int modpow(long long int a, long long int n) { long long int res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } int main() { long long int N, P; cin >> N >> ...
#include<iostream> #include<iterator> #include<algorithm> #include<climits> #include<map> #include<set> #include<numeric> #include<string> #include<sstream> #include<cstdio> #define ll long long using namespace std; int main() { int i, j; cin >> i >> j; cout << (abs(i-j)<3?"Yes":"No"); }
#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); } return x * f; } const int N = 3007, mod = 998244353...
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf 2147483647 #define mod 1000000007 #define int long long int x, y; map<int, int> mp; int...
#include <bits/stdc++.h> using namespace std; const int mxn=3e5+5; vector<int>a(mxn); template<typename T> struct segtree { const int n; vector<T> stree; segtree(int n) : n(n), stree(4*n) {} void build(int id,int l,int r){//build segment tree if(r-l<2){ stree[id]=a[l]; return; } int mid=(l+r)/2...
#include <vector> #include <array> #include <stack> #include <queue> #include <list> #include <bitset> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <algorithm> #include <numeric> #include <iostream> #include <iomanip> #include <string> #include <chrono> #include <random> #inc...
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("fast-math") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_...
// C - Compass Walking #include <bits/stdc++.h> using namespace std; int main(){ int64_t d2, ok, ng, m, r, x, y; cin>>r>>x>>y; d2 = x*x + y*y; ok = 0, ng = 1e6; while(ng - ok > 1){ m = (ok + ng) / 2; __int128_t rm2 = (__int128_t)r*r*m*m; (rm2 < d2? ok:ng) = m; } cout<< ok + 1 + (d2 < r*r) <<endl; }
#include<iostream> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; int main() { ll a, b; cin >> a >> b; if(abs(a - b) < 3) puts("Yes"); else puts("No"); }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define vll vector<ll> #define pll pair<ll,ll> #define vpll vector<pll> #define ub upper_bound #define lb lower_bound #define all(v) ((v).begin()),((v).end()) #define allr(v) ((v).rbegin()),((v).rend()) #define...
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; constexpr int MOD = 998244353; constexpr int INF = numeric_limits<int>::max() / 2; typedef pair<int,int> P; using Graph = vector<vector<int>>; template<class T> inline bool chmax(T& a, T b) { if (a ...
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define rb pop_back #define mp make_pair #define pii pair<int,int> #define vi vector<int> #de...
#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 <bits/stdc++.h> #define pb push_back #define mp make_pair #define sz(a) ((int)a.size()) #define re return #define all(a) a.begin(),a.end() #define int long long #define Type int #define rept(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,a) rept(i,0,a) using namespace std; const int mod=998244353; const int mul...
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/ /*** "ALHAMDULILLAH for Everything..." ***/ /* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") */ #include<bits/stdc++.h> using namespace st...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); ++i) #define fixed_setprecision(n) fixed << setprecision((n)) #define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC); #define pai 3.1415926535897932384 #define NUM_MAX 2e18 #define NUM_MIN -1e9 using names...