code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 2e5; vector<int> adj[MAXN]; int par[MAXN]; int nbSommets; int id[MAXN]; bool onPath[MAXN]; int cnt; int getFurthest(int source) { vector<int> dis(nbSommets, -1); dis[source] = 0; queue<int> q; q.push(source); while (!q.empt...
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define maxm 600005 #define maxn 200005 #define ls (tot << 1) #define rs (tot << 1 | 1) #define PII pair<int, int> typedef long long ll; typedef unsigned long long ull; using namespace std; const double pi = acos(-1); const ll mod = 1e9 + 7; const double eps = 1e-10; inl...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++) #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main(void) { ll N; ll K; cin >> N >> K; int append = 0; while (K-- > 0) { if (N % 200 == 0) { N /= 200; } else if (append) { N = (N/200.0) * 1000 + 1; ap...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vp = vector<P>; using vs = vector<string>; using vb = vector<bool>; usin...
#include<bits/stdc++.h> #define maxn 1000005 #define inf 9999999999999999 #define mod 1000000007 typedef long long LL; using namespace std; int main() { ios::sync_with_stdio(false); //freopen("bwxnQAQin.txt","r",stdin); LL x,y; cin>>x>>y; if(abs(x-y)<3)cout<<"Yes"; else cout<<"No"; return 0;...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) typedef long long ll; const ll INF = (1LL << 62) - (1LL << 31); /*オーバーフローしない程度に大きい数*/ // const ll MOD = 1000000007; using namespace std; struct UnionFind { vector<int> par, siz; ...
#include <bits/stdc++.h> using namespace std; template<typename T> struct fenwickTree { int n; vector<int> tree; fenwickTree(int n_ = 0) : n(n_) { tree.resize(n_ + 1, 0); } int lowbit(int x) { return x & (-x); } int size() { return n; } void add(int pos, int x) { // pos位置加上x for (; pos <...
#include <bits/stdc++.h> using namespace std; #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r)-1; i >= (int)(l); (i) -= 1) template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { a = (a > b ? a : b); } template <typename T1, typename T2> in...
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef unsigned long long ull; typedef unsigned uint; typedef long long ll; #define G getchar() int read() { int x=0; bool flg=false; char ch=G; for (;!isdigit(ch);ch=G) if (ch=='-') flg=true; for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48); return ...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; int a,b;ll k,c[66][66]; int main(){ cin>>a>>b>>k; rep(i,0,a+b){ c[i][0]=1; rep(j,1,i)c[i][j]=c[i-1][j-1]+c[i-1][j]; } int s=a+b; rep(i,1,s){ if(!a)putchar('b'),b--; else if(!b)putchar('a'),a--; els...
#include <iostream> using namespace std; int main() { int num1, num2, num3; int n = 2, m = 2; int matrix[n][m]; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> matrix[i][j]; } } num1 = matrix[0][0] * matrix[1][1]; num2 = matrix[0][1] * matrix[1][0]; num3 = num1 - num2;...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll B; cin >> B; ll C; cin >> C; ll ans = 0; if (C == 1) { if (B == 0) ans = 1; else ans = 2; cout << ans << '\n'; return 0; } if (B > 0) { bool zero = false; ...
#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 rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define rrep1(i, n) for (int i = n; i >= 1; i--) #define all(x) x.begi...
#include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> ans; for(int d = 1; d * d <= n; ++d) { if(n % d == 0 && d * d == n) { ans.emplace_back(d); //ans.emplace_back(n / d); } else if(n % ...
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; double rslt=n*1.08; rslt=(int)rslt; if(rslt<206)cout<<"Yay!"<<endl; else if(rslt==206)cout<<"so-so"<<endl; else { cout<<":("<<endl; } return 0; }
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define all(x) (x).begin(),(x).end() using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(N); vector<int> B(M); rep(i,0,N) cin >> A.at(i); rep(i,0,M) cin >> B.at(i); map<int, int> mp; ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int H, W; cin >> H >> W; vector<vector<char>> A(H, vector<char>(W)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> A[i][j]; } } vector<vector<vector<int>>> DP(H, vector<vector<int>>(W...
#include<bits/stdc++.h> using namespace std; long long n,tn,a[110][210],dp[210][210]; long long check(int x){ long long k = 0,tx=x; while(tx){ k++; tx/=10; } return x*pow(10,k); } int main(){ cin >> n; int m=0; tn = n; while(tn){ m++; tn/=10; } m/=2; for(int i=1;i<=pow(10,m+1);i++){ if(i+check(i)>n...
#include <iostream> #include <string> using namespace std; using ll = long long; int main(){ ll N; cin >> N; for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){ cout << i - 1 << endl; return 0; } }
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define X first #define Y second #define nl '\n' #define AC return 0 #define pb(a) push_back(a) #define mst(a,b) memset(a, b, sizeof a) #define rep(i,n) for(int i = 0; (i)<(n); i++) #define rep1(i,n) for(int i = 1; (i)<=(n); i++) #de...
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; vector<int> p(n), sz(n, 1); vector<map<int,int>> info(n); iota(p...
#include <bits/stdc++.h> #define INF 1e9 #define eps 1e-6 typedef long long ll; using namespace std; struct P{ ll a, b; }p[200010]; int n; ll now, las; bool cmp(P x, P y){ return x.a + 2 * x.b > y.a + 2 * y.b; } int main(){ cin >> n; for(int i = 1; i <= n; i++) cin >> p[i].b >> p[i].a; sort(p + 1, p + n + 1,...
#include <bits/stdc++.h> using namespace std; int main(){ int64_t n, takahashi=0, aoki=0, count=0; cin >> n; priority_queue<int64_t> q; for(int i=0; i<n; i++){ int64_t a, b; cin >> a >> b; aoki += a; q.push(2*a+b); } while(takahashi<=aoki){ takahashi += q.top();//-q.top().second; //a...
#include<cstdio> #include<algorithm> using namespace std; const int N=200010,P=998244353; int n; long long ans,a[N],clc; int main(){ scanf("%d",&n); for(int i=1;i<=n;++i)scanf("%lld",a+i); sort(a+1,a+n+1); for(int i=1;i<=n;++i){ ans=(ans+a[i]*(a[i]+clc))%P; clc=((clc<<1)+a[i])%P; } printf("%lld",ans); return...
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i,n) for(int i=0;i<(int)(n);i++) #define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++) #define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(i...
#include<bits/stdc++.h> #define print(x) cout << (#x) << ": " << (x) << endl #define p1d(x) cout << (#x) << ": ["; for(auto& zz: x) cout << zz << " "; cout << "]\n" #define p2d(x) cout << (#x) << ": \n["; for(auto& vec: x) {for(auto& v: vec) cout << v << " "; cout << ",\n";} #define p2s(x) cout << (#x) << ": ["; for(au...
//To debug : g++ -g file.cpp -o code //to flush output : fflush(stdout) or cout.flush() //cout<<setprecision(p)<<fixed<<var //use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll //take care of precedence rule of operators //do not forget to change the sizes of arrays and value of contants and other t...
#include <iostream> #include <sstream> #include <algorithm> #include <cmath> #include <functional> #include <vector> #include <set> #include <map> #include <queue> #include <stack> using namespace std; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; ...
#include "bits/stdc++.h" using namespace std; #define f first #define s second #define pb push_back #define ll long long #define ld long double #define lb lower_bound #define ub upper_bound #define m...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef std::vector<long long> vll; typedef std::vector<std::vector<long long>> vvll; typedef std::vector<bool> vb; typedef std::vector<std::vector<bool>> vvb; #define INF 1999999999 #define MODA 1000000007 #define rep(i,n) for (long long i = 0; i < (...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; #define rep(i, start, end) for (long long i = start; i < end; ++i) #define repreverse(i, start, end) for (long long i = start; i >= end; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define inrange(a, x...
#include<iostream> #include<vector> #include<deque> using namespace std; template<typename T>class Graph{ public: struct edge{int to;T cost;}; int Vertex_num,Edge_num; vector<edge>*g; const T INF=1000000000; Graph(int V){//0~V-1 Vertex_num=V; g=new vector<edge>[V]; } ...
#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <queue> #include <vector> using namespace std; typedef pair<int,int> pii; int h,w,dis[4000500],sx,sy,tx,ty,vis[4000500]; char sp[2005][2005]; priority_queue<pii > q; vector<int> gg[30]; int dx[4]={0,-1,0,1}; int dy[4]={1,0,-1,0}; ...
#include <bits/stdc++.h> #include <cmath> using namespace std; using ll = long long; int main () { ll n, a, p, x, min=1000000000; cin >> n; for (int i=0; i<n; i++){ cin >> a >> p >> x; int zai =0; if (x-a>0){ if(p<min){ min = p; ...
#include <bits/stdc++.h> using namespace std; #define int long long int int32_t main() { int i,j,n,a[10004],b,x; ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int d=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; int min1,max1=0; for(i=0;i<n;i++) { min1=a[i]; for(j=i;j<n;j++) { min1=min(a[j],min1); m...
#include <bits/stdc++.h> using namespace std; using lint = long long; template<int MOD> class ModInt { public: int v; ModInt() : v(0) {} ModInt(long long _v) { v = int((-MOD < _v && _v < MOD) ? (_v) : (_v % MOD)); if (v < 0) v += MOD; } friend bool operator==(const ModInt &a, const ModInt &b) { retu...
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; typedef long long ll; typedef pair<ll,ll> P; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define EFOR(i,a,b) for(int i=(a);i<=(b);++i) #define REP(i, n) FOR(i,0,n) #define IINF ll solve(string s){ vector<ll> c(10); //REP(i,10) card...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int T; long long int X, Y, P, Q; long long int INF = 8300000000000000008; long long int gcdExt(long long int a, long long int b, long long int &x, long long int &y) { if (b == 0) { x = 1; y = 0; return a; } lo...
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for(int i = (a); i <= (b); i++) #define PER(i, a, b) for(int i = (a); i >= (b); i--) #define rep(i, a, b) for(int i = (a); i < (b); i++) #define all(S) (S).begin(), (S).end() #define pb push_back #define mk make_pair #define S second #define F first t...
/* BY: shalekberli (Shahin Alekberli) LANG: C++ */ #include <bits/stdc++.h> //MACROS// #define PVP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define _crt_secure_no_warnings #define endl '\n' #define pb push_back #define mp make_pair #define gf greater<int>() #define INF 0x3F3F3F3F #define sz(x) (int)x.size(...
#include <iostream> using namespace std; int main(){ int a,b;float x=0; cin>>a>>b; x=float(a*b)/100.0; cout<<x; return 0; }
//~ author : Sumit Prajapati #include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long #define int long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb ...
#include <bits/stdc++.h> using namespace std; const int maxn=1e6+13; typedef long long ll; int p[maxn+13]; ll mu[maxn+13]; int tag[maxn+13]; void pre_mu(){ mu[1]=1; int cnt=0; for(int i=2;i<=maxn;i++) { if(!tag[i]) mu[i]=-1,p[++cnt]=i; for(int j=1;j<=cnt&&i*p[j]<=maxn;j++) { tag[i*p[j]]=1; if(i%p[j]==0)...
#include<bits/stdc++.h> #define all(x) x.begin(),x.end() #define INF 0x3f3f3f3f using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> iipair; typedef pair<unsigned,unsigned> uupair; typedef vector<int> vec; typedef vector<unsigned> uvec; int main() { ...
#include <bits/stdc++.h> #define ll long long #define For(i,a,b) for(int i=a; i<=b; i++) using namespace std; long double n, m; long long k; const int MaxN = 1e5 + 4; long double a[MaxN]; long long b[MaxN]; pair<long double, int> c[MaxN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t = 0, n, k, m; cin...
#include <vector> #include <iostream> using namespace std; #define debug puts("pigtoria bling bling ⚡️⚡️"); // https://atcoder.jp/contests/abc195/editorial/897 // tips: and | or , in reverse order. int main() { int N; string S, X, T; cin >> N >> S >> X; bool win; vector <vector<bool>> dp(N + 1, ve...
// problem: #include <bits/stdc++.h> using namespace std; #define pb push_back #define mk make_pair #define lob lower_bound #define upb upper_bound #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int>...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n , w ,i; cin>> n >> w ; int coun=w; for ( i =0 ; coun<=n ; i++) { coun +=w; } cout <<i; }
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N = (ll)(1e5)+10, mod = (ll)(1e9+7); const ll INF=1e17; ll dp[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int a,b; cin >> a >> b; if(a==b)cout << a; else{ if(a==0 && b==1)cout << 2; else if(a==0 && b==2)cout << 1...
#include "bits/stdc++.h" #define int long long using namespace std; using i128 = __int128_t; random_device rd; mt19937 gen(rd()); #define random_shuffle(begin, end) shuffle(begin, end, gen) template <typename T, typename U> ostream& operator << (ostream& out, const pair <T, U> &p) { out << p.first << ": " << p...
#include <bits/stdc++.h> const long long SZ = 1e5 + 7; const long long inf = 1e18; const long long MOD = 1e9 + 7; const long long mod = 1e9 + 7; long long opnmbr = 1; #define ll long long #define ld long double #define pb push_back #define mp make_p...
#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 int #define M 1000000007 #define mod 998244353 #define mp(x,y) make_pair(x,y) #define pb(x) push_back(x) #define pi pair<ll,ll> #define endl "\n" using namespace std; const ll N=200010; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <complex> #include <queue> #include <set> #include <unordered_set> #include <list> #include <chrono> #include <random> #include <iostream> #inc...
#include <iostream> using namespace std; int main() { int x,y,z; cin>>x>>z; for(int i=0;i<x;i++) { cin>>y; if(y==z) continue; else cout<<y<<" "; } return 0; }
#define DEB #include <map> #include <set> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstring> #define REP(i,m) for(int i=0;i<(m);++i) #define REPN(i,m,in) for(int i=(in);i<(m);++i) #define ALL(t) (t).begin(),(t).end() #define CLR(a) memset((a),0,sizeof(a)) #define pb push_ba...
#include<iostream> #include<algorithm> #include<string> using namespace std; int main(){ int H,W,ans=0; string S[102]; bool a[102][102]={0}; cin>>H>>W; for(int i=0;i<H;i++){ cin>>S[i]; for(int j=0;j<W;j++){ if(S[i][j]=='.')a[i+1][j+1]=true; } } for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ ans+=a[i...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define N 10100 #define MOD 998244353 #define ll long long #define rep(i, n) for(int i = 0; i < n; ++i) #define rep2(i, a, b) for(int i = a; i <= b; ++i) #define rep3(i, a, b) for(int i = a; i >= b; --i) #define eb emplace_back #define pb push_ba...
#include <cstdio> #include <cstring> const int maxn=100+10; const int Mod=998244353; int w[maxn]; int dp[2][maxn][maxn*maxn*2]; int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&w[i]); int ze=100*100+100; int now=0; dp[now^1][0][ze]=1; for(int i=1;i<=n;i++,now^=1){ memset(dp[now],0,sizeof(...
/* start of cp 3.0BETA NEW-BETA-LADDER https://codeforces.com/problemset/page/1?tags=1800-1800 DEAD PERSON CODING */ #include <iostream> #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define MOD 1000000007 #define int long long int #define pii...
#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; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<ll> a(n); for (auto &it: a) cin >> it; vector<ll> pre(n+1); ll pre_mx = 0, an = 0, pos = 0; for (int i = 0; i < n; ++i) { pre[i+...
#include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using vb=vector<bool>; using vvb=vector<vb>; using vd=vector<double>; using vvd=vector<vd>; using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; using pll=pair<ll,ll>; using tll=tuple<ll,ll>...
// --------------------------------------------------<C++ TEMPLATE>------------------------------------------------ /** * Nitin Gangwar * @wargang (codechef,codeforces,spoj,gfg) * MNNIT allahabad * CSE'23 * iamnitingangwar2000@gmail.com **/ #include <bits//stdc++.h> #include <ext/pb_ds/assoc_c...
#include <bits/stdc++.h> using namespace std; #define ll long long #define sz(a) int(a.size()) template <typename A, typename B> ostream& operator <<(ostream& out, const pair<A, B>& a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream& operator <<(ostream& out, con...
#include <cstdlib> #include<iostream> #include<unordered_set> #include<vector> #include<cstring> #include<string> #include<bitset> #include<algorithm> #include<cmath> #include<numeric> #include<iomanip> using namespace std; using ll = int64_t; int main(){ int n; cin >> n; vector<int> A(n+2); ll ans = 1...
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(void) { ll N; cin >> N; ll num = 1; ll count = 1; ll precount = 1; for (ll i = 1; i <= N; i++) { if (precount > num) { precount = 1; count ++; num = num * 2; ...
#define wiwihorz #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a,...
#include <bits/stdc++.h> using namespace std; using ll = long long; // 組合せを素数で割った値 const int MAX = 510000; const ll MOD = 1e9 + 7; ll fac[MAX], finv[MAX], inv[MAX]; // 前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MO...
#include<bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; int main(){ int n; cin >> n; vector<pair<int, string>> t(n); rep(i,n) cin >> t[i].second >> t[i].first; sort(t.rbegin(), t.rend()); cout << t[1].second << endl; return 0; }
#include <iostream> #include <cmath> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #inc...
#include <iostream> #include <unordered_set> #include <vector> int main() { std::vector<std::vector<bool>> field(10000, std::vector<bool>(10000)); int n; std::cin >> n; struct ad_rect { int x, y, r, x1, y1, x2, y2; }; std::vector<ad_rect> ads(n); for (int i {0}; i < n; ++i) { ...
#include<bits/stdc++.h> using namespace std; long long a,b; #define yes puts("Yes") #define no puts("No") int main (){ cin >> a>>b; if(b + 1 == a) { yes; return 0; } for(long long i = 1;i * i <= b;i++){ if(b % i == 0){ long long x = b/i; if(x + i == a) { yes; return 0; } } } no; retu...
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr ll mod=1e9+7; int main() { cin.tie(0); ios_base::sync_with_stdio(false); ll s,p; cin>>s>>p; for (ll x = 0; x*x <= p; ++x) { if (p == x*(s-x)) { cout << "Yes" << endl; return 0; } } cout << "No" <<endl; }
#include<bits/stdc++.h> #define PI 3.141592653589793238462 #define eps 1e-10 using namespace std; typedef long long ll; typedef long double db; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<db,db> pdd; int main(){ int a,b,c,d;cin>>a>>b>>c>>d; cout<<min(min(a,b),min(c,d))<<endl; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) using vi = vector<int64_t>; using vvi = vector<vi>; using ll = int64_t; using P = pair<ll,ll>; ll INF = 1000000007; // ll INF = 9223372036854775807; // ll INF = 998244353; int main() { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5; const double eps = 1e-6; int send[maxn]; double k[maxn], b[maxn], sumk = 0.0, sumb = 0.0; int main() { int N, M, K; scanf("%d %d %d", &N, &M, &K); int x; for (int i = 0; i < K; i++) { scanf("%d", &x); send[x] = 1; } ...
#include <bits/stdc++.h> #define rep(i,l,r) for (int i=(l);i<=(r);++i) #define per(i,r,l) for (int i=(r);i>=(l);--i) #define mp make_pair #define fi first #define se second #define ll long long using namespace std; int fpw(int x,int y,int p){ int s=1; for (;y;y>>=1,x=(ll)x*x%p) if (y&1) s=(ll)s*x%p; return s; } int m...
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include <cstdlib> #include <unordered_map> #include <queue> #include <vector> #include <algorithm> #include <cmath> using namespace std; int a[300010]; int c[300010]; int n; int lowbit(int x) { return x & -x; } void add(int x) { while (...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define endl "\n" #define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " const ll mod = 1e9 + 7; // const ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll nCk(ll a, ll b) { ll ret = 1; if (a < 0 || a < b) return 0; for (int i = 1; i <= b; i++) { ret = ret * (a + 1 - i) / i; } return ret; } int dp(int A, int B, long long K, string &res) { if (A == 0 && B ==...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=(0);(i)<(int)(n);++(i)) using ll = long long; using P = pair<int, int>; using namespace std; #define INF ((1<<30)-1) #define LLINF (1LL<<60) #define EPS (1e-10) int main() { int N, M; cin >> N >> M; vector<int> A(M), B(M); rep(...
//2*10^9 //9*10^18 // __int128_t #include<bits/stdc++.h> using namespace std; #define ull unsigned long long int #define ll long long int const ll M=1e9+7; //to handle when remainder is -neg we add + M //but when rem is +pos that time also we add so use %M //so it will work for both ll mod(ll n){ return (n%M + M)%...
/* Coming Soon */ #define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <cmath> #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_equal<int>, rb_tree_tag,tree_order_stati...
#include "bits/stdc++.h" using namespace std; using ll = long long; #define all(x) (x).begin(),(x).end() ll power(ll x , ll n,ll mod){ if(n == 0) return 1ll; ll cur = power(x, n >> 1,mod); if(n & 1) return (cur % mod * cur % mod * x) % mod ; return (cur % mod * cur % mod) % mod ; } const int maxx = 200...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long long, long long> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define agewari(a, b) ((ll)a + ((ll)b - 1)) / b const int MOD = 1000000007; const long long INF = 1LL << 60; int main() { ll n; cin>>n; vector<ll> A(n...
//Let's join Kaede Takagaki Fan Club !! #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <ctime> #include <cassert> #include <string> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <fun...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define ud unsigned int #define ll long long #define ull unsigned long long #define MAX_INF 0x3f #define MAX_INF_VAL 0x3f3f3f3f #define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f //#define pi 3.141592653589 #define eps 1e-9 #define F(x) ((x)/3+((x)%3==1?0:tb)) #define G(x) ...
#include <bits/stdc++.h> #include<string.h> #include<math.h> using namespace std; typedef long long int ll; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); ll x,y,a,b; cin>>x>>y>>a>>b; ll cnt=0; while(x<=(b-1)/a && x*a<y) { x*=a; cnt++; } cnt+=(y-x-1)/b; cout<<cn...
#include <bits/stdc++.h> using namespace std; int main() { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; int r = r1 - r2, c = c1 - c2; int ans = 3; if(!r && !c) ans = 0; else if(r == c || r == -c || abs(r) + abs(c) <= 3) ans = 1; else if((r ^ c ^ 1) & 1 || abs(r) + abs(c) <= 6 || abs(r +...
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp" #define _CRT_SECURE_NO_WARNINGS #pragma target("avx2") #pragma optimize("O3") #pragma optimize("unroll-loops") #include <string.h> #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath...
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //~ while (clock(...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<ll,ll,ll> using Graph = vector<vector<int>>; ll mod = 1000000007; int main() { ll N; cin >> N; vector<char> col = {'R','G','B'}; vector<vector<ll>> cute(...
/*...................................................................* *............___..................___.....____...______......___....* *.../|....../...\........./|...../...\...|.............|..../...\...* *../.|...../.....\......./.|....|.....|..|.............|.../........* *....|....|.......|...../..|....|.....
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i) #define per(i,a,b) for(int (i)=(b);(i)>=(a);--i) typedef long long ll; template<typename T> void read(T&x){ x=0; ll f=1; char ch=getchar(); while(!isdigit(ch)){ if(ch=='-')f*=-1; ch=getchar(); ...
// khodaya khodet komak kon # include <bits/stdc++.h> /* // ordered_set # include <ext/pb_ds/assoc_container.hpp> # include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; # define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ using namespace std; typedef l...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,x,n) for(int i=x; i<(n); i++) #define all(n) begin(n),end(n) using ll=long long; using P=pair<int,int>; int main(){ int n, m, t; cin >> n >> m >> t; vector<int> a(m+1), b(m+1); for(int i=1;i<m+1; i++)...
// Problem: B - Smartphone Addiction // Contest: AtCoder - AtCoder Beginner Contest 185 // URL: https://atcoder.jp/contests/abc185/tasks/abc185_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Problem: A - ABC Preparation // Contest: AtCoder - AtCode...
//a+b = (a^b) + 2*(a&b) //b^c = (a^b)^(a^c) //gcd(x,y) = gcd(x-y,y) //if n = 5000 then complexity cannot be (n^2*log(n)) means no map ,no sets //check for long long overflow if input is large #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long long //#define mod 1000000007 #define mod 998...
#include<bits/stdc++.h> using namespace std; bool check1(int n,vector<int>a) { int pow; for(int i=0;i<a.size();i++) { pow=1; int flag=0; for(int j=0;j<4;j++) { if((n/pow)%10==a[i]) flag=1; pow*=10; } if(flag==0) retu...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int A, B, C; cin >> A >> B >> C; cout << A + B + C - min({A, B, C}); }
// A - Keyboard #include <bits/stdc++.h> using namespace std; int main(){ string s, t; cin>>s>>t; cout<< (char)(s=="Y"? t[0]-'a'+'A': t[0]) <<endl; }
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; int main() { int N; cin>>N; vi A(N), B(N), C(N); for (int i = 0; i < N; i++)cin>>A[i]; for (int i = 0; i < N; i++)cin>>B[i]; for (int i = 0; i < N; i++)cin>>C[i]; map<int,int> d,e; f...
#include <iostream> #include <algorithm> #include <set> #include <vector> using namespace std; int main(){ int n; cin >> n; string s; set<string> no_excl; // '!'なし vector<string> excl; // '!'あり string result("satisfiable"); for(int i=0;i<n;++i){ cin >> s; if(s.substr(0,1)=...
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef pair<int,int>pint; typedef long double ld; using vll=vector<ll>; using vs=vector<string>; #define b2e(v)v.begin(),v.end() #define p2a(v, p) v[p.first][p.second] char s[(int)4e5+5],buf[(int)4e5+5];...
#include <bits/stdc++.h> #define ll long long #define float double #define sz 100005 #define all(a) a.begin(), a.end() #define mod 1000000007 using namespace std; #define vi vector<int> #define vvi vector<vector<int>> #define debug cout << "here" << endl; #define f(i, n) for (int i = 0; i < n; ++i) #define pb push_back...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define fi first #define se second #define ll long long #define tp top() #define fr front() #define vi vect...
#include<bits/stdc++.h> using namespace std; const int N = 3100; const int P = 998244353; #define fr(i,a,b) for(int i = a;i <= b; ++i) #define nfr(i,a,b) for(int i = a;i >= b; --i) int n,k; int f[N][N]; int vis[N][N]; inline void add(int &x,int y){ x += y; if(x >= P)x -= P; } int sum[N*2]; inline void insert(int ...
#include <iostream> using namespace std; long long int calc(int H, int W, int A, int B, int index, int countA, int countB, int tatami, long long int ans) { if(index == (H*W)) { return ++ans; } if (((tatami >> index) & 1) == 1) { return calc(H, W, A, B, index + 1, countA, countB, tatami, ans); } int w = in...
// Created by ash_98 #include<bits/stdc++.h> using namespace std; #define mx 200005 #define ll long long #define mod 1000000007 int ar[mx]; char ch[mx]; int n,m,ii,k; ll dp[(1<<16)+5][9][18]; int vis[(1<<16)+5][9][18]; int Set(int N,int pos) { return N=N|(1<<pos); } int Reset(int N,int pos) { return N=...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) using P = pair<int,int>; using ll = long long; ll n,k; int main() { cin >> n >> k; rep(i,k){ if(n%200==0){ n /= 200; } else{ n *= 1000; n += 200; } ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define For(i,a,b,c) for(ll i=a;i<b;i+=c) #define For2(i,a,b,c) for(ll i=a;i>=b;i-=c) #define vec_ll vector<vector<ll>> #define vec_pr vector<pair<ll,ll>> #define p_ll pair<ll,ll> #define pbk push_back #define mkpr make_pair #define fst first #define snd...
#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 = long long; using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int SINF = 1LL << 30; const ll mod = 1000000000+7; const int...
#include<iostream> #include<stdio.h> #include<string.h> #include<cmath> #include <bits/stdc++.h> using namespace std; int main(){ long long K; cin >> K; long long a1 = 0, a2 = 0, a3 = 0; for(long long i = 1; i <= pow(K, (double)1/3); i++){ for(long long j = i; j <= pow(K, (double)1/2); j++){ if(i < j...
#include <bits/stdc++.h> #include <math.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using P = pair<int,int>; using PQ = priority_queue<int,vector<int>,greater<int>>; ll perm(int n, int r) { ll t=1; rep(j,r) { t*=n; n--; } return t; } ll perm(int...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto e : v) os << e << ' '; return os; } template <typename T> ostream &operator<<(ostream &os, co...
#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 req(i,n) for(int i = 1;i <=n;i++) #define pai 3.14159265358979323846 const int INF = 1001001001; typedef long long ll; int A[3][3], N; bool punched[3][3]; //using Graph = vector<vector<int>>; ...
#include<iostream> using namespace std; int main() { int t; cin >> t; int i=0, a[t-1]; while(cin>>a[i]){ i++; } int get = 0; for(int j = 0; j < t;j++ ){ if(a[j] > 10){...
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <numeric> #include <functional> #include <bitset> using namespace std; typedef lon...
//wtrl,everybody hangbeat me #include<bits/stdc++.h> /*#include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstre...
#include <bits/stdc++.h> #define w(x) int x; cin >> x; while(x--) #define endl '\n' #define mod 1000000007 #define ll long long #define YES cout << "YES\n" #define NO cout << "NO\n" #define Yes cout << "Yes\n" #define No cout << "No\n" using namespace std; ll pow(ll x, ll y, ll p) { ll res = 1; x = x % p; ...
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using vpl = vector<pair<ll, ll>>; using pll = pair<ll, ll>; #define rep(i, k, n) for(ll i = k; i < n; i++) #define pb push_back #define mp make_pair int main(){ string s; cin ...
#include <bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ #define pii pair<int,int> #define fi first #define pb push_back #define si second #define int long long #define mod 1000000007 //998244353 #define fast ios_base::sync_with_stdio(...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using ll = int64_t; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vector<int>>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll =...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int64_t[2]>koma(n); for(auto &i:koma)cin>>i[0]>>i[1]; int m; cin>>m; // x=opx[0]*x+opx[1]*y+opx[2],y=opy[0]*x+opy[1]*y+opy[2] vector<int64_t[3]>opx(m+1),opy(m+1); opx[0][0]=1,opx[0][1]=0,opx[0][2]=0; opy[0][0]=0,opy[0][1...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define rep(i, n) for (int i = 0; (i) < (int)(n); i++) #define rep3(i, m, n) for (int i = (m); (i) < (int)(n); i++) #define all(x) begin(x), end(x) template<class ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); (i)++) #define per(i, n) for (ll i = n - 1; i >= 0; (i)--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define ROF(i, a, b) for (ll i = (b) - 1; i >= (a); i--) #define ALL(x) std::begin(x), std...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 7; struct node { ll u, d; bool operator < (const node x) const { return d > x.d; } }; struct edge{ ll to, w, k; }; vector<edge> g[N]; int vis[N]; priority_queue<node>q; ll dj(int s, int t) { q.push({s,...
#include <bits/stdc++.h> using namespace std; int main(){ int V, T, S, D; cin >> V >> T >> S >> D ; if (V*T <= D && D <= V*S)cout << "No" << endl; else cout << "Yes" << endl; }
#include<bits/stdc++.h> using namespace std; const int N=1e3+15; typedef long long ll; string s; int main() { ll a,b,c,d; cin>>a>>b>>c>>d; if(a==c&&b==d) { cout<<"0"<<endl; return 0; } if(a+b==c+d) { cout<<"1"<<endl; return 0; } if(a-b==c-d) { ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define f first #define s second #define all(vec) begin(vec), end(vec) #define pf push_front #define pb push_back #define lb lower_bound #define ub upper_bound #define mk make_pair using namespace std; using namespace __gnu_pbds; typedef long long ll; ty...
#include <bits/stdc++.h> using namespace std; #define int long long template <typename T> void print_vec(const vector<T>& v, bool newline = true) { for (int i = 0; i < v.size(); ++i) { cout << v[i] << " "; } if (newline) { cout << "\n"; } } mt19937 rng((uint32_t)chrono::steady...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double db; #define all(x) x.begin(),x.end() const int N=1e6; ll dp[3][N+N+N+10]; int main(){ int n;cin>>n; ll k;cin>>k; for(int i=1;i<=n;i++)dp[0][i]=1; for(int i=1;i<=n+n;i++)dp[0][i]+=dp[0][i-1]; for(int i=1;i<=n+n;i++){ dp[1][i]=...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long l...
#include <bits/stdc++.h> using namespace std; #define ll long long //clt + alt + b = run code int main() { int n, m; cin >> n >> m; ll a = 0, b = 0; for(int i = 0; i < n; i++) { string s; cin >> s; int cnt = 0; for(int j = 0; j < m; j++) { if(s[j] == '1') cn...
#include <bits/stdc++.h> using namespace std; vector<bool> city(2000,false); void search(int x,vector<vector<int>> &z){ if(city.at(x) == true){ return; } city.at(x) = true; for(int i : z.at(x)) search(i,z); } int main(){ int n,m,a,b,ans=0; cin >> n >> m; vector<vector<int>> road(n); for(int i=0;i<n;i++) road.at(i)....
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >>n; int a[n+1]; for (int i = 0; i < n; i++) cin >>a[i]; int buckets[1001] = {0}; for (int i = 0; i < n; i++) { for (int k = 2; k <= 1000; k++)...
#include<bits/stdc++.h> using namespace std; int n; vector<int> ans; const int MAX=5e2+7; int s[MAX],p[MAX]; void opt (int pos) { swap(p[s[pos]],p[s[pos+1]]); swap(s[pos],s[pos+1]); ans.push_back(pos); return; } void solve (int p1,int p2,int p3) { while (!(s[p1]<s[p2]&&s[p2]<s[p3])) { if (ans.size()%2==p1%2...
#include <bits/stdc++.h> using namespace std; #ifdef __local_leywar #include <debug/debugger.h> #endif #define int long long #define endl '\n' const int INF = 2e9, MOD = 998244353, INFLL = 1e18; using pii = pair<int, int>; mt19937_64 rng(time(0)); int qpow (int base, int exp) { if(exp == 0...
#include <math.h> #include <assert.h> #include <algorithm> #include <set> #include <iostream> #include <vector> #include <iomanip> #include <queue> #include <map> #include <string> #include <cstring> #include <functional> #include <stack> #include <array> #include <random> #include <chrono> #include <climits> #include ...
#include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() #define int long long const int N = 3005; int a[N]; int pre[N][N] = {{0}}; int sum[N][N] = {0}; int cur[N]; const int M = 1e9 + 7; void add (int &a, int b) { a += b; if (a >= M) a -= M; } int32_t main() { cin.tie(0)...
// #pragma GCC optimize("O2") #include <bits/stdc++.h> // #include "D:/program_learning/vs_code/workplace/ACMtemplate/data_structure/CompleteBinaryHeap.hpp" // #include "D:/program_learning/vs_code/workplace/ACMtemplate/math/Prime.hpp" using namespace std; #define mp make_pair #define phb push_back #define ppb pop_bac...
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <iomanip> #include <algorithm> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <array> //#include <atcoder/all> using namespace std; //using namespace at...
#include<bits/stdc++.h> using namespace std; const int Max = 200001; int main(){ int n; cin >> n; vector<int> vec(n); for(int& nvec:vec) cin >> nvec; vector<vector<int>> from(Max); for(int i=0;i<n/2;i++){ from[vec[i]].emplace_back(vec[n-1-i]); from[vec[n-1-i]].emplace_back(vec[i]); } ...
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") #include<bits/stdc++.h> //#include<bits/extc++.h> //using namespace __gnu_pbds; using namespace std; #define F first #define S second typedef long long ll; #define REP(i,n) for(register int i=0;i<(n);++i) #define REP1(i,a,b) for(register int i=(a...
/** * In The Name Of God * author : Behradm * Idvwhu wkdq idvw, Txlfnhu wkdq txlfn, L dp Oljkwqlqj, Vshhg, L dp Vshhg. **/ #include "bits/stdc++.h" using namespace std; const int N = 1e5 + 11; int c[N]; bool mk[N]; int col[N]; vector<vector<int>> g; vector<int> out; void dfs(int u) { if (col[c[u]] == 0) ...
#include<bits/stdc++.h> using namespace std; using ll = int64_t; int main(){ ll N; cin >> N; unordered_set<ll> s; for(ll a = 2; a * a <= N; a++){ ll x = a * a; while(x <= N){ s.insert(x); x *= a; } } cout << N - s.size() << endl; }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double typedef unsigned long long ull; #define loop(i,a,b) for(ll i=a;i<b;i++) #define f(i,a,b) for(ll i=a;i<=b;i++) // #define testcases ll t;cin>>t;while(t--) #define dec(x) greater<x>() /*** Define fues ***/ #define mx 200005 #define ...
#include<bits/stdc++.h> using namespace std; #define rep(i,l,r) for(i=(l);i<=(r);++i) #define per(i,l,r) for(i=(l);i>=(r);--i) #define REP(i,l,r) for(i=(l);i< (r);++i) #define PER(i,l,r) for(i=(l);i> (r);--i) typedef long long ll; /* #define REPE(i,a) for(i=(a). begin();i!=(a). end();++i) #define PERE(i,a) for(i=(a).rb...
///====================== TEMPLATE STARTS HERE =====================/// #include <bits/stdc++.h> using namespace std; #define endl "\n" #define pb push_back #define MP make_pair #define ff first #define ss second #define ABS(x) ((x)<0?-(x):(x)) #define FABS(x) ((x)+eps<0?-(x):(x)) #define LCM(x,y) (((x)/gcd((x),(y)))*...
/* ....................../´¯/) ....................,/¯../ .................../..../ ............./´¯/'...'/´¯¯`·¸ ........../'/.../..../......./¨¯\ ........('(...´...´.... ¯~/'...') .........\.................'...../ ..........''...\.......... _.·´ ............\..............( ..............\.............\... */ #in...
#include <algorithm> #include <iostream> #include <list> #include <numeric> #include <random> #include <vector> #include <map> #include <set> #include <iterator> #include <ostream> #include <sstream> #include <iomanip> #include <stdio.h> #include <queue> #include <cstdio> using namespace std; #define rep(i, n) for(in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for(int (i)=0; (i)<(n); (i)++) #define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++) #define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--) template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y)...
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <cmath> #include <set> #include <map> #define ll long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<int, int> using namespace std; int main(){ ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; ll ans = 1...
#define _GIBCXX_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() using namespace std; using ll = long long; int main(void) { string S; cin >> S; int ans = 0; rep(i, 10) rep(j, 10) rep(k, 10) rep(l, 10) { vect...
#pragma GCC optimize(2) #include<bits/stdc++.h> #define ll long long #define maxn 1000005 #define inf 1e9 #define pb push_back #define rep(i,a,b) for(int i=a;i<=b;i++) #define per(i,a,b) for(int i=a;i>=b;i--) using namespace std; inline int read() { int x=0,w=1; char c=getchar(); while(c<'0'||c>'9') {if(c=='-') w=-1...
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #define int long long #define loop(x) for (int i = 0; i < (int)(x); i++) #define loop2(x) for (int j = 0; j < (int)(x); j++) #define endl '\n' using namespace std; // vector<int> sieve; // void sieveoferathostene() // { // int x = 1000; /...
#include <iostream> #include <bits/stdc++.h> #include<string> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long i,j,l,q,t,m,n,h,p; long long k,z,p1,h1,x,y; string st="",st1=""; t = 1; while(t--) { std::cin >> n >> q;...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> p32; typedef pair<ll,ll> p64; typedef pair<double,double> p...
#include<bits/stdc++.h> #define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define Freed freopen ("0in.txt","r",stdin); #define Fout freopen ("0out.txt","w",stdout); #define ll long long int #define pb push_back #define mp make_pair #define pi acos(-1.0) #define Mod 1000000007 #define limit 1000008 using name...
#include<bits/stdc++.h> using namespace std; const int N=5005,mod=998244353; int n,m,l=1,dp[N][N],c[N][N]; int main() { scanf("%d%d",&n,&m); for(int i=0;i<=n;i++) { c[i][0]=1; for(int j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; } while((1<<l)<m) l++; dp[l+1][0]=1; for(int i=l+1;i;i--) { for(in...
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#def...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int h, w; cin >> h >> w; vector<vector<char>> s(h, vector<char>(w)); for(auto& sr : s){ for(auto& si : sr){ cin >> si; } } int ans = 0; for (int i = 0; i<h-1; i++){ for (int ...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) #define ll long long using namespace std; int main(){ ll n, aa = 0, bb = 0, ai = -1, bi = -1, bbb = 0; cin >> n; vector<ll> a(n), b(n); vector<ll> ans(n), am(n), bm(n); rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i]; rep(i, n){ if (b...
#include <bits/stdc++.h> using namespace std; int main() { int w, x, y, z; cin >> w >> x >> y >> z; cout << min(min(w, x), min(y, z)) << endl; return 0; }
#include<bits/stdc++.h> #define rep(i, N) for(i = 0; i < N; i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define printYN(ans) ans ? cout << "Yes\n" : cout << "No\n" #define printyn(ans) ans ? cout << "yes\n" : cout << "no\n" #define clnt(a, b) ((a + b - 1) / b) #define same(f1, f2) (abs(...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(){ int n; cin >> n; vector<pair<int,int>> A, B; for(int i = 0; i < n; ++i){ int x, y; cin >> x >> y; x *= n, y *= n; A.emplace_back(x,y); } for(int i = 0; i < n; ++i){ int x, y; cin >> x >> y; ...
#include <algorithm> #include <iostream> #include <vector> #include <map> #include <cstdio> #include <string> #include <cmath> #include <queue> #include <tuple> #include <bitset> #include <cassert> #include <chrono> #include <cstring> #include <iomanip> #include <iostream> #include <random> #include <set> #include <sta...
#include <bits/stdc++.h> using namespace std; double ans; int main() { int n; cin >> n; for (int i = 1; i < n; ++i) { ans += (double)n / (n - i); } printf("%.6lf", ans); return 0; }
/****************************************** By Lord Sanskar Bhargava******************************/ #include<bits/stdc++.h> #include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #includ...
#include <iostream> #include <iomanip> #include <cmath> #include <cstdlib> #include <vector> #include <string> #include <algorithm> #include <bitset> #include <queue> #include <set> #include <map> using namespace std; #define ll long long #define MOD 1000000007 #define rep(i, n) for( ll int i = 0; i < (n); i++ ) i...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) using P = pair<long long,long long>; using ll = long long; const double PI=3.14159265358979323846; double n; double x_0,y_0,x_2,y_2; int main(){ cin >> n; cin >> x_0 >> y_0; cin >> x_2 >> y_2; double cent_x =...
#include<bits/stdc++.h> using namespace std; struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(4); }; } fast_ios_; #define Local #ifdef Local #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0) void err() { std::cout << std::endl; } te...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define llu unsigned long long int //#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii]) #define sa(a,n) rep(ii,n) cin>>a[ii]; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,a,n) for(int i=a;i<n;i++) #define rrep(i,n) for(int...
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <stack> #include <algorithm> using ll = long long int; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = 998244353ll; #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const int MOD = (int)1e9 + 7; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DU...
#include <bits/stdc++.h> using namespace std; using ll = long long; static constexpr ll LIM = 1e10; constexpr ll mpow(const ll base, const ll exp) { if (!exp) return 1; if (exp % 2LL) return base * mpow(base, exp - 1LL); const ll q = mpow(base, exp / 2LL); return (q * q); } set<ll> all_powers() { ...
// DeNsE - EcLiPsE // // WHAT is DEAD may NEVER die // #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <unordered_map> #include <cmath> #include <iomanip> #include <set> #include <cstring> #include <stack> #include <sstream> #include <queue> #include <unordered_set...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; typedef pair<int,int> P; ll dp[65][3]; string S[65]; int main() { int N; cin >> N; rep(i,N) { cin >> S[i]; } dp[0][1] = 1; dp[0][0] = 1; rep(i,N) { if (S[i] == "AND") { dp[i+1][1] = dp[i][...
#include <bits/stdc++.h> #include <string> #include <map> #include <set> #include <sstream> #include <queue> #include <stack> #include <deque> #include <vector> #define loop(i,a,b) for (int i = (a); i <= (b); i++) #define loopr(i, a, b) for(int i = (a); i >= (b); i--) #define ff first #define ss ...
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; #define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() #define len(x) ((int)(x).size()) void _cin() {} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... ...
#include <cstdio> #include <algorithm> using namespace std; const int maxn=2000; const int t[5][2]={{0, 0}, {0, 0}, {0, -1}, {+1, 0}, {+1, -1}}; int n, a[maxn+1][2]; int main() { scanf("%d", &n); int cnt=0; for (int i=1; i<=n; i++) { int opt; scanf("%d %d %d", &opt, a[i], a[i]+1); a[i][0]=a[i][0]*2+t[opt][0...
#include <iostream> #include <math.h> #include <vector> #include <string> #include <numeric> #include <unordered_set> using namespace std; int main(){ long long l; cin >> l; long long ans = 1; for(int i=1;i<=11;i++){ ans *= (l-i); ans /= i; //cout << ans << endl; } cout ...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; if (a % 2 == 1) cout << "Black"; else cout << "White"; }
#include <bits/stdc++.h> #define fo(i, x, y) for (int i = (x); i <= (y); ++i) #define fd(i, x, y) for (int i = (x); i >= (y); --i) using namespace std; typedef long long ll; const int maxn = 1e6 + 5, lim = 1e6; int l, r, tot; int pri[maxn], v[maxn], cnt[maxn]; vector<int> fac[maxn], s[maxn]; int getint() { char c...
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ cin.tie(nullptr)->sync_with_stdio(false); int l,r; cin >> l >> r; l = max(l,2LL); vector<int>dp(1000001); for(int i = 1000000; i>=1; i--){ int nums = r/i - (l-1)/i; dp[i] = nums*nums; for(int j = 2*i; j<=1000000; j+=i){ dp...
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define inf 999999999999 #define F first #define S second #define eb emplace_back #define mpp make_pair #define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n' #define dbg ...
#include<bits/stdc++.h> using namespace std; void solve(); int main() { solve(); return 0; } void solve() { int x, total=100; cin>>x; if (x%total==0) { cout<<total; } else { int q = x%total; int res = total - q; cout<<res; } }
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #define gp __gnu_pbds #define iset(T) gp::tree<T,gp::null_type,less<T>,gp::rb_tree_tag,gp::tree_order_statistics_node_update> using namespace std; #define SQ(x) ((x)*(x)) #define u unsigned #define ull unsigned long long #define ll long long #define ld...
#include <bits/stdc++.h> #define int long long #define inf 5e18 #define MOD (int)(1e9 + 7) #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(),x.rend() #define vii vector<pii> #define vi vector<int> #define test \ int t; \ cin >> t; \ while (t--) #define fast ...
#include <cstdio> #define int long long int read() { int x=0,f=1;char c; while((c=getchar())<'0' || c>'9') {if(c=='-') f=-1;} while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+(c^48);c=getchar();} return x*f; } int T,n,cnt; signed main() { T=read(); while(T--) { n=read();cnt=0; while(n%2==0) n/=2,cnt++; if(cnt==0)...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mit map<int,int>::iterator #define sit set<int>::iterator #define itrm(g,x) for(mit g=x.begin();g!=x.end();g++) #define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) #define ltype int #define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++) #define r...
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0 ; i < (n); ++i) using namespace std ; typedef long long ll ; const int mod=1000000007; const int N=1e3 ; ll max_ll(const ll &a,const ll &b){ if(a>b) return a ; else return b ; } void solve(){ int n; cin>>n; vector<ll> a(n),b(n) ; rep(i,n){ cin>>a[...
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size() using namespace std; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //uniform_int_distribution<int>(1000,10000)(rng) ll binpow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = r...
#include <bits/stdc++.h> using namespace std; int main() { int A,B; cin >> A >> B; if(A+B >= 15 && B >= 8){ cout << 1 <<endl; } else if(A+B >= 10 && B >= 3){ cout << 2 <<endl; } else if(A+B >= 3){ cout << 3 <<endl; } else{ cout << 4 <<endl; } return 0; }
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <complex> #include <queue> #include <set> #include <unordered_set> #include <list> #include <chrono> #include <random> #include <iostream> #in...