code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; using ll = long long; int n, m, q, t[N], x[N], y[N], dic[N], L; int a[N], b[N]; ll d[4][N]; void add(int idx, int x, int v) { for(int i = x; i <= L; i += i & -i) d[idx][i] += v; } ll get(int idx, int x) { ll res = 0; for(int i = x; i; i -=...
#include <bits/stdc++.h> #include <algorithm> #define max(p, q) ((p)>(q)?(p):(q)) #define min(p, q) ((p)<(q)?(p):(q)) #define rep(i, n) for (ll i = 0; i < n; ++i) #define INF LLONG_MAX; #define MOD 1000000007 using ll = long long; using ld = long double; using namespace std; int main() { ll N, C; cin >> N >> C...
#include <bits/stdc++.h> using namespace std; bool HasSevenInDecimal(int n) { while (n != 0) { if (n % 10 == 7) { return true; } n = n / 10; } return false; } bool HasSevenInOctal(int n) { while (n != 0) { if (n % 8 == 7) { return true; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector <ll> vi; typedef vector <pi> vpi; #define f first #define s second #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i) #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end(...
#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 floop(i,a,n) for (ll i=a;i<n;i++) #define rfloop(i,a,n) for (ll i=n-1;i>=a;i--) #define mloop(it,x) for(it=x.begin();it!=x.end();it++) #define pb push_back #def...
#include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); typedef long long int ll; #define all(v) v.begin(),v.end() #include<bits/stdc++.h> using namespace std; int main(){ ll n,r=0; cin>>n; vector<ll>a(n); for(ll&i:a)cin>>i; sort(all(a)); for(ll i=n-1;i>...
#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 using namespace std; i...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define dd double #define ll long long int #define ull unsigned long long #define lld long double #define setpre(n) cout << std::setprecision(n); #define flush fflush(stdin); fflush(stdout); #define print cout<<"Case #"<<test_case<<": "; #defi...
#include <iostream> #include <sstream> #include <algorithm> #include <cmath> #include <functional> #include <vector> #include <set> #include <map> #include <queue> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; using ld = long double; using P =...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; map<string,int> mp, mp2; for(int i=0; i<n; ++i){ string s; cin >> s; if(s[0] == '!'){ mp2[s.substr(1)]++; }else{ mp[s]++; } } for(auto p:mp){ if(mp2[p.first]){ cout << p.first << endl; ...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; long long increase(long long aoki, long long takahashi) { return (2 * aoki) + takahashi; } struct data_t { long long aoki; long long takahashi; long sum; bool operator<(const struct data_t& right) const { return increase(aok...
#include<bits/stdc++.h> #include<math.h> using namespace std; using ll = long long; #define rep(i,n) for (int i=0; i<(n);++i) int main(){ int N; cin >> N; vector<int> A(N); rep(i,N) cin >> A[i]; ll count,ans; ans = 0; rep(i,N){ int x = A[i]; for(int j=i;j<N;j++){ ...
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<string> #include<unordered_map> #include <iomanip> using namespace std; #define intmax INT_MAX #define lmax LON...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pi (3.141592653589) #define int long long #define float double #define inf 1e18 #define w(x) ...
#include<bits/stdc++.h> using namespace std; #define RED_BULL ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define ll long long int #define all(a) a.begin(),a.end() const ll MOD = 1e9 + 7; const int N = 2e5 + 5; set<int> glo; //const ll N = 4e5 + 5; //vector<int> adj[N]; //ll dp[N], a[N]; ll a...
/***------------------------------------------------ "Bismillahir Rahmanir Rahim" "Author: Foyjul Islam Raju" ------------------------------------------------***/ #include <bits/stdc++.h> using namespace std; #define GameOn() int main() #define NO printf(...
#include<bits/stdc++.h> using namespace std; int main() { int A,B,X,Y; cin>>A>>B; X = (A+B)/2; Y = (A-X); cout<<X<<" "<<Y<<endl; return 0; }
//Bismillah Hir Rehmanir Rahim //Allah knows best //#include<bits/stdc++.h> using namespace std; #include <climits> #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <iomanip> #include <cmath> #include <vector> #include <set> #...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; int main(){ int N, M; cin >> N >> M; vector<int> w(N); for (int i = 0; i < N; i++){ cin >> w[i]; } vector<int> l(M), v(M); for (int i = 0; i < M; i++){ cin >> l[i] >> v[i]; } vector<pair<int, int>> P(M + 1); for (int i...
#include <bits/stdc++.h> //#include <atcoder/all> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb emplac...
// Create your own template by modifying this file! #include <string> #include <vector> #include <climits> #include <cstring> #include <map> #include <queue> #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <set> #include <unordered_set> #include <unordered_map> #include <cassert> #i...
// Problem: D - Message from Aliens // Contest: AtCoder - ZONe Energy Programming Contest // URL: https://atcoder.jp/contests/zone2021/tasks/zone2021_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> usi...
#include<bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> FindDiv(ll num) { vector<ll> res; for (ll i = 1; i * i <= num; ++i) if (num % i == 0) res.push_back(i); for (int i = res.size() - 1; i >= 0; --i) { if (res[i] * res[i] == num) continue; res.push_back(num / res[i]); } return res; }...
#include <bits/stdc++.h> using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; const int SECRET_NUMBER_NUMBER = 4; int main() { string s; cin >> s; int s_size = s.size(); int o_size = 0; int x_size = 0; for(int i = 0; i < s...
#include <bits/stdc++.h> using ll=long long; using namespace std; ll f(ll a){ string s; s=to_string(a); return stoll(s+s); } int main(){ ll n; cin >> n; ll i=1; while(f(i)<=n)i++; cout << i-1 << endl; }
#include<bits/stdc++.h> using namespace std; int main(){ long long n,k; cin >> n >> k; for(int i=0;i<k;i++){ if(n%200==0){ n/=200; } else{ n=n*1000+200; } } cout << n << endl; }
//*Bismillahir Rahmanir Raheem //!BlackBeard #include <bits/stdc++.h> #include <algorithm> #define NFS \ ios::sync_with_stdio(false); \ cin.tie(0) #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define yes cout << "yes" << endl #define No cout << "No" << endl #define N...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector<ll> vi; typedef vector<pi> vpi; typedef long double ld; const int inf = 1e9 + 7; const int mod = 1e9 + 7; const int maxn = 1e6 + 3; #define pb push_back #define mp make_pair #define ff first #define ss second #defi...
#include <bits/stdc++.h> /* #include <atcoder/lazysegtree> */ using namespace std; /* using namespace atcoder; */ using pint = pair<int, int>; using ll = long long; using ull = unsigned long long; using vint = vector<int>; using vll = vector<long long>; using pll = pair<ll, ll>; #define FOR(i, begin, end) \ for (lo...
// C++ (GCC9.2.1) AtCoder /* Ctrl+Option+N で 実行 */ #include <bits/stdc++.h> #define INF 100000000000 #define MOD 1000000007 #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define print(x) cout << (x) << endl; typedef long long ll; using namespace std; ll m = 7; long lon...
#include<bits/stdc++.h> #define double long double #define maxn 100010 using namespace std; 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<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w; } int n,m,K,v[maxn]; double k[maxn],b[maxn],sk[ma...
#include<iostream> #include<vector> #include<queue> #include<stack> #include<algorithm> #include<set> #include<iterator> #include <map> #include<cmath> #include <list> #include<string> #include <stdlib.h> #include<ctime> #include<cstring> #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL); #define PI 2*acos(...
#include<bits/stdc++.h> #define int long long using namespace std; const int N=100005; int n,a[N],b[N],ans; priority_queue<int>x,y; signed main() { ios::sync_with_stdio(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; ans+=a[i]; } for(int i=1;i<=n;i++) { cin>>b[i]; b[i]-=a[i]; if(i&1) x.push(b[i]); ...
#include<bits/stdc++.h> using namespace std; int main() { long long int n,k; cin>>n>>k; while(k--) { if(n%200==0) { n/=200; } else { n=n*1000+200; } } cout<<n; return 0; }
#pragma GCC optimization ("O3") #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> typedef tree<long long,...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll> pql; typedef set<ll> sl; typedef pair<ll, ll> pl; ty...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; typedef unsigned long long ull; constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/ #de...
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <map> #include <set> #include <unistd.h> #include <stdlib.h> #include <cassert> using namespace std; // using namespace atcoder; // using mint = long double; // using mint = modint998244353; // using mint = modint1000000007; typedef...
#include<bits/stdc++.h> #define ll long long int #define mp make_pair #define pii pair<int,int> #define pll pair<long long int,long long int> #define mii map<int,int> #define mll map<long long int,long long int> #define rep(it,m) for(auto it=m.begin();it!=m.end();it++) #define pb push_back #define fr first #define sc s...
#pragma GCC optimize ("Ofast,unroll-loops") #pragma GCC optimize("no-stack-protector,fast-math") #include <bits/stdc++.h> using namespace std; constexpr int N = 2e5+7; constexpr int M = 1e9+7; #define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); #define int long long #define pii pair<int, int> #defi...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/modint> // #include <atcoder/dsu> // using namespace atcoder; using ll = long long; using vi = vector<int>; using vll = vector<long long>; using vvi = vector<vector<int>>; using pii = pair<int,int>; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #de...
#include <iostream> #include <algorithm> int n, x; int v[1005]; int main() { std::cin >> n >> x; x *= 100; for(int i = 1; i <= n; i++) { int p; std::cin >> v[i] >> p; v[i] *= p; } for(int i = 1; i <= n; i++) { x -= v[i]; if(x < 0) { std::cout << i; return 0; } } std::cout << -1; }
# include <iostream> using namespace std; const int kMaxN = 51; int n; long long X; long long a[kMaxN], f[kMaxN], g[kMaxN][2]; int main() { scanf("%d %lld", &n, &X); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } for (int i = 1; i < n; i++) { a[i] = a[i + 1] / a[i]; f[i] = X % a[i]; ...
/******************************************************/ /******************************************************/ /** **/ /** BISMILLAHIR RAHMANIR RAHIM **/ /** REAZ AHAMMED CHOWDHURY - reaziii **/ /** Department of Computer Science...
#include <iostream> #include <iomanip> #include <sstream> #include <cstring> #include <vector> #include <deque> #include <queue> #include <set> #include <map> #include <valarray> #include <iterator> #include <functional> #include <limits> #include <algorithm> #include <numeric> #include <cmath> #include <cassert> #incl...
#include<bits/stdc++.h> #define fox(i,a,b) for(int i=a;i<=b;++i) #define ll long long using namespace std; int _x, _f; char _c; inline int rd() { _x = 0, _f = 1, _c = getchar(); for (; !isdigit(_c); _c = getchar()) if (_c == '-') _f = 0; for (; isdigit(_c); _c = getchar()) _x = _x * 10 + _c - '0'; return _f ? _x...
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ int N;cin>>N; vector<int>A(2*N); for(int i=0;i<2*N;i++)cin>>A[i]; int ans=0; for(int i=0;i<2*N;i++)ans+=A[i]; multiset<int>st; for(int i=0;i<N;i++){ st.insert(max(A[N-1-i],A[N+i])); if(st.size()&&*st.begin()<min(A[N-...
//My_Template #include<bits/stdc++.h> #define pb(a) push_back(a) #define vec vector<long long int> #define myfor(n) for(int i = 0; i < n; i++) #define tc(t) int t; cin>>t; while(t--) #define sortt(a) sort(a.begin(), a.end()) #define ll long long int #define revit(a) reverse(a.begin(), a.end()) #define summ(a) accumul...
#include <bits/stdc++.h> using namespace std; int main(){ int V, T, S, D; cin >> V >> T >> S >> D; T *= V; S *= V; if(T <= D && D <= S) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #define fi first #define se second #define INF 0x3f3f3f3f #define STD std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define FOR(i,a,b) for (int i(a); i < (b); i++) #define REP(x, l, u) for(int x = l; x <= u; x++) #define UN(v) sort((v).begin(),(v).end())...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() const int n = 20; const int n2 = 1 << n; const vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}; void solv...
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<cmath> #include<iomanip> #include<cstring> #include<complex> #include<cstdio> #define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1; #define fi first #define se second #define pb push_back #d...
#include <bits/stdc++.h> using namespace std; int win[7][200010], memo[80]; bool judge(bool tak, bool w1, bool w2){return tak ? w1 || w2 : w1 && w2;} int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; string s, x; cin >> n >> s >> x; for (int j = 0; j < 7; ++j) for (int i = 0; i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using std::cin; using std::cout; using std::vector; using std::string; using std::max; const int INF = 1001001001; int h, w; int a[2005][2005]; bool visited[2005][2005]; int memo[2005][2005]; int f(int i, int j) { if (i == h - 1 and j == w - ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll K, N, M; cin >> K >> N >> M; vector<ll> A(K); for ( int i = 0; i < K; i++ ) cin >> A[i]; ll INF = 1LL<<60; vector<ll> b1(K), b2(K); auto is_ok = [&](ll x) -> bool { ll b1s = 0, b2s = 0; for (...
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <sstream> #include <cstring> #include <set> #include <map> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> #include <string.h> #include <assert.h> #include <ioma...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long long, long long>; constexpr char ln = '\n'; constexpr long long MOD = 1000000007; constexpr long long INF = 1000000000 + 100; constexpr long long LINF = 1000000000000000000 + 100; #define all(v) v.begin(), v.end() #define rep(i, ...
#include <cstdio> #include <algorithm> #define ll long long int int N, P[200010]; int need[200010], nxd; int a[200010], r[200010]; void msort(int s, int t) { if(s==t) return; int mid = (s+t)/2; msort(s, mid); msort(mid+1, t); int i = s, j = mid+1, k = s; while(i<=mid&&j<=t) { if(a[i]<=a[j]) { r[k] = a[i];...
#include <bits/stdc++.h> using namespace std; #define ms(x,a) memset(x,a,sizeof x) typedef long long ll; const int mod=1e9+7, inf=0x3f3f3f3f, MAXN=0; int main(){ cin.tie(0)->sync_with_stdio(0); ll n; cin >> n; ll ans=n; for (ll i=2;i*i<=n;++i){ bool flag=1; for (ll j=2;j*j<=i;++j){ ...
#include<bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long u64; typedef pair<int,int> pii; typedef vector<int> vi; inline void read(int& x){ static char c; while(!isdigit(c=getchar()));x=c^48; while(isdigit(c=getchar()))x=(x*10)+(c^48); } i...
#include <iostream> #include <string> using namespace std; using ll = long long; int main(){ ll N; cin >> N; for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){ cout << i - 1 << endl; return 0; } }
#include <bits/stdc++.h> using namespace std; int main(){ int64_t N; cin >> N; int64_t ans= 0; int64_t div= 1'000; while(N >= div){ ans+= N- (div- 1); div*= 1'000; } cout << ans << endl; }
#include <bits/stdc++.h> #define ll long long #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int N,Q; string S; cin >> N >> S >> Q; string sf = S.substr(0, N); string sb = S.substr(N, N); rep(i,Q) { int t,a,b; cin>>t>>a>>b; a--; b--; if (t==1) { if (b < N) swap(sf[a], sf[...
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool ch...
#include <iostream> #include <cstdint> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unorder...
#include <algorithm> #include <array> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long l...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define ul unsigned long int #define pii pair<int,int> #define pll pair<lli, lli> #define vi vector<int> #define vii vector<pair<int,int>> #define vll vector<lli> #define pb push_back #define mpr make_pair #define ss second #define ff first #de...
#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); } return x * f; } int n,K; int Calc(int x) { return ...
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair<ll, ll> pll; typedef pair<int, int> pint; template <class T> inline bool...
# include <ciso646> # include <cstdio> # include <cstring> # include <algorithm> # include <map> # include <queue> namespace Main { namespace Source { typedef unsigned int uint; typedef long long unsigned int llu; template <const uint N> class Fenwick_tree { uint tree[N ...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; ...
#include<iostream> #include<string> #include<vector> int main () { int n, k, m; std::cin >> n >> k >> m; std::vector<int> a(n - 1); int sum = 0; for (int i = 0; i < n - 1; i++) { std::cin >> a[i]; sum += a[i]; } bool f = false; int ans; for (int i = 0; i <= k; i...
#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 <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <chrono> #include <climits> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstre...
#include <bits/stdc++.h> #define setIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define PI 3.14159265358979 #define f first #define s second #define ar array using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<string, int> psi; typedef pair<long long, long long> pll; typedef pai...
#include<cstdio> #include<set> #include<vector> #include<algorithm> #include<queue> #include<map> #include<cstdlib> #include<time.h> #include<string> #include<stack> #include<cstdio> #include<climits> #include<cmath> #include<iostream> #include<cstring> #include<complex> #include<tr1/unordered_set> #include<tr1/unorder...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define REP(i,m,n) for (int i = (m); i < (n); ++i) #define rrep(i,n) for (int i = (n)-1; i >= 0; --i) #define RREP(i,m,n) for (int i = (n)-1; i >= (m); ++i) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() using namespac...
#define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<vector> #include<functional> #include<algorithm> #include<stdlib.h> #include<string> #include<string.h> #define _USE_MATH_DEFINES #include<math.h> #include<deque> #include<set> #include<map> #include<queue> #include<list> #include<iostream> #include <bitset> usi...
#include <bits/stdc++.h> using namespace std; int main(){ int N,W,a,b; cin >> N >> W >> a >> b; vector<vector<char>> data(N, vector<char>(W)); for (int i=0;i<N;i++){ for(int j=0;j<W;j++){ cin >> data[i][j]; } } int count =-3; for(int i =b-1;i<W;i++){ if(data[a-1][i]=='.') count++; e...
/* I love the sound you make when you shut up. */ #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; /*-------typedefs------*/ template<class T> using or...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) ...
#include<bits/stdc++.h> #define db double #define reg register #define LL long long #define pb push_back #define lb lower_bound #define ub upper_bound #define ull unsigned long long #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) #define erep(i,a) for(int i...
#include <bits/stdc++.h> #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(), (x).end() #define ls k<<1 #define rs k<<1|1 #define lson k<<1, l, mid #define rson k<<1|1, mid+1, r #define lowbit(x) ((x) & (-(x))) #define ll long long using namespace std; struct my_hash { static uint64_t splitmix64(uint64_t x) {...
#include <bits/stdc++.h> using namespace std; using ll = long long; //素数判定 O√N bool is_prime(long long x) { assert(0<=x); if(x<2) { return false; } for(long long i=2;i*i<=x;i++) { if(x%i==0) { return false; } } return true; } template<class T> void chmin(T& a,T b){ if(a>b){ ...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=(n)-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue<x...
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include ...
#include <bits/stdc++.h> using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; typedef long double ldbl; typedef pair<int, int> pii; typedef pair<uint, uint> puu; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<double, double> pdd; typedef vector<int> vi...
#include<bits/stdc++.h> #define ll long long using namespace std; int read() { int a=0,f=1,c=getchar(); while(!isdigit(c)) { if(c=='-')f=-1; c=getchar(); } while(isdigit(c)) { a=a*10+c-'0'; c=getchar(); } return a*f; } const int N=500+10; const int P=998244353; int n,m; char s[N][N]; int f[N*2]; ...
#include <bits/stdc++.h> using namespace std; int main(void){ int n; cin>>n; vector<pair<int,string>> data(n); for(int i=0;i<n;i++){ cin>>data.at(i).second>>data.at(i).first; } sort(data.begin(),data.end()); cout<<data.at(n-2).second<<endl; }
#include <bits/stdc++.h> #define LOCAL using namespace std; using ll = long long; // const int MOD = 1e9 + 7; #define mem(a, b) memset(a, b, sizeof(a)) #define REP(i, a) for (int i = 0; i < a; ++i) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define ALL(a) a.begin(), a.end() #ifdef LOCAL #define trace(...) __f...
// Problem: A - kcal // Contest: AtCoder - AtCoder Beginner Contest 205 // URL: https://atcoder.jp/contests/abc205/tasks/abc205_a // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> using namespace std; typedef long long int ll; ll power(ll x,ll y,...
#include <bits/stdc++.h> // This will work only for g++ compiler. #define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inc...
#include <bits/stdc++.h> using namespace std; vector<vector<long long>> memo(201, vector<long long>(12, -1)); long long C(long long n, long long k) { if(memo[n][k] > 0) return memo[n][k]; if(n == k) return memo[n][k] = 1; if(k == 0) return memo[n][k] = 1; return memo[n][k] = C(n - 1, k) + C(n - 1, k - 1); } int...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; using Graph = vector<vector<int>>; const int INT_INF = 2147483647; //stoi(s) : string→int stoll(s) :string→longlong int→string to_string(i) const double PI = acos(-1.0); //小数点の表し方 cout << fixed << setprecision(5); const ll LLMA...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef long double ld; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; const int INF = 1e9 + 7; const int MOD = 1e...
#include<iostream> int main(){ int x,y; scanf("%d %d",&x,&y); printf("%d %d",(x+y)/2,(x-y)/2); }
#include <algorithm> #include <cassert> #include <functional> #include <iostream> #include <limits> #include <vector> namespace internal { __attribute__((const)) constexpr bool is_pow2(int n) { return __builtin_popcount(n) == 1; } __attribute__((const)) constexpr int floor_log2(int n) { return std::numeric_limits<...
#include<bits/stdc++.h> #define int long long #define pll pair<long long,long long> #define in(x) long long x;cin>>x #define pb push_back #define F first #define S second #define endl "\n" #define test() int t;cin>>t;while(t--) #define KStest() int t,t1;cin>>t;t1=t;while(t--) #define KScout cout<<"Case #"<<t1-t<<": ...
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <utility> #include <tuple> #include <cmath> #include <numeric> #include <set> #include <map> #include <array> #include <complex> #include <iomanip> #include <cassert> #include <random> #include <chrono> #include <vala...
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ub upper_bound #define lb lower_bound #define isrt insert #define clr clear #define rsz resize #define ff first #define ss...
#include <iostream> #include <cstring> using namespace std; string s; int ans, k; int a[10]; bool check (int l) { bool k[10]; for (int i = 0; i < 10; i++) { k[i] = 0; } k[l % 10] = 1; k[(l / 10) % 10] = 1; k[(l / 100) % 10] = 1; k[(l / 1000) % 10] = 1; for (int i = 0; i <= 9; i++) { if (k[i] ...
#include <bits/stdc++.h> using namespace std; int main(){ long long n; cin >> n ; int ans1 =0; int ans2 =0; bool judge = false; for(int i=1;i<100;i++){ for(int j=1;j<50;j++){ if((powl(3,i)+powl(5,j))==n){ judge = true ; ans1 = i; ans2 = j; break; } } ...
#include <bits/stdc++.h> using namespace std; const long long MOD=1e9+7; const int N=1e5+5; bool vis[N]; int u,v,c,n,m,r[N]; vector<pair<int,int>> adj[N]; void dfs(int x, int y){ vis[x]=true; for(auto p:adj[x]){ if(vis[p.first]) continue; if(p.second!=y) r[p.first]=p.second; else r[p.first]=p.second%n+1; d...
#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 <iostream> #include <cstring> #include <algorithm> #include <vector> #include <utility> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using ll = long long; using namespace std; ll a[25]; int n; int main() { cin >> n; rep(i,n){ cin >> a[i]; } ll xormin = 1<<30; ll tmpx = 0; ...
#include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<cmath> #include<vector> #include<queue> using namespace std; #define LL long long #define M 1005 #define N 5005 #define Mod 1000000007 void read(LL &x){ x=0;char c=getchar();LL f=1; while(c<'0'||c>'9'){ if(c=='-') f=-f; c=getcha...
#include <bits/stdc++.h> using namespace std; int main(){ int a, b, c; cin >> a >> b >> c; if(a == b) cout << c; else if(b == c) cout << a; else if(c == a) cout << b; else cout << 0; return 0; }
#include <bits/stdc++.h> int main(){ int V, T, S, D; std::cin >> V >> T >> S >> D; int begin = V * T; int end = V * S; if(D >= begin && D <= end){ std::cout << "No" << std::endl; }else{ std::cout << "Yes" << std::endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(void){ long long int N; int M,T; cin >> N >> M; int an,bn; int rn[M+1][M+1]; for (int i=0;i<M+1;i++){ for (int j=0;j<M+1;j++){ rn[i][j] = -1; } } if (M!=1){ an = 1; bn = 0; }else{ ...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, s, n) for (int i = (s); i < (n); ++i) #define rrep(i, n) for (int i = n - 1; i >= 0; --i) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define len(x) (int)(x).size() #define pb push_back #define em emplace_back #define ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VP...
#include <bits/stdc++.h> using namespace std; typedef long long ll ; #define sz(x) ((int)(x).size()) #define all(x) x.begin() , x.end() #define mem(arr,val) memset(arr,val,sizeof(arr)) #define deb(x) cout<<#x<<"="<<x<<endl #define debs(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl #define ppc __builtin_popcount #define...
#include <bits/stdc++.h> using namespace std; // template {{{ using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1) #define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1) #define w...
#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; int main() { string S,T; cin >> S >>T; if(S=="Y"&&T=="a"){ cout << "A" << endl; }else if(S=="Y"&&T=="b"){ cout << "B" << endl; }else if(S=="Y"&&T=="c"){ cout << "C" << endl; }else{ cout << T << endl; } }
#include<bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int i = 0; i < (n); i++) int main () { char s, t; cin >> s >> t; if(s == 'Y'){ cout << char(t - 0x20) << endl; } else { cout << t << endl; } return 0; }
#include"bits/stdc++.h" using namespace std; #define pb push_back #define eb emplace_back #define ins insert #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #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 lb lower_bound #define ub upper_bound #define sz(x...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; vector<int> studentClass(n + 1); vector<int> nodeParent(n + 1); vector<int> nodeRank(n + 1); vector< vector<int> > classStudents(n + 1); // position of ...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<l...
#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 <algorithm> #include <iostream> #include <cstdio> #include <map> #include <numeric> #include <cmath> #include <set> #include <sstream> #include <string> #include <vector> #include <queue> #include <stack> #include <complex> #include <string.h> #include <unordered_set> #include <unordered_map> #include <bitset>...
#include <iostream> #include <string> #include <vector> #include <utility> #include <functional> #include <numeric> #include <list> #include <set> #include <map> #include <algorithm> #include <cmath> #include <limits> #include <iomanip> #include <bitset> #include <queue> #include <unordered_set> #include <unordered_map...
#include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long #define ui unsigned int #define us unsigned short #define inf_int 1e9 #define inf_ll 1e18 #define mod 1000000007 #define smod 998244353 vector<pair<ll, ll>> v[5]; int main(){ ios_base::sync_with_stdio(0); cin.tie(...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using viii = vector<vector<vector<int>>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second #define setbits(x) __builtin_popcountll(x) #define lp(a,n) for(ll i=a; i<n; i++) #define lpi(a,n) for(int i=a; i<n; i++) #define w(t) int t; cin>>t; while(t--) #define vi vector<int> #define vll vector<ll> #d...
#include<bits/stdc++.h> #define int long long #define F first #define S second #define PB push_back #define MP make_pair #define fo(i,a,b) for (int i = a; i < b; i++) #define f(i,n) for (int i = 0; i < n; i++) using namespace std; typedef vector<int> vi; typedef pair<int,int> pi; void solve(){ int n; cin>>...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } ...
#include<bits/stdc++.h> using namespace std; int main() { string n; int k; cin>>n>>k; int ans=stoi(n); for(int i=0;i<=k;i++) { if(i!=0) {string desc=n; string asec=n; sort(asec.begin(),asec.end()); sort(desc.begin(),desc.end(),greater<char>()); int large=stoi(desc); ...
#include <bits/stdc++.h> using namespace std; #define SZ(x) (int)(x).size() #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REPR(i,n) for(int i=(n)-1;i>=0;i--) #define ALL(s) (s).begin(), (s).end() #define so(V) sort(ALL(V)) #define rev(V) reverse(ALL(V)) #define uni(v) v.er...
# include <bits/stdc++.h> # define ull unsigned long long # define ll long long # define double long double # define pll pair<ll,ll> # define pb push_back # define fi first # define se second # define mp make_pair # define max3(a,b,c) max(a,max(b,c)) # define min3(a,b,c) min(a,min(b,c)) # define all(x) x.begin(),x.end(...
#include <bits/stdc++.h> #define LL long long #define ull unsigned long long #define F(i, j, k) for(int i = j; i <= k; i++) #define DF(i, j, k) for(int i = j; i >= k; i--) using namespace std; template <typename T> inline void read(T &n) { T w = 1; n = 0; char ch = getchar(); while (!isdigit(ch) && ch != EOF)...
#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; #ifdef ENABLE_DEBUG #define dump(a) cerr<<#a<<"="<<a<<endl #define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl #else #define dump(a) #define dumparr(a,n) #endif #...
#include<bits/stdc++.h> using namespace std; int main(){ int64_t n, w; cin >> n >> w; vector<int> s(n); vector<int> t(n); vector<int64_t> p(n); vector<int64_t> sum(2000005); string ans = "Yes"; for(int i = 0;i < n;i++){ cin >> s.at(i) >> t.at(i) >> p.at(i); sum.at(s.at(...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using ull = unsigned long long; int main() { ull n, a; cin >> n; ull ans = 0; vector<ull> mod(200); rep(i, n) { cin >> a; mod.at(a % 200)++; } rep(i, 200) { if (mod.at(i)...
# include <bits/stdc++.h> using namespace std; # define endl "\n" # define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); typedef unsigned long long int ulli; typedef long long int lli; typedef unsigned int ui; int N, A[200005]; int main(){ cin >> N; for(int i = 0; i < N; ...
#include <bits/stdc++.h> #if MYDEBUG #include "lib/cp_debug.hpp" #else #define DBG(...) ; #endif #if __cplusplus <= 201402L template <typename T> T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #endif using LL = long long; constexpr LL ...
#include <iostream> #include <math.h> #include <iomanip> #include <bits/stdc++.h> #include <string.h> #include <string> #include <algorithm> #define ll long long int #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; ll binomialCoeff(ll n,ll k) { ll res = 1; if(k >n - k) ...
#include<bits/stdc++.h> #include<iterator> #include<math.h> #define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL); #define ll long long int #define pb push_back #define fi(a,b,c) for(i=a;i<=b;i=i+c) #define fia(a,b,c) for(i=a;i<b;i=i+c) #define s...
#include<bits/stdc++.h> #include<iostream> typedef long long ll; using namespace std; int main(){ int n,m; cin>>n; ll sum=0; while(n-->0){ ll a,b; cin>>a>>b; sum += ((a+b)*(b-a+1))/2; } cout<<sum<<endl...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(ll i=0;i<ll(n);i++) #define REPE(i,l,n) for(ll i=l;i<=ll(n);i++) #define FORA(i,I) for(const auto& i:I) #define ALL(v) v.begin(),v.end() #define UQ(v) v.erase(unique(ALL(v)), v.end()) #define ACM(v) accumulate(ALL(v), 0) #define P(...
// Code written by Shubham Agarwal #include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define ll long long #define V 8 using namespace std; void tsp(ll graph[][V], vector<bool>& v, ll currPos, ll n, ll count, ll cost, ll& ans, ll k, int &cnt) { if (cou...
/****************************** * author: minhkhoa * * location: * ******************************/ #include <bits/stdc++.h> using namespace std; typedef long long int64; typedef vector<int> vi; typedef pair<int, int> ii; const int P = 998244353; int solve(int A, int B, int C) { int64...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair<int, int>; // MODINT const int MOD = 998244353; struct mint { long long x; mint(long long x = 0):x((x % MOD + MOD) % MOD) {} mint operator-() const { return mint(-x); } m...
#include <bits/stdc++.h> #include <vector> #include <set> #include <map> #include <string> #include <algorithm> #include <cmath> #include <queue> #include <stack> using namespace std; #define pq_max priority_queue<ll> #define pq_min priority_queue<ll,vi,greater<ll> > #define iint int #define f(i,a,b)...
#include <fstream> #include <iostream> #include <string> #include <vector> #include <deque> #include <set> #include <algorithm> #include <math.h> using namespace std; int main(){ int n;cin>>n; vector<int> a(n); for (int i = 0; i < n; i++)cin>>a[i]; int mx = -1; int ans = 0; for (int j = 2; j < 100000; j++) { ...
#include <bits/stdc++.h> using namespace std; int mas[8]; int dist[256]; int dist1[8][8]; int ans[8]; pair<int,int> parts[100000]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m,ma=0; cin>>n>>m; for(int i=0; i<n; i++){ cin>>mas[i]; ma=max(ma,mas[i]); } for(int i=0...
//#pragma GCC optimize("O3") #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(0); #define trav(x,a) for (auto& x: a) #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define mem(a,v) memset((a)...
#include <bits/stdc++.h> #include <chrono> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // #include <atcoder/all> using namespace std; using namespace __gnu_pbds; using ll = long long int; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end...
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math") //~ #pragma GCC target ("avx2") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <algorithm> #incl...
#include <bits/stdc++.h> using namespace std; int main(){ vector<int> inp; for(int i = 0;i < 3;i++){ int a; cin >> a; inp.push_back(a); } sort(inp.begin(),inp.end()); cout << inp.at(2)+inp.at(1) << endl; }
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define FI first #define SE second #define pb push_back #define eb emplace_back #define mod 1000000007 #define all(c) (c).begin(),(c).end() #defi...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007 int main() { int x, y, z; cin >> x...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; if(a==b) cout<<c<<endl; else if(a==c) cout<<b<<endl; else if(b==c) cout<<a<<endl; else if(a!=b && b!=c && c!=a) cout<<0<<endl; return 0; }
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include <functional> #include<cmath> #include<string> #include<string.h> #include<iomanip> #include<algorithm> #include<cctype> #include<set> #include<vector> #include<stack> #include<queue> #include<deque> #include<map> #include <stdio.h> #include<bitset> using name...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define all(a) (a).begin(), (a).end() #define mp make_pair template<typename T1, typename T2> inline void chkmin(T1& x, const T2& y) { if (y < x) x = y; } template<typename T1, typename ...
#include <bits/stdc++.h> #define fo(a,b,c) for (a=b; a<=c; a++) #define fd(a,b,c) for (a=b; a>=c; a--) #define ll long long //#define file using namespace std; int i,j,k,l; ll n,K,ans,s; ll js(int t) { if (t<2 || t>n*2) return 0; if (t<=n+1) return t-1; return n*2+1-t; } int main() { #ifdef file freopen("b.in",...
//Code by Ritik Agarwal #include<bits/stdc++.h> using namespace std; #define sz(x) (int)(x).size() #define int long long int #define loop(i,a,b) for(int i=a;i<b;i++) #define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i] #define vi vector<int> #define si set<int> #define pii pair <int, int> #define sii set<pii>...
#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...
#include<iostream> #include<cstdio> #include<algorithm> #include<queue> #define int long long namespace do_while_true { #define ld double #define ll long long #define re register #define pb push_back #define fir first #define sec second #define pp std::pair<int, int> #define mp std::make_pair const ll mod = 10...
#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 fastio ios_base::sync_with_stdio(0);cin.tie(0) #define fp(i,a,b) for(int i=a ; i<b ; i++) #define fn(i,a,b) for(int i=a ; i>=b ; i--) #define ones(x) ...
#include "bits/stdc++.h" using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod = 1000000007; string s; cin >> a >> b; vector<vector<char>> v(a,vector<char>(b)); for(int i=0;i<a;i++) {...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) using ll = long long; using P = pair<int,int>; using ll_P = pair<ll,ll>; const double PI=3.14159265358979323846; const int INF = 1000000000; const ll ll_INF = 1001001001001001001; const int mod = 1000000007; int n; vector<int...
#include <bits/stdc++.h> using namespace std; //TEMPLATE #define pb push_back #define mp make_pair #define ll long long #define ld long double #define pii pair <ll, ll> #define piii pair <ll, pii> #define F first #d...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for(int i = n-1; i >= 0; i--) #define all(x) (x).begin(),(x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #d...
/* author:Karan created:14.06.2021 12:45:48 */ #include<bits/stdc++.h> using namespace std; #define ll long long #define all(ar) ar.begin(),ar.end() #define endl '\n' int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i) #define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i) #define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 60) -123456789; #define fastio cin.tie(0); ios_base::s...
#include <bits/stdc++.h> #define f first #define s second #define vec vector #define pb push_back #define all(x) x.begin(),x.end() #define m_p make_pair #define sz(x) (int)x.size() using namespace std; typedef long long ll; typedef pair<ll,int> pli; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int K=86...
#include "bits/stdc++.h" //#include "atcoder/all" using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; //const bool debug = false; #define rep(i, n...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; ll GD(ll num){//各桁の和 ll digit=0; while(num!=0){ num /= 10; digit++; } return digit; } bool is_integer( long double x ){//整数判定 return std::floor(x)==x; } int gcd(int aaa, int bbb)//最大公約数 { if...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define _GLIBCXX_DEBUG typedef long long int ll; typedef long double ld; const int inf = 10000; struct Point { int x; int y; }; struct Rect { Point start; Point end; }; int main() { int n; cin >> n; vect...
#include<bits/stdc++.h> using namespace std; #define ll long long #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i,n) for(ll i=0;i<(n);i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c)) #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define f...
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<stack>...
/* Miles Morales : When will I know I'm ready? Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith. */ //KEEP IT SIMPLE STUPID #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragm...
#include <bits/stdc++.h> #define DEBUG if(0) #define lli long long int #define ldouble long double using namespace std; const int maxN = 2e5; char s[maxN + 1]; map<int, int> cnt; int main() { while (scanf(" %s", s) != EOF) { cnt.clear(); int n = strlen(s); for (int i = 0; i < n; i++) { int v...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(v) v.size() #define INF 10000000000000000 //10^16 template <typename T> bool chmax(T &a, const T& b...
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <algorithm> #include <numeric> #include <queue> #include <iomanip> #include <numeric> #include <cmath> using namespace std; int main() { int x, y; cin >> x >> y; if (abs(x - y) < 3) { cou...
#include <bits/stdc++.h> using namespace std; const long long ANS=1e10; string t; int n; bool into_string(string t,string a){ for (int i=0; i<t.size(); i++) if (a[i%3] != t[i]) return false; return true; } main(){ cin>>n>>t; if (n==0){ cout<<0<<endl; return 0; }...
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin>>n; string t; cin>>t; ll ans = 0; ll N = 3e10l...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double vector<ll> count_divisor(ll& n) { vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (n / i != i) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return ret; } i...
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL <<60; const long long Mo=1000000007; long long gcn(long long x,long long y){ if(x%y==0){ return y; } else{ return gcn(y,x%y); } } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) {...
#include <bits/stdc++.h> #define ms(a,b) memset(a, b, sizeof(a)) #define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++) #define fi first #define se second #define pb push_back #define pf push_front #define m_p(a,b) make_pair(a, b) #define lson l,mid,o << 1 #define rson mid + 1,r,o << 1 | 1 #define ls o << 1 #defi...
#pragma GCC optimize ("O2") #pragma GCC target ("avx") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(...
#include<bits/stdc++.h> using namespace std; int main() { vector<int> v(4); int sum = 0; for (int i = 0; i < 4; i++) cin >> v[i], sum += v[i]; for (int i = 0; i < 16; i++) { int t = 0; for (int j = 0; j < 4; j++) { t += ((i >> j) & 1) * v[j]; } if (t == sum - t) { cout << "Yes" << en...
#include <bits/stdc++.h> #define endl "\n" using namespace std; void setup() { #ifdef LOCAL freopen("input", "r", stdin); #else ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif } int main() { setup(); int A, B, C, D; cin >> A >> B >> C >> D; int res = 0; if...
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <set> #include <map> #include <array> #include <random> #include <cmath> #include <chrono> #include <list> #include <ctime> #include <sstream> #include <queue> #include <climits> #include <stack> #include <random> #...
#include <bits/stdc++.h> using namespace std; char s[200200]; int main(void) { int n; scanf("%d%s",&n,s); int top=0; for (int i=0;i<n;i++) { if (top < 2) { s[top++]=s[i]; } else { if (s[i] == 'x') { if (s[top-2] == 'f' && s[top-1] == 'o') top -= 2; ...
#include<iostream> #include<set> using namespace std; struct Da{ int x , y; int dot , tim; int dc(Da b){ return x * b.x + y * b.y; } int tc(Da b){ return x * b.y - y * b.x; } }; int main(){ #ifdef LOCAL freopen("input.txt" , "r" , stdin); #endif int n ; Da a[11...
#include<iostream> #include<string> #include<algorithm> using namespace std; int n; const int N=1e6; struct moun{ int a; string b; }a[N]; bool cmp(moun a,moun b){ return a.a<b.a; } int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i].b>>a[i].a; sort(a+1,a+1+n,cmp); cout<<a[n-1].b<<end...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define all(x) (x).begin(),(x).end() template<typename A, size_t N, typename T> void...
#include <bits/stdc++.h> #include <unordered_set> #include <cmath> // URL: https://atcoder.jp/contests/abc195/tasks/abc195_d using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vs = vector<string>; #define rep(i, n) f...
#include<cstdio> #include<algorithm> #include<vector> #define SZ 262144 using namespace std; int n, M, A[2010]; long long Mod = 1000000007, Inv[101000]; long long Pow(long long a, long long b){ long long r=1; while(b){ if(b&1)r=r*a%Mod; a=a*a%Mod;b>>=1; } return r; } long long Comb(int...
// atcoder/abc185/E/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<algorithm> #include<functional> // for hash #include<climits> // all useful constants #include<cmath> #include<cstdio> #include<cstdlib> // random #include<ctime> #include<iostream> #include<sstream> #include<iomanip> // right justifying std::right and std::setw(width) /*** Data Structure ***/ #include<deque> ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; using vpi = vector<pair<int, int>>; using pl = pair<ll, ll>; using vl = vector<ll>; #define all(v) (v).begin(), (v).end() #define ar array #defin...
#include<bits/stdc++.h> #define int long long #define PB push_back #define F first #define S second #define all(x) begin(x), end(x) using namespace std; typedef pair<int,int> pii; const int MOD = 1e9 + 7; const int maxn = 200007; vector<int> G[maxn] = {}; vector<int> chart[maxn] = {}; int P[maxn][20] = {}; int dep[...
#include<bits/stdc++.h> using namespace std; #define ll long long #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i,n) for(ll i=0;i<(n);i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c)) #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define f...