code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> using namespace std; #define trav(a, x) for(auto& a : x) #define vi vector<int> #define fo(i, k, n) for(int i = k; i < n; ++i) typedef long long ll; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if(name.size()){ freopen((name+".in").c_str(), "r", stdi...
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; vector<int> A(N); for(int i = 0; i < N; ++i){ cin >> A[i]; } const int MIN_ELEM = *min_element(A.begin(), A.end()); unordered_map<int, int> memo; ...
#include<bits/stdc++.h> using namespace std; #define int long long #define w(x) int x; cin>>x; while(x--) #define endl ("\n") #define f(i, a, n) for(int i=a; i<n; i++) #define cc(r) cout<<r<<" " #define ce(r) cout<<r<<endl void inout() { ios_base::sync_...
#include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i <= b; ++i) #define repr(i,a,b) for(int i = a ; i >= b; --i) #define NAME "NAME" #define pb push_back #define mp make_pair #define EL cout << '\n' #define cqtshadow int main #define fillchar(a,x) memse...
#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; /*---------------------DEBUGGING--------------------------------------------*/ void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(lon...
#include<bits/stdc++.h> // #include<atcoder/all> // #include<boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace atcoder; // using bint = boost::multiprecision::cpp_int; using ll = long long; using ull = unsigned long long; using P = pair<int,int>; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #de...
#include <iostream> #include <stdio.h> #include <vector> #include <map> #include <stack> #include <cstring> #include <utility> #include <iostream> #include <iomanip> #include <list> #include <queue> #include <algorithm> #include <cmath> #include <set> #include <unordered_set> #include <bitset> #define FOR(i,a,b) for (...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } long long gcd_vec(vector<long long> const &A) { // N個の要素に対する最大公約数 int size = (int)A.size(); long long ret = A[0]; for (int i = 1; i <...
#include "bits/stdc++.h" #include <chrono> #include <random> #include <ext/pb_ds/assoc_container.hpp> #define INF 1000000007 #define F first #define S second #define PB push_back #define MP make_pair #define REP(i,a,b) for (int i = a; i < b; i++) #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<long long>; using vvl = vector<vector<long long>>; #define rep(i, s, n) for (int i = (int)s; i < (int)n; i++) #define repr(i...
#include <iostream> #include <string> #include <bits/stdc++.h> using namespace std; int main(){ double n, D, H; cin >> n >> D >> H; vector<double> d(n), h(n); for(int i = 0; i < n; i++) cin >> d[i] >> h[i]; vector<double> x(n); double ans = 0.0; for(int i = 0; i < n; i++){ x[i] = H - D * (H - h[i]) / (D - d[i]);...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #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++) const ll MAX = 1001001; const ll MOD = 1000000007; const double pi = 2.0 * asin(1.0); ll dx[4] = {1, 0, -1, 0}; ll dy[4]...
//@formatter:off #include<bits/stdc++.h> #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #defi...
#include <bits/stdc++.h> #define li long int #define lli long long #define pb push_back #define mp make_pair #define fi first #define se second #define si size() #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define lb lower_bound #define ub upper_bound #define BS binary_search #define...
//GOD PLEASE HELP ME ,GOD PLEASE HELP ME , GOD PLEASE HELP ME //Name Rishiraj Kalita // sc id : 1912041 #include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(i=0;i<n;i++) #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long #define si(x) scanf("%d",&x) #de...
#include<bits/stdc++.h> using namespace std; #define ll long long void solve(){ ll a,b,c,d; cin>>a>>b>>c>>d; ll temp=(a); ll temp1=(d*c-b); if(temp1<=0) cout<<-1<<endl; else{ if(temp%temp1==0) cout<<temp/temp1<<endl; else cout<<temp/temp1+1<<endl; } } int main...
#include<iostream> #include<string> #include<vector> #include<utility> #include<algorithm> #include<map> #include<set> #include<cstdlib> #include<cmath> #include<numeric> #include<iomanip> #include<functional> #include<cstdlib> #include<queue> #include<deque> #include<cassert> #include <iterator> // std::back_inser...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int n, d; cin >> n >> d; map<int, ll> mp; rep(i, n) { int a, b, c; cin >> a >> b >> c; mp[a] += c; mp[b + 1] -= c; } ll ans = 0; ...
#include <iostream> #include <vector> #include <queue> #include <utility> #define rep(i, n) for (long long i = 0; i < (n); ++i) typedef long long ll; using namespace std; int main() { ll H, W; ll start_x, start_y, goal_x, goal_y; cin >> H >> W; vector<vector<char>> map(H, vector<char>(W)); vector<...
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; vector<vector<int> > road(H*W); vector<vector<int> > port(26); vector<vector<char> > grid(H, vector<char>(W,'#')); int S, G; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> grid.at(i).at...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<vector<int>> children(n); vector<int> par(n); par[0] = -1; for (int i = 1; i < n; i++){ int p; cin >> p; p--; par[i] = p; children[p].push_back(i); } auto dfs = [...
/*input 20 2 8 4 7 5 3 1 2 4 1 2 5 4 3 3 8 1 7 8 2 */ #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 tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;...
#line 1 "/Users/haruki/kyopro/library/template.cpp" // code by lynmisakura. wish to be accepted! #include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using pi = pair<int,int>; using pl = pair<ll,ll>; using vpi = vector<pi>; using vpl...
#include <bits/stdc++.h> using namespace std; long long f(vector<long long>& a, vector<long long>& t, const long long& X0){ long long res = X0; for(int i = 1; i < (int)a.size(); ++i){ if(t[i] == 1){ res += a[i]; }else if(t[i] == 2){ res = max(a[i], res); }else{ ...
#include <bits/stdc++.h> #define debug_input freopen("stdin.in", "r", stdin) #define debug_output freopen("stdout.out", "w", stdout) #define FOR(i, a, b) for(int i = a; i <= b; i++) #define FORALL(i, n) for(int i = 0; i < n; i++) #define FORD(i, a, b) for(int i = a; i >= b; i--) #define SORT(a) sort(a.begin(), a.end()...
#include <bits/stdc++.h> using namespace std; int main(){ int N,W; int re; cin >> N >> W; re=N/W; cout << re << endl; }
//@sakshjha #include<bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define JALDI ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define pb push_back #define pi 3.14159265358979 const int mod = 1e9 +7; const int N = 1e6 +5 ; int a[1005],b[1005]; int dp[1005][1005]; i...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define rng(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i) #define per(i, b) gnr(i, 0, b) #define all(obj) begin(obj), end(obj) #define allr(ob...
#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 long double ld; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll...
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> ...
#include<iostream> #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define int long long using namespace std; int c[502][502],a[502],b[502]; signed main(){ ios::sync_with_stdio(false); int n; cin>>n; rep(i,1,n)rep(j,1,n)cin>>c[i][j]; bool flag=true; rep(i,1,n){rep(j,2,n){ if(i==1)a[j]=c[i][j]-c...
#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=...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <x86intrin.h> // __builtin_popcount(int x) using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define V vector #define pb push...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll ...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_...
#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...
#include <bits/stdc++.h> using namespace std; int main() { long S,P; cin >> S >> P; for(long i=1; i<S;i++){ if(i*(S-i) == P){ cout << "Yes" << endl; //cout << i << S << P << endl; return 0; } else if (i*(S-i) > P){ cout << "No" <...
#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; 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<vpll> vvpll; typedef vector<bool> vbl; typedef vector<vector<bool>> vvbl; void INX(){} template<typenam...
#include <bits/stdc++.h> #include <random> #include <unordered_map> #include <unordered_set> using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3,unroll-loops") using ll = long long; using ull = unsigned long long; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #def...
#pragma GCC optimize(2) #include <bits/stdc++.h> #define INF 1000000000 #define LINF 1000000000000000000 #define MOD 1000000007 #define mod 998244353 #define INF63 1061109567 #define INF127 9187201950435737471 #define UINF 18446744073709551615 #define F first #define S second #define ll long long #define N 5010 using n...
#include <bits/stdc++.h> using namespace std; int main() { char a, b; cin>>a>>b; if(a=='Y') {b=b-32; cout << b << endl;} else cout << b << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; int k=(2*a)+100; cout<<k-b<<endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define MOD 1000000007 #define MOD2 1000000009 #define endl "\n" #define pii pair <int, int> #define pll pair <ll, ll> #define F first #define S second map<ll, ll> dp, vis; ll ans = 1e...
#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; ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typed...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mp make_pair #define Fast_IO ios::sync_with_stdio(false); #define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__) //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #de...
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") //~ #pragma GCC target ("avx2") //~ #pragma GCC optimize("Ofast") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //~ #pragma GCC optimize("unroll-loops") #include <bits/st...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; if(n==2){ cout<<1<<" "<<2<<endl; cout<<1<<" "<<2<<endl; }else{ for(int i=1;i<=n;i++){ if(i==1){ cout<<1<<" "<<n/2+1<<endl; }else if(i==n){ cout<<n/2+1<<" "<<n<<endl; }else{ if(i!=2){ ...
#include<bits/stdc++.h> //#include <atcoder/all> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define rep(i,n)for(int i=0;(i)<(int)(n);i++) #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++) #define ALL(a) (a).begin(),(a).end() #define pb push_back #define fi first #...
#include <bits/stdc++.h> #define F first #define S second #define all(x) x.begin(),x.end() #define endl '\n' using namespace std; using ll = long long; using pii = pair<int, int>; const int INF = 0x3f3f3f3f; const ll INFLL = 0x3f3f3f3f3f3f3f3fLL; const int MOD = 1000000007; const int dx[] = { 0, 0, -1, 1, 1, -1, 1, ...
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define LD long double #define ST string #define BS bitset #define PA pair<LL...
#include <bits/stdc++.h> using namespace std; typedef long long ll; //int a[200000]; int main() { int n, m, t, k, s = 0; int a,b,c,d; cin>>a>>b>>c>>d; int t1=b*a; int t2=c*a; if(d>=t1&&d<=t2) { cout<<"No"; } else { cout<<"Yes"; } return 0; }
#include <bits/stdc++.h> using namespace std; std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now(); // Defines #define all(x) (x).begin(),(x).end() #define sortall(x) sort(x.begin(),x.end()) #define maxin(x) *max_element(x.begin(),x.end()) #define minin(x) *min_...
/* JAI JAGANNATH! */ //@Author : zanj0 #include<bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back #define MOD 1000000007 #define inf 1e18 #define ps(x,y) fixed<<setprecision(y...
// // main.cpp // Atcoder1 // // Created by Hamske on 2020/09/17. // Copyright © 2020 Author. All rights reserved. // #include <iostream> #include <vector> #include <queue> #include <algorithm> #include <string> #include <sstream> using namespace std; //#define pb push_back //#define mp make_pair #define fi firs...
/* _____________________ |Author : canhnam357| |___________________| */ #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef vector <int> vi; typedef vector <ll> vll; typedef vector <string...
#include<bits/stdc++.h> using namespace std; const int64_t MOD = 1e9+7; void experiment(vector<char> V){ for(int i=0; i<4; i++){ cout << V[i]; } cout << " "; set<string> S; S.insert("AB"); queue<string> Q; Q.push("AB"); for(int i=3; i<=10; i++){ cout << S.size() << " "; S.clear(); int ...
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define mp make_pair #define pb push_back #define pll pair<LL,LL> #define pii pair<int,int> #define y second #define x first #define LL long long #de...
#define ll long long int #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; string t = ""; for(int i=0; i<s.size(); i++){ if(s[i] == '.')...
#include <bits/stdc++.h> using namespace std ; #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); typedef long long ll ; typedef unsigned long long ull ; typedef long double ld ; const ll MOD = 1E9 + 7, INF = 2E18 + 5 ; const double PI = 2 * acos(0.0) ; const long double EPS = 1.0E-14 ; ...
#include <bits/stdc++.h> #define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) begin(x), end(x) using namespace std; using ll = long long; constexpr ll Mod = 998244353; constexpr ll mod = 1e9 + 7; constexpr ll inf =...
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long #define ull unsigned ll #define ld long double #define mod 1000000007 #define pb push_back #define pf push_front #defin...
#include<bits/stdc++.h> #define for0(n) for(lli i=0;i<n;i++) #define in(x) lli x; cin>>x using namespace std; typedef long long int lli; void buildTree(lli s,lli e,lli *arr, vector<lli> &tree,lli ind){ // base if(s==e){ // at the leaf node tree[ind] = arr[s]; return; } // recurse...
#include <bits/stdc++.h> using namespace std; #define LL long long #define int long long namespace IO { const int N = 2e6; char buf[N], *p1 = buf, *p2 = buf; inline char gc() { if(p1 == p2) p2 = (p1 = buf) + fread(buf, 1, N, stdin); return p1 == p2 ? EOF : *(p1 ++); } template <typename T> inline void read(...
#include <iostream> #include <iomanip> using namespace std; int main() { double Sx, Sy, Gx, Gy; cin >> Sx >> Sy >> Gx >> Gy; cout << fixed << setprecision(7) << Sx + Sy * (Gx - Sx) / (Gy + Sy) << endl; }
/* #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,sse,sse2,fma") //*/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int ,int > pii; mt19937 rng(chrono::steady_clock::now().time_sinc...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 10e16; int main() { int n, m; cin >> n >> m; vector<ll> a(m), b(m); vector<char> c(m); rep(i, m) { cin >> a[i] >> b[i] >> c[i]; ...
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> #include <set> #include <map> #include <queue> #include <deque> #include <bitset> #include <math.h> #include <random> #include <chrono> #include <assert.h> using namespace std ; using...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define int long long #define ld long double #define f(i,x,n) for(int i=x;i<n;i++) using namespace std; const int mod=1e9+7; const int inf=1e18; int n,x[20],y[20],z[20]; int dp[200000][20]; int dfs(int mask,int pos) { int &an=dp[mask][pos...
#include<bits/stdc++.h> #define int long long #define ld long double #define fi first #define se second #define vll vector<int> #define pii pair<int,int> #define pb push_back #define sz(v) (int)(v).size() #define inf (int)(1e18) #define md (int)(998244353) #define all(v) (v).begin(),(v).end() #define rep(i,a,b) for(int...
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<vector<int>> cnt(200, vector<int>(0)); for(int i = 0; i < N; i++) cin >> A[i]; int tg = min(N, 8); for(int i = 0; i < (1 << tg); i++) { int sum = 0; vector<int> ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; //#define ACL #ifdef ACL #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #if __has_include("acl-all.h") #include "acl-all.h" //on Wandbox using namespace atcoder; #endif #endif //#ifdef ACL typedef long...
/* Author: rrrr_wys **/ #include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define per(i, a, b) for (int i = (a); i >= (b); --i) #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second typedef double db; typedef long long ll; using namesp...
#include <bits/stdc++.h> #define int long long using namespace std; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')w=-1;ch=getchar(); } while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } inline bool read(int& a){ int s=0,w=1; ...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define M 1000000007 #define mod 998244353 #define pll pair<ll, ll> #define f first #define se second #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define pb push_back #define rb pop_back #define prdb(x) cout << fixed << se...
#include <bits/stdc++.h> using namespace std; #define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) typedef long long ll; typedef pair<int,int> pii; const int MAXN = 400005; const int INF = 0x3f3f3f3f; char s[MAXN]; inline void solve() { int n; cin >> n; string str; cin >> str; str =...
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> data(N); vector<long long> r(200, 0); for (int i = 0; i < N; ++i) { cin >> data.at(i); r[data.at(i) % 200]++; } long long ans = 0; //for (auto n : r) { // cout << n.first <<"," << n.second << endl; //}...
#include <bits/stdc++.h> using namespace std; /* #include <atcoder/all> using namespace atcoder; */ #define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i) #define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i) #define REP(i, n) rep(i, 0, n) #define REP2(i, n) rep2(i, 0, n) #define all(hoge) (hoge)....
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; #define pb push_back #define mp make_pair #define fi first #define se second const int NN = 2e5 + 5; const int mo = 1e9 + 7; const ld eps = 1e-9; ll n; int main() { ios_base::sync_with_stdio(0);cin.t...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <iomanip> #include <cmath> #include <numeric> using namespace std; using ll = long long; //ループ #define REP(i, n) for(int i = 0; i < n; ++i) #define REPR(i, n) for(int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for(int i = m; i < n; ...
#include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); #define ll long long #define t() int t;cin>>t;while(t--) #define lt() long long int t;cin>>t;while(t--) #define ff first #define ss second #define pb...
#include<cstdio> #include<algorithm> using namespace std; int Read() { int Output=0; char Input=getchar(); while(Input<'0'||Input>'9') Input=getchar(); while(Input>='0'&&Input<='9') { Output=Output*10+Input-'0'; Input=getchar(); } return Output; } int N; char Name[1001][1...
#include<bits/stdc++.h> #define ll long long using namespace std; int read() { char c; int w=1; while((c=getchar())>'9'||c<'0')if(c=='-')w=-1; int ans=c-'0'; while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0'; return ans*w; } int n; ll X; int a[105]; int b[105]; int f[105][105][105]; int vis[105][105][1...
#include<bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef std::vector<ll> vi; typedef std::vector<std::vector<ll> > vv; typedef std::vector<std::pair<ll,ll> > pii; #define mod 1000000007 #define IO ios_base::sync_with_stdio(false);cin.tie(NULL); #define fo(i,a,b) for(i=a;i<b;i++) #define f...
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; //vector string deque break continue #define forn(i, s, f) for (int i = (int)s; i < (int)f; i++) #define ll long long #define ull unsigned long long #define ld long double #define pii pair <int, int> #define fs first #define sc second #defi...
#include <bits/stdc++.h> using namespace std; // using mint = long double; // using mint = modint998244353; // using mint = modint1000000007; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<ll, vector<ll>> Pd; const ll INF = 2e18; const ll fact_table = 1200008; priority_queue<ll> ...
#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<ve...
#include<bits/stdc++.h> using namespace std; const int N = 1e5+100; typedef long long ll; const int inf = 0x3f3f3f3f; typedef pair<int,int> pii; #define fr(i,a,b) for(int i = a;i <= b; ++i) #define nfr(i,a,b) for(int i = a;i >= b; --i) int n,l; int a[N],b[N]; int pos[N]; set<pii> s1; int main(){ scanf("%d%d",&n,&l)...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <unordered_map> #include <unordered_set> using namespace std; 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; r...
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #include<bits/stdc++.h> #define ll long long #define pb push_back #define bg begin() #define en end() #define endl "\n" #define vvl(n,m) vector<vector<ll> > a( n , vector<ll> (m)) #define fast ios_...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<LD> VLD; typedef vector<string> VS; #define rep(i, max) for (LL i = 0; i < (LL)(max); i++) #define repm(i, min, max) for (LL i = (LL)(min); i < (LL)(max); i++) #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define rep(i,n) for (int i=0; i<(n);++i) ll n,p,q,mod=pow(10,9)+7; int main(){ cin >> n; p = n%5; if(p==0){ cout << -1; return 0; } if(p==1) q=4; else if(p==2) q=3; else if(p==3) q=1;...
#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=a;i<=b;i++) using LL = long long; const int Nmax=2e5+9; int N,M,A[109],B[109],C[19],D[19],K,ans,Ball[109],tmp; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M; REP(i,1,M) cin>>A[i]>>B[i]; cin>>K; REP(i,...
#include<bits/stdc++.h> using namespace std; mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count()); #define ll long long #define int long long #define vi std::vector<int> #define setbits(x) __builtin_popcountll(x) #define pb push_back #define fn...
#include <bits/stdc++.h> // #include <atcoder/all> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rep1(i,n) for(int i = 1; i <= (n); ++i) // #define MOD 998'244'353 // #define MOD 1'000'000'007 // #define INF 1'000'000'000'000'000'000 using namespace std; // using namespace atcoder; typedef long long ll; int ma...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <initializer_list> #include <cmath> #define REP(i, n) for(int i = 0; i < (n); i++) #define REPS(i, a, b) for(int i = (a); i <= (b); i++) #define REPR(i, n) for(int i = (n) - 1; i >= 0; i--) #define REPRS(i, b, a) for(in...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> #define mkp make_pair #define mkt make_tuple #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) v.begin(), v.end() using namespace...
#pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int mod = 998244353; ll binpow(ll a, ll p) { ll res = 1; while (p) { if (p & 1) { (res *= a) %= mod; ...
/** ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀ ⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀ ⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀ ⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀ ⠀⡇⠀⠀⠀⠀...
// Author : ps41 #include <bits/stdc++.h> using namespace std; #define ll int64_t const ll M = 1e9 + 7, N = 1e6 + 5; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); string s; cin >> s; int n = s.size(); int ch = 1; for (int i = 0; i < n; i++) { if (i % 2) { ...
#include<bits/stdc++.h> using namespace std; #define int long long // typedef long long int; int const N = 4e6 + 10, mod = 1e9 + 7; int fact[N], infact[N]; int n, m, k; int qmi(int a, int k, int p) { int res = 1; while (k) { if (k & 1) res = res * a % p; k >>= 1; a = a * a % p; } ...
// title #include <cstdint> template <std::uint_fast64_t Modulus> class modint { using u64 = std::uint_fast64_t; public: u64 a; constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define all(A) A.begin(), A.end() typede...
#include <iostream> using namespace std; int main() { int n; while(cin>>n){ cout<<n-1<<endl; } }
#include<iostream> #include<algorithm> #include<ctime> #include<vector> #include<string> #include<cmath> #include<map> #include<iomanip> #include<numeric> #include<queue> #include<deque> #include<cfloat> #include<functional> #include<tuple> #include<math.h> #include<bitset> #include<stack> #include<set> #include<random...
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define X first #define Y second #define nl '\n' #define AC return 0 #define pb(a) push_back(a) #define mst(a,b) memset(a, b, sizeof a) #define rep(i,n) for(int i = 0; (i)<(n); i++) #define rep1(i,n) for(int i = 1; (i)<=(n); i++) #de...
#include "bits/stdc++.h" #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 <iostream> #include <vector> #include <queue> using namespace std; const int INF = (1u<<30) - 1; struct BFS { int V; const vector<vector<int>> &g; int s; vector<int> dist; vector<int> previous; BFS(const vector<vector<int>> &g) : V(g.size()), g(g) {} void calc(int start) { s = start; dist.assign(...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x...
#include <string> #include <queue> #include <stack> #include <vector> #include <sstream> #include <algorithm> #include <deque> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <list> #include <cstdio> #include <iostream> #include <cmath> #include <climits> #include <bitset> #incl...
#include<iostream> #include<vector> #include<algorithm> int main(void){ int n, t; std::cin >> n >> t; std::vector<long long> vec1, vec2; vec1 = vec2 = {0}; for(int i = 0; i < n; i++){ int a; std::cin >> a; for(int j = vec1.size()-1; j >= 0; --j){ vec1.push_back(a...
#include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <bitset> #include <vector> #include <cstdio> #include <string> #include <sstream> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define PB push_back #define MP ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (ll 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; ll co...
/*** author: yuji9511 ***/ #include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; using lpair = pair<ll, ll>; using vll = vector<ll>; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);...
#include<iostream> #include<string> using namespace std; int main(){ string n; cin >> n; int a; a=n.length(); a--; int i=a,j; while(i>=0 && n[i]=='0'){ if(n[i]=='0') a--; i--; } j=a; int k=0,flag=0; while(k<=j){ if(n[k]!=n[j]) flag=1; k++; j--; } if(flag==0) cout << "Yes"; ...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long int gcd(int a, int b) { if(a == 0) return b; return gcd(b % a, a); } int lcm(int a, int b) { return ((a * b) / gcd(a, b)); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int x; cin >> x; int ans =...
// ahc002_a #pragma GCC optimize ("O3") #include <bits/stdc++.h> #ifdef LOCAL #include "../../debug_util/cxx-prettyprint/prettyprint.hpp" #include "../../debug_util/rng.hpp" #endif using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; #define REP(i, n) for (int i = 0 ; ...
#include <bits/stdc++.h> #include <stdio.h> using namespace std; using ll = long long; #define MOD 1000000007 #define SWAP(a,b) ((a != b)? (a += b,b = a - b,a -= b) : 0 ) //数値のみ #define SWAP(type,a,b) { type temp = a; a = b; b = temp; } //ポインタ, 構造体, 文字列 #define rng(i, a, b) for(int i = int(a); i < int(b); i++) #define...
#pragma warning(disable : 4996) #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; typedef tuple<ll,ll,ll> tl3; #define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++...
#include <stdio.h> #define MOD 3 int fact[400010],count[400010]; char x[400010]; int comb(int a, int b) { if(count[a]>count[b]+count[a-b]) return 0; else return (fact[a]*fact[b]*fact[a-b])%MOD; } int main() { fact[0] = 1; count[0] = 0; for(int i=1;i<=400000;i++) { int c = i; count[i] = count[i-1]; while(c%...
#include <bits/stdc++.h> #define ALL(A) (A).begin(), (A).end() #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) 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; retu...
#include<cstdio> #include<algorithm> #include<cstring> #include<queue> #include<vector> using namespace std; const int M=1e6+5; const int N=1e3+5; #define int long long int Max(int x,int y){return x>y?x:y;} int Min(int x,int y){return x>y?y:x;} int Abs(int x){return x>0?x:-x;} int read(){ int k=1,num=0; char s=getcha...
#include<bits/stdc++.h> using namespace std; #define ll long long #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define all(v) v.begin(),v.end() const int mod = 1e9 + 7; int main (){ fast_io; int x, y, z; cin >> x >> y >> z; int ans = (y * z)/ x + ((y * z) % x > 0...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<a+b+c-min(a,min(b,c)); return 0; }
#include<bits/stdc++.h> #define LL long long #define pb push_back #define SZ(x) ((int)x.size()-1) #define ms(a,b) memset(a,b,sizeof a) #define F(i,a,b) for (int i=(a);i<=(b);++i) #define DF(i,a,b) for (int i=(a);i>=(b);--i) using namespace std; inline int read(){ char ch=getchar(); int w=1,c=0; for(;!isdigit(ch);ch=g...
#include <bits/stdc++.h> #define div / /* ID: farukde1 TASK: beads LANG: C++ */ using namespace std; int main() { ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL); /* freopen("input.txt","r",stdin); freopen("beads.out","w",stdout); */ string s; cin >> s; int ans=0; ...
#include<bits/stdc++.h> using namespace std; #define int long long int n,ans=1e18; int a[100001]; signed main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=0;i<1<<(n-1);i++) { int x=0,o=0; for(int j=1;j<=n;j++) { o|=a[j]; if(1<<(j-1)&(i))x^=o,o=0; } x^=o; ans=min(ans,x); } cout<...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; const int MOD = 998244353; int N, a[200010], vis[200010]; int in[200010]; int main() { scanf("%d",&N); for (int i=1; i<=N; i++) { scanf("%d",&a[i]); in[a[i]]++; } queue<int>q; for (int i=1; i<=N; i++) if (!in[i])...
#include <iostream> using namespace std; int a, b, c, d; int main() { cin >> a >> b >> c >> d; cout << b - c; return 0; }
// coded by- mrNOBODY_ #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define in(x) cin>>x; #define print(x) cout<<x; #define println(x) cout<<x<<"\n"; #define vec(x) vector<x> #define endl "\n" #define all(x) x.begin(),x.end() #define inf 1e15 #define sqr(x) ((x) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // -------------------------------------------------------- template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1...
#pragma GCC optimize ("Ofast") #pragma GCC optimization ("unroll-loops, no-stack-protector") #pragma GCC target ("avx") #pragma GCC target ("avx2") #pragma GCC target ("fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define fastio ios_bas...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,n) for(ll i=0; i<n; i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rrep(i,n) for(ll i=n-1; i>=0; i--) #define fi first #define se second long long mo = 1000000007; typedef long long ll; typedef long double ld; typedef ...
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define INF LLONG_MAX #define FLT_INF pow(10.0, 16) using ll = long long; using vll = vector<ll>; using ull = unsigned long long; using int2 = pair<ll, ll>; using int3 = tuple<ll, ll, ll>; template <typename A> string to_strin...
#include <bits/stdc++.h> #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) #ifdef LOCAL #define log(val) std::cerr << std::setw(3) << __LINE__ << "| " << #val << " = " << (val) << std::endl #define dbg(proc) proc #else #de...
#include <bits/stdc++.h> using namespace std; #define fr(i,n) for(int i = 0; i<n; i++) #define sz(v) (int)(v.size()) #define prin(a) cout << #a << " = " << a << endl #define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl #define all(v) (v).begin(),(v).end() typedef long long ll; #def...
#include<bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') f=-1; c=getchar(); } while(c>='0'&&c<='9') { x=x*10+c-'0'; c=getchar(); } return x*f; } int n; int re[10005],a[2505]; in...
//#include <boost/multiprecision/cpp_int.hpp> #include "bits/stdc++.h" //using namespace boost::multiprecision; using namespace std; #define MODULO 1000000007 #define PI 3.14159265359 typedef long long int ll; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; cout<<...
#include <bits/stdc++.h> #define all(nums) nums.begin(), nums.end() #define allr(nums) nums.rbegin(), nums.rend() using namespace std; typedef long long int ll; typedef vector<vector<int>>graph; const int imax = INT32_MAX; const int imin = INT32_MIN; const int mx=1e5+1; const ll inf=1e18; template<class T>void print(ve...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; if (T % 2 == 1) cout << "Black"; else cout << "White"; return 0; }
#include<bits/stdc++.h> using namespace std; long long n, k, m, sum=0; int main(){ cin >> n >> k >> m; for (int i=0;i<n-1;i++){ long long a; cin >> a; sum+=a; } m*=n; cout << (m-sum<=k ? max((long long)0,m-sum) : -1) << "\n"; }
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <numeric> #include <cmath> #include <unordered_map> using namespace std; using ll = long long; void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); } v...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; int gc = 0; void br() { cout << "(" << gc++ << ") " << "======" << endl; } template <typename T> void print(vector<T> &a) { for (int i = 0; i < a.size(); i++) { cout << a[i]; ...
#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...
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) (int)(x).size() #define ALL(x) (x).begin(),(x).end() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for (int i=(a);i>=(b);--i) typedef long long ll; const int mxN = 5e3+...
// Problem: C - IPFL // Contest: AtCoder - AtCoder Beginner Contest 199(Sponsored by Panasonic) // URL: https://atcoder.jp/contests/abc199/tasks/abc199_c // Memory Limit: 1024 MB // Time Limit: 2000 ms #include<bits/stdc++.h> // #define int long long // #define maxn // #define mod using namespace std; // template<cl...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mit map<int,int>::iterator #define sit set<int>::iterator #define itrm(g,x) for(mit g=x.begin();g!=x.end();g++) #define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) #define ltype int #define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++) #define r...
#include <bits/stdc++.h> const int mod=998244353; using namespace std; int T,n,m,fac[110],a[110],f[110][5010]; void init(int N){ fac[0]=1; for(int i=1;i<=N;i++) fac[i]=1ll*fac[i-1]*i%mod; } void qmo(int &x){ x+=(x>>31)&mod; } int main(){ scanf("%d",&n),init(n); for(int i=1;i<=n;i++) scanf("%d",&a[i]),m+=a[i]; if(...
#include <iostream> #include <vector> #include <string> #include <stdint.h> #include <math.h> #include <algorithm> #include <cmath> #define rep(i, j) for (int i = 0; i < (j); ++i) #define fep(i, j) for (i = 0; i < (j); ++i) #define pb push_back #define ll long long #define dp vector<pair<ll, int> > #define dn vector<v...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; int n,s,d; int main(){ scanf("%d%d%d",&n,&s,&d); bool flag=false; for(int i=1;i<=n;i++){ int x,y; scanf("%d%d",&x,&y); if(x<s&&y>d) flag=true; } if(flag) puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define MV 200001 #define LMV 21 #define ff first #define ss second #define pb push_back #define eb emplace_back #define emp emplace #define mp make_pair #define ins in...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz(x) int(x).size() typedef pair<int,int>ii; typedef vector<int> vi; const int mxn=2e5+5; int n,a[mxn],me=1e9+10; int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; me=m...
#include <bits/stdc++.h> #define int long long using namespace std; #define lowbit(x) (x & (-x)) const int maxn = 2e5+8, inf = 1e18+9, mod = 1e9+7; int n, m, a[maxn], b[maxn], bit[maxn], pos[maxn]; map<int, set<int>> mp; void update(int x, int v) { while (x < maxn) bit[x] += v, x += lowbit(x); } int ask(int x) ...
#include <bits/stdc++.h> using namespace std; #define e1 first #define e2 second #define pb push_back #define mp make_pair #define boost {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } #define eb emplace_back #define OUT(x) {cout << x; exit(0); } #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define scanf...
#include <bits/stdc++.h> using namespace std; int par[110]; int depth[110]; int siz[110]; void init(){ for(int i = 0; i < 110; i++){ par[i] = i; depth[i] = 0; siz[i] = 1; } } int find(int x){ if(par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x, int y){ x = find(x); y = find(y)...
#include <bits/stdc++.h> #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) #define vall(x) (x).begin(), (x).end() using namespace std; namespace atcoder {} using namespace atcoder; using lli = long long int; void YESNO(bool), YesNo(bool); template <class T1, class T2> b...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <numeric> #include <optional> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ll long long int #define fast ios_base::sync_with_stdio(false) #define fast_input cin.tie(NULL) #define fast_output cout.tie(NULL) #define vi vector<long ...
#include <bits/stdc++.h> #define endl '\n' #define fr first #define sc second #define all(v) v.begin(),v.end() #define unq(v) sort( all(v) ); v.erase( unique( all(v) ), v.end() ) #define bout(x) cout << bitset<sizeof(x)*8>(x) << endl #define mkp(a,b) make_pair(a,b) #define gcd(a,b) __gcd(a,b) using namespace std; using...
#include <bits/stdc++.h> using namespace std; #define int long long long long MOD =1e9+7; vector<vector<long long> > m(3e3+10,vector<long long>(3e3+10,-1)); vector<long long> v; vector<vector<int> > tps; long long bourrin(int i, int from) { if(from == -1) return 0; if(m[i][from]!= -1) { return m[i][...
#include <iostream> #include <vector> #include <set> using namespace std; typedef long long ll; typedef pair <ll, ll> pll; #define x first #define y second #define mp make_pair const int MAXN = (int)2e5; int n, q; ll a[MAXN + 5], t[MAXN + 5], x[MAXN + 5], sol[2 * MAXN + 5]; vector <int> ms[2 * MAXN + 5]; set <pll> s...
#ifdef _DEBUG #define _GLIBCXX_DEBUG #endif #if __has_include(<atcoder/all>) #include <atcoder/all> #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, ll>; #define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++) #define rrep(i, a, b) for(int i =...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define int long long #define ll long long #define all(v) v.begin(...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ff first #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll ans = 0; template<typename T> struct HamiltonGraph { int n; T M; vector<vector<T>> DP, dt, rt; const T INF = numeric_limits<T>::max(); HamiltonGraph (const int n_) : n(n_), M(1ll<<n_) { dt.assign(n_, vector<T>(n_, INF));...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; 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) #define rng(a) a.begin(),a.end() #define rrng(a) a.rbegin(),a.rend() #define isin(x,l,r) ((l) <= (x) &&...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937/*_64*/ rng(chrono::ste...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; const int N = 40, M = 1<<(N / 2); int n, t, a[N]; vector<ll> v1(M), v2(M); int main() { cin >> n >> t; rep(i, n) cin >> a[i]; rep(bit, M) { ll now = 0; rep(i, N ...
#include <cstdio> #include <cstdlib> using namespace std; #define ll long long const ll MAXN = 400011; struct fhqTreap { ll tot, rt; ll val[MAXN], sum[MAXN], sz[MAXN], ls[MAXN], rs[MAXN], rd[MAXN]; void pushup(ll u) {sz[u] = sz[ls[u]] + sz[rs[u]] + 1; sum[u] = sum[ls[u]] + sum[rs[u]] + val[u];} void split(ll u, ...
#include <bits/stdc++.h> using namespace std; template <typename T> struct binary_indexed_tree{ int N; vector<T> BIT; binary_indexed_tree(int n){ N = 1; while (N < n){ N *= 2; } BIT = vector<T>(N + 1, 0); } void add(int i, T x){ i++; while (i <= N){ BIT[i] += x; i += i & -i; } } T sum(int ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define fi first #define se second #define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++) #define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++) #define DN(a,b,c) ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M, T; int R = 0; cin >> N >> M >> T; int L = N; for (int i = 0; i < M; i++){ int A = 0, B = 0; cin >> A >> B; L -= (A - R); if (L <= 0){ break; } else{ L += (B - A); if(L > N) { L = N; } R =...
#include <bits/stdc++.h> using namespace std; #ifdef Dhiraj #include "D:/dhiraj/Programming/debug.h" #else #define d(...) 11 #define cerr if(0) cerr #endif #define ll long long int #define endl '\n' template <typename T, typename U> inline istream& operator >> (istream& in, pair<T, U>& p) { in >> p.f...
#include <bits/stdc++.h> using namespace std; int sum=0; int dd=0; int vg=0; int d[400000]; vector<int> ed[400000]; int vis[400000]; void dfs(int v,int p) { //cout<<v<<endl; sum+=ed[v].size(); vis[v]=1; vg++; if(d[v]!=0) dd++; if(ed[v].size()==0) return; for(int i=0;i<ed[v].size();i++) if(vis[ed[v][i]]==0) dfs...
#include <iostream> using namespace std; int main(){ int n,sum=0; int a[n]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; if (a[i]>10){ sum+=(a[i]-10); } } cout<<sum; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <functional> #include <iostream> #include <map> #include <stack> #include <queue> #include <vector> static const int IINF = 1 << 30; static const long long LINF = 1LL << 60; static const long long MOD = 1.0e+9 + 7; template <typename T> std::vector<T> ...
#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<bits/stdc++.h> #define inf 1e18 #define endl "\n" #define mp make_pair #define pb push_back #define loop(i,x,y) for(int i = x; i < y ; i++ ) #define all(x) (x).begin(),(x).end() #define in(n) int n; cin>>n; #define inarr(arr,n) vector<int>arr(n); for(int i = 0; i < n ; i++){cin>>arr[i];} #define maploop(...
#include <bits/stdc++.h> using namespace std; #define rep(i, a) for (int i = 0; i < (int)(a); i++) #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll typedef long long ll; template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;} template<typename T>string join(const vec...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using iPair = pair<int,int>; using lPair = pair<ll, ll>; using ivector = vector<int>; using lvector = vector<ll>; using istack = stack<int>; using iqueue = queue<int>; using ivv = vector<vector<int>>; using lvv = vector<vector<ll>>; const int INF =...
/**Bismillahir Rahmanir Rahim.**/ #include<bits/stdc++.h> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef long double ld; #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pi acos(-1); #defi...
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n; int x; cin >> n >> x; int curr = 0; for(int i = 0; i < n; i++){ int a, b; cin >> a >> b; curr += a*b; ...
#include <bits/stdc++.h> typedef long long ll; #define rep(i,a,n) for (int i=a;i<n;i++) using namespace std; int main() { int n,w; cin>>n>>w; cout<<n/w; return 0; }
#include<cstdio> #include<algorithm> using namespace std; int main(void) { int n,w; scanf("%d%d",&n,&w); printf("%d\n",n/w); return 0; }
#include <bits/stdc++.h> using namespace std ; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin() , (x).end() #define sz(x) (int)((x).size()) #define rep(i,a,b) for(int i=a;i<b;i++) #define ppc __builtin_popcount #...
#include<iostream> #include<bitset> #include<string> #include<vector> #include<queue> #include<random> #include<map> #include<set> #include<stack> #include<functional> #include<unordered_map> #include<unordered_set> #include<algorithm> #include<ctime> using namespace std; using Graph = vector<vector<int>>; const long...
// g++ -std=c++11 a.cpp #include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<unordered_map> #include<utility> #include<cmath> #include<random> #include<cstring> #include<queue> #include<stack> #include<bitset> #include<cstdio> #include<sstream> #include<random> #...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 400005; vector<int> BIT(N, 0); vector<bool> seen(N, false); void update(int x, int delta) { for (; x <= N; x += x & -x) BIT[x] += delta; } int query(int x) { int sum = 0; for (; x > 0; x -= x & -x) sum += BIT[x]; return sum; } i...
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; ll x, y; map<ll, ll> vis, cache; ll solve(ll val); int main() { //freopen("input.txt", "r", stdin); ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> x >> y; cout << solve(y) << endl; return 0; } ll solve(ll val) { if (vis[val]) return c...
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ int x,y; cin>>x>>y; if(x>=y){ cout<<x-y; return 0; } int ans=y-x; queue<pair<int,int>>q; q.push({0,y}); set<int>s; while(!q.empty()){ pair<int,int>f=q.front(); q.pop();...
#include<bits/stdc++.h> using namespace std; #define ll long long #define db long double #define fi first #define se second #define mem(x) memset(x,0,sizeof x) db x0,y00,r; bool isv(int x,int y){ db dx=1.0*x-x0; db dy=1.0*y-y00; dx*=dx;dy*=dy; dx+=dy; return dx<=(r)+1e-10; } int main(){ cin>>x0>>y00>>r; int xl=c...
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<char, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define POPCOUNT(x) __builtin_popcount(x) template <typename T> void chmin(T &a, const T &b) { a = mi...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, s, n) for (int i = (int)s; i < (int)n; i++) #define repr(i, n,...
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define F first #define S second #define all(x) (x).begin(), (x).end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x)...
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <math.h> #include <cassert> #define rep(i,n) for(int i = 0; i < n; ++i ) using namespace std; using ll = long long; const int p[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int x = ri(); int a[n]; for (auto &i : a) i = ri(); bool beginning = true; for (int i = 0; i < n; i++) { if (a[i] == x) continue; if (beginning) beginning = false; else printf(" "); printf("%d", a[i])...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,x,n) for(int i=x; i<(n); i++) #define all(n) begin(n),end(n) typedef vector<int> vi; typedef vector<string> vs; const int mod = 1000000007; const int inf = 1061109567; int gcd(int a,int b){return...
#include <iostream> #include <set> #include <cmath> using namespace std; int main(){ long long int n,k; cin>>n; set<long long int> s; for(int a=2;a<=100000;a++){ for(int b=2;b<=34;b++){ k=pow(a,b); if(k>n) break; else s.insert(k); } } cout<<n-s.si...