code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#ifdef _LOCAL # include <dbg_print.h> #else # define NDEBUG # define dprint(...) #endif #include <cmath> #include <cstdio> #include <cstring> #include <vector> #include <iostream> #include <algorithm> #include <assert.h> using namespace std; typedef long long ll; bool connected[32][32] = {0}; int n, m; int check_his...
#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> using namespace std; #define int long long const int mod=1e9; signed main() { int a,b; cin>>a>>b; a=a*2+100; cout<<max(0ll,a-b)<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; if (15<=a+b&&8<=b){ cout<<1; } else if (10<=a+b&&3<=b){ cout<<2; } else if (3<=a+b){ cout<<3; } else{ cout<<4; } }
#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 = 7; const ll INF = (ll) 1e15; char C[2] = {'T', 'A'}; int main() { cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; int n; int dp[200001][8] ; string s, x ; bool fun(int idx, int num) { if (idx > n) return (num == 0) ; int &ret = dp[idx][num] ; if (ret != -1) return ret ; int cur = 0 ; if (x[idx] == 'A') { cur = fun(idx+1, (num * 10)%7) ; if (cur == 1) cur = fun(idx+...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define forin(in) for(ll i=0; i<(ll)in.size(); i++) cin>>in[i] #define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<" " #define rep(i, n) for(ll i=0; i<(n); i++) #define rep_up(i, a, n) for (ll i = a; i < n; ++i) #define rep_down(i, a, n...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #d...
#include <bits/stdc++.h> #define _overload(_1, _2, _3, _4, name, ...) name #define _rep1(Itr, N) _rep3(Itr, 0, N, 1) #define _rep2(Itr, a, b) _rep3(Itr, a, b, 1) #define _rep3(Itr, a, b, step) for (i64(Itr) = a; (Itr) < b; (Itr) += step) #define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__) #def...
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cassert> #include <algorithm> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define repi(i,a,b) for(ll i=...
#include <bits/stdc++.h> #define M 1000000007 #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define d(x) cout << #x << " " << x << "\n"; #define min(x1, x2) (x1 > x2 ? x2 : x1) #define max(x1, x2) (x1 < x2 ? x2 : x1) #define min3(x1, x2, x3) (x3 > min(x1, x2) ? min(x...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define per(i, a, b) for (auto i = (b); i-- > (a); ) #define all(x) begin(x), end(x) #define rall(x) (x).rbegin(), (x).rend() #define sz(x) int((x).size()) #define lb(x...)...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace std; // size(x), rbegin(x), rend(x) need C++17 #define sz(x) int((x).size()) #define all(x) begin(x), end(x) #define rall(x) x.rbegin(), x.rend() #define sor(x) sort(all(...
#include<bits/stdc++.h> using namespace std; #define ll long long int int main() { ll n; cin>>n; ll a[n]; ll max=0,res=-1; for(ll i=0;i<n;i++) cin>>a[i]; for(ll i=2;i<1000;i++) { ll cnt=0; for(ll j=0;j<n;j++){ if(a[j]%i==0) cnt++; } if(c...
/** * author: kuins_air * created: 28.05.2021 11:21:10 **/ #include <bits/stdc++.h> using namespace std; #define rep(i, r, n) for(int i = r; i < (int)(n); i++) #define ll long long string S; int main() { cin >> S; int n = (int)S.size(); rep(i, 1, (int)S.size() + 1) { if(S[n-i] == '0') cout <...
#include<bits/stdc++.h> using namespace std; const int N=4e5+10; int T,n; char s1[N],s2[N],s3[N]; int pos[4][2][N],now[4]; int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); scanf("%s%s%s",s1+1,s2+1,s3+1); for(int i=1;i<=n;++i) printf("0"); for(int i=1;i<=n;++i) printf("1"); printf("0\n"); } return 0...
//#include<i_am_noob_orz> #include<bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define int ll #define ull unsigned long long #define pii pair<int,int> #define X first #define Y second #define mod ((ll)...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string(string(s)); } string to_string(bool b) { return to_string(int(b)); } string to_string(vector<bool>::reference b) { return to_string(int(b)); } string to_stri...
#include<bits/stdc++.h> using namespace std; bitset<101> acc[201]; int dir[201], nxt[201], tmp[201]; int main() { int n; cin >> n; for (int i = 1; i <= n * 2; i++) acc[i] = ~acc[i]; for (int i = 1; i <= n; i++) { int a, b; cin >> a >> b; if (a != -1 && b != -1 && a >= b) { puts("No"); return 0; } if...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<pair<int, int>> p(n); for(auto& [x, y] : p) cin >> x >> y; for(int i = n; i--; ) for(int j = i; j--; ) for(int k = j; k--; ){ auto [x1, y1] = p[i]; auto [x2, y2] = p[j]; auto [x3, y3] = p[k]; ...
#include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> v[100000]; pair<int, pair<int, int>> dfs(int x) { int p1 = 0, p2 = 0, sa = 0, sb = 0, f = 0, i; vector<pair<int, pair<int, int>>> w; p1++; f = 1 - f; for (i = 0; i < v[x].size(); i++) { pai...
#include <bits/stdc++.h> using namespace std; // DEBUG BEGIN #ifdef LOCAL template<class L, class R> ostream &operator<<(ostream &out, const pair<L, R> &p){ return out << "(" << p.first << ", " << p.second << ")"; } template<class Tuple, size_t N> struct TuplePrinter{ static ostream &print(ostream &out, const Tuple ...
#include <iostream> using namespace std; #define N 805 #define MAX_A 1000000000 #define rep(i, n) for(int i = 0; i < n; ++i) int main() { int n, k, lim; int a[N][N]; int s[N][N]; rep(i, N) { s[i][0] = 0; s[0][i] = 0; } int ng = -1; int ok = MAX_A; int mid; bool ext; cin >> n >> k; lim = ((k * k) / 2) +...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef pair <int, int> pin; const int N = 805; const int M = 7e5 + 5; const int Maxn = 1e9; const ll P = 998244353LL; const int inf = 1e9 + 5; int n, k, pos, a[N][N], sum[N][N], ans = inf; template <typename T> inline void read(...
// youngjinp20 // 2021 06 #include<stdio.h> #include<iostream> #include<vector> #include<stack> #include<queue> #include<algorithm> #define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } #define byr(x) [](const auto& a, const auto& b) { return a.x > b.x; } #define smax(a, b) ((a) < (b) ? ((a)=(b), true)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<pll> vpll; typedef vector<bool> vbl; typedef vector<vector<bool>> vvbl; void INX(){} template<typename Head, typename... Tail> vo...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n,t,t1,t2; string s,s1,s2; cin >> n; t1=0; t2=-1; s1="a"; s2="b"; rep(i,n){ cin >> s >> t; if(t>t1){ t2=t1; s2=s1; t1=t; s1=s; }else if(t>t2){ t2=t; s2=s; } } cout <<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define int ll #define ld long double #define reps(i,s,n) for(int i=(s);i<(int)(n);i++) #define rep(i,n) reps(i,0,n) #define rreps(i,s,n) for(int i=(int)(s-1);i>=n;i--) #define rrep(i,n) rreps(i,n,0) #defin...
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("O3") #pragma GCC optimize ("O2") #include"bits/stdc++.h" using namespace std; const int p = 31; const int M = 998244353; typedef long long ll; typedef long double d; typedef unsigned long long ull; typedef int in; #define ar array #define ff first #define ss second...
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define sz(a) (int)(a.size()) #define pb push_back #define all(c) c.begin(),c.end() #define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++) #define fr(i,a,n) for(int i=a;i<n;i++) #define present(c,x) (c.find(x)!=c.end()) //fo...
#include <bits/stdc++.h> using namespace std; void Main(); using i8 = int8_t; /* -128 ~ 127 */ using u8 = uint8_t; /* 0 ~ 255 */ using i16 = int16_t; /* -32,768 ~ 32,767 */ using u16 = uint16_t; /* 0 ~ 65,535 */ using i32 = int32_t; /* -2,147,483,648 ~ 2,147,483,647 */ using u32 = uint32_t; /* 0 ~ 4,294,967,295...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1505; int pref[N][N], block[N][N]; int main(){ int h,w,n,m; scanf("%d %d %d %d",&h,&w,&n,&m); for(int i=0;i<=h+1;i++){ block[i][0] = block[i][w+1] = -1; } for(int i=0;i<=w+1;i++){ block[0][i] = block[h+1][i] = -1; } for(int i=0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define REP(i,m,n) for(ll i = (m); i < (ll)(n); i++) #define rep(i,n) REP(i, 0, n) #define rrep(i,n) REP(i,1,n+1) const int MX = 1505; const int di[] = {1, 0, -1, 0}; const int dj...
#include<bits/stdc++.h> using namespace std; const int mod=998244353; int a,b,c; int main( ) { cin>>a>>b>>c; a%=mod, b%=mod, c%=mod; a=1ll*a*(a+1)/2%mod; b=1ll*b*(b+1)/2%mod; c=1ll*c*(c+1)/2%mod; cout<<1ll*a*b%mod*c%mod; return 0; }
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target ("avx2") #pragma GCC optimize("unroll-loops") #pragma comment(linker, "/stack:200000000") #define ll long long int #define endl '\n' #define M 998244353 #define f first #define s second #define pb push_back #define mp make_pair #define FOR(i,a,b) for...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
#include<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> #include <climits> using namespace std; #define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ps(x,y) fixed<<setprecision(y)<<x #define int long long int solve(int arr[],int n,int sum){ bool dp[n+1][sum+1]; memset(dp,false,sizeof(dp)); for(int i=0;i<=n;i++){ dp[i][0]=t...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=ll(a); i<=ll(b); i++)// a<=i<=b i++ のforの開始 #define ALL(a) (a).begin(),(a).end()//全要素,min,max,findなどで使う #define ITE(e,a,i) auto ite=find(ALL(a),e);\ (i)=distance((a).begin(),ite);\ if(ite==(a).end()) i=-1; #define EACH(i...
/****************************** Author: jhnah917(Justice_Hui) g++ -std=c++14 -DLOCAL ******************************/ #include <bits/stdc++.h> #define x first #define y second #define all(v) v.begin(), v.end() #define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end()) using namespace std; typedef long long ll;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; const int dy[4] = { -1, 0, 1, 0 }, dx[4] = { 0, 1, 0, -1 }; char mp[1000][1000]; vector<int> gph[2000]; bool chk[2000]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int r, c; cin >> r >> c; gph[...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i) namespace IO { const int MAXIOSIZE = 1 << 24 | 1; unsigned char buf[MAXIOSIZE], *p1, *p2; // #define gc (p1 == p2 && (p2 = (p1 =...
#include <bits/stdc++.h> #include<algorithm> #include<cstring> #include<cmath> #include<cstdlib> #include<string.h> using namespace std; #define pb push_back #define all(v) v. begin(),v. end() #define rep(i,n,v) for(i=n;i<v;i++) #define per(i,n,v) for(i=n;i>v;i--) #define ff first #define ss second #define pp pair<l...
#include <bits/stdc++.h> #define LL long long using namespace std; template <typename T> void read(T &x){ x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();} while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();} x *= f; } inline void write(int x){if (x > 9) wr...
#include<stdio.h> int n,m,a[1002],b[1002],dp[1002][1002]; inline int min(int x,int y){return x<y?x:y; } inline int min(int x,int y,int z){ return min(x,min(y,z)); } int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&a[i]),dp[i][0]=i; for(int i=1;i<=m;i++) scanf("%d",&b[i]),dp[0][i]=i; for(in...
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 3000005; int main() { int n; ll k; ll dp[4][N] = {0}; cin >> n >> k; dp[0][0] = 1; for (int i = 0; i < 3; i ++ ) { for (int j = 0; j <= i * n; j ++ ) { //只在1~n之间加上 dp[i + 1][j + 1] += dp[i][j]; dp[...
#include<bits/stdc++.h> #define pb push_back #define pf push_front #define clr(x) memset(x, 0, sizeof(x)) #define all(a) a.begin(),a.end() #define s second #define f first #define forn(i, a,b) for(int i = int(a); i < int(b); ++i) #define forn_r(i, b, a) for(int i = int(b); i > int(a); i--) #define trav(a,x) for (auto& ...
#include <bits/stdc++.h> using namespace std; // #pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,avx,avx2,tune=native") // #pragma GCC optimaze("O3") // #pragma GCC optimaze("unroll-loops") #define int long long typedef long long ll; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int ...
#include <iostream> #include <vector> #include <iterator> #include <algorithm> #include <string> #include <numeric> #include <iterator> #include <climits> using namespace std; template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "{"; for (int i = 0; i < (int)v.size(); i++) o << (i > 0...
#include <bits/stdc++.h> using namespace std; ////////////////////////////////////////////////////////////////////////////<editor-fold desc="macros"> //#define mod 9999991 long mod=9999991; #define endl "\n" #define long long long #define all(v) (v).begin(),(v).end() #define makeset(v) (v).resize(unique((v).begin(),(v...
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> // #include <boost/rational.hpp> // using bigint = boost::multiprecision::cpp_int; // using fraction = boost::rational<bigint>; using namespace std; #define pb push_back #define eb emplace_back #define unused [[maybe_unused]] #define tempT templa...
#include<cstdio> using namespace std; int n, m; int main() { scanf("%d %d", &n, &m); if ((m + 1 == n && m != 0) || m == n || m < 0) { printf("-1\n"); return 0; } printf("1 1000000000\n"); for (int i = 1; i <= m; i++) { printf("%d %d\n", i * 2, i * 2 + 1); } for (int i = m + 1; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0); #define LL_MAX LLONG_MAX #define ub(v,x) upper_b...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <unordered_map> #include <vector> #include <queue> #define lc u << 1 #define rc u << 1 | 1 using namespace std; typedef long long LL; typedef pair<int,int> PII; LL n,s,k; LL exgcd(LL a,LL b,LL &x,LL &y) { if(!b) { ...
#include <bits/stdc++.h> using namespace std; int T; long long L, R; long long solve(int L, int R) { if (R < 2*L) return 0; long long c = R - 2*L + 1; return c * (c+1) / 2; } int main() { scanf("%d", &T); while (T --) { scanf("%lld%lld", &L, &R); printf("%lld\n", solve(L, R)); } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #define RST(i,n) memset(i,n,sizeof i) #define SZ(a) (int)a.size() #define ALL(a) a.begin(),a.end() #define X first #define Y second #define eb emplace_back #ifdef cold66 #define debug(...) do{\ fp...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define pll pair<ll,ll> #define ldb double template<typename T>void ckmn(T&a,T b){a=min(a,b);} template<typename T>void ckmx(T&a,T b)...
#include <bits/stdc++.h> using namespace std; int main(){ int N, M; cin >> N >> M; vector<vector<pair<int, int>>> E(N); for (int i = 0; i < M; i++){ int A, B, C; cin >> A >> B >> C; A--; B--; E[A].push_back(make_pair(C, B)); } for (...
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(),v.end() #define MP make_pair #define MT make_tuple typedef int64_t ll; #define PA pair<ll,ll> #define TU tuple<ll,ll,ll> #define vi vector<ll> #define vii vector<vector<ll> > #define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++) #define rep2(i,m,n) for...
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, m, fa[N]; int main() { int x; cin >> x; for (int i = x + 1; ; i++) { if (i % 100 == 0) { cout << i - x << endl; return 0; } } }
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define INF ((1LL<<62)-(1LL<<31)) typedef long long ll; int main() { ll n; cin >> n; string s=to_string(n); int x=s.size(); int ans=0; if(x<=2) ans=n/11; else if(x==3) ans=9; else if(x<=4) ans=n/101;...
#include<bits/stdc++.h> using namespace std; #define ll long long ll n; vector<ll>vec; int main() { string s,s1=""; cin>>s; if(s.size()==1) { cout<<0<<endl; exit(0); } ll n=s.size(),ans=0; for(ll i=0; i<=n/2; i++) { s1+=s[i]; } ll val=stoll(s1),tar=stoll(s...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // DEBUG #ifdef _DEBUG #define debug(x) cout << #x << ": " << x << endl #else #define debug(x) #endif // iter #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPD(i, n) for (int i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (int i = a;...
#include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<ll> vll; #define PI (2*acos(0.0)) #define eps 1e-9 #define pb push_back #define endl "\n" #define watch(x) cout << (#x) << " is ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>; #define FOR(i,a,n) for(int i=(a);i<(n);++i) #define eFOR(i,a,n) for(int i=(a);i<=(n...
#include <bits/stdc++.h> using namespace std; int main() { long long n, count=0; cin >> n; map<long long, int> m; for(int i=2; i<=sqrt(n); i++){ long long a; a=i; a*=i; while(a<=n){ if(!(m.count(a))){ count++; m[a]=0; ...
#include<bits/stdc++.h> using namespace std; int main() { int t=1; //cin>>t; while(t--) { string s,p; cin>>s; for(int i=0;i<s.size();i++) { if(s[i]!='.') { p+=s[i]; } else break; } cout<<p<<"\n"; } return 0; }
/* -*- coding: utf-8 -*- * * f.cc: */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #includ...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define ndl '\n' #define mp make_pair #define mt make_tuple #define pb push_back #define up_b upper_bound #define low_b lower_bound #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin...
// SmartCoder #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c)...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; ll funcy(ll a[], ll n) { ll sum = 0; ll i; for(i=0;i<n;i++) { sum += (a[i]*(i) - a[i]*(n-i-1)); } return sum; } int main(){ ios::sync_with_stdio(0);cin.tie(0); ll i,n;cin>>n;ll v[n+1]; for(i=0;i<n;i++)cin>>v[i]; sort(&v[0],&v[n]); cout<<funcy(v,n...
/* author : Aryan Agarwal, IIT KGP created : 20-February-2021 17:32:16 IST */ #include <bits/stdc++.h> using namespace std; #define int long long const int mxn = 1e5; const long long INF = 2e18; const int32_t M = 1000000007; /*more than 1e9 */ /*7 + 1e9*/ // const int32_t M = 998244353; /*less than 1e9 */ /...
#include<bits/stdc++.h> using namespace std; int main() { bool b=true; char a[10000]; cin>>a; for(int i=0;i<strlen(a);i++) { if(i%2==0) { if(a[i]<97||a[i]>122) { b=false; break; } } else { if(a[i]<65||a[i]>90) { b=false; break; } } } if(b==true) { cout<<"Yes"; } ...
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define mod2 998244353 #define ll long long #define gi(n) long long n;cin>>n #define ga(a,n) long long a[n];for(ll i=0;i<n;i++)cin>>a[i] #define YES cout<<"YES"<<endl #define NO cout<<"NO"<<endl #define TEST(t) ll t; cin>>t; while(t--) #define fast...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } using ll = long long; usi...
//ΔAGC053B #include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<bitset> #include<cmath> #include<cstring> #include<cstdlib> using namespace std; typedef long long LL; typedef double DB; const int N = 444444; int n,a[N]; priority_...
#include <bits/stdc++.h> using namespace std; bool check(string S, string pass) { vector<bool> b(10, false); b.at(pass.at(0) - '0') = true; b.at(pass.at(1) - '0') = true; b.at(pass.at(2) - '0') = true; b.at(pass.at(3) - '0') = true; for (int i = 0; i < 10; i++) { if (S.at(i) == 'o' && b.at(i) == fals...
// // Created by David on 2020/10/03 0003. // #include <iostream> #include <cstring> #include <map> using namespace std; string str; int n; struct complex { int real, imagine; explicit complex(int re = 0, int im = 0) : real(re), imagine(im) {} friend complex operator+(complex a, complex b) { c...
/* _/_/_/_/ _/_/_/_/_/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/_/_/_/ _/_/ _/_/_/_/_/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/_/ _/ _/ _/_/ ...
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = mod * mod; const int INF_N = 1e+9; typedef pair<int, int> P; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n...
#include <iostream> #include <string> #include <cmath> #include <vector> #include <algorithm> #include <set> #include <iterator> using namespace std; long long int tab[100006]; long long int tab2[100006]; int main(int argc, char** argv) { long long int n,m,a; int sum, k,dif; sum = 0; multiset <pair<long long...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 200010; const int MOD = 1e9 + 7; int n; ll a[N], fib[N]; inline ll get (int x) { return x < 0 ? 1 : fib[x + 2]; } int main() { fib[1] = 1; for (int i = 2; i < N; ++i) { fib[i] = fib[i - 1] + fib[i - 2]; if (fib[i] >= M...
#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; typedef long long ll; typedef long double ld; const int M = 10000; ll cnt(ll X, ll Y, ll R, ll lim) { ll a = 0; ll b = M; ll res = 0; auto fn = [&](int t, int i) { return (t - X) * (t - X) + (i - Y) * (i - Y) <= R * R; }; for (ll i = (Y + ...
#include <bits/stdc++.h> using int32 = int; using int64 = long long; using namespace std; class Solution { #define int int64 #define sfor(i, n) for (int i = 1; i <= n; ++i) #define tfor(i, n) for (int i = 0; i < n; ++i) int x, y, r, res = 0; void SHURU() { double a, b, c; cin >> a >> b >>...
#include<bits/stdc++.h> #define ll long long int #define mk make_pair #define pb push_back #define INF (ll)6e18 #define pii pair<ll,ll> #define mod 998244353 #define f(i,a,b) for(ll i=a;i<b;i++) #define fb(i,a,b) for(ll i=a;i>b;i--) #define ff first #define ss second #define srt(v) if(!v.empty())sort(v.begin(),v.end()...
#include<bits/stdc++.h> using namespace std; inline int read(){ int res=0; char c; bool zf=0; while(((c=getchar())<'0'||c>'9')&&c!= '-'); if(c=='-')zf=1; else res=c-'0'; while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0'; if(zf)return -res; return res; } signed main(){ dou...
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<sstream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> #include<t...
#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 ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> #define ll long long #define ull unsigned long long #define pb...
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) using namespace std; int main() { int N; cin >> N; vector<int> used(2 * N); auto out = []() { cout << "No" << endl; exit(0); }; REP(i, N) { int A, B; cin >> A >...
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<vector> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<deque> #include<iomanip> #include<tuple> #include<cassert> #include<set> using namespace std; typedef long long int LL; typedef pair<int,int> P; typedef pair...
#line 1 "main_b.cpp" #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #i...
/******************************************************/ /******************************************************/ /** **/ /** BISMILLAHIR RAHMANIR RAHIM **/ /** REAZ AHAMMED CHOWDHURY - reaziii **/ /** Department of Computer Science...
#include<bits/stdc++.h> #define ll long long using namespace std; int t;ll n,s,k,d; inline ll gcd(ll x,ll y){ while(y^=x^=y^=x%=y); return x; } ll exgcd(ll a,ll b,ll &x,ll &y){ if(b==0){x=1,y=0;return a;} int r=exgcd(b,a%b,y,x); y-=a/b*x; return r; } signed main(){ scanf("%d",&t); while(t--){ ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define reps(i, s, n) for (int i = (s); i < (int)(n); ++i) #define ZERO {puts("0"); return 0;} #define NO {puts("No"); return 0;} #define ALL(obj) begin(obj), end(obj...
#include <bits/stdc++.h> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include<ext/rope> #define pb push_back #define F first #define S second #define ll long long #define ull unsigned long long #define ld long double #define TIME 1.0*c...
// Powered by CP Editor (https://cpeditor.org) //a+b = (a^b) + 2*(a&b) //b^c = (a^b)^(a^c) //gcd(x,y) = gcd(x-y,y) //if n = 5000 then complexity cannot be (n^2*log(n)) means no map ,no sets //check for long long overflow if input is large #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int lo...
#include <bits/stdc++.h> using namespace std; int main() { long long int t,a,b,s,z,r; cin>>t; s=0; while(t--) { cin>>a>>b; z=((b+1)*(b))/2; r=((a)*(a-1))/2; s+=z-r; } cout<<s<<"\n"; return 0; }
/*input 1000 1 */ #include<bits/stdc++.h> using namespace std; int main() { int T = 1; // cin>>T; while(T--) { int N,W;cin>>N>>W;cout<<(N/W)<<"\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main () { int n; cin >> n; if(n<=100) cout << "1"; else { int l=n/100; if(l*100<n) l++; cout << l; } }
#include <bits/stdc++.h> #define INT_MINs -2000000000 #define INT_MAXs 1000000001 #define MID int mid=(l+r)/2 #define REP1(i,x,y) for(int i=x;i<y;i++) #define REP2(i,x,y) for(int i=x;i<=y;i++) #define ls (2*k) #define rs (2*k+1) #define lson l,mid,2*k #define rson mid+1,r,2*k+1 #define lc u << 1 #define rc u << 1 | 1 #...
#include <iostream> int main(){ int n, i; double re=0.0; std::cin >> n; for(i=0; i<n-1; i++){ re += (double) (n/(n-1.0-i)); } std::cout << std::fixed << re << std::endl; }
#include <bits/stdc++.h> template <typename T> T next() { T temp; std::cin >> temp; return temp; } template <> int next() { int temp; scanf("%d", &temp); return temp; } template <> long long next() { long long temp; scanf("%lld", &temp); return temp; } template <> double next() { double te...
//~ author : Sumit Prajapati #include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long // #define int long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb ...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define mp make_pair #define lli long long int #define F first #define S second #define all(v) v.begin(),v.end() #define mii map<lli,lli> #define ...
#include <bits/stdc++.h> using namespace std; int ctoi(char); #define MAX_N 200001 #define l long #define ll long long #define f(a, b) for (ll i = a; i < b; i++) #define f0(a) for (ll i=0;i<a;i++) #define input(d) cin >> d; #define inputs(n,d) for(int i=0;i<n;i++){cin >> d[i];} #define output(d) cout << d << endl; #def...
#include<bits/stdc++.h> #define ll long long int #define ul unsigned long long int #define mp make_pair #define endl "\n" #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define lb lower_bound #define forn(i,n) for(ll i=0 ; i<n ; i++) #define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; } #define ub upper_bound...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int64_t comb(int x, int y) { int64_t res(1); for (int i = 1; i <= x; ++i) { res *= (x + y + 1 - i); res /= i; } return res; } string solve(int64_t A, int64_t B, int64_t K) { string res; while (A + B > 0) { ...
// I solemnly swear that I am upto no good // #include <bits/stdc++.h> using namespace std; #define sub freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout); #define ll long long #define ld long double #define ttime cerr << '\...
#include <iostream> using namespace std; int main(void){ 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" #define rep(i,n) for(int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef pair<int, int> P; 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; } re...
#include <set> #include <iostream> using namespace std; #define int long long const int N = 2e5 + 10; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; set<int> s; for (int i = 0; i < n; ++i) { int x; cin >> x; s.insert(x); } while (s.size() >...
#include<bits/stdc++.h> using namespace std; int main(){ int a; cin>>a; int arr[a]; for(int i=0;i<a;i++){ cin>>arr[i]; } sort(arr,arr+a); for(int i=0;i<a;i++){ if(arr[i]!=i+1){ cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
#include<bits/stdc++.h> #define ll long long int #define pii pair<int,int> #define pll pair<ll,ll> #define vpii vector< pii > #define vpll vector< pll > #define mpii map<int,int> #define mpll map<ll,ll> #define MOD 1000000007 #define all(v) v.begin(),v.end() #define s(v) v.size() #define test ll t;cin>>t;while(t--) #de...
#include <iostream> const int LAW = 200; long long int count[LAW]; int main() { for (int i=0; i<LAW; ++i) { count[i] = 0; } long long int N, n; std::cin >> N; for (long long int i=0; i<N; ++i) { std::cin >> n; n %= LAW; count[n]++; } long long int answer =...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array double calculate_expected(double x, ll nums[], ll n, ll sum, unordered_map<double, double>& visited) { if(visited.find(x) != visited.end()){ return visited[x]; } double expected_val = sum + x*n; for(int i=0; i...
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double template <typename T> void print_vec(const vector<T>& v, bool newline = true) { for (int i = 0; i < v.size(); ++i) { cout << v[i] << " "; } if (newline) { cout << "\n"; } } mt19937 rng...
#include <bits/stdc++.h> #define PI 3.14159265358979323846 #define MAXINF (1e18L) #define INF (1e9L) #define EPS (1e-9) #define MOD ((ll)(1e9+7)) #define REP(i, n) for(int i=0;i<int(n);++i) #define REPA(x, v) for(auto&& x:v) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define RREP(i, n) for(int i=int(n)-1;i>=0;--i) #de...
/* /^--^\ \____/ / \ _____ _ __ __ ____ _ ____ ____ _____ | || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_ _| \__ __/ |_| |_|/_/\_\|____...
#include <bits/stdc++.h> typedef long long int LL; typedef unsigned long long int ULL; using namespace std; // 插入此處 const LL M = 1e9 + 7; LL a[3005]; LL dp[3005][3005]; LL fix[3005]; // dp[k][r] 代表 k 節,剩餘 r int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } dp[1][0] = 1; int mk = ...
#include<stdio.h> const int MOD=998244353; static inline int IN(void) { int x=0,f=0,c=getchar();while(c<48||c>57){f^=(c==45),c=getchar();} while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x; } static inline void OUT(int x){if(x<0){putchar('-'),x=-x;}if(x>=10){OUT(x/10);}putchar(x%10+48);} static inline int MP...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, ll> pii; #define pb push_back const int MOD = 1e9 + 7, N = 2e5 + 5, K = 60; vector<pii> g[N]; int sub[N]; ll add(ll x, ll y) { x += y; while (x >= MOD) x -= MOD; while (x < 0) x += MOD; return x; } ...
/*/ Author : Abhishek Chauhan /*/ #include<bits/stdc++.h> #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" using namespace __gnu_pbds; using namespace std; // a+b = a^b + 2*(a&b) // According to Fermat's little theorem, (a^b)%mod = ((a^(b%(mod - 1)))%mod) if mod is a pri...
#include<algorithm> #include<iostream> #include<cstring> #include<bitset> #include<cstdio> #include<string> #include<cmath> #include<queue> #include<stack> #include<map> #include<set> using namespace std; #define neinf 0xc0c0c0c0c0c0c0c0ll #define inf 0x3f3f3f3f3f3f3f3fll #define uint unsigned int #define ull unsigned ...
#include <bits/stdc++.h> #define ll long long #define db(x) cout << (#x) << " = " << x << "\n" ; #define pb push_back using namespace std; set <ll> ok; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); ...
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long int #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define vi vector <int> #define ff first #define ss second #define...
#include <iostream> #include <cmath> #define ll long long int using namespace std; int main() { int n; cin>>n; int a[n],b[n]; ll ans[1001]={0}; for(int i=0;i<n;i++) {cin>>a[i];} for(int i=0;i<n;i++) {cin>>b[i];} for (int i=0;i<n;i++) { for (int j=a[i];j<=b[i];j++) { ans[j]++...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define ff first #define ss second #define d(x) cout<<x<<" " #define nl cout<<endl #define rep(var,init_val,final_val) for(int var = init_val; var < final_val; ++var) #define show(a,b) rep(i,0,b) d(a[i]);nl;...
#define _GLIBCXX_DEBUG #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++) using ll = int64_t; using vi = vector<int>; using vs = vector<string>; using vc = vector<char>; using vvi = vector<vi>; using vvs = vector<...
#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 <bits/stdc++.h> using namespace std; #define LL long long //#define MOD 1000000007 #define MOD 998244353 #define INF 1000000000000000000 #define VE vector #define VL vector<LL> #define VVL VE<VL> #define VVVL VE<VVL> #define LD long double #define PB push_back #define POB pop_back #define FOR(i,a,k) for(LL i=a...
#include <bits/stdc++.h> #define INF 1000000007 #define F first #define S second #define PB push_back #define MP make_pair #define REP(i,a,b) for (int i = a; i < b; i++) using namespace std; typedef long long ll; typedef long long int lli; typedef long double ld; typedef vector<int> vi; typedef unordered_map<int,i...
#include <bits/stdc++.h> #include <math.h> using namespace std; template<typename T> long long modpow(const T n,const T p,const T mod); template<typename T> long long modinv(const T n,const T mod); template<typename T> bool chmax(T &a,const T &b); template<typename T> bool chmin(T &a,const T &b); long long inf=10000...
#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 //#pragma GCC optimize("Ofast") //#pragma comment(linker, "/stack:200000000") //#pragma GCC targe...
#include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define pb(a) push_back(a) #define eb(a) emplace_b...
/******************************************************/ /******************************************************/ /** **/ /** BISMILLAHIR RAHMANIR RAHIM **/ /** REAZ AHAMMED CHOWDHURY - reaziii **/ /** Department of Computer Science...
#include<bits/stdc++.h> #include<iostream> #include<cmath> #include<vector> #include<string> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin>>s; if(s[0] == s[1] && s[0] == s[2] && s[1]==s[2]){ cout<<"Won"; ...
#pragma region Macros #include <bits/stdc++.h> using namespace std; 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; } #ifdef DEB...
#include<cstdio> #include<algorithm> #include<vector> #include<set> using namespace std; using ll = long long; constexpr int N = 1e6 + 5; int n; int a[N]; ll sum[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + n); for(int i = 1; i <...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); ++i) #define fixed_setprecision(n) fixed << setprecision((n)) #define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC); #define pai 3.1415926535897932384 #define NUM_MAX 2e18 #define NUM_MIN -1e9 using names...
#include "bits/stdc++.h" using namespace std; #define endl "\n" using ll = long long; const int MOD = 1e9 + 7; void solve() { int n; cin >> n; double ans = 0.0; for (int i = 1; i < n; i++) { ans += double(n) / double(i); } cout << setprecision(10) << ans << endl; } int main() { ios_base::sync_with_stdio(false...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Kein Yukiyoshi */ // clang-format off //#pragma GCC optimize("Ofast") //#pragma GCC target("avx") #include <bits/stdc++.h> using namespace std; #define int long long #define stoi stoll #define Endl endl #define itn int...
#include <bits/stdc++.h> #define loop(n) for(ll i=0;i<n;i++) #define loopj(n) for(ll j=0;j<n;j++) #define loopR(i,a,b,c) for(ll i=a;i>=b;i-=c) #define rng(i,a,b,c) for(ll i = a; i<b;i+=c) #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define ll long long #define ld long double #...
#include<iostream> #include<vector> #include<string> #include<cstdio> #include<iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; const ll LLMAX = (1llu<<(sizeof(ll)*8-1)) - 1; const int IMAX = (1llu<<(sizeof(int)*8-1)) - 1; double sx, sy, gx, gy; int main(){ cin >> sx >> sy >> gx...
#include <bits/stdc++.h> using namespace std; int main() { double Sx, Sy, Gx, Gy; cin >> Sx >> Sy >> Gx >> Gy; double x; x = (10000000000 * Sy * (Gx - Sx) / (Sy + Gy) + 10000000000 * Sx) /10000000000; cout << std::fixed << std::setprecision(10) << x << endl; }
# include <iostream> # include <vector> using namespace std; int main() { string s; cin>>s; long long t; char p; t=0; p='0'; long long k; k=0; vector<char>v; for(int i=s.size()-2; i>0; i--) { if(s[i]==s[i-1] && s[i]!=s[i+1]) { if(s[i]==p) ...
#include<bits/stdc++.h> #define endl "\n" #define pb push_back #define ll long long int #define f first #define s second using namespace std; ll mod=1e9+7; int decimal(int x) { int f=0; while(x){if(x%10==7)f=1;x/=10;} return f; } int octal(int x) { vector<int>oc; while(x){oc.pb(x%8);x/=8;} int ...
#include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { int n;cin>>n; vector<int>arr(n); for(int i=0;i<n;i++) cin>>arr[i]; sort(arr.begin(),arr.end()); vector<int>pref(n+1,0); for(int i=1;i<=n;i++) pref[i]=pref[i-1]+arr[i-1]; int ans=0; for(int i=1;i<=n;i++) ...
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define int long long int #define ll long long #define F first #define S second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define mll unordered_map<ll,ll> #define dec(v) sort(v.rbegin(),v.rend());...
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") #include <bits/stdc++.h> #ifdef __LOCAL #include <debug/debugger.h> #endif #include <ext/pb_ds/assoc_container.hpp> #define PB push_back #define PI acos(-1) #define all(x) x.begin(),x.end() #define vi vector<ll> #define ii pair<ll,ll> #define v...
#include <cstdio> #include <cmath> #include <iostream> #include <set> #include <algorithm> #include <vector> #include <map> #include <cassert> #include <string> #include <cstring> #include <queue> using namespace std; #define rep(i,a,b) for(int i = a; i < b; i++) #define S(x) scanf("%d",&x) #define S2(x,y) scanf("%d%...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} const int MAX_N = 200100; int par[M...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdio> #include <cmath> #include <tuple> #include <random> #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; co...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; const int INF = int (1e9) + int (1e5); const ll INFL = ll(2e18) + ll(1e10); const ui MOD = 1E9 ...
#include <iostream> #include <algorithm> using namespace std; #pragma warning (disable: 4996) long long mod = 1000000007; long long N, A[1 << 18], Q[1 << 18]; long long Answer = 1; int main() { cin >> N; for(int i = 1; i <= N; i++) cin >> A[i]; sort(A + 1, A + N + 1); for(int i = 1; i <= N; i++) Q[i] ...
#include <bits/stdc++.h> #define int long long using namespace std; const int MAX_N = 2e5 + 7; const int MOD = 1e9 + 7; char s[MAX_N]; int d[MAX_N], dp[MAX_N][17]; int n, k, state; signed main() { scanf("%s%lld", s, &k); n = strlen(s); for (int i = 0; i < n; ++i) { if (s[i] >= '0' && s[i] <= '9')...
// atcoder/abc194/F/main.cpp // author: @___Johniel // github: https://github.com/johniel/ #include <bits/stdc++.h> #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) using namespace std; template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ...
#include<bits/stdc++.h> using namespace std; const int N=2500+5; int a[N]; vector<int> b; int vis[10005]; int main() { int n; cin>>n; for(int i=2;i*6<=10000;i++) b.push_back(i*6),vis[i*6]=1; for(int i=2;i*10<=10000;i++) if(!vis[i*10]) b.push_back(i*10),vis[i*10]=1; for(int i=2;i*15<=10000;i+...
#include "bits/stdc++.h" #include <chrono> #include <random> #define lli long long int using namespace std; #define mod 1000000007 #define mod1 998244353 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define INF 1000000000 #define common cout << "Case #" << w+1 << ": " #define maxn 10...
// created: 16.02.2021 03:26:23 #include <iostream> #include <numeric> #include <cmath> #include<vector> using namespace std; #define REP(i,n) for(int i=0;i<int(n);i++) #define REPD(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,a,b) for(int i=a;i<=int(b);i++) #define FORD(i,a,b) for(int i=a;i>=int(b);i--) int decima...
#include <bits/stdc++.h> using Int = long long; // clang-format off #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) #define RREP_(i, a_, b_, a, b, ...) for (Int i = Int(b) - 1, low##i = (a); i >= low##i; i--) #def...
#include <bits/stdc++.h> #define LOCAL #define mkp make_pair #define ft first #define sd second using namespace std; typedef long long ll; typedef long double lld; typedef pair<ll,ll> pll; const lld pi = 3.14159265358979323846; const ll maxn=1e5+10; const ll mod=998244353; void init(void); ll pow_mod(ll a,ll k); void ...
#include<bits/stdc++.h> using namespace std; #define local #ifdef local template<class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template<class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); ...
#include <iostream> #include <vector> #include <unordered_set> int main() { long long N; std::cin >> N; std::unordered_set<long long> hashset; for(long long i = 2; (i * i) <= N; i++){ hashset.emplace(i*i); long long t = i*i; while(1){ t *= i; if(t > N){...
// .-""""-. // / j \ // :.d; ; // $P : // .m._ $$ : // dSMMSSSss.__$b. __ : // :MMSMMSSSMMMSS$$b $P ; // SMMMSMMSMMMSSS$$$$ :b // dSMMMSMMMMMMSSMM$$b.dP ...
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <string> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <ctime> #include <cassert> #include <fstream> #include <stack> #include <random> #include <i...
/************************************************************************* > File Name: solve.cpp > Author: liupo > Mail: lanzongwei@gmail.com > Created Time: 2021-02-28 21:37:24 ************************************************************************/ #define GOODOJ #define SYNC 0 #ifdef GOODOJ #include <bi...
#include "bits/stdc++.h" #define rep(i,n) for(int i=0;i<(n);++i) #define reps(i,cc,n) for(int i=cc;i<(n);++i) #define dreps(i,cc,n) for(int i=cc;i>(n);--i) #define llreps(i,cc,n) for(long long i=cc;i<(n);++i) #define ALL(v) begin(v),end(v) using namespace std; using ll = long long; using ld = long double; using ull = ...
#include <iostream> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if (a==b){ cout<<c; return 0; } if (a==c){ cout<<b; return 0; } if (c==b){ cout<<a; return 0; } cout<<0; }
// ABC183C #include <bits/stdc++.h> #include <iostream> #include <cstring> #include <string> #include <regex> #include <cstdio> #include <algorithm> #include <cstdlib> #include <cctype> #include <cmath> #include <vector> #include <set> #define rep(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, n, m) for(int i = (i...
#include <iostream> #include<bits/stdc++.h> #include <string> using namespace std; int main(void){ int h,w,x,y; std::cin >> h >> w >> x >> y; x -= 1; y -= 1; string s[h]; for (int i= 0;i<h;i++){ std::cin >> s[i]; } int cnt = -3; // down for (int i = x; i < h && ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<long long> vll; //A /*int main(){ int n; cin >> n; int x=n%100; if(n==0) { cout << 100 << endl; return 0; } cout << 100-x << endl; return 0; } */ //B /*int main(){ string s; cin >> s; bool ...
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; for(int i=0;i<k;i++){ string s1=to_string(n); string s2=to_string(n); sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end(),greater<char>()); int tmp1=stoi(s1); int tmp2=stoi(s2); n=tmp2-tmp1; } cout<<...
#include <bits/stdc++.h> using namespace std; #define ll long long #define fr(i,j,k) for(int i=j;i<k;i++) #define f(n) fr(i,0,n) #define f1(n) fr(i,1,n+1) #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() const int mod = 1e9 + 7; const int maxn = 200005; ll sum[maxn << 2]; ll lzd[m...
#include<bits/stdc++.h> using namespace std; const long long mod = 998244353; long long n , a [200005] , t [200005] , q , x [200005] , ans [200005] , ad [200005] , anss [200005]; deque < pair < long long , long long > > dq; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //...
#include <bits/stdc++.h> #include <vector> #include <string> #include <algorithm> using namespace std; vector<string> split(const string &s, char delim) { vector<string> elems; string item; for (char ch: s) { if (ch == delim) { if (!item.empty()) { elems.push_back(item); } item.cle...
#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 <bits/stdc++.h> #include <iostream> #include <queue> #include <stack> #include <vector> #include <string> #include <set> #include <map> #include <random> #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) #define repl(i,n) for (long long i = 0; i < (n); ++i) #defin...
#include<cstdio> #include<cctype> #include<set> #include<map> using namespace std; typedef map<int,int>::iterator Mit; template<class T> void read(T& x) { x=0; int f=1,ch=getchar(); while(!isdigit(ch)){ if(ch=='-') f=-1; ch=getchar(); } while(isdigit(ch)){ x=x*10+ch-'0'; ...
#include <bits/stdc++.h> #define MAXN 1500000 using namespace std; vector<int>pos[MAXN + 1]; int main() { int m, n; cin>>n>>m; for(int i=0; i<=n; i++) pos[i].push_back(-1); for(int i=0; i<n; i++) { int x; cin>>x; pos[x].push_back(i); } for(int i=0; i<=n; i++) ...
#include <cstdio> #include <cstring> #include <algorithm> #define N 1500010 using namespace std; int n, m; int tr[4*N], a[N], ans; void ins(int i, int x, int k, int l, int r){ if (l==r){ tr[i]+=k; return; } int mid=(l+r)/2; if (x<=mid) ins(i<<1, x, k, l, mid); else ins(i<<1|1, x, k, mid+1, r); if (!tr[i<<1...
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> pll; typedef pair<long long, pll> plp; priority_queue<plp, vector<plp>, greater<plp> > q; long long n, m, a[507][507], b[507][507], vis[507][507], dist[507][507], v, x, y; void check(long long x, long long y, long long d) { if(x=...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using TIII = tuple<int, int, int>; template<class T> inline bool chmin(T& a, T b) { return (a > b) ? (a = b, true) : false; } const int INF = 1 << 30; int main(void) { int R, C; cin >> R >> C; vector<vector<int>...
/*input 10 -31 -35 8 -36 22 64 5 73 -14 8 18 -58 -41 -85 1 -88 -21 -85 -11 82 */ #include<bits/stdc++.h> using namespace std; int fun(pair<int,int> p1,pair<int,int> p2) { int dy = abs(p2.second - p1.second); int dx = abs(p2.first - p1.first); // cout<<(dy*1.0/dx*1.0)<<" "<<(dy<=dx && dy>=(-1*dx))<<"\n"; return ...
#include<bits/stdc++.h> using namespace std; //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vect...
#include<iostream> #include<cstdio> #define mod 998244353 #define N 5000 using namespace std; long long n,m,ans,dp[N+1][3]; int main() { cin>>n>>m; for (int i=1;i<=m;++i) { for (int j=0;j<=n;++j) dp[j][0]=dp[j][1]=dp[j][2]=0; dp[0][1]=1; for (int j=1;j<=n;++j) dp[j][2]=(dp[j][2]+dp[j-1][2]*m%m...
#include <bits/stdc++.h> #define fi first #define se second #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,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 TPP...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <sstream> #include <numeric> #include <map> #include <set> #include <queue> #include <vector> using namespace std; const int64_t MOD = 1000000007LL; struct modint { int64_t x; modint() { } modint(int _x) : x(_x...
#include <bits/stdc++.h> using namespace std; template <int MOD_> struct modnum { static constexpr int MOD = MOD_; static_assert(MOD_ > 0, "MOD must be positive"); private: using ll = long long; int v; static int minv(int a, int m) { a %= m; assert(a); return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define x first #define y second #define FOR(i, m, n) for (ll i(m); i < n; i++) #define DWN(i, m, n) for (ll i(m); i >= n; i--) #define REP(i, n) FOR(i, 0, n) #define DW(i, n) DWN(i, n, 0) #define F(n) REP(i, n) #define FF(n) REP...
#include<bits/stdc++.h> using namespace std; #define int long long #define For(i,a,b) for(register int i=a;i<=b;++i) #define Down(i,a,b) for(register int i=a;i>=b;i--) #define reg register namespace yspm{ inline int read(){ int res=0,f=1; char k; while(!isdigit(k=getchar())) if(k=='-') f=-1; while(isdigit(k)) re...
#include <bits/stdc++.h> #define REP(i, m, n) for (int(i) = (m); (i) < (n); ++i) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() using namespace std; using Graph = vector<vector<int>>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } ...
#include"bits/stdc++.h" #include <inttypes.h> using namespace std; #define ll long long int mod = 1e9+7; #define int ll int d, x, y; void extendedEuclid(int A, int B) { if(B == 0) { d = A; x = 1; y = 0; } else { extendedEuclid(B, A%B); int temp = x; x = y; ...
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, init, end) ...
#include <bits/stdc++.h> #define rep(i, begin, end) for (i=begin;i<end;i++) #define printint(i0, i1) printf("%d %d\n", i0, i1) #define MAX_N 1000 using namespace std; typedef long long int ll; const int inf = 1000000000; const int mod = 1000000007; const int nil = -1; ll i, j, n, m, k, ans; ll corr[27], exist[27] = {}...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; double dp[110][110][110]; int main(){ vector<int> A(3); rep(i,3) cin >> A[i]; dp[A[0]][A[1]][A[2]] = 1.0; rep(i,100){ rep(j,100){ rep(k,100){ if(i + j + k == 0) con...
#include <bits/stdc++.h> using namespace std; const int n = 100; double dp[n + 1][n + 1][n + 1]; int main() { ios_base::sync_with_stdio(false); for (int i = n - 1; i >= 0; i--) { for (int j = n - 1; j >= 0; j--) { for (int k = n - 1; k >= 0; k--) { int s = i + j + k; if (s > 0) { ...
#include <bits/stdc++.h> #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define all(x) begin(x), end(x) #define chmax(x,y) x = max(x,y) #define chmin(x,y) x = min(x,y) #define fi first #define se second using namespace std; typedef long long ll; typedef pair <int,int> P; const int INF=1e9; const in...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2E5; int par[MAXN]; int sz[MAXN]; int rep[MAXN]; pair<long long, int> a[MAXN]; pair<long long, int> f[MAXN]; long long ans[MAXN]; int getRoot(int x) { if (par[x] != x) par[x] = getRoot(par[x]); return par[x]; } void mge(int x, int y) { ...