code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<bits/stdc++.h> using namespace std; inline int read(){ int res=0; char c; bool zf=0; while(((c=getchar())<'0'||c>'9')&&c!= '-'); if(c=='-')zf=1; else res=c-'0'; while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0'; if(zf)return -res; return res; } const int maxn=505...
#include<bits/stdc++.h> #include<iostream> #include<vector> #include<algorithm> #include<set> #include<iomanip> #include<queue> #include<cmath> #include<stack> #include<map> #define ll long long #define skip cin>>ws; #define vll vector<ll> #define vb ...
#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 ll mod = 1e9+7; const ll N = 1e5+2; //My tools #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define rep(i,s,e) for(ll i=s;i<e;i++) #define ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL_ void debug_out() {cerr << endl;} template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);} #define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__) #define dump(x) cer...
#include<iostream> #include<map> #include<vector> #include<algorithm> #include<set> #include<queue> #include<stack> #include<math.h> #include<time.h> #include<deque> #include<cstring> #define ll long long #define DB double #define FOR(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define F first #define S second #de...
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool ch...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define fz(i,a,b) for(int i=a;i<=b;i++) #define fd(i,a,b) for(int i=a;i>=b;i--) #define ffe(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++) #define fill0(a) memset(a,0,sizeof(a)) #define fill1(a) memset(a,-1,sizeof(a)) #define...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef vector<vl> vvl; #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++) #define all(v) (v).begin(), (v).end() const char newl = '\n'; vl S; vvl G; void dfs(ll v) { ...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; if(n%2==1)cout<<"Black"; else cout<<"White"; }
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define rrep(i,n) for(int i = (n)-1; i >= 0; i--) #define rep1(i,n) for(int i = 1; i <= (n); i++) #define rrep1(i,n) for(int i = (n); i > 0; i--) #define ll long long #define pi pair<int, int> #define pll pair<ll, ll> #define MOD 1000000007 #defin...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long int #define ld long double #define pb push_back #define MOD 10...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; using vl = vector<long long>; using vi = vector<int>; int main(){ ll r,x,y; cin >> r >> x >> y; ll l = x*x + y*y; int ans; for(ll ix=1;;ix++){ if(l < r*r){ ans = 2; break; ...
#include<bits/stdc++.h> using namespace std; int n; int h[1000001]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int a,b,c; cin>>a>>b>>c; if(a==b||c==0) { cout<<"="; return 0; } if(c%2) { if(a>b) { cout<<">"; re...
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int N = 2000 + 5, mod = 1e9 + 7; ll a, b, c, d; bool check1(int a, int b, int c, int d){ if(a + b == c + d) return 1; if(a - b == c - d) return 1; if(abs(a - c) + abs(b - d) <= 3) return 1; return 0; } bo...
#include <bits/stdc++.h> using namespace std; int main() { long N, A, m, b = 0, c = 0; cin >> N; m = N; while (m) { m--; cin >> A; b += A; c += A * A; } cout << N * c - b * b << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define len(a) (int)a.size() #define all(a) a.begi...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
/** * Coded by : lucky_21 * --------Lokesh Singh **/ #include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_upd...
#include <bits/stdc++.h> using namespace std; #define MS(a, b) memset(a, b, sizeof(a)) #define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a) #define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a) #define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a) #define EREP(a, b) for (reg...
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << ...
#include <iostream> #include <algorithm> using namespace std; int main() { // your code goes here int n; cin >> n; string s[n]; int a[n],b[n]; for(int i=0;i<n;i++){ cin >> s[i] >> a[i]; b[i]=a[i]; } sort(a,a+n); for(int i=0;i<n;i++){ if(b[i]==a[n-2]){ cout << s[i] << endl; } } return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mx = -1; int prev = -1; map<int, string> m; while(n--) { string s; int temp; cin >> s ; cin >> temp; m[temp] = s; if(mx<temp){ prev = mx; mx = temp; } else if(temp < mx && temp > prev) prev = temp; } ...
#include<iostream> using namespace std; int main() { long long int n,d,h,i,j,k,a[200],b[200]; double s=0; cin>>n>>d>>h; for(i=0;i<n;i++) { cin>>a[i]>>b[i]; double x=d-a[i]; double y=h-b[i]; double m=y/x; double k=m*(-1)*d+h; s=max(s,k); } if(s==0)cout<<"0.0"<<endl; else printf("%.13lf\n",s); }
#include<stdio.h> #define rep(i,N) for(int i=0;i<(int)N;i++) const int MOD=1e9+7; static long IN(void) { long x=0,f=1,c=getchar();while(c<48||c>57){if(c==45){f=-f;}c=getchar();} while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f*x; } static void OUT(int x){if(x<0){putchar('-'),x=-x;}if(x>=10){OUT(x/10);}putchar(x-...
#include <bits/stdc++.h> #define clog(x) std::clog << (#x) << " is " << (x) << '\n'; using LL = long long; constexpr int M = 1e9 + 7; int main() { //freopen("in", "r", stdin); std::cin.tie(nullptr)->sync_with_stdio(false); int n; std::cin >> n; std::vector<LL> a(n + 1); for (int i = 1; i <= n; ++i) { std::cin ...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include <cstdio> #include <algorithm> using namespace std; int a[400005]; int f[400005]; pair<int,int> p[400005]; int c[3]; int main() { int n; scanf("%d",&n); for(int i=1;i<=2*n;i++) scanf("%d",&a[i]); for(int i=1;i<=2*n;i++) p[i]=make_pair(a[i],i); sort(p+1,p+2*n+1); for(int i...
#include <bits/stdc++.h> using namespace std; long long int tab[200007]; int main() { long long int i, n, k=0, w=0; cin >> n; for(i=0; i<n; i++){ cin >> tab[i]; tab[i]%=200; } sort(tab, tab+n); for(i=1; i<n; i++){ if(tab[i]==tab[i-1]){ k++; } ...
#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(10) const ll MOD = 1000000007; const ll INF = (ll) 1e15; struct vec3 { ll x; ll y; ll z; }; l...
#include<bits/stdc++.h> #define pb push_back #define eb emplace_back using namespace std; //#define DEBUG #ifdef DEBUG template<typename ...Args> int debug(const Args &...args){ return fprintf(stderr,args...); } #else #define debug(...) void() #endif typedef unsigned long long ull; typedef unsigned uint; typedef lon...
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> using namespace std; const int N = 210, M = 810; int h[N], e[M], ne[M], w[M], idx; int a, b, x, y; bool st[N]; int d[N]; void add(int a, int b, int c) { e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ; } void spfa(i...
//! ๅฐบๅ‚ไนƒๅ‚.ๅ‚๏พŒไน‡ไน‡ใ„’ #include<bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; //Using namespace __gnu_pbds; //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set; #define ll long long #define int long long #define ld...
#include <iostream> using namespace std; int main(void) { int x; cin >> x; if (x < 0) cout << 0 << endl; else cout << x << endl; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; n=floor(n*1.08); if(n<206)cout<<"Yay!"; else if(n==206)cout<<"so-so"; else cout<<":("; retu...
#include <iostream> using namespace std; int main() { int x ,y ; cin >> x >> y ; if (x != y){ if (x < y){ if (x+3 > y){ cout<< "Yes"<<endl; } else if (x+3 <= y){ cout << "No" <<endl; } } else if(y < x){ if (y+3 > x){ cout<< "Yes"<<endl; } else if (y+3 <= x){ cout << "...
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ int X,Y; cin>>X>>Y; if(abs(X-Y)<=2) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include<bits/stdc++.h> #define ll long long #define pb push_back #define Mp make_pair #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--) #define FIO ios_base::sync_with_stdio(false);cin.tie(NULL) using namespace std; template<class X> void temfunc(const X a) { for(auto it=a.b...
#include<bits/stdc++.h> #include<unordered_map> #define sz(s) (int)s.size() #define all(s) s.begin(),s.end() using namespace std; typedef long long ll; void fast(){ std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } void Men7a() { double r, x, y,d; int ans; cin >> r >> x >> y; d = sqrt((x*x)+(y*...
#define DEBUG 0 #include <bits/stdc++.h> #define all(v) (v).begin(), (v).end() #define pb push_back #define rep(i,n) for(int i=0; i<(n); i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define REP(i, begin, end) for(int i = int(begin); i < int(end); i++) using namespace std; using ll = long long; using ld = long ...
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <utility> #include <string> #include <fstream> #include <map> #include <set> #include <queue> #include <memory.h> using namespace std; typedef vector<int> VI; typedef pair<int, int> PI; typedef vector<PI> VPI; #define FOR(i,a,n) fo...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int mod = 1e9 + 7; int add (int x, int y) {return x + y >= mod ? x + y - mod : x + y;} int mul (int x, int y) {return 1LL * x * y % mod;} int sub (int x, int y) {return x - y < 0 ? x - y + mod : x - y;} int n, a[maxn]; int f[maxn][2], g[ma...
#include <bits/stdc++.h> const int N = 200005; int n, a[N * 2], b[N * 2], ok[N * 2], st[N], top = 0; int main() { scanf("%d", &n); for (int i = 1; i <= n * 2; i++) scanf("%d", &a[i]), b[i] = i; std::sort(b + 1, b + n * 2 + 1, [](int x, int y) { return a[x] < a[y]; }); for (int i = 1; i <= n; i++) ok[b[i]] = 1; f...
#include <bits/stdc++.h> using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; typedef long double ldbl; typedef pair<int, int> pii; typedef pair<uint, uint> puu; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<double, double> pdd; typedef vector<int> vi...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> P; typedef vector<string> vs; typedef vector<double> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<vi> vvi; typedef vector<vl> vvl; type...
#include <iostream> using namespace std; int main() { int N; cin >> N; int A[N]; int i = 0; int max_num = 2; while (i != N) { scanf("%d", &A[i]); if (max_num < A[i]) { max_num = A[i]; } i++; if (i != N) { scanf(...
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn=200005; inline int read() { register int r=0,f=1; register char ch=getchar(); while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9') { r=(r<<1)+(r<<3)+(ch^48); ch=getchar(); } return r*f; } i...
#include <bits/stdc++.h> using namespace std; #define rep(index,num) for(int index=0;index<num;index++) #define rep1(index,num) for(int index=1;index<=num;index++) #define brep(index,num) for(int index=num-1;index>=0;index--) #define brep1(index,num) for(int index=num;index>0;index--) #define prin(a) cout<<a<<"\n" #def...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;} template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;} #define itn int #define fi first #define se second #def...
#include<bits/stdc++.h> using namespace std; int gcd(int a,int b){ while(b){ a=a%b; swap(a,b); } return a; } int n,a[2005],mn; map<int,int> mp; set<int> s; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; m...
#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define ld long double #define forr(i,a,n) for(int i=a;i<n;i++) #define rep(i,n) forr(i,0,n) #define repp(i,n) forr(i,1,n+1) #define pb push_back #define mp make_pair #define vvi vector<vector<int> > #define MAXN 0x3f3f3f3f int n,a[201...
#include<bits/stdc++.h> using namespace std; #define reg register typedef long long ll; #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++) static char buf[100000],*p1=buf,*p2=buf; inline int read(void){ reg char ch=getchar(); reg int res=0; while(!isdigit(ch))ch=getchar(); while(is...
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;} template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); } template<class T> ostrea...
#include<iostream> #include<string> using namespace std; typedef long long ll; int main() { int n,m,t,i,j; ll r[2]; string s; cin >> n >> m; r[0]=0; r[1]=0; for(i=0;i<n;i++){ cin >> s; t=0; for(j=0;j<m;j++) if(s[j]=='1') t++; r[t%2]++; } cout << r[0]*r[1] << endl; return ...
#include "bits/stdc++.h" using namespace std; #define ll long long #define pb push_back #define all(_obj) _obj.begin(),_obj.end() #define F first #define S second #define INF 1e18 #define pll pair<ll, ll> #define vll vector<ll> ll n,m,a,b,c,k,temp,x,y; const int MAXN=1e5+11,mod=998244353; ll max(ll a,ll b) {return ((a...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG using LL = long long; using VI = vector<int>; using VS = vector<string>; using VLL = vector<LL>; using VC = vector<char>; using VD = vector<double>; using PII = pair<int, int>; using PSS = pair<string, string>; using PIS = pair<int , string>; using...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a,b) for(int a=0;a<(b);++a) #define REP1(i,n) for(int i=1;i<=(n);++i) #define debug(x) cerr<<#x<<": "<<x<<'\n' #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define YES() printf("YES\n") #define NO()...
#include<iostream> using namespace std; int n; int a(int m){ if(m%n==0)return n; else return m%n; } int main(){ cin>>n; for(int i=1;i<=n;i++)cout<<a(2*i)<<" "<<a(2*i+1)<<endl; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MAXN = 1e3 + 5; #define bbit(i) (1<<(i)) #define bdig(x,i) (((x)>>(i))&1) inline int get_lb(int x) { int lb = 0; while(x>>lb) ++lb; return lb-1; } int n; inline int tidy(int x){ while(x>n) x ^= bbit(get_lb(x));...
#include<bits/stdc++.h> #define int long long using namespace std; constexpr int mod=1000000007; struct edge{int to,cost;}; void dfs(int v,int p,auto&G,auto&x){ for(edge e:G[v])if(e.to!=p){ x[e.to]=x[v]^e.cost; dfs(e.to,v,G,x); } } int mod_pow(int a,int b){ if(!b)return 1; if(b&1)return mod_pow(a,b-1)*a...
#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define ROF(i,a,b) for(int i=(a); i>=(b); --i) #define pb push_back #define eb emplace_back #define SZ(a) (int)(a).size() #define all(a) (a).begin(), (a).end() #define make_unique(a) sort(all((a))), (a).erase(unique(all((a))),(a).end()) #define x fi...
#include <bits/stdc++.h> #include <chrono> using namespace std; template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //typedef //------------------------------------------ typedef pair<int, int> PII; typedef long long LL; typedef pair<LL, LL> PLL; //container util //---...
#include <iostream> using namespace std; int main() { int N; cin >> N; if (N%2==1) { cout << "Black" << endl; } else { cout << "White" << endl; } return 0; }
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tre...
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 998244353; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll a, b, c; ...
#include<bits/stdc++.h> using namespace std; const long long mod=1e9+7; int a[2001][2001]; long long dp[2001][2001]; long long h[2001],l[2001],hjl[4001]; int main() { int n,m;scanf("%d%d",&n,&m);getchar(); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) a[i][j]=getchar(); getchar(); } for(int i=1;i<=n;i++) ...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<cstdint> #include<cstddef> #include<vector> //#include<atcoder/all> //using namespace atcoder; using namespace std; using i32 = int_fast32_t; using i64 = int_fast64_t; using usize = uint_fast64_t; temp...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define f(x, m) for(auto x : m) #define cpu() ios::sync_with_stdio(false); cin.tie(nullptr) #define pb push_back #define pii pair<int,int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #d...
#include <bits/stdc++.h> using namespace std; #define int long long const int N = (2e5 + 10), INF = 0x3f3f3f3f3f3f3f3f, mod = 998244353; int ksm(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; } signed main() { ...
#include<bits/stdc++.h> using namespace std; #define int long long int #define endl '\n' #define all(v) (v).begin(), (v).end() #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; int sum = 0; for(int floor...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll = long long; struct Edge{ ll to; ll cost; }; using Graph = vector<vector<Edge>>; using P =pair<ll,ll>; #define mp make_pair #define REP(i, n) for (int i = 0; i < (n); ++...
#include<bits/stdc++.h> using namespace std; #define ll long long #define Mod 1000000007 ll cmod(ll a){return (a%Mod+Mod)%Mod;} inline ll read(){ll x;scanf("%lld",&x);return x;} ll solve() { ll N=read(),A=read(),B=read(); if(N-A-B<0) return 0; if(A<B) swap(A,B); ll x1=(B-1)*(B-1)%Mod*(2*N+2-2*A-B)%Mod*(2*N+2-2*A-B)...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; int64_t N, A, B; const int64_t mod = 1000000007; for (int Case = 0; Case < T; Case++) { cin >> N >> A >> B; if (A+B>N) { cout << 0 << endl; continue; } int64_t Count = (N+1-A)*(N+1-A) % ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<ll, ll> P; typedef vector<P> vp; typedef tuple<int, int, P> T; typedef vector<T> vt; typedef vector<vl> vvl; // input int N; vl X, Y; int ...
#include <iostream> using namespace std; typedef long long ll; struct State{ int dir; bool xrev, yrev; ll dx, dy; }; int main() { int n; cin >> n; ll x[200005], y[200005]; for(int i = 0; i < n; i++) cin >> x[i] >> y[i]; int m; cin >> m; State state[200005]; state[0] = (Stat...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> x(n); vector<int> y(n); vector<int> r(n); for (int i = 0; i < n; i++) { cin >> x.at(i) >> y.at(i) >> r.at(i); } int maxx = 0; int minx = 114514; for (int i = 0; i < n; i++) { maxx = max(maxx, x.at(i)); minx = min(mi...
#define _USE_MATH_DEFIMES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <ioman...
#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 <bits/stdc++.h> #include <string> typedef long long ll; typedef long double ldb; typedef double db; using namespace std; #define ff first #define ss second #define pb push_back #define pf push_front #define ins insert #define mp make_pair #define len(s) s.length() #define forp(i, a, b) for (ll i = a; i <= b;...
#include<bits/stdc++.h> using namespace std; #define int long long #define w(x) int x; cin>>x; while(x--) #define endl ("\n") #define f(i, a, n) for(int i=a; i<n; i++) #define cc(r) cout<<r<<" " #define ce(r) cout<<r<<endl void inout() { ios_base::sync_...
#include <bits/stdc++.h> using namespace std; using namespace chrono; using ll = long long; constexpr double TIME_LIMIT = 2.95; system_clock::time_point start; double elapsed = 0; int loops = 1; int steps = 10; int N; int M; vector<string> S; vector<string> output; int base_num = 9; char bases[] = {'A', 'B', 'C', 'D'...
#include<bits/stdc++.h> #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i, 0, n) #define all(x) (x).begin(),(x).end() const int INF = 1e9+1; using namespace std; using ll = long long; using p = pair<int, int>; using v = vector<int>; int main(){ int N, M; cin >> N >> M; vector<bool> A(N+1, fals...
#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)) using namespace std; int main() { ll n,m; cin>>n>>m; V a(m); rep(i,m)cin>>a[i];...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define ...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define fill0(a) memset(a,0,sizeof(a)) #define fill1(a) memset(a,-1,sizeof(a)) #define fillbig(a) memset(a,63,sizeof(a)) #define pb push_back #define ppb pop_back #define mp make_pair template<typename T1,typename T2> void chkmin(T1 &x,T2 ...
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << ...
#include<bits/stdc++.h> using namespace std; const int N = 4e5 + 213; int a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; a[1] = 2 * 5; a[n] = 5 * 3; int x = 1; int len = 2; for(int i = 1; i <= 10000; i++) { if(i != a[1] && i != a[n] && ((i % 2 == 0 && (i % 3 == 0 or i % 5...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <iomanip> #include <climits> #include <functional> #include <cassert> using namespace std; typedef long long ll; typedef pair<int,int>...
#include<bits/stdc++.h> using namespace std; string s; int main() { cin>>s; reverse(s.begin(),s.end()); for(int i=0;i<s.size();i++){ if(s[i]=='6')s[i]='9'; else if(s[i]=='9')s[i]='6'; } cout<<s<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define t_times int t; cin >> t; while(t--) #define fr(i, st, n) for(int i = (int )st; i < (int )n; i++) #define rfr(i, en, st) for(int i = (int )en; i >= (int )st; i--) #define all(c) (c).begin(),...
#include<cstdio> #include<cstring> #include<iostream> using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } int n; int main(){ n=read(); if(n<0)pri...
#ifdef Rahul #include "RAHUL.h" #else #include <bits/stdc++.h> using namespace std; #define error(...) 42; #endif #define SZ(v) int((v).size()) #define ALL(vec) begin(vec), end(vec) typedef long long i64; template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;} template<typename T> inline...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using pll = pair<ll, ll>; using vpll = vector<pll>; using ld = long double; using vld = vector<ld>; using vb = vector<bool>; #define rep(i, n) for ...
#include<bits/stdc++.h> using namespace std; #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long int #define pb push_back #define mp make_pair #define pii pair<int,int> #define vec vector<int> #define mii ...
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(), x.end() #define MP make_pair using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; int main(int argc, char *argv[]) { #ifndef LOCAL ios::sync_with_stdio(false); cin.tie(nullptr); #endif vector<int> prime{3, 5,...
/* python3 ../../CompetitionHelpers/run_codeforces.py --problem E --test 0 g++ -ggdb -fsanitize=address -std=c++14 E.cpp && ./a.out <<< "5 1 2 2 3 2 4 4 5 4 1 1 1 1 4 10 2 1 100 2 2 1000" g++ -ggdb -fsanitize=address -std=c++14 E.cpp && ./a.out <<< "7 2 1 2 3 4 2 4 5 6 1 3 7 7 2 2 1 1 3 2 2 2 4 1 6 8 1 3 16 2 4 32 2 1...
#include <stdio.h> #include <vector> #define N 200005 using namespace std; long long sum[N]; long long ans[N]; int dis[N], dis_cnt; int n; struct EDGE { int x, y; }edge[N]; vector<int> e[N]; void dfs(int x, int pa) { dis[x] = ++dis_cnt; for (int i = 0; i < e[x].size(); i++) { int y = e[x][i];...
#include <bits/stdc++.h> #define ll long long #define INF 1e9 #define pb push_back #define mp make_pair #define loop(a,n) for(long long i=a;i<n;i++) #define vil vector<long long int> #define vi vector<int> #define sz(v) v.size() #define setbits(x) __builtin_popcountll(x) #define ff first #define ss second #de...
#pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define ll long long int #define deb(x) cout << #x << " " << x << endl; #define mod 1000000007 #define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NU...
#include <bits/stdc++.h> #define ll long long #define INF 1000000007 using namespace std; vector<ll> A(2001); map<ll,ll> mapp; ll bgcd(ll a, ll b) { if (b == 0) return a; return bgcd(b, a % b); } int main() { int N; cin>>N; A.resize(N+1); ll minn=-1; for(int i=1; i<=N; i++) { cin>>A[i]; if(A[i...
#include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<(n);++i) typedef long long ll; using namespace std; ll gcd(ll a, ll b) { if (a % b == 0ll) return b; return gcd(b, a%b); } ll gcd_multi(vector<ll> A) { ll n = A.size(); ll G = A[0]; for (ll i = 1; i < n; ++i) G = gcd(G, A[i]); return G; } ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #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 mydeb(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) //#define mydeb(fmt, ...) int main() { uint6...
#include "stdio.h" long long f[1000010]; int l, r; long long sol(int m, int n) { long long ans = 0, num = 0; for (int i = m; i > 1; -- i) { f[i] = 1ll * (n / i) * (m / i); for (int j = i << 1; j <= m; j += i) f[i] -= f[j]; ans += f[i]; } return ans; } main() { scanf("%d%d", &l, &r...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; int main() { int H, W, min, ans = 0; cin >> H >> W; vector <int> vec(H * W); rep(i, H * W) cin >> vec.at(i); sort(vec.begin(), vec.end()); min = vec.at(0); rep(i, H * W) an...
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define FOR(i,l,r,d) for(int i=(l);i<=(r);i+=(d)) #define vi vector<int> #define pii pair<int,int> #define F first #define S second #define pb push_back #define eb emplace_back #define mkp make_pair const int INF=21474...
#include <algorithm> #include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) int main() { int n; std::cin >> n; std::vector<std::vector<int64_t> > a(3); std::string rgb = "RGB"; REP(i, 2*n) { int64_t x; std::cin >> x; char c; std::cin >> c; a[rgb.fi...
#include<iostream> #include<vector> #include<algorithm> using namespace std; const int BUF = 200005; const long long INF = 1LL << 60; int N; pair<long long, char> vCh[BUF]; void read() { cin >> N; N *= 2; for (int i = 0; i < N; ++i) { cin >> vCh[i].first >> vCh[i].second; } } void work() { ...
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; bool flag=false; string ans; map<string , bool > mp; for(int i=0;i<n;i++) { string s; cin>>s; if(s[0]=='!') { string r=s; mp[s]=true; int n=s.size(); r=r.substr(1,n-1); if(mp.find(r)!=mp.end()) { flag=...
#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...
#include <bits/stdc++.h> // #include <atcoder/all> // #include "icld.cpp" using namespace std; using ll = long long int; using vi = vector<int>; using si = set<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using ss = string; using db = double; template<typename T> using minpq = priority_queue <T,vector...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(100001, 0), b(n), c(n); int tmp; for(int i = 0; i < n; i++) { cin >> tmp; a[tmp - 1]++; } for(int i = 0; i < n; i++) cin >> b[i]; for(int i = 0; i < n; i++) cin >> c[i]; long l...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> range(long long b, long long c) { long long n = c / 2; if (c % 2 == 0) { if (c == 0) return {b, b}; else return {b - n, b + n - 1}; } else { return {-b - n, -b + n}; } } int main() { long long b, c; ...
#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> #define ll long long #define pb push_back #define ff first #define ss second #define setbits(x) __builtin_popcountll(x) #define lp(a,n) for(ll i=a; i<n; i++) #define lpi(a,n) for(int i=a; i<n; i++) #define w(t) int t; cin>>t; while(t--) #define vi vector<int> #define vll vector<ll> #d...
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(),v.end() #define MP make_pair #define MT make_tuple typedef int64_t ll; #define PA pair<ll,ll> #define TU tuple<ll,ll,ll> #define vi vector<ll> #define vii vector<vector<ll> > #define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++) #define rep2(i,m,n) for...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define lli long long int #define tc int t;cin>>t;while(t--) #define all(x) x.begin(),x.end() #define f first #define s second #define pb push_back #define vi vector<int> #define vll vector<lli> #d...
#include <iostream> #include <string> #include <vector> #include <numeric> #include <map> using namespace std; int main() { ios::sync_with_stdio(false); int n; string s; cin >> n >> s; pair<int, int> cnt = {0, 0}; map< pair<int, int>, int > m; m[cnt] = 1; for (int i = 0; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int maxn = 1e6 + 10; int main() { string s; cin >> s; int n = s.length(); vector<int> cnt(26); ll ans = 0; for (int i = n - 1; ~i; i--) { int m = n - i; int c = s[i] - 'a';...
#include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define REP(i,x) for(int i=0;i<(int)(x);i++) #define REPS(i,x) for(int i=1;i<=(int)(x);i++) #define REPO(i,x) for(int i=x-1;i>=0;i--) #define T int tc; cin>>tc;while(tc--) #define READ freopen("input.txt","r", s...
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define rep1(i,n) for (int i = 1; i <= (n); ++i) #define bit(n,k) ((n>>k)&1) //nใฎkใ€€bit็›ฎ #define vec(T) vector<T> #define vvec(T) vector<vector<T>> using ll = long long; using ...
#include <bits/stdc++.h> #include <chrono> using namespace std; template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //typedef //------------------------------------------ typedef pair<int, int> PII; typedef long long LL; typedef pair<LL, LL> PLL; //container util //---...
#include<bits/stdc++.h> using namespace std; int main(){ int v,t,s,d; cin>>v>>t>>s>>d; int st=v*t; int en=v*s; if(d<st||d>en) cout<<"Yes"; else cout<<"No"; return 0; }
#include<iostream> using namespace std; int main() { long long n,m,t; cin>>n>>m>>t; long long answer = n; int start,end; cin>>start>>end; answer -= (start); if(answer<1){ cout<<"No"<<endl; return 0; } answer+= (end-start); if(answer>n){ answer=n; } for(int i = 1 ;...
#include<bits/stdc++.h> #define N 60 #define A(i,m,n) for(int i=m;i<=n;++i) using namespace std; typedef long long LL; const LL mod=998244353; int a[N][N],n,k; inline bool check1(int x,int y){ A(i,1,n)if(a[x][i]+a[y][i]>k)return 0; return 1; } inline bool check2(int x,int y){ A(i,1,n)if(a[i][x]+a[i][y]>k)return 0; ...
#include<bits/stdc++.h> #include<iostream> #include<map> #include<math.h> #include<string> #include<string.h> #include<vector> #include<queue> #include<algorithm> #include<set> #include<stack> #define _GLIBCXX_DEBUG #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() using namespace std; using ...
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n]; for (auto &i : a) i = ri(); int res = 2000000000; for (int i = 0; i < 1 << (n - 1); i++) { int xored = 0; int ored = 0; for (int j = 0; j <= n; j++) { if (j < n) ored |= a[j]; if (j == n ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n); i >= 0; i--) #define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++) #define all(v) v.begin(), v.end() typedef long long ll; template<class T> inline bool chmax(T& a, T b...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define all(x) (x).begin(), (x).end() #def...
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define mod 1000000007 #define maxn 100011 #define el "\n" #define pi acos(-1.0) using namespace std; #define lcm(a,b) (a/__gcd(a,b))*b #define ios ios_base::sync_with_stdio...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MOD = 1e9 + 7; ll modpow(ll a, ll b){ ll ans = 1; while (b > 0){ if (b % 2 == 1){ ans *= a; ans %= MOD; } a *= a; a %= MOD; b /= 2; } return ans; } ll modinv(ll a){ return modpow(a, MOD - 2); } vector<ll> mf = {1}; vector<l...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define pii pair<ll,ll> #define inf 1000000000000000000 #define bpc(x) __...
/* Code written by Talant I.D. */ #include <bits/stdc++.h> //~ #include <ext/pb_ds/assoc_container.hpp> //~ using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; //~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_s...
#include <bits/stdc++.h> using namespace std; using int64 = long long; #define endl '\n' #define INF 0x3f3f3f3f #define LINF 1LL<<62 #define MSET(a) memset(a, 0, sizeof(a)) #define FOR(i, a, b) for(int i = a; i < b; ++i) #define key first #define val second #define pb push_back template <typename T> bool ckmax(T &...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x)...
#include <bits/stdc++.h> #include <algorithm> using namespace std; int main(){ int a, b, c, d; cin >> a >> b >> c >> d; int ans; ans = min(a, b); ans = min(ans, c); ans = min(ans, d); cout << ans << endl; }
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front typedef long long ll; typedef unsigned long long ull; typedef short int si; typedef pair<int,int> pii; typedef pair<ll,ll> pll; co...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin>>s; if(s.find('.') != s.npos) { s=s.substr(0,s.find('.')); } cout<<s<<endl; }
#include <bits/stdc++.h> #define for0(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) #define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (int)(n); i >= 1; --i) #def...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long int #define pb push_back #de...
#include<bits/stdc++.h> #include <string> #include<vector> #include<bits/stdc++.h> #include<algorithm> using namespace std; int main() { int n; cin>>n; int a[n],i; for(i=0;i<n;i++) cin>>a[i]; set<int> s(a,a+n); if(s.size()==n) cout<<"Yes"; else cout<<"No"; return 0; }
// ConsoleApplication1.cpp : Defines the entry point for the console application. // #include <stack> #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cmath> #include <queue> #include <climits> #define MAXCHAR 255 #define ll long long using namespac...
//* Jai shree Ram #include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define lli long long int #define ll long long #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define vi ...
#include <vector> #include <stdio.h> using namespace std; #include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; #define pcnt __builtin_popcount//1ใƒ“ใƒƒใƒˆใŒใŸใฃใฆใ„ใ‚‹ๆ•ฐใ‚’ๆ•ฐใˆใ‚‹ int main() { int n; cin >> n; int a[n]; ll b[200] = {0}; rep(i,n) { cin >> a[i]; b[...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0; i<n; i++) int main() { int n; string s,t; cin >> n >> s >> t; vector<int> sz,tz; rep(i,n){ if(s[i] == '0') sz.push_back(i); if(t[i] == '0') tz.push_back(i); } int ans = 0; ...
#include <iostream> #include <string> #include <vector> int main() { int N; std::string S, T; std::cin >> N >> S >> T; int SS = 0, TT = 0; for (int i = N - 1; i >= 0; i--) { if (S[i] == '1') { SS++; } } for (int i = N - 1; i >= 0; i--) { if...
#include<iostream> #include<vector> using namespace std; using ll = long long; const int mod = 1e9+7; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this;...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ll long long int main(){ ll n; cin >> n; vector<ll> a(n); ll sigma = 0; ll p = 0; ll maxd = 0; ll ans = 0; for(ll i=0;i<n;i++){ cin >> a.at(i); sigma += a.at(i); maxd = max(maxd,sigma); ans = max(ans,p+m...
#include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #define all(s) begin(s), end(s) #define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sz(s) int(s.size()) #define ENDL '\n' #define vv(type, name, h, ...) vec...
//BISMILLAHIR RAHMANIR RAHIM #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define mem(a, b) (memset(a, b, sizeof(a))) #define pb push_back #define mk make_pair #define ff first #define ss second #define PI acos(-1) #define INF 2147483647 #define MOD 1000000007 #...
#include <bits/stdc++.h> using namespace std; int main() { string s; set<char> ele; cin >> s; for (auto i: s) { ele.insert(i); } if (ele.size() == 1) cout << "Won"; else cout << "Lost"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ string str; cin>>str; if(str[0]==str[1]&&str[1]==str[2]) cout<<"Won"; else cout<<"Lost"; return 0; }
/* * @Author: Luisvacson * @LastEditors: Luisvacson * @Descriptions: None * @Date: 2021-06-12 19:05:10 * @LastEditTime: 2021-06-12 19:38:21 * @FilePath: \C++\Public\ABC203D - Pond.cpp */ #include <bits/stdc++.h> using namespace std; int n, k, t; int a[805][805], b[805][805]; int sum[805][805]; inline bool chec...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mp make_pair #define fr first #define sc second template<class T> T T_INF(){ return 1000000000000000000; } template<> int T_INF<int>(){ return 1000000000; } template<int MOD> struct modint{ ull val; modint(...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constex...
#define as(array) (sizeof(array)/sizeof(array[0])) #define ll long long #define dd double #define mp make_pair #define pb push_back #define se second #define fi first #define mod 10000007 #define sob(v) v.begin(),v....
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int sum; sum = 21 - a - b - c; cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main () { int a, b, c, d; cin >> a >> b >> c >> d; cout << a*d - b*c << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll ans=0,n,k;cin>>n>>k; map<ll,ll>a; while(n--) { ll x,y;cin>>x>>y; a[x]+=y; } ll pre=0,j=0; for(auto i=a.begin();i!=a.end();i++) { if(k>=(i->first)-pre) { ...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define w(x) int x; cin>>x; while(x--) #define mii map<int,int> #define endl ("\n") #define vi vector<int> #define pqb p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=100005; ll a[N],n,m,k; int check(ll x) { int now=upper_bound(a+1,a+1+n,x)-a-1; return x-now>=k; } void solve() { cin>>k; ll l=1,r=2e18+10LL; while(r-l>1) { ll mid=(l+r)>>1; if(check(mid)) r=mid; else l=mid; } if(check(l)) prin...
#include <bits/stdc++.h> using namespace std; #define int ll #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i) #define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i) #define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL #define db(x) cerr << #x << "=" << x << "\n" #define db2(x, y) cerr << #x << "=" <...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, b) for(ll i = (a); i < (b); i++) #define REP(i, a) FOR(i, 0, a) ll T, X, Y, P, Q; ll extgcd(ll a, ll b, ll& x, ll &y){ ll d = a; if(b != 0){ d = extgcd(b, a % b, y, x); y -= (a / b) * x; }else{ x = 1; y = 0; } return d; }...
#include <bits/stdc++.h> #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define...
#include <iostream> #include <cstdio> #include <vector> #include <map> #include <algorithm> #include <cstring> #include <queue> #include <set> #include <cmath> //========================[define]======================= #define ll long long //#define File #define ull unsigned long long #define loop(i,a,b,k) for(registe...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1LL << 60; const ll MOD = 1e9 + 7; struct Edge { int to, cost; Edge(){}; Edge(int to, int cost): to(to), cost(cost){}; }; using Graph = vector<vector<Edge>>; using P = pair<ll, int>; int main() { cin.tie(0); cin.sync_...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll qpow(ll a,ll b) { ll ans=1; while(b>0) { if(b&1) { ans=ans*a; } a=a*a; b>>=1; } return ans; } int main() { ll n; scanf("%lld",&n); for(ll i = 1;i<=38;i++){ for(ll j = 1;j<=26;j++){ if(qpow(3,i) + qpow(5,j) == n && qpow(3,i)...
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define ll long long int #define sz(x) (int)(x.size()) #define FOR(i,x,y) for(int i=x;i<=y;++i) #define FORN(i,x,y) for(int i=x;i>=y;--i) #define debug(x )cout<<'['<<#x<<" is "<<x<<"]"<<endl; #define yes cout<<"YES"<<endl; #define no cout<<"NO"<<endl; #d...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return fa...
#include<bits/stdc++.h> using namespace std; using P=pair<int,int>; constexpr int mod=1000000007; constexpr int inf=1e9; int in(){ int x; scanf("%d",&x); return x; } int main(){ int n=in(); long long a[n],b[n]; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; long long amax=...
/* ใ€€ใ€€ใ€€ใ€€ใ€€๏ผ๏ผžใ€€ ใƒ• ใ€€ใ€€ใ€€ใ€€ใ€€| ใ€€_ใ€€ _| ใ€€ ใ€€ใ€€ใ€€๏ผ`ใƒŸ _x ๅฝก ใ€€ใ€€ ใ€€ /ใ€€ใ€€ใ€€ ใ€€ | ใ€€ใ€€ใ€€ /ใ€€ ใƒฝใ€€ใ€€ ? ใ€€๏ผ๏ฟฃ|ใ€€ใ€€ |ใ€€|ใ€€| ใ€€| (๏ฟฃใƒฝ๏ผฟ_ใƒฝ_)_) ใ€€๏ผผไบŒใค */ #pragma GCC optimize("Ofast","inline","-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,mmx") #include<bits/stdc++.h> #define int long long #define pb push_back #define pf push_front #define F first #define S s...
#include <bits/stdc++.h> #define int long long using namespace std; int n, x, a[100], b[100], c[100], dp[100][2][2]; signed main() { scanf("%lld%lld", &n, &x); for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]); for (int i = n, y = x; i >= 1; --i) b[i] += y/a[i], y %= a[i]; for (int i = 1; i < n; ++i) c[i] = a...
#include<bits/stdc++.h> using namespace std; int main() { int a[]={15,10,3,0}; int b[]={8,3,0,0}; int p,q; cin>>p>>q; p+=q; int i,j; for(i=0;i<4;i++) { if(p>=a[i]) break; } for(j=0;j<4;j++) { if(q>=b[j]) break; } int ps=max(i,j); cout<<ps+1<<"\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int A, B; cin >> A >> B; int C = A + B; if (C >= 15 && B >= 8) cout << 1 << endl; else if (C >= 10 && B >= 3) cout << 2 << endl; else if (C >= 3) cout << 3 << endl; else cout << 4 << endl; }
#include "bits/stdc++.h" using namespace std; int n,x,y,ans; string a; map <pair <int,int>,int> m; int main() { cin>>n>>a; m[{x,y}]++; for(auto c:a) { if(c=='A') x++; else if(c=='T') x--; else if(c=='C') y++; else y--; ans+=m[{x,y}]; m[{x,y}]++; } cout<<ans; }
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <utility> #include <queue> #include <map> #include <assert.h> #include <stack> #include <string> #include <stdlib.h> #include <stdio.h> #include <cstring> #include <cmath> #include<iomanip> #define int long long int usi...
/* after dusk passed, there is a starry sky. */ #include <bits/stdc++.h> #define inf 0x3f3f3f3f #define m_k make_pair using namespace std; int n,m; inline int read() { int f=1,x=0;char s=getchar(); while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();} while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();} return x*f; } signed...
#include <bits/stdc++.h> using namespace std; void setup() { #ifdef LOCAL freopen("input", "r", stdin); #else ios::sync_with_stdio(0); cin.tie(NULL); #endif } #define int long long vector<int> getTimes(vector<int> &a, int start, int end) { const int n = end - start; const int total =...
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; typedef long long LL; typedef pair<LL, LL> ii; LL N, L, R; bool isPrime[1000100]; LL leastFac[1000100]; LL numFac[1000100]; bool freeSquareFaq[1000100]; void main1() { cin >> L >> R; LL ans = 0; for (LL i = 0; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main () { int N; ll K; cin >> N >> K; ll pk = N; pk *= N; pk *= N; if (K == pk) { cout << N << ' ' << N << ' ' << N << endl; return 0; } ll dp[4][3000030]; ll sum[4][3000030]; dp[0][0] = 1; sum[0][0] = 1; for (int ...
#include<iostream> #include<math.h> using namespace std; int main(void){ int a[100]={}; int min=INFINITY; for(int i=0;i<4;i++){ cin >> a[i]; } for(int i=0;i<4;i++){ if(min>a[i]){ min=a[i]; } } cout << min; return 0; }
#include<bits/stdc++.h> using namespace std; #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/gcd(a,b) #define p pair<long long,long long> #define endl '\n' #define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); #define pi acos(-1) int fx[]={0,0,1,-1,1,1,-1,-1}; int fy[]={1,-1,0,0,-1,1,-1,1}; c...
#include <iostream> using namespace std; int main(void) { char S[12]; cin >> S; int number = 0; for (int i = 0; i < 12; i++) { if (S[i] == 'Z' && S[i + 1] == 'O' && S[i + 2] == 'N' && S[i + 3] == 'e') { number ++; } } cout << number << endl; return 0; }
// template for atcoder beginners // when you create a *.cpp file, this template is loaded #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string n_str(to_string(n)); int zero_count = 0; // ใŠๅฐปใŒ0ใฎๅ ดๅˆใใฎๆ•ฐๅˆ†ไป˜ใ‘่ถณใ™ใ€‚ if (n_str[n_str.size() - 1] == '0') { string n_str_temp(n_str); do { ...
// E - ๆฝœๅ…ฅ #include <bits/stdc++.h> using namespace std; #define vec vector using vi = vec<int>; using PR = pair<int,int>; #define rep(i,n) for(int i=0;i<(int)(n);++i) int V; // ้ ‚็‚นๆ•ฐ vec<vec<PR>> G; // [from]<to, cost> ้šฃๆŽฅใƒชใ‚นใƒˆ int INF = 1e9; vi dijkstra(int s){ vi dist(V, INF); dist[s] = 0; priority_queue<PR, vec<PR>,...
#include <bits/stdc++.h> #define ll long long int #define ld long double #define pb push_back #define MP make_pair #define mt make_tuple #define eb emplace_back #define ar array #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define mem(arr,x) memset(arr, x, sizeof arr) #define db(arr) for(auto ...
#include <bits/stdc++.h> #include <unordered_set> #include <vector> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; // using Graph = vector<vector<int>>; vector<bool> visited; vector<bool> good; vector<int> C; vector<int> G[100009]; void dfs(int v, vector<int> &color...
/* code of Ayush Tiwari codeforces- servermonk codechef- ayush572000 */ #include <bits/stdc++.h> #define ll long long //STL #define pb push_back #define lb lower_bound #define ub upper_bound #define mp make_pair #define all(v) v.begin(), v.end() //loops #define forn(i,a,b) for(int i=a; i<b; i++) #define rf...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define REPR(i, n) for(int i = n - 1; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i <= n; i++) #define FORR(i, m, n) for(int i = m; i >= n; i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #de...
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "unordered_map" #include "unordered_set" #include "iomanip" #include "cmath" #include "random" #include "bitset" #include "cstdio" ...
#include<bits/stdc++.h> using namespace std; namespace IO { const int buffer_size=1e5+5; char buf[buffer_size],*S,*T; bool flag_EOF; inline char read_char() { if(S==T) T=(S=buf)+fread(buf,1,buffer_size,stdin); return S!=T?*(S++):EOF; } inline int read_int() { int flag=1; char c=read_char(...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; long long int mod = 1e9+7; int main(){ int a,b; cin>>a>>b; cout<<2*a+100-b<<endl; return 0; }
#include<bits/stdc++.h> //Ithea Myse Valgulious namespace chtholly{ typedef long long ll; #define re0 register int #define rel register ll #define rec register char #define gc getchar //#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++) #define pc putchar #define p32 pc(' ') #define pl puts("...
//#pragma once #include <stdio.h> #include <stdlib.h> #include <string> #include <iostream> #include <queue> #include <algorithm> #include <sstream> #include <vector> #include <math.h> #include <set> #include <map> #include <unordered_map> #include <numeric> #include <bitset> #include <iomanip> #include <cctype> #inclu...
#include <bits/stdc++.h> using namespace std; int main() { int M; cin >> M >> M; vector<string> s(M); map<string, int> m; set<string> S; vector<vector<char>> a(20, vector<char>(20, 'A')); deque<tuple<int, int, string>> t; for (int i = 0; i < M; i++) { cin >> s.at(i); if (m.count(s.at(i))) { ...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<string.h> #include<random> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) do {} while (0)...
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<cmath> #include<queue> #include<map> #include<bitset> #include<deque> #include<cstdlib> #include<set> #include<ctime> #define ll long long #define mp make_pair #define mod 1000000007 using namespace std; ll read() { ll...
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 400010, mod = 1e9 + 7; set<LL> s; int n; int main(){ cin >> n; s.insert(0); for (int i = 0; i < n; i ++) { int x; cin >> x; s.insert(x); } LL ans = 1; for (auto it = next(s.begin(...
// // Created by yamunaku on 2021/03/07. // #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define rep(i, n) for(int i = 0; i < (n); i++) #define repl(i, l, r) for(int i = (l); i < (r); i++) #define per(i, n) for(int i = ((n)-1); i >= 0; i--) #define perl(i, l, r) f...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pp pop_back #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define f0(i,a,n) for(i=a;i<n;i++) #define f1(i,a,b) for(i=a;i<=b;i++) #define all(v) sort(v.begin(),v.end()); #define stp setprecision #define...