code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // -------------------------------------------------------- template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1...
#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 n; cin >> n; vector<int> a(2 * n); for(auto &e : a) cin >> e; vector<P> ps; rep(i, 2 * n) ps.emplace_back(a[i], i); sort(ps.rbegin(), ps...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vll = vector<ll>; using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using pll = pair<ll, ll>; using pii = pair<int, int>; using vpii = vector<pii>; using vpll = vector<pll>; const ll LIN...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define endl "\n" typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for...
//ver 8.1 #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#include<bits/stdc++.h> using namespace std; int n,b[404040]; pair<int,int>a[404040]; stack<pair<int,int> >st; int main() { string ans=""; cin>>n; for(int i=0;i<2*n;i++) { cin>>a[i].first; a[i].second=i; ans+='('; } sort(a,a+2*n); for(int i=0;i<n;i++) { b[a[i].second]=1; } for(int i=0;i<2*n;i++) { ...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long uLL; typedef pair<int,int> pii; typedef pair<double,double> pdd; const int N=2e5+5; const int M=1e5+5; const int inf=0x3f3f3f3f; const int mod=1e9+7; const double eps=1e-8; const long double pi=acos(-1.0L); #define ls (i<<1) #...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin(...
#include <bits/stdc++.h> #define max0(x,y) (x<y?y:x) #define min0(x,y) (x>y?y:x) using namespace std; const double eps=1e-14,down=0.9997; const int mn=3e3+7; int n; int w[mn][6],q1[4],q2[mn]; int fx() { int ans=1e9+7; for(int j=1;j<=5;++j) { int mx=0; for(int i=1;i<=3;++i) mx=max0(w[q1[i]][j],...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #include <bits/stdc++.h> using namespace std; #define ll long long inline int in_int(istream& in) {int x; in >> x; return x;} inline ll in_ll(istream& in) {ll x; in >> x; ret...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vs = vector<string>; using vb = vector<bool>; using pii = pair<int, int>; #define endl " \n" #define size(x) int((x).size()) #define all(a) a.begin(), a.end() const int mod = 1e9+7, inf = INT_MAX, ninf = INT_MIN; void s...
#include<bits/stdc++.h> using namespace std; int main(){ int N,K;cin>>N>>K; int ans=0; for(int i=1;i<=N;i++){ ans+=K*i*100; ans+=K*(K+1)/2; } cout<<ans<<endl; }
#include<bits/stdc++.h> #define ll long long using namespace std; const int MAXN=1e5+10; int k,n,m,a[MAXN],b[MAXN]; ll ans[2*MAXN],ans2[2*MAXN]; bool check(int mid){ int i,x,minb=0,maxb=0; for(i=1;i<=k;i++){ x=(ll)m*a[i]/n; if(ans[2*i-1]>ans2[mid]&&ans[2*i]>ans2[mid])return 0; if(ans[2*i-1]<=ans2[mid]&&...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; signed main() { int k, n, m; cin >> k >> n >> m; ll a[k...
#include<bits/stdc++.h> #define ll long long int #define mk make_pair #define pb push_back #define INF (ll)1e18 #define pii pair<ll,ll> #define mod 998244353 #define f(i,a,b) for(ll i=a;i<b;i++) #define fb(i,a,b) for(ll i=a;i>b;i--) #define ff first #define ss second #define srt(v) if(!v.empty())sort(v.begin(),v.end()...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; using ll = long long; const ll MOD = 1e9+7; ll dp[2001][2001]; int main() { int h,w; cin >> h >> w; map<ll,ll> sumx,sumy,sumxy; vector<string> S(h); for(auto &i:S)cin >> i; for(int i = 0;i<h;i++){ for(int j = 0;j<w;j++){ if(i==0&&j==0){ ...
#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() { const ll LINF = 1LL<<62; int n,t; cin >> n >> t; vector<int> a(n); rep(i,n) cin >> a[i]; int l = n/2; int r = n-l; set<ll> sa; for (int s=0; s<(1<<l)...
#include<bits/stdc++.h> namespace my_std{ using namespace std; #define pii pair<int,int> #define fir first #define sec second #define MP make_pair #define rep(i,x,y) for (int i=(x);i<=(y);i++) #define drep(i,x,y) for (int i=(x);i>=(y);i--) #define go(x) for (int i=head[x];i;i=edge[i].nxt) #define templ templat...
#include <algorithm> #include <iostream> #include <iterator> #include <sstream> #include <utility> #include <cstdarg> #include <cassert> #include <climits> #include <cstdlib> #include <cstring> #include <cstdio> #include <cctype> #include <vector> #include <stack> #include <queue> #include <cmath> #include <set> #inclu...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0; i<(n);i++) using ll = long long; const ll INF = 1e9+7; const ll mod=1000000007; using P = pair<ll, ll>; ll x, y, a, b; int main(){ cin >> x >> y >> a >> b; ll ans2 = 0; while((double)a*x< y && a*x < x+b){ x *= a; an...
#include<bits/stdc++.h> #define FastRead \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define ll long long #define endl "\n" #define f for #define ml ll t,g; cin>>t; f(g=0;g<t;g++) #define pi acos(-1) using namespace std; ...
/*ver 7*/ #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#include <bits/stdc++.h> #define FOR(ii,aa,bb) for(int ii=aa;ii<bb;ii++) #define for0(ii,bb) FOR(ii,0,bb) #define for1(ii,bb) FOR(ii,1,bb+1) #define pb push_back #define ppb pop_back #define mp make_pair #define st first #define nd second #define pii pair<int,int> #define piii pair<int,pii> #define pdi pair<double,int>...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; using Vi = vector<int>; using VVi = vector<Vi>; using Vl = vector<ll>; using VVl =...
#include <algorithm> #include <iostream> using namespace std; const int MD = 1000000007; long long inv(int n) { return n == 1 ? 1 : inv(n - MD % n) * (MD / n + 1) % MD; } long long choose(int n, int k) { return n < k ? 0 : k == 0 ? 1 : choose(n - 1, k - 1) * n % MD * inv(k) % MD; } int main() { int n, m, k; cin...
#include <bits/stdc++.h> using namespace std; #define deb(k) cerr << #k << ": " << k << "\n"; #define size(a) (int)a.size() #define fastcin cin.tie(0)->sync_with_stdio(0); #define st first #define nd second #define pb push_back #define mk make_pair #define int long long typedef long double ldbl; typedef double dbl; typ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++) typedef long long ll; const int NUM = 2e5+10; ll x[NUM], y[NUM]; ll x00[NUM], y00[NUM]; ll x01[NUM], y01[NUM]; ll x10[NUM], y10[NUM]; int main() { int n; cin >> n; rep(i, n) cin >> x[i + 1] >> y [i...
//kyoprosaikoooooooooooo!! #include <bits/stdc++.h> #define ll long long #define MOD 1000000007 double pai = 3.141592653589793238; using namespace std; //素数判定 O(√N) ll prime (ll abc) { if (abc < 2) { return 0; } else if (abc == 2) { return 1; } else if (abc % 2 == 0) { return 0; } double sqrta...
#include <iostream> #include <cstdio> #include <cmath> #include <ctime> #include <cstdlib> #include <cassert> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <string> #include <algorithm> #include <utility> #include <complex> ...
#include <bits/stdc++.h> #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ll long long #define lol __int128 #define ld long double #define pii pair<int, int> #define dbg(x) cerr << #x << " = " << x << "\n" using namespace std; ll a, b, c; ll power(ll x, ll y, ll m) { x %= m; ll res = 1; wh...
/****************************************** * AUTHOR : RTG * ******************************************/ #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE // For getting input from input.txt file FILE *input = freopen("/home/...
#include<bits/stdc++.h> using namespace std; int main(){ int n,x,a; cin >> n >> x; while(cin >> a){ if(a != x) cout << a << ' '; } }
#include<bits/stdc++.h> #define int ll #define sz(x) int((x).size()) #define all(x) (x).begin(),(x).end() #define pb push_back #define x first #define y second using namespace std; using ll = long long; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; vector<int> adj[2...
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pii pair<long long,long long> #define mp make_pair #define pb push_back int n,c[100005],vis[100005],nowc[100005]; vector <int> g[100005]; vector <int> ans; void dfs(int now) { /* cout<<now<<endl; for(int i=1;...
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false);cin.tie(0); int a, b, w; cin>>a>>b>>w; w*=1000; int l=1e6+1, r=-(1e6+1); for(int i=1;i<=w;i++){ if(a*i<=w && w<=b*i){ l=min(l, i); r=max(r, i); } } if(l==1e6+1) ...
#include <bits/stdc++.h> long long mod = 1e9 + 7; long long modinv(long long dividend, long long divisor, long long modnum){ long long b = mod, u = 1, v = 0; while (b) { long long t = divisor / b; divisor -= t * b; std::swap(divisor, b); u -= t * v; std::swap(u, v); } u %= mod;...
#include <iostream> #include <array> #include <algorithm> #include <vector> using namespace std; #define rep(i,n) for (int i = 0; i < (int)(n); i++) #define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++) #define prl(a) cout << (a) << endl #define allrange(a) a.begin(),a.end() bool solve_translated(vector<pair<i...
#include<iostream> #include<iomanip> #include<string> #include<vector> #include<algorithm> #include<utility> #include<tuple> #include<map> #include<queue> #include<deque> #include<set> #include<stack> #include<numeric> #include<complex> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<casse...
// ※※※ 解答不能 ※※※ // https://atcoder.jp/contests/abc207/editorial/2153 // C++(GCC 9.2.1) #include <bits/stdc++.h> using namespace std; using vd = vector<double>; #define repex(i, a, b, c) for(int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for(int i ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll modn = 1000000007; const double eps = 1e-3; const double pi = acos(-1); struct pii{ double x,y; double len2() const{ return x*x+y*y; } double arc(){ return atan2(y,x); } pii rot(double th){ return...
#include <iostream> #include<cmath> #include<vector> #include<set> #include <algorithm> #include<map> #include<string> using namespace std;typedef long long ll; #define rep(i,n) for(i=0;i<n;i++) #define pb push_back #define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf #define INF64 9223372036854775807 //9.22337203...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A.at(i); int ans = 2, count = 0; rep(i, 1010) { if (i < 2) continue; int j = 0; rep(k, N) if (!(A.at(k) % i)) j++; if (j >= cou...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <deque> #include <set> #include <sstream> #include <stack> #include <...
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ int n; cin >> n; ll a[401]; for(int i = 0; i < 401; ++i){ a[i] = 0; } for(int i = 0; i < n; ++i){ ll tmp; cin >> tmp; ++a[tmp+200]; } ll sum = 0; for(int i = 0; i < 401; +...
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define rng(i, a, b) for (int i=int(a);i<int(b);++i) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i=int(b)-1;i>=int(a);--i) #define per(i, b) gnr(i, 0, b) #define all(obj) begin(obj), end(obj) #define allr(obj) rbegin(obj)...
#include <iostream> using namespace std; int main(){ long long a, b, c; cin >> a >> b >> c; if (a * a + b * b < c * c){ cout << "Yes" << endl; } else{ cout << "No" << endl; } }
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using db = double; using vi = vector<int>; #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 _GLIBCXX_DEBUG #include <bits/stdc++.h> #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 namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vect...
#include <bits/stdc++.h> using namespace std; #define FREP(i,a,b) for(long long i=a;i<b;i++) #define REP(i,n) FREP(i,0,n) #define PB push_back #define ll long long #define MP make_pair #define mod 1000000007 #define endl "\n" #define vi vector<ll> #define si set<ll> #define mi map<ll,ll> #define bs binary_search #defi...
#include<iostream> using namespace std; #include<vector> #include <algorithm> #define re(i,n) for(int i = 0; i < n; i++) const int MOD = 998244353; long long mod(long long val, long long m) { long long res = val % m; if (res < 0) res += m; return res; } template<class T> inline bool chmin(T& a, T b) { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) long long a[60]; long long ans; map<long long,long long> dp[60]; long long coin(int n,long long x) { long long p,q,r; if (dp[n][x]>0) return dp[n][x]; p=x/a[n]; q=x%a[n]; if (q==0){ dp[n][x]=1; return dp[n][x]...
#include <complex> #include <iomanip> #include <iostream> #include <vector> using namespace std; using Expr = complex<double>; int main() { int n, m, k; cin >> n >> m >> k; vector<bool> portal(n + 1, false); for (int i = 0; i < k; i += 1) { int pos; cin >> pos; portal[pos] = ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<long long, long long>; constexpr char ln = '\n'; constexpr long long MOD = 1000000007; //constexpr long long MOD = 998244353; constexpr long long INF = 1e9+100; constexpr long long LINF = 1e18+100; #define...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,x,y; while(cin>>a>>b>>x>>y) { long long ans1,ans2; if(a==b) cout<<x<<endl; else if(a>b) { ans1=(a-b-1)*y+x; ans2=(a-b-1)*2*x+x; cout<<min(ans1,ans2)<<endl; ...
#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)-1; i >= (a); --i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second ...
#include <bits/stdc++.h> const int K = 300; const int N = 200000; const int P = 998244353; inline int add(int x, int y) {x += y; return x >= P ? x - P : x;} inline int sub(int x, int y) {x -= y; return x < 0 ? x + P : x;} inline int mul(int x, int y) {return (int)(1ll * x * y % P);} int s[K + 5], t[K + 5], c[K + 5][K...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define speed ios_base::sync_with_stdio(false);cin.tie(NULL) #define mod 1000000007 const int N = 100005; ll sigma(ll n) { return (n*(n+1))/2; } signed main() { speed; int n,k; cin>>n>>k; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int main() { fast_io; int n, k; cin >> n >> k; string res = ""; ll sum = 0; for (int i = 1; i <= n; i++) { f...
#include <bits/stdc++.h> #define FOR(i,n) for(lli i=0;i<(lli)(n);++i) #define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i) #define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i) #define pb push_back #define mt make_tuple using namespace std; using lli = long long int; using pll = pair<lli, lli>; using vi = vector<lli...
#include <bits/stdc++.h> using namespace std; int64_t ans=0; int sx,sy; int H,W; vector<vector<bool> > flag; vector<vector<int> > vv; void dfs(int x,int y,int num,int64_t count,char dir){ if(num==0){ if(sy==y-1){ if(dir!='L'){ count++; } }else if(sy==y+1){ if(dir!='R'){ cou...
#include <bits/stdc++.h> using namespace std; #define ll long long int; #define fast ios_base::sync_with_stdio; cin.tie(NULL); cout.tie(NULL); #define rloop(i, a, b) for(int i=a; i>=b; i--) #define loop(i, a, b) for(int i=a; i<b; i++) int main() { fast; { int n, y; cin>>n; map<int, stri...
#define _GLIBCXX_DEBUG //配列外参照の検出 #include <bits/stdc++.h> //標準ライブラリをインクルード using namespace std; //std::の省略 typedef long long ll; //long longをllに省略 bool compare_second(pair<string, ll> a, pair<string, ll> b) { if(a.second != b.second){ return a.second < b.second; }else{ ret...
/* * @author: codancer * @createTime: 2020-11-16, 22:37:41 */ #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include ...
#include<bits/stdc++.h> #define ll long long #define test(t) int t;cin>>t;while(t--) using namespace std; int main() { ll x; cin>>x; if(x<0) cout<<0<<"\n"; else cout<<x<<"\n"; return 0; }
#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 ll read(void){ reg bool f=false; reg char ch=getchar(); reg ll res=0; while(!isdigit(ch))f|=(ch...
#include <iostream> #include <iomanip> #include <algorithm> #include <array> #include <cassert> #include <optional> #include <utility> #include <vector> #include <cmath> // #include <atcoder/all> template <class InputIterator> std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last...
#include<cstdio> #include<cstring> #include<iostream> using namespace std; #define N 150300 #define M 301300 #define INF 0x3f3f3f3f int A[N],B[N],C[N],fa[N],tag[N],que[N],dis[N],n,D[20][20],f[20][N],vis[N]; struct node{ int to,next; }q[M]; int head[N],ss; void addedge(int x,int y) { q[++ss]=(node){y,head[x]};head[x]=...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ld = long double; using P = pair<ll, ll>; using Vec = vector<ll>; using VecP = vector<P>; template <class T> using Vec2 = vector<vector<T>>; #define REP(i, m, n) for(ll i = (m); i < (n); ++i) #define REPN(i, m, n) for(ll i = (m); i <= (n); ++i) #de...
#include<bits/stdc++.h> //#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)? EOF:*p1++) using namespace std; typedef long long ll; const int N=2e5+5,mod=1e9+7; int n,k; ll f[N][2][2][17]; bool vs[N][2][2][17]; int cnt[N],bk[N][17]; char s[N]; int gt(char x) { if(x<='9') return x-'0'; return x-'...
#include <iostream> using namespace std; using ll = long long; const int kMod = 1e9 + 7; const int kMaxN = 2e5 + 1; string s; int a[kMaxN]; ll c[20][20], dp[kMaxN][20]; ll ans, k, n, fl, b[20]; ll ksm(ll a, ll b) { ll x = 1; for (; b; b /= 2, a = a * a % kMod) { if (b % 2 == 1) { x = x * a % kMod; ...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define fast ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; int main() { int N; int count =0; cin>>N; vector<int> vec(N); for (int i = 0; i < N; i++) {cin >> vec.at(i);} sort(vec.begin(), vec.end()); for(int n=0;n<N;n++){if(vec.at(n)!=n+1){count++;break;}} if(count==0){cout<<"Yes"<<endl;} else if(count==1){cout<<"No"<<endl;} }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937/*_64*/ rng(chrono::ste...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; constexpr ll MOD = 1000000007; #ifndef ONLINE_JUDGE template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : "...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int d = floor(1.08 * N) - 206; if(d > 0) cout << ":("; else if(d == 0) cout << "so-so"; else if(d < 0) cout << "Yay!"; cout << endl; }
#line 1 "main.cpp" #include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; void solve() { int n; cin >> n; cout << (1 << n) - 1 << "\n"; for (int b = 1; b < (1 << n); ++b) { for (int x = 0; x < (1 << n); ++x) { cout << "AB"[__builtin_popco...
#include<bits/stdc++.h> using namespace std; #define MAXN 500005 char s[MAXN],t[MAXN]; int n,cnt1,cnt2; int main() { scanf("%d",&n); scanf("%s %s",s,t); for(int i=0;i<n;i++)if(s[i]=='0')cnt1++; for(int i=0;i<n;i++)if(t[i]=='0')cnt2++; if(cnt1!=cnt2)printf("-1\n"); else { int i=0,j=0;...
#include <algorithm> #include <chrono> #include <cmath> #include <ctime> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <cassert> #include <assert.h> //#pragma G...
#include <bits/stdc++.h> #define MAXN 100005 #define INF 1000000000000000005 using namespace std; int main (){ int a,b,ms,mf; cin>>a>>b; ms = a+b; mf = b; //cout<<ms<<" "<<mf<<endl; if ( ms >= 15 && mf >=8 ) { cout<<1; return 0; } else if ( ms >= 10 && mf >=3 ){ cout<<2; return 0; } else if (...
#include <bits/stdc++.h> using namespace std; long myPow(long x, long n, long m){ if(n == 0) return 1; if(n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } int main() { long N, M; cin >> N >> M; cout << myPow(10,N,M*M) / M << endl; system("pause...
#include <iostream> #include <algorithm> using namespace std; int main(){ string s; cin>>s; reverse(s.begin(),s.end()); for(auto& a:s){ if (a=='6') { a='9'; } else if(a=='9') { a='6'; } } cout<<s<<endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s, S; cin >> s; int n; n = s.size(); for (int i = n - 1; -1 < i; i--){ if (s.at(i) == '6') S += '9'; if (s.at(i) == '9') S += '6'; if (s.at(i) != '9' && s.at(i) != '6') S += s.at(i); if (i == 0) cout ...
#include<iostream> #include<iomanip> #include<string> #include<vector> #include<algorithm> #include<utility> #include<tuple> #include<map> #include<queue> #include<deque> #include<set> #include<stack> #include<numeric> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> using namespa...
#include<bits/stdc++.h> using namespace std; const int Mod=998244353; namespace modular{ int add(int a,int b){return a+b>=Mod?a+b-Mod:a+b;} int mul(int a,int b){return 1ll*a*b%Mod;} }using namespace modular; #define cout cerr #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define per(i,a,b) for(int i=(a);i>=(b);--i) ...
#include <bits/stdc++.h> using namespace std; int main(){ int N; long long X; cin >> N >> X; vector<long long> A(N); for(int i = 0; i < N; i++) cin >> A[i]; long long ans = X; for(int i = 1; i <= N; i++){ vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>> (i + 1, v...
#include<bits/stdc++.h> #define pb push_back #define pl pair<ll,ll> #define pll pair<ll,pair<ll,ll>> #define ll long long #define vl vector<ll> #define fastio ios_base::sync_with_stdio(false);...
/* これを入れて実行 g++ code.cpp ./a.out */ #include <iostream> #include <cstdio> #include <stdio.h> #include <vector> #include <string> #include <cstring> #include <queue> #include <deque> #include <stack> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <unordered_set...
#if _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> using namespace std; #ifndef ONLINE_JUDGE const bool DEBUG = true; #else const bool DEBUG = false; #endif // Reads a 1D vector template <class T> void read1d(vector<T> & arg) { const int l ...
#include<bits/stdc++.h> using namespace std; int k; long long n, a[50]; long long g1(long long x){ int len = 0; while(x){ a[len ++] = x%10; x /= 10; } sort(a, a+len); for(int i = 0; i < len; ++ i){ x *= 10; x += a[i]; } // cout << x << endl; return x;...
#include <iostream> #include <climits> #include <set> #include <string> #include <algorithm> #include <vector> #define MAX 1000000007 using namespace std; #define ll long long #define dbg if(0) #define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi)) int main(){ ll ans,a,b; cin>>a>>b; ans=(3-(a+b)%3)%3; ...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define Rep(i,n) for(int i = 1; i <= n; i++) #define sz(a) int(a.size()) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define debug(a) { cerr << #a << ':' << a << endl; } #define endl '\n' #define fi first...
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >>S; int ans=0; for(int i=0;i<10000;i++) { vector<bool> used(10); int x=i; for(int j=0;j<4;j++) { used[x%10] = true; x /=10; } bool able = true; for(int j=0;j<10;j++) { if(S[j] == 'o' && !used...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) fo...
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" map<ll,vector<ll>>adjlist; void dfs(ll curr,ll P,vector<ll>&parent){ parent[curr]=P; for(auto i:adjlist[curr]){ if(i!=P){ dfs(i,curr,parent); } } return; } void Sum(ll rt,ll P,ll val,vector<ll...
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll i,j,k,n,m,t,c=0; cin>>n>>m>>t; k = n; ll a[m][2]; for(i=0;i<m;i++){ cin>>a[i][0]>>a[i][1]; } n -= a[0][0]; if(n<1){ c = 1; } n+=a[0][1]-a[0][0]; if(n>k){ n = k; } for(i=1;i<m;i++){ n -= a[i][0]-a[i-1][1]; if(n<1){ ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define _GLIBCXX_DEBUG typedef long long int ll; typedef long double ld; const int inf = 1e8; const ll llinf = 1e18; const double PI = acos(-1); #define yes "Yes" #define no "No" #define all(n) n.begin(), n.end() templa...
#pragma region Macros #include <bits/stdc++.h> using namespace std; using ll = long long; #define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i) #define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i) #define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME #define REP(...) GET_MACRO_...
#include <bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define f(i,j,n) for(int i = j; i <= n; i++) #define r(i,n,j) for(int i = n; i >= j; i--) #define all(container) container.begin() , container.en...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000001; void chmin(int& x, int y){ x = min(x,y); } int main() { int N; cin >> N; vector<int> X(N); vector<int> Y(N); vector<int> Z(N); for (int i = 0; i < N; ++i) { cin >> X[i] >> Y[i] >> Z[i]; } int N2 = 1<<N; vector<vect...
#include "bits/stdc++.h" #define rep(i,b) for(ll i=0;i<b;i++) #define ll long long using namespace std; /*--Input//////////////////////////////////////////////////*/ inline void IN(void){return;} template <typename First, typename... Rest> void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); ret...
#include <bits/stdc++.h> #include <math.h> #include <cmath> using namespace std; using ll =long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vecto...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define endl '\n' #define pb push_back #define fi first #define se second #define all(c) (c).begin(),(c).end() typedef long long ll; typedef long ...
#include <bits/stdc++.h> #define MAX 1000005 #define M 1000000000 using namespace std; #define ll long long int // bool prime[MAX+1]; // ll ans[MAX]; // void seive() // { // memset(prime, true, sizeof(prime)); // for (int p=2; p*p<=MAX; p++) // { // if (prime[p] == true) // { // ...
#include <iostream> #include <sstream> #include <cstdio> #include <vector> #include <cmath> #include <queue> #include <string> #include <cstring> #include <cassert> #include <iomanip> #include <algorithm> #include <set> #include <map> #include <ctime> #include <cmath> using namespace std; #define fastio ios::sync_wit...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #define RST(i,n) memset(i,n,sizeof i) #define SZ(a) (int)a.size() #define ALL(a) a.begin(),a.end() #define X first #define Y second #define eb emplace_back #ifdef cold66 #define debug(...) do{\ fp...
#include <bits/stdc++.h> using namespace std; const int max_n = 11, inf = 1000111222; const int max_m = 100011; int n, m, a[max_n], dp[max_n][max_n]; pair<int, int> b[max_m]; vector<pair<int, int>> v; int solve() { for (int i = 0; i < n; ++i) { if (a[i] > v[0].first) { return inf; } ...
#include <bits/stdc++.h> #include <cstdlib> using namespace std; #define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long int #define pb push_back #define S second #define F first //#define int long long int #define endl "\n" ll MOD=1e9+7; void solve() { ll x,y; ...
#include "bits/stdc++.h" using namespace std; int main(){ int A, B; cin>>A>>B; if(A<B&&A+3>B||B<A&&B+3>A) cout<<"Yes"<<endl; else cout<<"No"<<endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n; ll f(ll k){ return k*(k+1)/2; } bool ok(ll k){ return f(k) <= n+1 and n+1 < f(k+1); } int main(void){ cin >> n; ll left = 1, right = n, k; while(true){ ll m = (left+right)/2; if(m<=2*(n+1)/(m+1) and 2*(n+1)/...
#include <bits/stdc++.h> using namespace std; /* エイリアス */ #define ll long long #define ld long double #define vi vector<int> #define vll vector<ll> #define pii pair<int,int> #define pll pair<ll,ll> #define vpi vector<pii> #define vpll vector<pll> #define endl '\n' #define fi first #define se second #define pb push_b...
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0, length = n; i < length; i++) #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ep emplace #define epb emplace_back #define scll static_cast<long long> #define sz(x) static_cast<int>((x).size()) #define pfll(x) printf("%lld...
// Author: wlzhouzhuan #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pb push_back #define fir first #define sec second #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> ostream& operator<<(ostream &os, vector<T> &v){ string sep = " "; if(v.size()) os << v[0]; for(int i=1; i<v.size(); i++) os << sep << v[i]; return os; } template<typename T> istream& operator>>(istream &is, vector<...
#include <iostream> #include <fstream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <algorithm> #include <bitset> #include <set> #include <map> #include <vector> #include <string> #include <cstring> #include <queue> #include <memory.h> #include <cmath> using namespace std; #define min(a,b) ((a)<(b...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf=0x3f3f3f3f; const double pi=3.1415926535897932384626; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }...
#include<bits/stdc++.h> using namespace std; int main(){ int h, w; cin >> h >> w; const int mod = 998244353; string tmp; vector<vector<char>> grid(h, vector<char>(w)); for(int i = 0; i < h; ++i){ cin >> tmp; for(int j = 0; j < w; ++j){grid[i][j] = tmp[j];} } vector<vector<int>> state(h+w-1, ve...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; constexpr int MAX_N = 100000; int n, m; vector<pair<int, int>> G[M...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; vector<pair<int, int>> g[N]; void solve() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int u, v, c; cin >> u >> v >> c; g[u].emplace_back(v, c); g[v].emplace_back(u, c); } vector<int>...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ long long n, m, q; long long w[100],v[100]; vector<long long> x(100); vector<long long> tempx(100); long long max = 0; long long l,r; vector<pair<long long, long long>> p(100); cin >> n >> m >> q; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define MV 200001 #define LMV 21 #define ff first #define ss second #define pb push_back #define eb emplace_back #define emp emplace #define mp make_pair #define ins in...
// 2021-04-19 00:32:20 // clang-format off #include <bits/stdc++.h> #ifdef LOCAL #include "lib/debug.hpp" #else #define debug(...) 1 #endif #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define rep(i, n) REP(i, 0, (n)) #define repc(i, n) REPC(i, 0, (n)) #define REP(i, n, m) for (int i =...
#include<iostream> #include<vector> #include<queue> #include<cstring> #include<cmath> #include<map> #include<set> #include<cstdio> #include<algorithm> #define debug(a) cout<<#a<<"="<<a<<endl; using namespace std; const int maxn=4e5+1000; typedef long long LL; const LL mod=3; inline LL read(){LL x=0,f=1;char ch=getchar(...
#include<bits/stdc++.h> #define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i) #define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i) #define foreach(i, n) for(auto &i:(n)) #define all(x) (x).begin(),...
#include <iostream> #include <string> using namespace std; using ll = int64_t; ll n, k; ll numar(ll x) { ll g1 = 0, g2 = 0; int c[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; while(x) c[x % 10]++, x /= 10; for(int i = 0 ; i < 10 ; i++) for(int j = 1 ; j <= c[i] ; j++) g1 = g1 * 10 + i; for(...
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; using P = pair<ll,int>; const char EOLN = '\n'; #define rep(i,n) for (int i = 0; i < (n); ++i) // DP template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline b...
#if _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> using namespace std; #ifndef ONLINE_JUDGE const bool DEBUG = true; #else const bool DEBUG = false; #endif // Reads a 1D vector template <class T> void read1d(vector<T> & arg) { const int l ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<(int)(n); i++) #define rep1(i, n) for(int i=1; i<=(int)(n); i++) #define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++) typedef long long ll; typedef vector<int> vi; typedef vector<vi> wi; typedef vector<ll> vl; typedef vector<vl> wl; const...
#include <stack> #include <queue> #include <bitset> #include <unordered_set> #include <unordered_map> #include <map> #include <set> #include <tuple> #include <cmath> #include <random> #include <algorithm> #include <vector> #include <iostream> #include <fstream> #include <chrono> #include <numeric> #define fio ios_base...
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <math.h> #include <cassert> #define rep(i,n) for(int i = 0; i < n; ++i ) using namespace std; using ll = long long; // auto mod int const int mod = 1000000007; struct min...
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; const ll MOD = 1000000007; ll p[20][200005]; ll dp[200005][20][2][2]; ll com[20][20]; ll sub(int r, int k, bool *b){ int c = 0; for(int i = 0; i < 16; i++) c += b[i]; if(c > k || r + c < k) return 0; ll res = 0; f...
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define FF first.first #define FS first.second #define pb push_back using namespace std; const ll N=1000006, INF=1e18, MOD=1e9+7; ll n, m, t, a[N][2], f[N], q=1, e, o, u, x, y, k, ans, Ans0[2], Ans1[2], mx; vector <ll> v; string s[101...
// Always remember that you are absolutely unique, just like everyone else! #include <iostream> #include <vector> using namespace std; // DEBUGGING SECTION void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsi...
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; int score(int N, vector<int> A, string S) { vector<int> st; int ans = 0; for (int i = 0; i < 2 * N; ++i) { if (S[i] == '(') st.push_back(i); else { ans += abs(A[st.back()] - A[i]); st.pop_back(); } } retur...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(2 * n); for (auto &x : a) cin >> x; vector<int> ind(2 * n); iota(ind.begin(), ind.end(), 0); sort(ind.begin(), ind.end(), [&](int i, int j) { return a[i] < a[j]; }); ...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1001001001; const long long LINF = 1001002003004005006; const double PI = acos(-1); int d4r[] = {1, 0, -1, 0}; int d4c[] = {0, 1, 0, -1}; int d8r[] = {1, 1, 0, -1, -1, -1, 0, 1}; int d8c[] = {0, 1, 1,...
#include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long int #define fi first #define se second #define pb push_back #define mp make_pair #define vec vector<ll> #define be begin() #define en end() #define MOD 1000000007 #define ull unsigned long long #de...
#include <bits/stdc++.h> using namespace std; // vtqi6hy80o@email.edu.pl #define rep(i, a, b) for(lli i = a; i < b; i++) #define lli long long int #define ld long double #define all(v) v.begin(), v.end() #define hell 1000000000000000 #define pb push_back #define pf push_front #define vi vector<lli> #define vip vector<p...
#include <iostream> //#include <vector> //#include <string> //#include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used //#include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long L...
/*g++ main.cpp -o main.out*/ /*./main.out*/ #include<bits/stdc++.h> using namespace std; #define LL long long #define LD long double #define Mod 1000000007 #define L_Mod 17100000013 const double eps = 1e-9; const int INF = 0x3f3f3f3f; const double PI = 3.1415926535; #define NO_TLE std::ios::sync_with_stdio(false);c...
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if(a + c > b) { cout << "Takahashi" << endl; } else { cout << "Aoki" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int get() { int x = 0; char s = getchar(); while (s < '0' || s > '9') s = getchar(); while (s >= '0' && s <= '9') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar(); return x; } char gc() { char s = getchar(); while (s < 'A' || s > 'B') s = getc...
#include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define MP make_pair #define EB emplace_back #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << (x) <...
#include <vector> #include <functional> using namespace std; template<typename T> class SegmentTree { int n; function<T(T,T)> op; vector<T> V; T q(int l, int r) { if (l >= r) return V[0]; T a = q((l+1)/2, r/2); if (l%2 != 0) a = op(a, V[l]); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=2e5+105; const ll mod=1e9+7; int a[maxn]; int main(){ int n,ans=0; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++){ int tp=a[i]; for(int j=i+1;j<=n;j++) { if(a[j]<a[i]){ break; } ...
#include <bits/stdc++.h> #define rep(begin, end) for (i=begin;i<end;i++) #define repj(begin, end) for (j=begin;j<end;j++) #define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val; #define printint(i0, i1) printf("%d %d\n", i0, i1) using namespace std; typedef long long int ll; const ll inf = 1000000000; const ll m...
/* @Author Sujeet Kushwaha */ #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 ll long long int #define fast ios_base::sync_with_stdio(false) #define fast_input cin.tie(NULL) #define fast_output cout...
#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = 998244353; template <typename T> struct BIT { int n; // 配列の要素数(数列の要素数+1) vector<T> bit; // データの格納先 BIT(int n_) : n(n_ + 1), bit(n, 0) {} void add(int i, T ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() int main(){ ll n;cin >>n; vector<vector<ll>> c(n,vector<ll>(n)); rep(i,n)rep(j,n)cin >>c[i][j]; bool y_n=true; vector<ll> dc(n-1); rep...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, a[N], b[N], p[N], rp[N], id[N]; void gao(int x, int y) { if(a[x]<=b[p[x]] || a[y]<=b[p[y]]) { puts("-1"); exit(0); } rp[p[y]] = x, rp[p[x]] = y; swap(p[x], p[y]); } int main() { scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", a+...
#include<bits/stdc++.h> #define int long long #define rint regester int const int maxn = 1e6 + 10; const int INF = 1e9; using std::ios; using std::cin; using std::cout; using std::max; using std::min; using std::sort; using std::unique; using std::lower_bound; using std::swap; using std::abs; using std::acos; using std...
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b; cin>>a>>b; float c = (float)((b/100.0)*a); int d = c; if(c == d){ cout<<d; }else{ cout<<c; } //cout<<(b/100)*a; }
#include <bits/stdc++.h> using namespace std; int main(){ double a,b; double x; cin >> a >> b; x = a*b/100; cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i < (b); i++) #define REP(i,n) rep(i,0,n) void solve() { int n,m;cin>>n>>m; int a[n],b[m],dp[n+1][m+1]; for(auto &i:a)cin>>i; for(auto &i:b)cin>>i; REP(i,n+1)dp[i][0]=i; REP(i,m+1)dp[0][i]=i; rep(i,1,n+1)rep(j...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { int N, M; cin >> N >> M; vector<int> A(N), B(M); rep(i, N) cin >> A[i]; rep(i, M) cin >> B[i]; vector<vector<int>> dp(N, vector<int>(M, 0)); rep(i, N) { ...
#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 int64_t lint; #define rep(i, n) for(lint i=0; i<n; i++) int main() { lint N; cin >> N; lint a=0, b=0, c=N+1, x, y, z; rep(i, N) { c -= i+1; if (c >= 0) a++; else break; } std::cout << N+1-a << '\n'; }
#include <bits/stdc++.h> // clang-format off using namespace std; using i64 = int64_t; using pii = pair<i64, i64>; #define rep(i, n) for (i64 i = 0; i < i64(n); i++) #define per(i, n) for (i64 i = n - 1; i >= 0; i--) #define REP(i, a, b) for (i64 i = a; i < i64(b); i++) #define all(x) (x).begin(), (x).end() #define ra...
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <cmath> #include <set> #include <map> #include <stack> #include <queue> #define ll long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll, ll> using namespace std; int main(){ int n; cin >> n; vector<ll...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // DEBUG #ifdef _DEBUG #define debug(x) cout << #x << ": " << x << endl #else #define debug(x) #endif // iter #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPD(i, n) for (int i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (int i = a;...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll=long long; using ld=long double; //using mint = modint1000000007; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) #define PI acos(-1) #define oo 2e18 template<typename T1, typename T2> bool ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull long long #define pll pair<ll,ll> #define ff first #define ss second #define pb push_back #define endl "\n" const ll maxn =5e5+5; const ll mod=998242361 ; const ll base=1e18; map<ll,vector<ll>> mp; ll a[maxn]; ll b[maxn]; ll fwt[2*maxn]; l...
#include "bits/stdc++.h" #include <chrono> #include <random> #include <ext/pb_ds/assoc_container.hpp> #define INF 1000000007 #define F first #define S second #define PB push_back #define MP make_pair #define REP(i,a,b) for (int i = a; i < b; i++) #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <map> #include <queue> #include <iomanip> #include <set> #include <tuple> #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std...
#include <bits/stdc++.h> using namespace std; //↓AC-library使うなら //型関係 using Graph = vector<vector<int>>; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> pll; typedef priority_queue<int, vector<int>, greater<int>> PQ;//昇順priority_queue typedef unsigned long long int ull; typedef vector<int> vi; typ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; using vl = vector<ll>; /* short */ #define pb push_back #define mp make_pair #define Fi first #define Se second #define ALL(v) begin(v), end(v) #define RALL(v) rbegin(v), rend(v) /* REPmacro */ #define FOR(i, a, b) for(int i...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; ...
#include <bits/stdc++.h> using namespace std; #define set_precision(ans,l) cout << fixed << setprecision(l)<<ans; #define rep(i, a, b) for (int i = a; i < b; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define vi vector<int> #define vl vector<long long int> #define Vi vector<vector<int>> #define vpi vector...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include <bits/stdc++.h> using namespace std; int main(void){ int n; cin>>n; vector<long long> data(n); for(int i=0;i<n;i++){ if(i==0){ cin>>data.at(i); continue; } if(i%2==1){ int a; cin>>a; data.at(i)=data.at(i-1)-a; ...
#include <iostream> #include <string> #include <vector> #include <deque> #include <algorithm> #include <math.h> #include <iomanip> #include <map> #include <sstream> #define INF 1000000009 #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using p = pair<int, int>; int main() { ...
//int a = s - '0'; 文字から数字 //小文字から大文字 //transform(a.begin(), a.end(), a.begin(), ::toupper); //map 全探索 //auto begin = p.begin(), end = p.end(); //for (auto it = begin; it != end; it++) {} //mapのキー:it->first mapのバリュー:it->second //大文字判定 isupper(文字) 小文字判定 islower(文字) //do{}while(next_permutation(ALL(配列))) //小文字に対応する文字コード:S...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; typedef unsigned long long ull; constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/ #de...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <utility> #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <limits> #include <chrono> #include <ctime> #include <random> #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i...
/** * Dont raise your voice, improve your argument. * --Desmond Tutu */ #include <bits/stdc++.h> using namespace std; const bool ready = []() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); return true; } (); using ld=long double; const ld PI = acos((ld)-1); usin...
#include<bits/stdc++.h> typedef long long ll; //#define ll long long #define int long long //#define ull unsigned long long //#define PI pair<int,int> //#define PII pair<int,PI> //#define PI pair<ll,int> //#define endl "\n" using namespace std; const int maxm=2e3+5; const int p=1e4; int read(){ string s;cin>>s; ...
#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> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const...
#include <bits/stdc++.h> #define debug(var) do{std::cout << #var << " :";std::cout << std::endl;view(var);}while(0) template<typename T> void view(T e){ std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if...
#include <bits/stdc++.h> using namespace std; typedef long long int lld; typedef pair<int,int> pi; typedef pair<lld,lld> pl; typedef pair<int,lld> pil; typedef pair<lld,int> pli; typedef vector<int> vit; typedef vector<vit> vitt; typedef vector<lld> vlt; typedef vector<vlt> vltt; typedef vector<pi> vpit; typedef vector...
#include <bits/stdc++.h> using namespace std; #define co(n) cout<<n<<endl; const double eps=1e-10,pi=3.1415926535898; const int mod=998244353,maxn=5e3+10; int T,n,m,k,x,y; long long dp[maxn][15],vis[maxn][15]; long long fac[maxn]={1,1},inv[maxn]={1,1},fac_inv[maxn]={1,1}; void init() { for (int i=2;i<maxn;++i) { ...
// Template #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <iomanip> #include <tuple> #include <utility> #include <queue> #include <set> #include <map> #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (int)(n); ++i) #define rep3(i, l, r) for (i...
#include <bits/stdc++.h> #define fi first #define se second #define sz(v) ((int)v.size()) #define all(v) (v).begin(), (v).end() #define pb push_back using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; int n; int S,E; int ans[200010],cur; bool chk[200010]; vector<int> g[200010];...
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() using namespace std; constexpr int inf = 1 << 30; constexpr long long llinf = 1LL << 62; constexpr int mod = 1000000007; // 998244353; constexpr int ...
#include<bits/stdc++.h> using namespace std; int main() { int64_t N; cin >> N; vector<int64_t> A(N), F(N, 0); int64_t curPos = 0, curMoves = 0, maxPos = 0; for (int64_t i = 0; i < N; ++i) { cin >> A[i]; curMoves += A[i]; F[i] = max((int64_t)0, curMoves...
/* Author : Chandan Agrawal College : Poornima College of Engg. jaipur, Raj Mail : chandanagrawal23@gmail.com " when you are not practicing someone else is , and the day u meet them u will lose " */ #include<bits/stdc++.h> #include<stdio.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin...
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 9; int a[N], b[N], p[N], sk[N], top; bool vis[N]; inline bool check(int j){ return !(a[j] <= b[p[j]] && p[j] != j); } int main(){ int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", a + i); for (int i = 1; i <= n; ++i...
#include<bits/stdc++.h> using namespace std; #define M 998244353 #define N 200000 typedef long long int LL; LL fact[301],invfact[301],sum[301],sum2[301]; LL ap[N][301],p2[301]; LL mult(LL a, LL b){ return a*b%M; } LL add(LL a, LL b){ return (a+b+M)%M; } LL c(LL n, LL k){ return mult(fact[n],mult(invfact[k],...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define DIV 998244353 #define INF LONG_MAX/3 #define bit(n) (1LL<<(n)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, cons...
// Pratiyush Mishra #include <bits/stdc++.h> #define ull unsigned long long int #define ll long long int #define LL_MAX 9223372036854775807 #define pb push_back #define pf push_front #define mp make_pair #define popb pop_back #define vl vector<ll> #define pl pair<ll,ll> #define bs(v, x) binary_search(v.begin(), v.end(...
#include<iostream> #define minx(a,b) ((a)<(b)?(a):(b)) using namespace std; int n,m,i,j,f[2000][2000],a[2000],b[2000]; int main(){ cin>>n>>m; f[0][0]=0; for(i=1;i<=n;++i)cin>>a[i],f[i][0]=i; for(i=1;i<=m;++i)cin>>b[i],f[0][i]=i; for(i=1;i<=n;++i){ for(j=1;j<=m;++j){ f[i][j]=minx(f[i-1][j],f[i][j-1])+1; f[i...
#include<bits/stdc++.h> #define rep(i,j,n) for(int i = (j); i < (n); ++i) using namespace std; #define pri(str) cout << str << endl using ll = long long; using P = pair<int, int>; const ll MX = 1e18; const long double PI = acos(-1); template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; ...
#include <bits/stdc++.h> using namespace std; // clang-format off // #include <atcoder/all> // using namespace atcoder; // using mint = modint1000000007; // using mint = modint998244353 using ll = int64_t; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v) cin >> a; return is...
#include <stdio.h> int main(){ int N; scanf("%d",&N); int A[N],P[N],X[N]; int a,b,c; long long d=1000000000001; int e=0; for(a=0;a<N;a++) { scanf("%d %d %d\n",&A[a],&P[a],&X[a]); } for(b=0;b<N;b++) { if(X[b]-A[b]>0) { if(d>P[b]) { d=P[b]; } } else e++; } if(e!=N) printf("%lld",d); else ...
//CODED BY SUMIT KUMAR PRAJAPATI #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pl; #define PI 3.1415926535897932384626 #define pb push_back #define mk make_pair #define ff first #define ss second #define watch(x) ...
/* 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; typedef long long ll; #define Vi vector<int> #define for_(i, a, b) for(int i = (a);i < (b);++i) #define ford_(i, a, b) for(int i = (b)-1;i >= (a);--i) #define rep(i, n) for_(i, 0, n) #define repd(i, n) rfor_(i, 0, n) int ctoi(const char c){ if('0' <= c && c <= '9') retur...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; using vi = vector<int>; int main(){ int a, b; cin >> a >> b; int plus = 2000*b - a + 1; int minus = -2000*a - b + 1; rep(i,a){ printf("%d ", plus + 2*i); } rep(i,b){ printf("%d%c", minu...
#include<bits/stdc++.h> using namespace std; int main(){ int n; long long k; cin >> n >> k; long long dp[4][3000005]={0}; dp[0][0]=1; for(int i=0;i<3;i++){ for(int j=0;j<=i*n;j++){ dp[i+1][j+1]+=dp[i][j]; dp[i+1][j+n+1]-=dp[i][j]; } for(int j=1;j<=(i+1)*n;j++){ dp[i+1][j]+=dp...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main() { ll mod = 1e9+7; int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i]; vector<vector<ll>> sum(N, vector<ll>(2, 0)), cnt(N, vector<ll>(2, 0)); sum[0][0] = A[0]; cnt[...
#include <iostream> #include <algorithm> #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> #include <deque> #include <valarray> #include <unordered_map> #include <unordered_set> #include <array> #include <cassert> ...