code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> #define fi first #define se second #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++) #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define IT iterator #define V vector #define TP template <class o> #define TP...
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <cstdlib> #include <numeric> #include <sstream> #include <iostream> #include <algorithm> #include <functiona...
#include<iostream> #include<bits/stdc++.h> using namespace std; using ll=long long; void test_case(){ int n,k; cin>>n>>k; k=abs(k); int a=2+k,b=2; ll ans=0; while(a<=2*n){ int A=min(n,a-1), B=a-A; int C=min(n,b-1), D=b-C; int cnt_a=1+(min(A-1, n-B)); int cnt_b=1...
#define LOCAL #define _USE_MATH_DEFINES #include <array> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include <stack> #include <list> #include <set> #include <map> #include <unordered_set> #include...
#include<bits/stdc++.h> using namespace std; #define asll unsigned long long #define ULL unsigned long long #define ll long long #define LL long long #define ld long double #define imt long long #define pii pair<long long,long long> #define x first #define fi first #define y second #define se second #define psbk(x) pu...
#include <cstring> #include <cmath> #include <algorithm> #include <string> #include <map> #include <iostream> #include <vector> #include <queue> #include <unordered_map> #include <random> #include <stack> #include <set> #include <list> #include <unordered_set> #define bug(x) cout<<"zdongdebug1: "<<x<<endl; #define bug...
/* written by Pankaj Kumar. country:-INDIA */ #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 ; typedef vector<ll> vl; #define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); /...
#include <bits/stdc++.h> using namespace std; #define double long double #define int long long const int mod = 1e9 + 7; const int N = 1e5 + 50; int a[N]; int n; double getSum(double x) { double ret = 0; for (int i = 0; i < n; i++) { ret += x + (double) a[i] - min((double) a[i], (double) 2.0 * x); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i=0; i < n; i++) // 0 ~ n-1 template<class T> inline bool chmax(T& a, T& b) { if (a < b) { int tmp=a; a=b; b=tmp; return 1; } return 0; } template<class T> inline bool chmin(T& a, T& b) { if (a > b) { int tmp=a; a=b; b=tmp; r...
// Problem: A - Tax Included Price // Contest: AtCoder - AtCoder Regular Contest 118 // URL: https://atcoder.jp/contests/arc118/tasks/arc118_a // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> using namespace std; #define int long long inline int...
#include<bits/stdc++.h> using namespace std; #define ll long long #define FastIO ios_base::sync_with_stdio(false),cin.tie(0) #define f(n) for(int i=0;i<n;i++) #define endl "\n" const double PI = 3.141592653589793238460; #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) int arr[]={1,1,4,4,...
#include <cstdio> #include <cstring> #include <cmath> #include <utility> #include <iostream> #include <functional> #include <bitset> #include <algorithm> #include <vector> #include <forward_list> #include <set> #include <map> #include <queue> #include <deque> #include <stack> #include <tuple> #include <numeric> #includ...
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265358979323 #define ll long long int #define vi vector <int> #define vl vector <ll> #define all(v) (v).begin(),(v).end() #define pb push_back #define ff first #define ss second #define MOD 1000000007 ll power(ll a, ll b) { //a^b ll res = 1; a = a % MOD;...
#include<bits/stdc++.h> using namespace std; namespace Sakurajima_Mai{ #define ms(a) memset(a,0,sizeof(a)) #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ? #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i) #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].t...
#include <bits/stdc++.h> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; } template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os <<...
//#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("section-anchors") //#pragma GCC optimize("profile-values,profile-reorder-functions,tr...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define rrep1(i, n) for (int i = n; i >= 1; i--) #define all(x) x.begi...
#include <bits/stdc++.h> #include"map" #include"string" #include"cmath" #include"cstdio" #include"iostream" #include"cstring" #include"algorithm" #include"vector" using namespace std; typedef unsigned long long ull; typedef long long ll; #ifdef local #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__V...
#include <bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("cpp.in", "r", stdin); #endif int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; int ans = 3; if (abs(r1 - r2) + abs(c1 - c2) <= 6 || ((r1 + c1) & 1) == ((r2 + c2) & 1)) ans = 2; for (int tx, ty, i = 3; i >= 0; i--) for ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define db double #define pii pair<int,int> #define pli pair<ll,int> #define pil pair<int,ll> #define pll pair<ll,ll> #define ti3 tuple<int,int,int> #define mat vector<vector<int>> const int inf = 1 << 30; const ll linf = 1...
#include <iostream> using namespace std; long long int n,goal,t[9][9],ans; bool used[9]; void dfs(int sum,int it,int step){ if(step==n-1){ if(sum+t[it][0]==goal){ ++ans; } return; } for(int i=1;i<n;++i){ if(!used[i]&&t[it][i]+sum<=goal){ used[i]=1; dfs(t[it][i]+sum,i,step+1); used[i]=0; } } } ...
#include <bits/stdc++.h> using namespace std; int64_t MOD = 1000000007; double PI = 3.141592653589793; int main() { int N, K; cin >> N >> K; vector<vector<int>> list(N, vector<int>(N)); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> list[i][j]; vector<int> route...
#include <bits/stdc++.h> // #include <atcoder/all> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb empla...
#include<iostream> #include<algorithm> #include<math.h> #include<cstring> #include<queue> #include<vector> #include<map> #include<set> #include<stack> using namespace std; vector<int> g[100000]; int flag[100000]; int dis[17][100000]; int D[17][17]; int cost[17][131072]; int bin[18]; int DP(int v, int s); int n, m, k; i...
#include<bits/stdc++.h> using namespace std ; #define MOD 1e9 + 7 #define inf 1e18 + 1 #define int long long #define LMAX LLONG_MAX #define IMAX INT_MAX #define LMIN LLONG_MIN #define IMIN INT_MIN #define sort_1(a) sort(a.begin(),a.end()) #define sort_2(a) sort(a.begin(),a.end(),greater<int>()) #define DEBUG_1(v,a) for...
#include<iostream> #include<iomanip> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> #define ull unsigned long long ull n,m,k; int a[75]; int main() { scanf("%lld%lld",&n,&k); while(k) { if(n%200==0)n/=200,k--; else { if(k>=2) { n=n*5+1; k-=2; } else { n=n*10...
#include <cstdio> using namespace std; int main() { int n; double ans = 0; scanf("%d", &n); for (int i = 1; i < n; i++) ans += double(n) / (n - i); printf("%.9lf\n", ans); return 0; }
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair int tt,f[100100],n,p=1e9+7; void prepare(){ f[0]=1; f[1]=1; f[2]=2; for(int i=3;i<=n;i++)f[i]=(f[i-1]+f[i-2])%p; } void solve(){ cin>>n; prepare(); int a[n],ans=0; for(int i=0;i<n;i++){cin>>a[i];} ans+...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b; ++i) int debug = 0; const int N = 5000; int n, x, d, a[N]; set <int> ds, s; main() { cin >> n; rep(i, 0, n) { cin >> a[i]; int d = 1; while (d * d <= a[i]) { if (a[i] % d == 0) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INFint = 1e9+1; const ll INFll = (ll)1e18+1; const int MOD=1e9+7; template <typename T> vector<T> divisor(T n){ vector<T> res; for (T i(1);i*i<=n;i++){ if (n%i==0){ res.push_back(i); // if (i != n/i) res.push_back(n/i); ...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> 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)...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) typedef long long ll; typedef long double ld; typedef pair<int,int> P; constexpr int mod = 1e9+7; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} ...
#include <bits/stdc++.h> using namespace std; #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r)-1; i >= (int)(l); (i) -= 1) template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { a = (a > b ? a : b); } template <typename T1, typename T2> in...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int N; cin >> N; string S, T, U; cin >> S >> T >> U; for (int i = 0; i < N; i++) cout << '0'; for (int i = 0; i < N; i++) cout << '1'; cout << '0' << endl; } }
#include <iostream> #include <string> #include <algorithm> using namespace std; string s; bool cmp(char a, char b){ return a > b; } int main () { int T; cin >> T; string cp = "atcoder"; while (T --){ cin >> s; string temp = s; sort(temp.begin(), temp.end(), cmp); if(temp < cp){ cout << -1 <<"\n"; con...
#include<bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/detail/standard_policies.hpp> // using namespace __gnu_pbds; #pragma GCC optimize("O3") #ifdef LOCAL #include "/Users/lbjlc/Desktop/coding/debug_utils.h" #else #define print(...) ; #define printn(...) ; #de...
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define pb push_back int main(){ int t = 1; // cin >> t; while(t--){ int n; cin >> n; if(n%2){ cout << "Black"; } else{ cout << "White"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int x=N*1.08; if(x<206) cout << "Yay!" << endl; else if(x>206) cout << ":(" << endl; else cout << "so-so" << endl; return 0; }
#include<bits/stdc++.h> using namespace std; #define maxn 105 typedef long long ll; ll n,a[maxn],b[maxn]; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++) cin>>b[i]; ll counter=0; for(int i=1;i<=1000;i++){ bool flag=false; for(int j=1;j<=n;j++) if(! (a[j]<=i && i<=b[j])) ...
/* * Lang : C++ 17 * Author: Debajyoti Dasgupta * Date : 10-04-2021 23:37 10 */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> oset; co...
//Author: Xzirium //Time and Date: 20:18:14 15 June 2021 //Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") //Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.h...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MOD int(1e9+7) #define INF int(1e9+7) #define LINF ll(1e18+7) #define PI acos(-1) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll,ll> #define chmax(x,y) (x = max(x,y)) #define chmin(x,y) (x = min(x,y)) int main(){ ll n...
#include<bits/stdc++.h> using namespace std; #define Mod(x) (x>=P)&&(x-=P) #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) #define erep(i,a) for(int i=hd[a];i;i=nxt[i]) typedef long long ll; void Max(int &x,int y){(x<y)&&(x=y);} void Min(int &x,int y){(x>...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define X first #define Y second #define sep ' ' #define endl '\n' #define SZ(x) ll(x.size()) const ll MAXN = 1e6 + 10; const...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
//Author: Xzirium //Time and Date: 17:59:04 11 April 2021 //Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") //Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container....
#include <bits/stdc++.h> using namespace std; #define stp(var, init, end) for (auto var = init; var < end; ++var) #define ll long long bool comp(pair<int, int> l, pair<int, int> r) { if (l.first < r.first) return true; else return false; } int main(void) { int n; cin >> n; int a, ...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <ios> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #...
#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; typedef tree<pair<int, int>,null_type,less<pair<int, int...
#include<bits/stdc++.h> #define ll long long #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC optimize("unroll-loops") #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; int main(){ ll n,q; cin >> n >> q; vector<ll> arr(n);...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const string target = "atcoder"; int T; string a; int calc(int k, char c) { for (int i = 0; i + k < a.length(); i++) { if (a[i + k] > c) { return i; } } return inf; } int move(int k, char c) { for (int i = 0; i + k < a.length(); i++) { i...
#include <cstdio> int main(){ int T; int L, R; long long Ans=0LL; scanf("%d", &T); while(T--){ scanf("%d%d", &L, &R); if(R-L<L) puts("0"); else{ int Cnt=R-L-L+1; Ans=0LL; Ans=Cnt*(long long)(R-L+1)-((R*(long long)Cnt)>>1); printf("%lld\n", Ans); } } return 0; }
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N = 2e3+5; vector<int>g[N]; bool vis[N]; int cnt = 0; void dfs(int src) { vis[src] = true; cnt++; for(auto i :g[src]) if(!vis[i]) dfs(i); } i...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MOD=1000000007; #define INF 1LL<<30 #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() vector<vector<int>> G; bool temp[2010]; void dfs(int v){ if(temp[v]) return; temp[v]=true; for(auto vv : G[v])...
#include <bits/stdc++.h> #include <unordered_set> #include <algorithm> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vs = vector<string>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repll(i,n)...
#include <bits/stdc++.h> using namespace std; // ---------------------------------------------------------Defines---------------------------------------------------------- #define fast_cin ios_base::sync_with_stdio(0); cin.tie(NULL); cerr.tie(NULL); #define sz(a) (int)a.size() #define pb(a) ...
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <queue> #include <random> #include <regex> #incl...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) int main(){ string s; cin>>s; int len=s.length(); while(1){ if(s[len-1]=='0'){ s=s.substr(0,len-1); len--; continue; } break; } //cout<<s<<endl; rep(i,len){ if...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i,n) for (ll i = 0; i < (ll)n ;i++) #define rept(i,k,n) for(ll i = (ll)(k);i < (ll)(n);i++) #define all(vec) vec.begin(),vec.end() #define ll int64_t int main(){ int a,b,c,d; cin >> a >> b >> c >> d; cout << a*d-b*c << endl; }
#include<bits/stdc++.h> #define N 1000005 #define LL long long using namespace std; int t,n,m; char a,b,c; inline int qr() { char a=0;int x=0,w=1; while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar(); } while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();} return x*w; } int main() { cin>>a>>b>>c; if(a==b&&b==...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define fr(i,n) for(int i=0;i<n;i++) #define fro(i,j,n) for(int i=j;i<n;i++) #define ifr(i,n) for(int i=n-1;i>=0;i--) int main() { int n; cin >> n; cout <<"6 10 15 "; int count=3; fro(i,16,10001){ if(count==n...
#include<bits/stdc++.h> #define pb push_back #define eb emplace_back using namespace std; //#define DEBUG #ifdef DEBUG template<typename ...Args> int debug(const Args &...args){ return fprintf(stderr,args...); } #else #define debug(...) void() #endif typedef unsigned long long ull; typedef unsigned uint; typedef lon...
//#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 <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <iostream> #include <math.h> #include <algorithm> #include <string> #include <string.h> #include <vector> #include <functional> #include <queue> #include <unordered_set> #include <climits> #include <set> #include <list> #include <cma...
// Created by vamsi #define _CRT_SECURE_NO_DEPRECATE #define _SECURE_SCL 0 #pragma comment(linker, "/STACK:200000000") #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define mset(mas,val) memset(mas,val,sizeof(mas)) #define sz(a) (int)(a).size() #define all(a) (a).begin(), (a)....
#include<bits/stdc++.h> using namespace std; #define ll long long typedef long double ld; #define syncboost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr) #define mp make_pair #define pb push_back #define psy push #define pp pop_back #define pl pair<ll,ll> #define vl vector<ll> #define vvl vect...
#include "bits/stdc++.h" #define FI first.first #define SE first.second #define TH second #define fi first #define se second #define th second using namespace std; string to_string(const string& str) { return str; } template<typename T> string to_string(const set<T>& mys) { if(mys.empty()) return "{}"; string ...
#include <bits/stdc++.h> #define rep(i,N) for (int i = 0; i < (N); ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<int, int>; const int inf{int(1e9)}; int main(void){ int N; cin >> N; string S, T; cin >> S >> T; int S_count_1 = 0; // Sに含まれる1の個数 int T_count_1 ...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; using V = vector<int>; int main() { int n, q; string s; cin >> n >> s >> q; string sf = s.substr(0,n); string sb = s.substr(n,2*n); int flip = 0; ...
#include<bits/stdc++.h> using namespace std; /*-----------------------------------------------------------------------------------------*/ #define ll long long #define ld long double #define pb push_back #define vll vector<ll> #define pll pair<ll,ll> #define vpll vector<pll> #define ub upper_bound #define lb lower_boun...
#include <bits/stdc++.h> #define rng(a) a.begin(),a.end() #define rrng(a) a.rbegin(),a.rend() #define INF 2000000000000000000 #define ll long long #define ld long double #define pll pair<ll, ll> using namespace std; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T...
#include <iostream> using namespace std; #define ll long long const ll mod = 1e9 + 7; const ll MAX = 2e5 + 1; ll t; ll power(ll x, ll p) { ll ans = 1; while (p) { if (p & 1) { ans = (ans * x) % mod; p--; } x = (x * x) % mod; p >>= 1; } return ans; } ll add(ll x, ll y) { return (...
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 3*1e5+2; const int MOD = 998244353; namespace numb{ vector<bool> isprime; vector<int> fac,rfac,phi; vector<vector<int>> prime_factors; int add(int a,int b) { a+=b; if(a>=MOD) a-=MOD; return a; } int sub(int a,...
#include <cstdio> #include <cstring> #include <algorithm> const int p=998244353; const int maxn=2e5+1; #define int long long #define rep(a,b,c) for(int a=b;a<=c;a++) int n,k,a[maxn],sum[301],fac[301],inv[301],inv2=(1ll*p+1)/2,s[maxn],ans,tmp; inline int ksm(int a,int b) { int ans=1,tmp=a; for(;b;b>>=1,(tmp*=tmp)%=p) if...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define ...
#include <stdio.h> #include <algorithm> #include <tuple> #include <vector> #include <queue> using namespace std; using ll = long long; using pii = pair<int, int>; int bits[400001]; void add(int index, int value) { for (int i = index; i <= 400000; i += i & -i) bits[i] += value; } int sum(int index) { int res = 0; ...
#include <bits/stdc++.h> using namespace std; void __print(int x) {cout << x;} void __print(long x) {cout << x;} void __print(long long x) {cout << x;} void __print(unsigned x) {cout << x;} void __print(unsigned long x) {cout << x;} void __print(unsigned long long x) {cout << x;} void __print(float x) {cout << x;} void...
// --------------------------------------------------<C++ TEMPLATE>------------------------------------------------ /** * Nitin Gangwar * @wargang (codechef,codeforces,spoj,atcoder) * MNNIT allahabad * CSE'23 * iamnitingangwar2000@gmail.com **/ #include <bits//stdc++.h> #include <ext/pb_ds/ass...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int ans = 0; if (a == b) ans = c; if (a == c) ans = b; if (b == c) ans = a; cout << ans << "\n"; }
#include <iostream> #include <string.h> #include <math.h> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <queue> #include <deque> #include <map> #include <stack> #include <cmath> #include <stdio.h> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define TEN5 100005...
#include <bits/stdc++.h> using namespace std; vector< int64_t > divisor(int64_t n) { vector< int64_t > ret; for(int64_t i = 1; i * i <= n; i++) { if(n % i == 0) { ret.push_back(i); if(i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if ...
#include<iostream> using namespace std; int main() { int k; int i; unsigned long n; cin >> n >> k; for (i = 1; i <= k; i++) { if (n % 200 == 0) { n = n / 200; } else { if (i <= k - 2) { n = n * (unsigned long)5 + (unsigned long)1; i++; } else { n = n * (unsigned long)1000 + (unsigne...
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=...
#include<bits/stdc++.h> #define int long long using namespace std; int const MOD=1000000007ll; int n,a[233333],fp,fs,gp,gs; signed main(){ ios::sync_with_stdio(0); cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; fs=a[1];gs=1; for(int i=2;i<=n;i++){ int pgs=gs,pgp=gp,pfp=fp,pfs=fs; gs=(pgs+pgp)%MOD; gp=pgs; fs=(pfs...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define forn(i,x,n) for(int i = x;i <= n;++i) #define forr(i,x,n) for(int i = n;i >= x;--i) #define Angel_Dust ios::sync_with_stdio(0);cin.tie(0) const int N = 1e5+7,MOD = 1e9+7; int a[N],f[N][2],c[N][2]; int main() { int n;scanf("%d",&n); fo...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mkp make_pair #define vi vector<int> #define pii pair<int,int> #define FI(n) FastIO::read(n) #define FO(n) FastIO::write(n) #define ull unsigned long long #define mst(a,b) memset(a,b,sizeof(a)) #define foR(i,k,j) for(int i=(k);i>=(j);i--) #define...
#include <bits/stdc++.h> #include <variant> #define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++) #define rep(i,n) rep2(i,0,n) #define all(x) begin(x),end(x) #ifdef ENV_LOCAL #define dump if (1) cerr #else #define dump if (0) cerr #endif using namespace std; using namespace std::string_literals; using i32 = int32...
#include <iostream> using namespace std; int main() { float V, T, S, D; scanf("%f %f %f %f", &V, &T, &S, &D); float s = D / V; if ((T <= s) & (s <= S)) { printf("No"); } else { printf("Yes"); } }
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t=1; //cin>>t; while(t--) { int n;...
#include <bits/stdc++.h> // Tomasz Nowak using namespace std; // University of Warsaw using LL = long long; #define FOR(i, l, r) for(int i = (l); i <= (r); ++i) #define REP(i, n) FOR(i, 0, (n) - 1) #define ssize(x) int((x).size()) template<class A, class B> auto& operator<<(ostream &o, pair<A, B> p) { return o << ...
#include <bits/stdc++.h> #define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++) #define rep(i,n) Rep(i,0,n) #define all(v) v.begin(),v.end() using namespace std; using ll=long long; using vi=vector<int>; using vll=vector<ll>; #define _GLIBCXX_DEBUG int main(){ int N;cin>>N; string S;cin>>S;S+="<<"; vector<int> a(...
#include<bits/stdc++.h> #define rep(i,n) for (int i=0; i<n; i++) #define REP(i,x,n) for (int i=x; i<n; i++) using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; using T = tuple<int,int,int>; using P = pair<int,int>; const ll SEG_LEN = (1 << 20); ll seg[SEG_LEN * 2]; void update(...
#include <bits/stdc++.h> using namespace std; int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0); //int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0); using Int = long long; struct SegTree { int N; vector<int> A; Se...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> 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...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=(n)-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue<x...
#include <iostream> #include <vector> #include <unordered_map> #include <cmath> #include <algorithm> #include <unordered_set> #include <bits/stdc++.h> using namespace std; using p = pair<int,int>; int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); int32_t N; cin >> N; int64_t X = (1 << N); N = ...
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define endl "\n" #define int long long int int number=1,number1; void solve() { vector<pair<int,int>> vec; int n; cin>>n; for(int i=1;i<=pow(2,n);i++) { cin>>number; vec.push_back({number,i}); } while(vec.size()>2) { vector<pair<int,int>> vec...
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ int N; cin >> N; ll K; cin >> K; vector<pair<ll,ll>> A(N); rep(i,N) cin >> A[i].first >> A[i].second; sort(A.begin(),A.en...
#include <bits/stdc++.h> using namespace std; #define int long long int n,k; map<int,int>m; int a[200005],b[200005]; set<int>s; signed main() { scanf("%lld %lld",&n,&k); for(int i=0;i<n;i++) { scanf("%lld %lld",&a[i],&b[i]); m[a[i]]+=b[i]; s.insert(a[i]); } set<int>::iterator it=s.begin(); int t=0; while(...
#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() using ...
#include <iostream> #include <stdio.h> #include <vector> #include <queue> #include <utility> using namespace std; typedef struct edge{ int to; int cost; }Edge; typedef pair<int,int> P; long long INF=250000010; int V; vector<Edge> G[1000000]; long long d[1000000]; void dijkstra(int s){ priority_queue<P,vector<P>...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; #define debug(args...) (Debugger()), args class Debugger { public: Debugger(const std::string &_separator = " => ") : first(true), separator(_separator) {} template <typename ObjectType> Debugger &operat...
#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> */ typedef long long ll; typedef long double ld; typedef unsigne...
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define pb push_back #define fi first #define se second #define endl "\n" #define all(v) v.begin(), v.end() typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPII; typedef vector<VI> VVI; const string YESNO[...
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> using namespace std; // using namespace __gnu_pbds; // Policy based data structure // template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long int #define pii pair<ll,ll> #defin...
#include<bits/stdc++.h> const int N=200010,mod=1e9+7; char s[N]; int c[N],fac[N],f[17][N],n,KK,a[17],cnt,g[N][17],C[17][17]; int qp(int x,int y) { int ans=1; for(;y;y >>=1,x=1ll*x*x%mod) if(y&1)ans=1ll*ans*x%mod; return ans; } void ins(int x) { if(!a[x]++)cnt++; } void eras(int x) { if(!--a[x]) cnt--; } int m...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+50; const int mod=1e9+7; char s[N]; int k; int dig[N]; // 低i位满足有k个不同数位的数字个数 ll dp[N][22]; void print(int x){ if(x){ print(x/2); } printf("%d",x%2); } ll dfs(int idx,int sta,int dif,bool lead,bool limit){ if(idx==...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <cstring> #include <list> #include <cassert> #include <climits> #inclu...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define all(v) begin(v), end(v) #define sz(v) v.size() #define INF 1e18+9 #define EPSILON 1e-14 template <typename T> bool chmax(T &a, const T& ...
#include<cstdio> using namespace std; typedef long long ll; ll n,sum1,sum2,i,j; int main() { scanf("%lld",&n); sum1=3;i=1; while(sum1<n) { sum2=5;j=1; while(sum1+sum2<n) { j++; sum2=5ll*sum2; } if(sum1+sum2==n) { printf("%lld %lld\n",i,j); return 0; } i++; sum1=3ll*sum1; } printf("-1...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) using ll = long long; int main(){ ll N,z,x,y; bool sw=0; cin >> N; ll a=0,b=0; for(ll i=1;i<=25;i++){ for(ll j=1;j<=39;j++){ //cout << pow(5,i)+pow(3,j) << endl; ...
#include<iostream> #include<stdio.h> #include<algorithm> #include<queue> #include<cstring> #include<map> #include<cmath> #include<iomanip> #include<set> #include<fstream> constexpr int Mod = 998244353; using namespace std; struct Node { string name; int h; }; bool comp(Node a, Node b) { return a.h > b.h; ...
#include <algorithm> #include <bitset> #include <array> #include <chrono> #include <cmath> #include <cstdlib> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> S(N); for(int i = 0; i < N; i++) { cin >> S.at(i); } int god = 0; int e = 0; int ans = 2; for(int i = 2; i < 1001; i++) { for(int j = 0; j < N; j++) { if(S.at(j) % i == 0) god++; } if(god > e){...
/*Bismillahi-r-Rahmani-r-Rahim*/ #include<bits/stdc++.h> using namespace std; #define ll long long #define pi acos(-1.0) #define mod 1000000007 #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl #define vi vector<int> #define vl vector<ll int> #define ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll mod = 1000000007; map<ll, ll> factorize(ll n) { map<ll, ll> m; ll lim = (ll)sqrt(n) + 10; while (n % 2 == 0) { n >>= 1; m[2]++; } for (int i = 3; i < lim; i += 2) { while (n ...
#include <bits/stdc++.h> using namespace std; #define ll long ll kpk(ll m, ll n){ ll a = m; ll b = n; ll r = m%n; while(r != 0) { m = n; n = r; r = m % n; } return a*b/n; } int main(){ ll a; cin >> a; ll k = kpk(a,a-1); for(int i=a-2;i>2;i--){ k = kpk(k,i); } cout << k+1;...
#include <bits/stdc++.h> constexpr int DEBUG = 0; using namespace std; using int64 = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; cout << (n + 99) / 100 << endl; }
#import<bits/stdc++.h> using namespace std; int n; int main() { cin >> n; for( int i=1;i<=n;++i ) cout << int(log2(i))+1 << " "; cout << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define PB push_back #define MP make_pair typedef vector<int> vi; typedef pair<int,int> pi; #define REP(i,a,b) for (int i = a; i <= b; i++) void solve(){ ll n; cin>>n; for (ll i = 0; i < n+5; i++) { if((i*(i+1...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) begin(v), end(v) using namespace std; using P = pair<int,int>; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using Graph = vector<vector<int>>; ll ll_pow(ll a, ll n) { ll ans = 1; for(ll i = 0; i < ...
#include <iostream> int a[100]; int b[100]; int used[200]; int main() { int n; std::cin >> n; for (int i = 0; i < n; ++i) { std::cin >> a[i] >> b[i]; if (a[i] != -1) ++used[a[i] - 1]; if (b[i] != -1) ++used[b[i] - 1]; if (a[i] != -1 and b[i] != -1 and a[i] >= b[i]) { ...
#include<iostream> #include<math.h> #include<algorithm> #include<stdint.h> #include<vector> #include<deque> #include<stack> #include<functional> #include<string> #include<numeric> #include<cstring> #include<random> #include<array> #include<fstream> #include<iomanip> #include<list> #include<set> #include<map> #include<u...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,x,y) for(ll i=(x);i<(y);i++) #define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--) #define all(x) (x).begin(),(x).end() #define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");} #ifdef LOCAL #define de...
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int>A(N); vector<int>B(N); for(int i=0; i<N; i++){ cin >> A[i]; } for(int i=0; i<N; i++){ cin >> B[i]; } int ans = 100000000; ans = min(ans, B[0]- A[0] + 1); for(int i=1; i<N; i++){ if(A[i-1] < A[i] && B[i...
/* __ ___ __ / |/ /____ / /_ ____ _____ ____ _ _____ / /|_/ // __ \ / __// __ \ / ___// __ `// ___/ / / / // /_/ // /_ / /_/ // / / /_/ /(__ ) /_/ /_/ \____/ \__/ \____//_/ \__,_//____/ */ #ifndef __AHA__HEADER #define __AHA__HEADER #include <bits/stdc++.h> using namespace std; #define...
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << e...
#include<bits/stdc++.h> #include<string> using namespace std; #define ll long long int #define ld long double #define pb push_back #define all(v) v.begin(),v.end() #define sz(x) ((int)(x).size()) #define fi first #define se second #define deb(x) cout<< #x << '=' << x <<endl #define MOD 1000000007 int main() { io...
#include <iostream> #include <math.h> #include <algorithm> #include <queue> #include <map> #include <list> //#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++) typedef long long ll; bool solve(string s) { if(s.size() == 1) return s == "8"; if(s.size...
/** * Author: Oak_limy * Created: 2020-11-15 01:26:42 * Wish you and me a better future. **/ #include <bits/stdc++.h> #define endl '\n' #define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define zy -2147382637 #define bql 2147483647 #define ll long long #define ull unsigned long long #define ld lo...
#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 <cstdio> # define ef else if namespace Main { namespace Source { typedef short unsigned int hu; typedef unsigned int uint; static inline const void swap(hu& a, hu& b) { hu c(a); a = b, b = c; } } using namespace Source; namespace Testcase { enum { N = 500 }; ...
//Coded by Abhijay Mitra (AbJ) #include "bits/stdc++.h" #define double long double #define int long long int #define ibs ios_base::sync_with_stdio(false) #define cti cin.tie(0) #define mp make_pair #define pb emplace_back #define F first #define S second using vi = std::vector<int>; using vvi = std::vector<vi>; using p...
#include<bits/stdc++.h> typedef long long ll; #define rep(i,l,r) for(int i=l;i<=r;i++) #define nep(i,r,l) for(int i=r;i>=l;i--) void re(int &x){scanf("%d",&x);} void re(int &x,int &y){scanf("%d %d",&x,&y);} void re(ll &x){scanf("%lld",&x);} void re(ll &x,ll &y){scanf("%lld %lld",&x,&y);} void re(double &x){scanf("%lf",...
// editorial #include<iostream> #include<vector> #include<numeric> using namespace std; typedef long long ll; const ll mod = 998244353; ll modpow(ll a, ll b, ll p = 1e9+7){ if(b == 0) return 1; if(b % 2 == 0){ ll d = modpow(a, b/2, p); return (d*d) % p; }else{ return (a%p * modpo...
#include<bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<long long>; using vvl = vector<vector<long long>>; using vc = vector<char>; using vvc = vector<vector<char>>; const long long MOD2 = 998244353LL; const l...
#include<iostream> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<21-a-b-c<<endl; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> using namespace std; using namespace __gnu_pbds; typedef long long ll; #define int long long typedef unsigned long lo...
#include<iostream> #include<stdio.h> #include<cstdio> #include<vector> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<string> #include<stack> #include<set> #include<map> #include<bitset> //#include<unordered_map> #include<time.h> #include<cstdlib> typedef long long ll; //#pragma comment(...
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> #include<utility> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(n...
#include<bits/stdc++.h> #define maxn 10005 using namespace std; int n,m; string s[805]; int son[800*13][8],tot=1; vector<int> has[800*13]; struct mat{ int v[20][20]; int score; bool vis[800]; }arr[maxn]; int vis[800*13],col; int dx[4]={0,1},dy[4]={1,0}; void getscore(mat &tt) { memset(tt.vis,0,sizeof(tt.vis)); tt...
#include <bits/stdc++.h> #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define repb(i, n) for (ll i = (n)-1; i >= 0; i--) #define rep(i, n) repd(i, 0, n) using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; const ul mod = 1000000007; int main() { ios_base::syn...
#include<bits/stdc++.h> using namespace std; //to insert pair use eb or { } #define int int64_t typedef pair<int,int> pii; const int X=1e9+7; const int inf=1e18; #define lld int #define pqu priority_queue #define eb emplace_back #define mp make_pair #define fi first #define se...
#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 constexpr int inf=1000001000; constexpr ll INF=2e18; constexpr ll mod=1000000007; // ll MOD=998244353; ...
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i, a, b) for(int i = b; i >= a; i --) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define MAXN 1000005 #define INF 100000000000000000...
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif //#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const int mod = 998244353; int mult(int a, int b) { return (1LL * a * b) % mod; } int sum(int a, int b) { int s = a + b; if (s >= mod) s -= mod;...
#include<bits/stdc++.h> #define it register int #define ct const int #define il inline using namespace std; typedef long long ll; #define rll register ll #define cll const ll const int N=5005; #define P 998244353 int fac[N],sz[N],k,n,cnt,ans,f[N][N]; il void mo(it&p,ct q){p+=q,p=(p>=P?p-P:p);} int main(){ //freopen("a...
#include <cstdio> #include <queue> #include <algorithm> using namespace std; int d[101][2]; int main() { int a, b, x, y, i, j; priority_queue<pair<int, pair<int, int>>> q; scanf("%d %d %d %d", &a, &b, &x, &y); for (i = 1; i <= 100; i++) { for (j = 0; j < 2; j++) { d[i][j...
#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; template <typename T> vector<T> Dijkstra(int s, vector<vector<pair<...
#include<bits/stdc++.h> using namespace std; void output(vector<int> &a){ cout << a.size(); for(auto &nx : a){ cout << ' ' << nx; } cout << '\n'; } int main(){ int n; cin >> n; vector<int> a(n); for(auto &nx : a){cin >> nx;} vector<vector<int>> bk(200,vector<int>(0)); int cnt=min(n,8); f...
/* author:ujwalll */ #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define for1(i, n) for (int i = 1; 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--) #define nx cout <...
#include <bits/stdc++.h> using namespace std; int H, W, A, B, Ans; void dfs(int p, int bitdp, int rec, int squ) { // 終端 if (p == H * W) { Ans++; return; } // すでに利用済み if (bitdp & 1 << p) dfs(p + 1, bitdp, rec, squ); // 半畳を利用 if (squ && ~bitdp & 1 << p) dfs(p + 1, bitdp | 1 << p, rec, squ - 1); ...
#include <bits/stdc++.h> using namespace std; const long long mod1 = 1000000007; using ll = long long; using pq = priority_queue<ll>; vector<int> dx = {0,1,0,-1}; vector<int> dy = {-1,0,1,0}; long long pow(long long x,long long n){ long long ans = 1; while(n != 0){ long long a = x; long long z ...
#include <bits/stdc++.h> int main(){ std::string S; std::cin >> S; int st = 8, ed = 10; if(S.size() == 2){ st = 16; ed = 100; }else if(S.size() >= 3){ st = 104; ed = 1000; } std::vector< int > eight; for(int i=st; i<ed; i+=8){ int tmp = i; bool zero ...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil ...
#include <bits/stdc++.h> using namespace std; string A, B, C; long long x, y, z; int func(vector<int> &V) { x = y = z = 0; for (int i=0; i<A.size(); i++) { int dig = V[ A[i] - 'a' ]; if (i == 0 && dig == 0) return 0; x = x * 10 + dig; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; char s1[15],s2[15],s3[15]; int a[15],b[15],c[15]; int n,m,k; char dig[45]; int len; void Discretize() { for(int i=1;i<=n;i++) { dig[++len]=s1[i]; } for(int i=1;i<=m;i++) { dig[++len]=s2[i]; } for(int i=1;i<=k;i++) { dig[++len]=s3[i]; } s...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i) #define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i) #define revrep(i,n) for(ll i=(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 60) -123456789; #define fastio cin.tie(0); ios_base::sync_...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Kein Yukiyoshi */ // clang-format off #include <bits/stdc++.h> //#pragma GCC optimize("Ofast") //#pragma GCC target("avx") #define int long long using namespace std; #define stoi stoll #define fi first #define se secon...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; double arr[105][105][105]; double f(int a, int b, int c) { if (arr[a][b][c]) return arr[a][b][c]; if (a == 100 || b == 100 || c == 100) return 0.0; double ans = 0.0; ans += (f(a + 1, b, c) + 1) * a / (a + b + c); ans += (f(a, b + 1, c) ...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} using ll = long long; using P = pair<in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long llu; #define INF 0x3f3f3f3f const int N=600010,mod=1e9+7,P=19260817; ll n,m,T,k,x,cnt,y,b[N],c[N],vis[N],ans,t,a[N],x2,y2; string s; int main() { scanf("%lld%lld",&n,&m); if (n==1) { if (m==0) printf("%lld %lld\n",(ll)1,...
#include <bits/stdc++.h> using namespace std; long long qwq(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) { ans = ans * a % 1000000007; } a *= a; a %= 1000000007; b >>= 1; } return ans; } int main() { int n, m; scanf("%d %d", &n, &m); printf("%lld\n", qwq(m - 2, n - 1) * (m -...
#include<stdio.h> int main(void){ int n; scanf("%d",&n); printf("%d",n-1); return 0; }
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { int a, b, c, d; cin >> a >> b >> c >> d; cout << a*d - b*c << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define fast ios::sync_with_stdio(false);cin.tie(0); typedef long long ll; typedef long double ld; typedef unsigned long long ull; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> dsu,sz,rnk; vector<ve...
#include<bits/stdc++.h> #define int long long using namespace std; const int N=2e5+5; const int LOGN=log2(N+10)+1; int depth[N+1], a[N], b[N], delta[N], ans[N]; int parent[LOGN][N]; vector<int>edges[N]; int n; void init(int n){ for(int bit=0;bit<LOGN;bit++){ for(int i=0;i<n;i++){ parent[bit]...
#include<bits/stdc++.h> using namespace std; #define MAXN 200005 #define lowbit(x) (x&-x) #define reg register typedef long long LL; typedef unsigned long long uLL; typedef unsigned int uint; const int INF=0x7f7f7f7f; const int jzm=233; const int mo=998244353; const double Pi=acos(-1.0); typedef pair<int,int> pii; cons...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main() { ll A, B; cin >> A >> B; vector<int> primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71}; int K = primes.size(); vector<ll> from(1<<K, 0), to(1<<K, 0); from[0] = 1; for (ll i...
#include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <queue> #include <se...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define fi first #define se second #define ll long long #define tp top() #define fr front() #define vi vect...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a) for(int i = 0; i < (int) a; i++) #define PB push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define F first #define S second typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; int grid[2007][2007]...
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; using llpair = pair<llong, lpair>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9+7; constexpr llong inf = mod * mod; struct union_find { std::vector<int> par; vector<u...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <tuple> #include <cmath> using namespace std; #define _GLIBCXX_DEBUG int main(void){ char S, T; cin >> S >> T; if(S == 'Y'){ if(T == 'a'){ cout << 'A' << endl; ...
#include <cstring> #include <cmath> #include <algorithm> #include <string> #include <map> #include <iostream> #include <vector> #include <queue> #include <unordered_map> #include <random> #include <stack> #include <set> #include <unordered_set> #define bug(x) cout<<"zdongdebug1: "<<x<<endl; #define bug2(x, y) cout<<"z...
#include <bits/stdc++.h> //#include <atcoder/all> #define endl "\n" using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bo...
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0);ios_base::sync_with_stdio(0); string to_string(string s) { return '"' + s + '"';} string to_string(char s) { return string(1, s);} string to_string(const char* s) { return to_string((string) s);} string to_string(bool b) { return (b ? "true" : "fa...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using order...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mp make_pair #define fr first #define sc second template<class T> T T_INF(){ return 1000000000000000000; } template<> int T_INF<int>(){ return 1000000000; } template<int MOD> struct modint{ ull val; modint(...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; t...
#include <iostream> #include <vector> using namespace std; using LL = long long; const int kMaxN = 2e5 + 1; const int kMaxM = 101; const int kM = 1e9 + 7; LL n, ans, u, v, w; LL c[kMaxN], d[kMaxM]; bool vis[kMaxN]; vector<LL> a[kMaxN], b[kMaxN]; void Dfs(LL x, LL y) { if (vis[x]) { return; } vis[x] = tr...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(), x.end() typedef vector<int> vi; using ll = long long; typedef pair<int, int> pii; typedef unsigned long long ul; const int mn = 3005; const int mod = 998244353; int n, K; ll d[mn][mn]; ll dp(i...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using ll = int64_t; using db = double; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vector<int>>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector...
#include<bits/stdc++.h> #define ll long long int #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number. #define pii pair<int,int> #define pll pair<ll,ll> #define mod 1000000007 //#define mod 99...
#include <iostream> #include <string> #include <vector> #include <math.h> #include <algorithm> using namespace std; long long n; long long x1; int ans = 1; string s; int main() { cin >> n; long long x = 1; int count = 0; long long x1 =0; while(x1<=n){ s = to_string(x); x1 =...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vec = vector<ll>; using mat = vector<vec>; using pll = pair<ll,ll>; #define INF (1LL << 60) #define MOD 1000000007 #define PI 3.14159265358979323846 #define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i)) #define FORR(i,v) for(auto (i):...
#include <bits/stdc++.h> using namespace std; #define ll long long vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N/i != i) res.pus...
#include <iostream> using namespace std; using ll = long long; constexpr ll INFll = (ll)1e18 + 1; ll Power(int a, int b) { ll ret = 1; while(b--) { if(INFll / ret < a) { ret = INFll; break; } ret *= a; } return ret; } int main() { ll n; cin >> n; ...
#include<bits/stdc++.h> using namespace std; void __print(int x){cout<<x;}void __print(long x){cout<<x;} void __print(long long x){cout<<x;}void __print(unsigned x){cout<<x;} void __print(unsigned long x){cout<<x;}void __print(unsigned long long x){cout<<x;} void __print(float x){cout<<x;}void __print(double x){cout<<x...
#include<bits/stdc++.h> using ll = int_fast64_t; int main(){ ll b, c; scanf("%ld %ld", &b, &c); ll l1 = b-c/2, r1 = b + std::max(0l, c-2)/2; ll l2 = -b-(c-1)/2, r2 = -b + (c-1)/2; if(l1<=r2 && l2<=r1){ bool l = (l1<=l2 && l2<=r1); bool r = (l1<=r2 && r2<=r1); if(l && r) printf("%ld\n", r1-l1+1); if(l &&...
#include<bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using pl = pair<ll, ll>; #define rep(i,n) for(int i=0;i<(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep1(i,n) for(int i=(n);i>0;i--) #define REP(i...
/* * @author: codancer * @createTime: 2020-10-17, 21:33:55 */ #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 ...
#pragma GCC optimize("Ofast") #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> // ...
#include <bits/stdc++.h> using namespace std; int main(){ int N,A; cin >> N; vector<int> vec,vec2; for(int i = 0;i<N;i++){ cin >> A; vec.push_back(A); vec2.push_back(A); } sort(vec2.begin(), vec2.end()); int min = vec2.at(0); //cout << min << endl; int max = min * N; for(int i = 0;i < N;...
#include<bits/stdc++.h> #define ll long long int #define ld long double using namespace std; #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define mp make_pair #define fi first #define se second #define pb push_back #define endl "\n" #define maxpq priority_queue<ll> #define minpq priority_...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define rep(i,a,b) for (int i=(a); i<=(b); i++) #define drep(i,a,b) for (int i=(b); i>=(a); i--) #define erep(e,u) for (int e=Head[u]; e; e=Next[e]) #define arep(i,A) for (auto i : A) #define push_back pb #define print(x,c) printf ("%d%c", x, c); type...
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; typedef long long ll; string num; int rn[200005]; int k; int n; int dp[200005][20]; ll dfs(int x,ll now,bool zero,bool flag) { int cnt=0; for(int i=0;i<16;i++) { if(now&(1<<i))cnt++; } if(x>=n)return cnt==k; if(cnt>k)retur...
#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; #pragma GCC target("popcnt") //https://godbolt.org/z/yQv94Y typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; const ld pi = ...
#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>...