code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
//clear adj and visited vector declared globally after each test case //check for long long overflow //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod; //Incase of close mle change language to c++17 or c++14 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long lon...
#include "bits/stdc++.h" #define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define endl '\n' #define all(V) (V).begin(), (V).end() using namespace std; typedef long long ll; int main() {fio; int N; cin >> N; vector <int> A(N); ll ans = 0; for(int i = 0; i < N; i++) { cin >> A[i]; if(i % 2) A[...
#include <iostream> #include <algorithm> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <string.h> #include <vector> #include <queue> #include <cmath> #include <complex> #include <functional> #include <numeric> #include <iomanip> #include <cassert> #include <random> #include ...
#include<iostream> using namespace std; int main() { string s; cin>>s; for(int i=0;i<s.size();i++) { if(i%2==0) { if(s[i]<'a'||s[i]>'z') { cout<<"No";return 0; } } else{ if(s[i]<'A'||s[i]>'Z') { ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll> pql; typedef set<ll> sl; typedef pair<ll, ll> pl; ty...
#include <iostream> #include <vector> using namespace std; void sub(int n, int *p, vector<int> &ans, int k){ for(int c = 0; c < 20; c++){ bool f = true; for(int i = n - 3; i < n; i++){ if(p[i] != i) f = false; } if(f) return; else{ if(k % 2 == (n - 2)...
#include<bits/stdc++.h> using namespace std; int n,a[100010]; inline int read() { int x=0,w=0;char ch=0; while(!isdigit(ch)){w|=ch=='-';ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} return w?-x:x; } int gcd(int N,int M) {while(N^=M^=N^=M%=N);return M;} int main() { n=read(); for(int i=1...
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10; int a[N]; int n; int gcd(int x,int y){return (y==0) ? x : gcd(y,x%y);} signed main() { scanf("%lld",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); int s = a[1]; for(int i=2;i<=n;i++) s = gcd(s,a[i]); printf("%lld\n",...
#include <bits/stdc++.h> using namespace std; long long dp[205][12]; int n; int main() { cin >> n; for(int i = 1; i <= n; i++) { dp[i][1] = 1; } for(int i = 2; i <= 12; i++) { for(int j = 1; j <= n; j++) { for(int k = 1; k < j; k++) { dp[j][i] += dp[k][i - 1...
#include<bits/stdc++.h> using namespace std; int main(){ int L; cin >> L; L --; long long answer = 1; vector<bool> check(12, true); for(int n = L-10; n <= L; n++){ int n_before = n; for(int r = 11; r >= 2; r--){ if(check.at(r)){ if(n_before % r == 0){ n_before /= r; ...
//Codeforcesで128bit整数を使いたいとき //→__int128_tを使う&GNU C++17 (64)で提出する //インクルードなど #include<bits/stdc++.h> using namespace std; typedef long long ll; //イテレーション #define REP(i,n) for(ll i=0;i<ll(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#i...
#include <bits/stdc++.h> using namespace std; int n, t, a[100]; vector<int> l, r; void dfs(int dep, int sum) { if (sum > t) return; if (dep > (n >> 1)) { l.push_back(sum); return; } dfs(dep + 1, sum); dfs(dep + 1, sum + a[dep]); } void dfs2(int dep, int sum) { if (sum > t) return; if (dep > n) { r.push_...
#include <algorithm> #include <iostream> #include <cstring> using namespace std; char cc[64]; int maxdigit(int n) { return n == 0 ? 0 : max(maxdigit(n - 1), cc[n - 1] - '0'); } bool ok(int n, long long b, long long m) { long long x = 0; for (int i = 0; i < n; i++) { if (x > (m - (cc[i] - '0')) / b) return f...
//----AUTHOR:developer.eeshan----/ #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ff first #define ss second #define it(a, x) for (auto &a : x) #define ll long long #define ld long double #define pb push_back #define ppb pop_back #define pii pair<int, int> #define pll pair<ll, ll> #define vi ...
#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 rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define ALL(x) x.begin(), x.end() using ll = long long; using pii = pair<int, int>; const int INF = 1e9; struct City { int x, y, z; City() {} City(int x, int y, in...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define ll long long #define pp pair<ll,ll> #define ld long double #define all(a) (a).begin(),(a).end() #define mk make_pair int inf=1000001000; ll INF=2e18; ll MOD=1000000007; ll mod=998244353; int main() { int n; cin >>...
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n+1]; for(int i=0; i<n; i++){ cin>>a[i]; } int ans=0; int m=-1; sort(a,a+n); int mx=a[n-1]; for(int i=2; i<=mx; i++){ int c=0; for(int j=0; j<n; j++){ if(a[j]%i...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define len(x) int((x).size()) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define randint(n) uniform_int_distribution<int>(1, (n))(rng) int main() { ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long int ll; #define int ll using vi = vector<int>; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; bitset<100001> dp; dp[0]=1; int tot = 0; rep(i,n){ ...
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <tuple> #include <utility> #include <vector> #define rep(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<cstdlib> #include<map> #include<ctime> #include<queue> #define mp make_pair #define zjx printf("%d\n", #define AK ans #define IOI ); #define maxn 200005 #define lson now<<1 #define rson now<<1|1 using nam...
#include <bits/stdc++.h> using namespace std; const int N = 105; int f[N][2]; int main() { int a,b,x,y;scanf("%d%d%d%d",&a,&b,&x,&y); memset(f,0x3f,sizeof f); f[a][0] = 0; for(int i = a;i <= 100;++i) { f[i][0] = min(f[i][0],f[i][1] + x); f[i][1] = min(f[i][1],f[i][0] + x); ...
#include <iostream> #include <algorithm> using namespace std; int main() { double sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; if (gx < sx) { swap(sx, gx); swap(sy, gy); } printf("%.10lf", sx + (gx - sx) * sy / (sy + gy)); return 0; }
#include <iostream> #include <algorithm> #include <vector> #include <numeric> #include <string> using namespace std; #define SIZE 200000 ////////// Mod #include <iostream> using namespace std; class Mod { public: const long MOD = 1000000007; //const long MOD = 17; const int MaxIntPower = 30; Mod(long v = 0)...
/* Written By mafailure */ #define ill //In the name of God #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> // for less using namespace std; using namespace __gnu_pbds; #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)...
#include <bits/stdc++.h> using namespace std; #define ll long long #define loop(i,l,n)for(int i=l;i<n;i++) #define dloop(i,l,n)for(int i=l;i>=n;i--) #define read(x) cin>>x #define print(x) cout<<x bool compare(pair<int,int>p1,pair<int,int>p2){ if(p1.first>p2.first)return true; else if(p1.first==p2.first){ if(p...
#include "bits/stdc++.h" using namespace std; int main() { int A, B; cin >> A >> B; int type = -1; if ((A + B >= 15) && (B >= 8)) { type = 1; } else if ((A + B >= 10) && (B >= 3)) { type = 2; } else if ((A + B >= 3)) { type = 3; } else { type =...
#include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #define maxn 51 #define ll long long #define mo 998244353 using namespace std; int n,m,i,j,k,a[maxn][maxn],fa[maxn],g[maxn]; int father(int x){return (fa[x]==x)?x:fa[x]=father(fa[x]);} void link(int x,int y){x=father(x),y=father(y);if (x!=y) g[y]+...
#include <bits/stdc++.h> using namespace std; long long cur[101][10001], pre[101][10001]; long long MOD = 998244353; int main() { int N; cin >> N; vector<int> W(N); for(int i = 0; i < N; i++) { cin >> W[i]; } pre[0][0] = 1LL; int sum = 0; for(int i = 0; i < N; i++) sum += W...
#include <bits/stdc++.h> #include <vector> #include<math.h> #include<string.h> using namespace std; #define MAX 300005 #define MOD 1000000007 #define INF 1000000000000000000 #define EPS 0.0000000001 #define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL) #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_d...
//Author: RingweEH #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #define ll long long #define db double using namespace std; int min( int a,int b ) { return a<b ? a : b; } int max( int a,int b ) { return a>b ? a : b; } int read() { int x=0,w=1; char ch=getchar(); while ( ch>'9' |...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; #define rep(i, j, n) for (int i = j; i < (n); ++i) #define...
#include <iostream> using namespace std; int main(){ unsigned int a, b; cin >> a >> b; unsigned long max; max = 2 * a + 100; cout << max - b << endl; return 0; }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define si(a) scanf("%d",&a) #define si2(a,b) scanf("%d%d",&a,&b) #define si3(a,b,c) scanf("%d%d%d",&a,&b,&c) #define sl(a) scanf("%lld",&a) #define sl2(a,b) scanf("%lld%lld",&a,&b) #define sl3...
#include <bits/stdc++.h> using namespace std; int N,M; vector<int> lst[2000]; bitset<2000> visited; queue<int> q; int main() { scanf("%d %d", &N, &M); for (int i = 0; i < M; ++i) { int u,v; scanf("%d %d", &u, &v); u--, v--; lst[u].push_back(v); } int ans = 0; for (int i = 0; i < N;...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb p...
/************************************************************************* > File Name: main.cpp > Author: Song > Mail: 2675791037@qq.com > Created Time: 四 11/19 08:58:42 2020 ************************************************************************/ #include <iostream> #include <algorithm> #include <iomanip> #inc...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) using ll = long long; const ll INF = 1LL << 60; using pll = pair<ll, ll>; int main() { ll A, B; cin >> A >> B; ll cut = 0, V = 501510; rep(i, A) { cout << V << " "; cut += V; V--; } V = -1; rep(i, B-1) {...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> // Picasso didn't learn to paint by watching lectures /* * coder :: ATUL_PANDEY_2608 * >>>...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int a, b; cin >> a >> b; int c = a + b; if (c >= 15 && b >= 8) { cout << 1; } else if (c >= 10 && b >= 3) { cout << 2; } else if (c >= 3) { cout << 3; } else { cout << 4; } cout...
/* * Author: Moon_light * Solution: */ #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define lowbit(x) ((x)&(-x)) #define sz(x) ((int)x.size()) #define fr(x) freopen(x,'r',stdin)...
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout<<fixed<<setprecision(10) #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #define P...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i,n) for(ll i=0;i<(n);++i) #define OREP(i,n) for(ll i=1;...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pob pop_back void solve() { int a,b,c,d; cin>>a>>b>>c>>d; cout<<(a*d)-(b*c); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("in...
// International Master sm0016 #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define raftaar ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; const ll MOD1=1000000007; const ll MOD2= 998244353; const int N=1e6+6; int main(){ raftaar int ...
#include<ctime> #include<cstdio> #include<cctype> #include<cstring> #define ll long long using namespace std; const ll N=3e6+7; ll read() { char c; ll x=0,f=1; while(!isdigit(c=getchar())) f-=2*(c=='-'); while (isdigit(c)){ x=x*10+(c-48)*f; c=getchar(); } return x; } ll n,k,t,sum,f[5][N]; ll c[N]; void add(...
#include <bits/stdc++.h> int n; long long k, dp[4][3000005]; int main() { std::cin >> n >> k; for (int i = 1; i <= n; ++i) dp[1][i] = 1; for (int i = 2; i <= 3; ++i) { for (int j = 1; j <= i * n; ++j) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1]; for (int j = i * n; j > n; --j) dp[i][j] -= dp[i][j - n]; ...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <map> #include <queue> #include <set> #include <algorithm> #include <numeric> #include <climits> using namespace std; int main(void) { float a, b; cin >> a >> b; cout << b / 100.0 * a << endl; return 0; }
/* dont stick to an approach */ #include <iostream> #include <iomanip> #include <cmath> #include <string> #include <algorithm> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> #include <numeric> #include <cstdlib> #include <bitset> #include <chr...
#include <iostream> using namespace std; unsigned long long a,n,cnt=0; int d; void calc(){ a=1000;d=1; while(a*1000<=n){ a*=1000; d++; } cnt+=d+(n-a)*d; } int main(void){ cin>>n; while(n>=1000){ calc(); n=a-1; } cout<<cnt<<endl; }
#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 rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x)...
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i<(n); ++i) #define all(a) a.begin(), a.end() using namespace std; using P = pair<int, int>; using ll = long long; using vi = vector<ll>; using vv = vector<vi>; int main(){ int n; cin >> n; vv x(n, vi (3, 1)); rep(i,n)cin >> x[i][0] >> x[i][1]; ...
#pragma GCC optimize(3,"Ofast","inline") #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 ll read() { int x=0,w=1; char c=getchar(); while(c<'0'||c>'9') ...
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <stack> #include <algorithm> #include <random> #include <fstream> using ll = long long int; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = (ll)(1e9+7); #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %...
#if __has_include(<atcoder/all>) #include <atcoder/all> #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, ll>; #define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++) #define rrep(i, a, b) for(int i = (int)(a); i >= (int)(b); i--) const ll INF ...
/* Author : Anurag Bhatt * Date : 2021-05-15 17:32:03 */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<pi> vpi; #define mp make_pair #define sz(x) (int)(x).size() #define all(x) begin(x), end(x) #def...
/*if ((double) ((double)(clock() - cl)/(double)CLOCKS_PER_SEC)>1.85) {break;}*/ //#pragma GCC optimize ("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long long #define double long double #define ft first #define sc second #define pb push_back #define booost ios_base::sync_with_stdi...
#include<bits/stdc++.h> #define rep(i,n) for ( int i=0; i< (n); ++i ) using namespace std; using ll = long long; using P = pair<int,int>; int main(){ ll n; int m; cin >> n >> m; vector<ll> a(m),sec(0); rep(i,m) cin >> a[i]; a.push_back(n+1);a.push_back(0); sort(a.begin(),a.end()); rep(...
#include <bits/stdc++.h> #define all(V) V.begin(),V.end() #define pi 3.1415926535897932384626 #define fi fixed<<setprecision(13) #define MOD 1000000007 #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define REP(i, n) for (ll i = 1; i <=(ll)(n); i++) #define reps(i,k,n) for (ll i = (ll)k; i < (...
#include <iostream> #include <string> #include <sstream> using namespace std; int main(void){ int N, K; cin >> N >> K; int sum = 0; for(int z=1; z <= N; ++z) { for(int i=1; i <= K; ++i) { sum = sum + z * 100 + i; } } cout << sum << endl; ...
#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 << 29; const ll mod = 1000000000+7; const int...
/* Author : Anurag Bhatt * Date : 2021-05-22 17:35:47 */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<pi> vpi; #define mp make_pair #define sz(x) (int)(x).size() #define all(x) begin(x), end(x) #def...
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define FS ios::sync_with_stdio(0); cin...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i, n) FOR(i,n,0) #define OF64 std::setprecision(40) const ll MOD = 1000000007; const ll INF = (ll) 1e15; ll cmb(ll L) { ll p = L; ll n = 11; l...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; unsigned long long int binomialCoeff(int n, int k) { unsigned long long int C[n + 1][k + 1]; int i, j; // Caculate value of Binomial Coefficient // in bottom up manner for (i = 0; i <= n; i++) { for (j = 0;...
#include <iostream> #include <map> using namespace std; int main() { int n; string s; cin >> n >> s; map<pair<int, int>, int> pre; pre[{0, 0}] = 1; int at = 0, cg = 0; int ans = 0; for (char c : s) { if (c == 'A') at++; if (c == 'T') at--; if (c == 'C') cg++; if (c == ...
#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 <complex> #include <string> #include <cstring> #include <chrono> ...
#include<bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; const double pi=acos(-1.0); #define rep(i, n) for (int i = 0; i < (int)(n); i++) int max(int a,int b){if(a>b){return a;}return b;} int min(int a,int b){if(a<b){return a;}return b;} int main(void){ int n; int ans; cin>>n; ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; cout << N-1 << endl; }
#include"bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define all(v) begin(v), end(v) #define inf (int)(4e18) #define N (int)(2e5 + 10) int isPos(int x, int n, int i) { if (i > 2) return 0; int len = 3 * (1e10); return 3 * (x - 1) + i + n - 1 < len; } bool check(strin...
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <queue> #include <stack> #include <cstdlib> #include <map> #include <iomanip> #include <set> #include <functional> #include <stdio.h> #include <ctype.h> #include <random> #include <string.h> #include <unordered_map>...
#include <bits/stdc++.h> using namespace std; #define int long long #define bitcount(x) (int)__builtin_popcount(x) int n, m, dp[19][1<<19] ; vector <pair<int, int>> g[20] ; int fun(int idx, int mask) { int &ans = dp[idx][mask] ; if (ans != -1) return ans ; ans = 0 ; bool ok = true ; for...
#include <bits/stdc++.h> using namespace std; void f(string &X, string &Y, int t, int a, int b, int N) { if (t == 2) { swap(X, Y); return; } if (a < N && b < N) { swap(X.at(a), X.at(b)); } else if (a < N && b >= N) { swap(X.at(a), Y.at(b-N)); } else if (a >= N &...
#include <bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%lld",&(x)); #define pb push_back #define fi first #define se second int A[55]; int P[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}; int B[55]; int ans = -1; int n; void dfs(int x){ if(x == 15){ int y = 1; for(...
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if(c==0) { if(a>b) cout<<"Takahashi\n"; else cout<<"Aoki\n"; } else { if(b>a) cout<<"Aoki\n"; else cout<<"Takahashi\n"; } return 0; }
#include<iostream> #include<string.h> #include<bits/stdc++.h> #include<cctype> #include<cstring> using namespace std; int main() { string s; char c; int flag1=1,flag2=1; cin>>s; int l = s.length(); for (int i = 0; i < l; i+=2) { if(i==l) break; c=s.at(i); if(i...
#include <cstdio> #include <iostream> #include <cassert> #include <string> #include <algorithm> #include <cstring> #include <utility> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #include <cmath> #include <deque> #include <random> #include <chrono> #include <numeric> #include <unord...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long #define ld long double #define pii pair<int,int> #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rep(i,x,y) for(int i=x; i<y; i++) #defi...
// Problem: E - White and Black Balls // Contest: AtCoder - AtCoder Beginner Contest 205 // URL: https://atcoder.jp/contests/abc205/tasks/abc205_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include <bits/stdc++.h> using namespace std; #define SPEED ios_base::sy...
#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; typedef long double ld; typedef pair< ll, ll > Pi; using vl = vector<ll>; using vs = vector<string>; using vvl = vector<vector<ll>>; #define rep(i,n) for(int i=0;i<(n);i++) #define rep2(i,n) for(int i=1...
#include <bits/stdc++.h> #pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #define hh "\n" #define fi first #define se second #define inf 0x3f3f3f3f #define mapa(a,b) make_pair(a,b) #define mm(a,b) memset(a,b, sizeof(a)); #define For(i,a,b) for(int i=a;i<=b;i++) #define Rof(i,a,b)...
#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5 + 10; int n, ans; int a[N], f[N]; vector < int > v; main() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i], f[a[i]] = i; for(int i = 1; i <= n; i++) { if(f[i] != i) { if(f[i] > i) { for(int j = f[i]; j > i; j--) { f...
#include <bits/stdc++.h> using namespace std; float inf = numeric_limits<float>::infinity(); using ll = long long; struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for(int i = 0; i < N; i++) par[i] = i; } int root(int x...
#include "iostream" #include "vector" #include "queue" #include "stack" #include "algorithm" #include "string" #include "cstring" using namespace std; typedef long long ll; int main() { int n; cin >> n; cout << (n + 99) / 100 << endl; }
#include<bits/stdc++.h> using namespace::std; long long n; int solve(){ int ans = 0; for(int len = 1; 2 * n + len - 1ll * len * len > 0; len++){ long long sum = 2 * n + len - 1ll * len * len; int d = 2 * len; if(sum % d == 0) ans += 2; } return ans; } int main(){ scanf("%lld", &n); printf("%d\n", solve()...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #define vpii vector<pair<int,int>> #define vpll vector<pair<ll,ll>> #define fr(i,k,n) for (int i = k; i < n; ++i) #define fri(i,k,n) for (int i = k; i >= n...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin(...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); const int MOD = 998244353; int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; A[i] += i; } vector<int> B(N); for (int i = 0; i < N; ++i) { cin >> B[i]; B[i] += i; ...
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define f first #define s second set<pi> st; const int nax=2e5+10; int a[nax],b[nax]; struct node { int n; int bit[nax+1]; node(){} node(int _n):n(_n){ memset(bit,0,sizeof(bit)); } void add(int p...
// coached by Dukkha and rainboy #include <algorithm> #include <iostream> using namespace std; const int N = 100; int aa[N], bb[N], cc[N], dd[N]; int pp[N], qq[N], ii[N]; int rr[N], ss[N], jj[N]; int cross(int x1, int y1, int x2, int y2) { return x1 * y2 - x2 * y1; } int dot(int x1, int y1, int x2, int y2) { ret...
// 問題の URL を書いておく // #include <bits/stdc++.h> using namespace std; //#define ENABLE_PRINT #if defined(ENABLE_PRINT) #define Print(v) \ do {\ cout << #v << ": " << v << endl; \ }while(0) #define PrintVec(v) \ do {\ for(int __i = 0; __i < v.size(); ++__i) \ { \ cout << #v << "[" << __i << "]: "...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define st first #define nd second #define endl '\n' #define what_is(x) cerr << #x << " is " << x << endl; #define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set #define...
#include <iostream> using namespace std; int main() { // C - Rotate char a,b,c; cin>>a>>b>>c; cout<<b<<c<<a; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; int main() { ll S, P; cin >> S >> P; vector<ll> div; for (ll i = 1; i * i <= P; ++i) { if (P % i == 0) { div.push_back(i); if (i * i != P) d...
#include <iostream> using namespace std; long S, P; int main() { cin >> S >> P; for ( int i = 0; i < 10000000; i++ ) { if ( ( i * (S-i) ) == P ) { cout << "Yes" << endl; goto END; } } cout << "No" << endl; END: return 0; }
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long int lst[3][11]; int nlst[10]; bool check(void) { int num[3] = {0}; for (int i = 0; i < 3; i++) { if (nlst[lst[i][0]] == 0) return false; for (int j = 0; j < lst[i][10]; j++) { num[i...
#include <bits/stdc++.h> #define rep3(i, s, n, a) for (long long i = (s); i < (long long)(n); i += a) #define rep2(i, s, n) rep3(i, s, n, 1) #define rep(i, n) rep2(i, 0, n) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using Pll = pair<ll, ll>; int main() { ...
#include <bits/stdc++.h> //#include <chrono> #pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using v...
#include<bits/stdc++.h> using namespace std; #define ll long long int parent[200005],a[200005],b[200005]; ll prop[200005]; vector<int>edges[200005]; void dfs(int u,int p) { parent[u] = p; for(int v:edges[u]) { if(v==p) continue; dfs(v,u); } return ; } void dfs2(int u,int p) { pr...
#include<bits/stdc++.h> #define rep(i,n) for(ll i=0;i<ll(n);i++) #define reps(i,n) for(ll i=1;i<ll(n);i++) #define rrep(i,n) for(ll i=ll(n);i>=0;i--) #define ALL(x) x.begin(),x.end() #define FOR(i,a,b) for(ll i=a;i<=b;i++)//使いにくかったら消す #define len(x) x.length()//配列の長さ #define SIZE(x) x.size()//vectorのサイズ #define NPOS st...
#pragma GCC optimize("O3") #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include...
#include "bits/stdc++.h" using namespace std; #define dbg(var) cout<<#var<<"="<<var<<" " #define nl cout<<"\n" #define fr(i,n) for(int i=0;i<n;i++) #define rep(i,a,n) for(int i = a; i <= n; i++) #define per(i,a,n) for(int i = a; i >= n; i--) #define vi vector<int> #define pb push_back #define itr(i,v) for(auto &i:v) #...
#include <bits/stdc++.h> //#include <chrono> //#pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using ve...
#include <iostream> #include <map> #define int long long using namespace std; const int MAXN = 4e5 + 10; int f[MAXN], g[MAXN]; int C(int n, int k) { int sum = f[k] + f[n - k]; if (f[n] > sum) { return 0; } return g[n] * g[n - k] * g[k] % 3; } signed main() { g[0] = 1; f[1] = 0; g[1] = 1; for (int i = 2; i ...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i=0; i<(n); ++i) #define RREP(i, n) for(int i=(n);i>=0;--i) #define FOR(i, a, n) for (int i=(a); i<(n); ++i) #define RFOR(i, a, b) for(int i=(a);i>=(b);--i) #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(),(x).end() #define DUMP(x) c...
#include <bits/stdc++.h> #define fi first #define se second #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define eps 1e-18 #define pi acos(-1) #define ar array #define int int64_t using namespace std; template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v); templat...
#include <bits/stdc++.h> #define FOR(i,x,n) for(int i=x; i<n; i++) #define F0R(i,n) FOR(i,0,n) #define ROF(i,x,n) for(int i=n-1; i>=x; i--) #define R0F(i,n) ROF(i,0,n) #define WTF cerr << "WTF" << endl #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define F first #define S second #d...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> using namespace std; const int MOD = 1000000007; vector<long long> fac, finv, inv; void InitializeCombination(int COMMAX){ fac.push_back(1LL); fac.push_back(1LL); finv.push_back(1LL); finv.push_back(1LL); ...
#pragma GCC optimize("Ofast") #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--) #de...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; #define mod ((int)1e9+7) #define lim 1000000000000000007 #define lim1 18446744073709551615 //Unsigned #define sq(a) ((a)*(a)) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define mms(v,i) memset(v,i,siz...
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstd...
#include <bits/stdc++.h> using namespace std; using namespace chrono; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("error.txt", "w", stderr); template <ty...
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,...
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d); if(a==c&&b==d)return puts("0"),0; if(a+b==c+d||a-b==c-d||abs(a-c)+abs(b-d)<=3)return puts("1"),0; if(abs(a-b-c+d)<=3||abs(a+b-c-d)<=3||((a+b)%2)==((c+d)%2))return puts("2"),0; puts("3"); return 0; }
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back #define ALL(x) (x).begin(),(x).end() #define REP(i,n) for(int i=0;i<(n);i++) #define REP1(i,n) for(int i=1;i<(n);i++) #define REP2(i,d,n) for(int i=(d);i<(n);i++) #define RREP(i,n) for(int i=(n);i>=0;i--) #define CLR(a)...
#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 <vector> #include <utility> using namespace std; struct Operation { int M; vector<vector<long long>> op; vector<vector<long long>> sel = { {0, 1, 0, -1, 0, 0, 0, 0, 1}, {0, -1, 0, 1, 0, 0, 0, 0, 1}, {-1, 0, 0, 0, 1, 0, 0, 0, 1}, {1, 0, 0, 0, -1, 0, 0, 0, 1} }; O...
#include <iostream> #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n,m; cin>>n>>m; cout<<(n+m)/2<<" "<<(n-m)/2; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ll MOD = 1e9+7; const int INF=1LL<<30; const string YYY="YES"; const string yyy="Yes"; const string NNN="NO"; const string nnn="No"; template<class T>void chmin(T& a,T b){ if(a>b){ a=b; } } template<class T>void ch...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 500010; ll prime[N] = {0}, num_prime = 0; //prime存放着小于N的素数 int isNotPrime[N] = {1, 1}; // isNotPrime[i]如果i不是素数,则为1 ll n, cnt; ll Not[N]; int Prime() { for (ll i = 2; i < N; i++) { if (!isNotPrime[i]) prim...
#include<iostream> using namespace std; int main(){ int N; cin>>N; int arr[N]; for(int i=0;i<N;i++){ cin>>arr[i]; } int sum=0; for(int i=0;i<N;i++){ if(arr[i]>10) sum+=arr[i]-10; } cout<<sum<<endl; return 0; }
// International Master sm0016 #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define raftaar ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; const ll MOD1=1000000007; const ll MOD2= 998244353; const int N=1e6+6; int main(){ raftaar int ...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define P pair<ll,int> #define PI 3.141592653589793 #define pb push_back #define C complex<double> const int INF = 1001001001; const ll MX = 1e18; const int mod = 998244353; template<class T> inline b...
#include<bits/stdc++.h> using namespace std; #define ff first #define brn "\n" #define ss second #define mk make_pair #define int long long #define pb push_back #define ps(x,y) fixed<<setprecision(y)<<x #define w(x) ...
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <numeric> #include <utility> #include <string> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int ans = min({a, b, c, d}); cout << ans << endl; return 0; }
#include <bits/stdc++.h> //#include <bits/extc++.h> #define int long long #define ll long long //#define ull unsigned ll #define endl "\n" #define pb push_back #define ms(v,x) memset(v, x, sizeof v) #define ff first #define ss second #define td(v) v.begin(), v.end() #define rep(i,a,n) for (int i=(a);i<(n);i++) #define...
#include<bits/stdc++.h> using namespace std; #define LL long long #define pb push_back int n, m, i, j; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; string s, x; cin >> s >> x; vector<int>dp(10); dp[0] = 1; for(i=s.size()-1;i>=0;i--){ vector<int>tmp(10); for(j=0;j<7;j++){ int ps = j*10+...
#include<bits/stdc++.h> #define int long long using namespace std; #define MOD 1000000007 void solve() { int n; cin>>n; int a,b,c; int num = n+1; int ans = 0; vector<vector<pair<int,int>>>gra(num); for(int i=0;i<n-1;i++) { cin>>a>>b>>c; gra[a].push_back({b,c}); ...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
// Problem : B - Abbreviate Fox // Contest : AtCoder - AtCoder Regular Contest 108 // URL : https://atcoder.jp/contests/arc108/tasks/arc108_b // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #define DEBUG fprintf(stderr, "Passing...
#include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; int main(){ int H,W; cin>>H>>W; string fie[510]; for(int i=0;i<H;i++)cin>>fie[i]; int flglis[1010]={0}; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(fie[i][j]=='B')f...
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long li; #define rep(i,n) for(int i=0;i<(n);i++) #define df 0 template<class T> void print(const T& t){ cout << t << "\n"; } template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) co...
#include"bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define all(v) begin(v), end(v) #define mod (int)(1e9 + 7) #define inf (int)(4e18) #define N (int)(2e5 + 10) #define ff first #define ss second /* Clear global containers without fail */ list<pair<int, int>> adjList[10]; int vis[1...
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; int A[n]; map< int,int>P; int mx=-1; for(int i=0;i<n;++i){ cin>>A[i]; P[A[i]]++; mx=max(mx,A[i]); } int c=0; int tot=0;int f=0,g=0; for(int i=0;i<=(mx+1);++i){ ...
// ----------------------------------- // author : MatsuTaku // country : Japan // created : 12/19/20 19:28:51 // ----------------------------------- #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int h,w; cin>>h>>w; int minv...
#include <bits/stdc++.h> #define rep(i,cc,n) for(int i=cc;i<=n;++i) using namespace std; struct P { int id, x, y; }; int chebyshev(P p1, P p2) { return max(abs(p1.x - p2.x), abs(p1.y - p2.y)); } int main() { int n; cin >> n; vector<P> v(n); rep(i,0,n-1) { v[i].id = i; cin >> v[i].x >> v[i].y; ...
#include<cstdio> #include<algorithm> #include<vector> #include<set> #include<queue> #include<string> #include<unordered_map> using namespace std; using ll = long long; constexpr int N = 2e5 + 5; struct Point { int x; int y; int id; }p[N]; bool cmpx(Point a, Point b) { return a.x < b.x; } bool cmpy(Po...
#include<iostream> #include<string> #include<algorithm> #include<cmath> #include<ctime> #include<map> #include<vector> #include<math.h> #include<stdio.h> #include<stack> #include<queue> #include<tuple> #include<cassert> #include<set> #include<bitset> #include<functional> #include <fstream> //#include<bits/stdc++.h>...
#include<bits/stdc++.h> using namespace std; using ll = int64_t; #define rep(i,n) for(int i=0; i<(n); i++) #define ALL(n) n.begin(), n.end() int main(){ int N; cin >> N; if(N % 100 == 0) cout << N / 100; else cout << N / 100 + 1; cout << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> x(N), y(N); for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; } int ans = 0; for (int i = 0; i < N; i++) for(int j = i + 1; j < N; j++) { double slope = (double) (y[j] - y[...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define ff first #define ss second #define pb push_back #define mod 1000000007 #define pl pair<lli,lli> #define vl vector<lli> #define vvl vector<vl> #define INF (lli)2e18 lli slope(lli x1,lli y1,lli x2,lli y2){ auto l = (y2-y1)*(y2-y1); au...
#define pb push_back #define mp make_pair #define fi first #define se second #define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__) #define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();} #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long...
#include <iostream> #include <vector> using namespace std; class Solution{ private: int N, M; public: int solve(int N, int M, vector<int>& A, vector<int>& B){ this->N = N, this->M = M; vector<vector<int>> dp(N, vector<int>(M, -1)); return dfs(A, B, 0, 0, dp); } private: in...
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long #define ll long long #define ld long double using namespace __gnu_pbds; using namespace std; te...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll = long long; struct Edge { ll to; ll cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; #define mp make_pair #define REP(i, n) for (int i = 0; i < (n);...
#include <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; using P = pair<int,int>; vector<int> g[200005]; vecto...
#include<iostream> #include<bits/stdc++.h> #define int long long int #define vi vector<int> #define fo(i,n) for(int i=1;i<=n;i++) #define foo(i,n) for(int i=0;i<n;i++) #define sort(v) sort(v.begin(), v.end()) #define rev(v) reverse(v.begin(), v.end()) #define uniq(v) sort(v); v.resize(unique(v.begin(), v.end())-v.begin...
#include <bits/stdc++.h> using namespace std; typedef long long int lld; #define all(m) m.begin(),m.end() #define sz(m) lld(m.size()) #define pb push_back #define mod 1000000007 #define st first #define nd second #define endl "\n" void swagWaalaFunction() { lld a,b,c,ans=0; cin>>a>>b>>c; ans=21-a-b-c; cout<<ans<...
#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> using namespace std; const int MN = 200012; int n, q; int c[MN]; int id[MN]; set<int> st[MN]; map<int, int> ctr[MN]; int main (void) { ios::sync_with_stdio(false);cin.tie(0); cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> c[i]; id[i] = i; st[i].insert(i); ctr[i][c...
#include <iostream> #include <string> #include <vector> #include <array> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <set> #include <map> #include <bitset> #include <cmath> #include <functional> #include <cassert> #include <iomanip> #include <numeric> #include <memory> #include <ran...
#include<bits/stdc++.h> #define ll long long #define nl "\n" #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define pcase printf("Case %d: ",ca) int ca=1; using namespace std; int main(){ fast; { string n; cin>>n; string x=""; string y; int s = n.size(); int ans = 1; int i = 0, j = s...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; long long int N; int main(void) { cin >> N; if (N == 0) { cout << "Yes" << endl; return 0; } while (N % 10 == 0) { N /= 10; } vector<int> V; long long int K = N; while (K > 0) { V.push_back(K % 10); K /= 10; ...
#line 1 "/workspaces/compro/lib/template.hpp" #line 1 "/workspaces/compro/lib/io/vector.hpp" #include <iostream> #include <vector> #ifndef IO_VECTOR #define IO_VECTOR template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { int size = v.size(); for (int i = 0; i < size; i++) { ...
#include<bits/stdc++.h> #define M 200005 typedef long long ll; using namespace std; char IO; int rd(){ int num=0; while(IO=getchar(),IO<48||IO>57); do num=(num<<1)+(num<<3)+(IO^48); while(IO=getchar(),IO>=48&&IO<=57); return num; } int n; int dp[M][7]; char S[M],T[M]; bool dfs(int x,int rst){ if(x==n+1)return rst...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); ++i) #define Erep(i,n) for(int i = 0; i <= (n); ++i) #define repS(i,s,n) for(int i = s; i < (n); ++i) #define ErepS(i,s,n) for(int i = s; i <= (n); ++i) #define Sort(a) sort(a.begin(), a.end()) #de...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 400010, mod = 1e9 + 7; int e[N], ne[N], h[N], idx, w[N][61], n; ll tar, d[N][2], res; void add(int a, int b, long long c) { e[idx] = b, ne[idx] = h[a]; for (int i = 0; i < 60; ++i) { if (c & 1) w[idx][i] = 1; c /= 2; if (!c) b...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef long int li; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define test ll t; cin >> t; while(t--) #define print_tc(t, c) cout << "Case #" << t << ": " << c << "\n"; ...
#include <bits/stdc++.h> #define DEBUG if(0) #define lli long long int #define ldouble long double using namespace std; const int maxN = 800; int n, k; vector<int> as; int medianPos; int a[maxN][maxN]; int b[maxN][maxN]; int acc[maxN + 1][maxN + 1]; int getSum(int loi, int loj, int hii, int hij) { return acc[hii + ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<vector<int>> G(N); for (int i = 1; i < N; i++) { int p; cin >> p; p--; G[i].emplace_back(p); G[p].emplace_back(i); } vector<int> in(N), out(N); vector...
#include "bits/stdc++.h" using namespace std; using ll=int64_t; using ld=long double; using ull=unsigned long long; template <class T> using grid=vector<vector<T>>; #define ALL(x) x.begin(),x.end() #define rep(iter,from,to) for(ll iter=from;iter<to;++iter) const ll MOD=1e9+7; const ll INF=1e17; //#####################...
// Author : Sarthak Kapoor #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define int ll #define rep(i,n) for(int i=0;i<n;++i) #define repa(i,a,n) for(int i=a;i<n;++i) #define repr(i,n) for(int i=n-1;i>=0;--i) #define ll long long #define pi pair<int,in...
#include <bits/stdc++.h> using namespace std; //左に行きたい各それについて、自分の左でa[i]-iが一致しているやつを見つけて飛び込む //a[i]-iが一致しているやつの中で最大のものを見つけたらそこまでギュッとする #define int long long template<typename T> void fin(T a){ cout<<a<<endl; exit(0); } const int INF=1e9+7; int ans; typedef pair<int,int> P; signed main(){ int n,l;cin>>n>>l; vec...
#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 f first #define int long long #define s second #define pii pair<int,int> using namespace std; const int N=2e5+5,mod=1e9+7,INF=1e15; int t,n,m,u,v,dist[N]; vector<pii>V[N]; priority_queue<pii,vector<pii>,greater<pii> > q; string s; main(){ cin>>n>>m; for(int i=1;i<=m;i++){ cin>>u...
#include <bits/stdc++.h> #define mod 1000000007 #define ll long long int #define endl "\n" #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; void solve() { ll n, i; ll x; cin>>n>>x; ll v[n+9], p[n+9]; for(i=0; i<n; i++) { cin>>v[i]>>p[i]; } ll ...
#pragma warning (disable:4996) #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define ll long long #define REP(i, n) for(int i = 0; i < n; i++) #define SET(a) int a = 0; (void)scanf("%d", &a); #define NMAX 1000 typedef struct { int V; int P; }ALCOHOL; int main() { SET(N); SET(X); ALCO...
#include <bits/stdc++.h> #define int int64_t using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); double a,b; cin>>a>>b; double res=b/a*100; res=100-res; cout<<fixed<<setprecision(18)<<res; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll x,y; unordered_map<ll,ll> k;//h[y]表示将x变成y需要的步数 ll dfs(ll z) { if(z<=x) return x-z; if(k.count(z)) return k[z]; ll re=z-x; if(z%2==0) re=min(re,dfs(z/2)+1); //二倍优先 else re=min(re,min(dfs(z+1),dfs(z-1))+1); return k[z]=re; } in...
#include <bits/stdc++.h> using namespace std; const int64_t MOD = 1e9 + 7; const int64_t MOD2 = 998244353; const int INF = 1e9; int main() { long long h, w; cin >> h >> w; vector<string> s(h); for (int i=0; i<h; i++) { cin >> s.at(i); } vector<vector<long long>> dp(h, vector<long long>(w)); dp.at(0)...
#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> #define rep(x, s, t...
#include <bits/stdc++.h> using namespace std; int main() { int a,b; cin >> a >> b; int c = a+b; if(c >= 15 && b >= 8) cout << "1" << endl; else if(c >= 10 && b >= 3) cout << "2" << endl; else if(c >= 3) cout << "3" << endl; else cout << "4" << endl; }
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #pragma comment(linker, "/stack:200000000") #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 pb push_...
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define FS ios::sync_with_stdio(0); cin.tie(0); cout.t...
#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> using namespace std; struct Ed...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pll pair<ll, ll> #define vll vector<ll> using namespace std; inline void sol() { // ll n, m; cin >> n >> m; vector<pll> adj[n + 1]; for (int i = 0; i < m; i++) { ll u, v, c; cin >> u >> v >> c; adj[u].push_back({c...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0;...
#include <bits/stdc++.h> const int N = 200010; const long long INF = 1ll<<60; const int inf = 0x3f3f3f3f; typedef std::pair<int, int> PairInt; typedef std::pair<long long, int> Pair; const long long mod = 1e9 + 7; int n; std::vector<std::pair<int, long long>> g[N]; int dp[N][60][2]; int mi[100]; int ans; void Dfs(in...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define rep(i,s,e) for(int i=s ; i < e ; i++) #define rrep(i,s,e) for(int i=s ; i > e ; i--) #define srep(i,s,e,j) for(int i=s ; i < e ; i+=j) #define tr(i,x) for(auto i : x) #define inp(a) for(int i=0 ; i...
#include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<=n;i++) #define per(i,a,n) for (int i=n;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()) #define mem(a,b) memset(a,b,sizeof (a)) #defi...
// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T& x, T y){ if(x > y){ x = y; return true...
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ld long double #define TIME clock() * 1.0 / CLOCKS_PER_SEC #define sz(x) (int)(x.size()) template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define mem0(x) memset(x, 0, sizeof (x)) #define mem1(x) memset(x, -1, sizeof (...
#include<bits/stdc++.h> using namespace std; int main(){ char a,b,c; cin>>a>>b>>c; cout<<b<<c<<a; return 0; }
#include <bits/stdc++.h> #include <cmath> using namespace std; using ll = long long; #define for(i, a, b) for (int i=(a); i < (b); i++) #define rep(i, n) for(i, 0, n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() int main () { string s; cin >> s; cout << s[1] << s[2] << s[...
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define rep1(i,n) for (int i = 1; i <= (n); ++i) #define bit(n,k) ((n>>k)&1) //nのk bit目 #define vec(T) vector<T> #define vvec(T) vector<vector<T>> using ll = long long; using ...
#include "bits/stdc++.h" #define rep(i,a,n) for(int i=a;i<=n;i++) #define per(i,a,n) for(int i=n;i>=a;i--) #define pb push_back #define mp make_pair #define FI first #define SE second #define maxn 2000 #define mod 1000000007 #define inf 0x3f3f3f3f using namespace std; typedef long long ll; typedef pair<int,int> pii; ty...
#include <bits/stdc++.h> using namespace std; int main() { int 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> //#include <atcoder/all> using namespace std; //using namespace atcoder; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,cc,n) for(int i=cc...
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <algorithm> #include <utility> #include <deque> #include <stack> #include <bitset> using namespace std; typedef long ...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <utility> #include <tuple> #define REP(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#include <bits/stdc++.h> #define DB double #define LL long long #define MST(a,b) memset((a),(b),sizeof(a)) #ifdef _DEBUG_ #define MRK() cout<<"Mark"<<endl; #define WRT(x) cout<<#x<<" = "<<(x)<<endl; #else #define MRK() ; #define WRT(x) ; #endif #define MAXN 1010000 #define MAXM 2010000 #define MOD 998244353 //10000...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define fi first #define se second #define INF 1000000009 #define LLINF 1000000000000000009LL ...
#include <stdio.h> #include <stack> typedef long long ll; int main(void) { ll i, j, k, n, ans = 0; scanf("%lld", &n); char s[n + 10], t[n + 10]; scanf("%s%s", s, t); std::stack<ll> a, b; for(i = 0; i < n; ++i) { if(t[i] == '1') a.push(i); if(s[i] == '1') { if(b.size()) ans += i - b.top(), b.p...
#define _LIBCPP_DEBUG 0 #include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<ll>>; template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;} template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;} #define rep(i,n) for(ll i=0;i<ll(n);i++) #def...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5; int main(){ vector<pair<int,int>>ans; int n,m;cin>>n>>m; int x=m; if((m>0&&x+2>n)||m<0){ cout<<"-1\n"; return 0; } ans.emplace_back(1,4*x+3); for(int i=0;i<n-1;i++){ ans.emplace_back(4*i+2,4*i+4); } for(auto& i:ans){ ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; if(n == 1) { if(m != 0) cout << -1 << endl; else cout << "1 2" << endl; return 0; } if(m < 0 || m > n - 2) { cout << -1 << endl; return 0; } if(m == 0) { for(int...