code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
//#pragma GCC optimize("Ofast") #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; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //~ while (clock(...
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <complex> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #include <queue> #define INF 1010101010LL #define INFLL 101...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #d...
#include<bits/stdc++.h> #define st string #define sz(x) (x).size() #define pb push_back #define pp pop_back using namespace std; int main() { st s; cin >> s; while (s[sz(s) - 1] == '0')s.pp(); for (int i = 0; i <sz(s) / 2; i++) { if(s[i] != s[sz(s) -1 -i]){ cout << "No"; return 0; ...
#define _DEBUG #include "bits/stdc++.h" //#include <atcoder/all> #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x #define debug_1(x1) cout<<#x1<<": "<<x1<<endl #define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl #define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "...
#include <bits/stdc++.h> using namespace std; #define int long long using vec_int = vector<int>; using P = pair<int,int>; using T = tuple<int,int,int>; using ll = long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int charToInt(char c){ char zero_num = '0'; return (int)c - (int)zero_num; } void co...
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; //using namespace atcoder; using ll = long long; typedef pair<ll,ll> P; typedef pair<ll,P> PP; typedef vector<vector<int> > Graph; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } temp...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n; int arr[100005]; bool vis[100005]; vector<int>vec; multiset<int>ms; void dfs(int node,vector<vector<int>>&v) { vis[node]=1; if(!ms.count(arr[node-1])) vec.push_back(node); ms.insert(arr[node-1]); for(int i=0;i<v[node].size...
//...Bismillahir Rahmanir Rahim... // Code by Asad Bin Saber #include <bits/stdc++.h> using namespace std; // typedefs... typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<ll, ll> pll; // ...
// #pragma GCC optimise ("O1") #include<bits/stdc++.h> using namespace std; #define ll int #define rep(i,j,n) for(ll i=j;i<n;i++) #define _rep(i,n) for(ll i=n-1;i>=1;i--) #define scn(a) scanf("%lld",&a) #define scns(a,b) scanf("%lld %lld",&a,&b) #define print(a) printf("%lld",a) #define vec ...
/* Author: QAQAutomaton Lang: C++ Code: C.cpp Mail: lk@qaq-am.com Blog: https://www.qaq-am.com/ */ #include<bits/stdc++.h> #define debug(...) fprintf(stderr,__VA_ARGS__) #define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__) #define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__) #define...
// Pratiyush Mishra #include <bits/stdc++.h> #define ull unsigned long long int #define ll long long int #define LL_MAX 9223372036854775807 #define pb push_back #define pf push_front #define mp make_pair #define popb pop_back #define vl vector<ll> #define bs(v, x) binary_search(v.begin(), v.end(), x) #define popf pop_...
/* written by Pankaj Kumar. country:-INDIA Institute: National Institute of Technology, Uttarakhand */ #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 unsigned long long ull...
#include <bits/stdc++.h> #define sz(c) int(c.size()) #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = (b)-1; i >= (a); --i) using namespace std; using ll = long long; #ifdef LOCAL #include <local/debug.h> #else #define debug(...) (void)0 #endif struct DSU { vector<int> r; DSU(i...
#include<bits/stdc++.h> #define w(x) int x; cin>>x; for(int tc=1;tc<=x;tc++) #define trace(x) cerr<<#x<<": "<<x<<" "<<endl; #define trace1(x,y) cerr<<#x<<": "<<x<<" "<<endl;cerr<<#y<<": "<<y<<" "<<endl; #define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long #d...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> // -_-bruh u copying mah code?! #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; #define lli long long int #define i int #define cr char #define f float #define u...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int a, b, c; cin >> a >> b >> c; if ( a == b ) cout << c << endl; else if ( b == c ) cout << a << endl; else if ( c == a ) cout << b << endl; else cout << 0 << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::en...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define f(x, m) for(auto x : m) #define cpu() ios::sync_with_stdio(false); cin.tie(nullptr) #define pb push_back #define pii pair<int,int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #d...
#include <bits/stdc++.h> using namespace std; template <typename T> void print(const vector<vector<T>>& matrix, const string& name = "") { if (!name.empty()) cout << name << ": " << endl; for (const auto& row : matrix) { for (const auto& element : row) { cout << element << " "; } cout << endl; ...
#include <bits/stdc++.h> #define ll long long using namespace std; int main(){ ll n,k; cin>>n>>k; vector<ll> dp2(3*n+1); for (ll s2=2;s2<=2*n;++s2){ dp2[s2]=min(s2-1,n)-max(s2-n,1LL)+1; } vector<ll> dp3(3*n+1); ll acu2=0; for (int i=0;i<=3*n;++i){ dp3[i]=acu2; acu2+=dp2[i]; if (i>=n) acu2-=dp2[i-n]; }...
#include <bits/stdc++.h> #define double long double using namespace std; struct Complex { double r, i; Complex(double _r = 0, double _i = 0) : r(_r), i(_i) {} }; Complex operator + (const Complex &a, const Complex &b) { return Complex(a.r + b.r, a.i + b.i); } Complex operator - (const Complex &a, const Compl...
#include <iostream> using namespace std; int H, W, A, B, ans = 0; void dfs(int i, int bit, int A, int B){ if(i == H * W) return (void)ans++; if(bit & 1 << i) return dfs(i + 1, bit, A, B); if(B) dfs(i + 1, bit | 1 << i, A, B - 1); if(A){ if(i % W != W - 1 && ~bit & 1 << (i + 1)) dfs(i + 1, bit | ...
#include <bits/stdc++.h> using namespace std; long long INF = 1000000000000000000; int ans = 0; int H, W; void dfs(vector<vector<int>> &f, int A){ if(A == 0) ans++; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(f[i][j] == 0){ if(i + 1 < H && f[i + 1][j] == 0){ ...
#include <bits/stdc++.h> using namespace std; typedef long long i64; typedef unsigned long long ui64; typedef vector<i64> vi; typedef vector<vi> vvi; typedef pair<i64, i64> pi; #define pb push_back #define sz(a) i64((a).size()) #define all(c) (c).begin(), (c).end() #define REP(s, e, i) for(i=(s); i < (e); ++i) inlin...
//Bismillahir Rahmanir Raheem #include<bits/stdc++.h> typedef long long ll; const ll INFLL = 1e18; const ll INF =1e9; using namespace std; void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } ll n,a[300005],t,k; int main() { cin>>n>>k; for(int i=0;i<n;i++) { cin>>t; a[...
#include <bits/stdc++.h> using namespace std; int main() { #ifndef LOCAL ios::sync_with_stdio(0); cin.tie(0); #endif long long k, n, m; cin >> k >> n >> m; vector<int> arr(k); for (int &it : arr) { cin >> it; } int left = m; vector<int> brr(k); priority_queue<pair<...
#include <bits/stdc++.h> using namespace std; using i64 = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; constexpr int INF = 1001001001...
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n, m, fa[N], ans1, ans2, siz[N]; char a[N][N]; int find_(int x) { return x == fa[x] ? x : fa[x] = find_(fa[x]); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n + m; i++) fa[i] = i, siz[i] = 1; for (int i = 1; i <= n; i++) sc...
#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 all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define ll long long #define int long long template <typename T>...
#include <bits/stdc++.h> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; using ll = long long; #define rep(i,n) for (ll i=0; i < (n); ++i) #define rep2(i,n,m) for(ll i=n;i<=m;i++) #define rep3(i,n,m) for(ll i=n;i>=m;i--) #define P pair<ll,ll> #define pb push_back #define eb emplace_back #...
#include <bits/stdc++.h> using namespace std; int main(){ int a[4]; for(int i=0;i<4;i++){ cin>>a[i]; } int min=1000; for(int i=0;i<4;i++){ if(a[i]<min)min=a[i]; } cout<<min; }
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <cassert> #include <stack> #include <numeric> typedef long long ll; typedef std::pair<int, int> Pii; typedef ...
#include <stdio.h> #define _USE_MATH_DEFINES #include <math.h> #include <iostream> using namespace std; int main(){ long x,y; scanf("%ld %ld", &x, &y); long nAns = abs(x-y); long nTmp = 0; while (y>x) { if (y%2 == 0) { y /= 2; nTmp++; } else { nA...
#include <bits/stdc++.h> using namespace std; const double PI=acos(-1); const double eps=1e-5; int main(){ int n,a,b,c,d; scanf("%d",&n); scanf("%d%d%d%d",&a,&b,&c,&d); double x=1.0*(a+c)/2.0,y=1.0*(b+d)/2.0; double len=sqrt(1.0*(a-c)*(a-c)+1.0*(b-d)*(b-d))/2; double al=atan2(1.0*(d-b),1.0*(c-a));//用atan()会WA, ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll N; cin >> N; double x, y; cin >> x >> y; complex<double> z0(x,y); cin >> x >> y; complex<double> zh(x,y), zo = (z0+zh); zo /= 2; complex<double> a(cos(2*M_PI/N),sin(2*M_PI/N)); complex<double> an...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using namespace std; int main(){ int n, D, H; cin >> n >> D>> H; double ans = 0; rep(i, n){ int d, h; cin >> d >> h; double now = H - double (H-h) * D/ (D-d); ans = max(a...
#include <bits/stdc++.h> using namespace std; // using ll = long long; #define int long long void solve(){ int n, d, h; cin>>n>>d>>h; vector<pair<int,int>> a(n); for(int i=0;i<n;i++){ cin>>a[i].first>>a[i].second; } sort(a.begin(), a.end()); double ans = 0; for(int i=0;i<n;i++){ double now = double(a[i].s...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; #define endl "\n"; using namespace std; const int INFINT = 2e9; const ll INFLL = 2e18; const ll mod = 1000000007; template<ll mod> class modint{ public: ll val=0; //コンストラクタ modint(ll x=0){while(x<0)x+=mod;val=x%mod;} //コピーコ...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() int dp[3000000]; int main(){ int n;cin>>n; vector<int> v(n); REP(i,n)cin>>v[i]; int sum=0; REP(i,n)sum+=v[i]; dp[0]=1; REP(i,n){ for(int j=sum;j>=0;j--){ if(dp[j])dp[j+v[i]]=...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; constexpr int kN = int(1E5 + 10); int a[kN], b[kN], y[kN], x[kN]; int main() { int n, l, idx = -1, now = 0, lst = 0; ll ans = 0; scanf("%d%d", &n, &l); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) scanf("%d"...
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<string> #include<algorithm> #include<queue> #include<vector> #include<set> #include<map> using std::cin;using std::cerr; using std::max;using std::min; #define N 100005 #define ll long long #define db double #define dbg1(x)...
#include <bits/stdc++.h> #define FAST_IO ios::sync_with_stdio(false); cin.tie(0), cout << setprecision(15); #define ll long long int #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, k, n) for (ll i = k; i>=n; i--) #define repp(i, k, n) for (ll i = k; i < (n); i++) #define pb push_back #define all(x) begi...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long #define S second #define F first #define pb push_back #define all(c) (c).begin(),(c).end(...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll,ll> 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; } ret...
/*It is better to taste failure than to regret*/ #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <c...
#include<iostream> using namespace std; int main() { int a,b,c,d; cin>>a>>b>>c>>d; cout<<a*d-b*c; return 0; }
#include <iostream> #include <cstdio> #include <queue> #include <vector> #define N 2005 using namespace std; int n, m, d[N][N], cnt[30]; vector<int> er[30], ec[30]; int dr[4] = {-1, 0, 0, 1}, dc[4] = {0, -1, 1, 0}; bool v[N][N]; int va[30]; char a[N][N]; queue<int> qr, qc, qs; void f(int p, int q, int w) { int t; if...
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<map> #include<utility> #include<set> #include<stack> #include<list> #include<deque> #include<bitset> #include<iomanip> #include<cstring> #include<sstream> #include<cstdio> #include<cstdlib> #include<climits> #include<cmath> #include<cctype...
#include <bits/stdc++.h> using namespace std; using ll = long long; int cnt; ll n; unordered_set<ll> factor; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 1; (ll)i * i <= 2 * n; ++i) { if (2 * n % i == 0) { factor.insert(i); fact...
#include <bits/stdc++.h> #define int long long using namespace std; int n; vector<int> a; int k; vector<pair<int, int>> c; int m; int maxi = 0; void f(vector<int> a, vector<pair<int, int>> v, int k) { if(k == 0) { int cc = 0; // for(auto e: a) cout << e << ' '; // cout << endl; for(int i = 0; i < m; i++) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int INF = (int)1e9; constexpr long long LINF = (long long)1e18; //constexpr long long MOD = 1e9 + 7; constexpr long long MOD = 998244353; constexpr double pi = 3.141592653589793238; int main() { int n; cin >> n; set<int> ans; ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,cc,n) for(int i=cc...
#include <iostream> #include <iomanip> #include <algorithm> #include <assert.h> #include <complex> #include <utility> #include <vector> #include <string> #include <stack> #include <queue> #include <tuple> #include <cmath> #include <bitset> #include <cctype> #include <set> #include <map> #include <unordered_map> #includ...
#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, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if ...
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; if(s[0]==s[1] and s[1]==s[2] and s[0]==s[2]) cout<<"Won"<<endl; else cout<<"Lost"<<endl; return 0; }
#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include<bits/stdc++.h> using namespace std; #define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++) #define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<ll,ll> Pll; typede...
#include <bits/stdc++.h> using namespace std; const int P = 998244353; long long power(long long x, long long t) { long long ret = 1; for (; t; t >>= 1, x = x * x % P) { if (t & 1) { ret = ret * x % P; } } return ret; } int main() { int N, M; cin >> N >> M; long long ans = power(M, N) * N % ...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i<n;i++) 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); ...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) (int)(a.size()) #define all(a) a.begin(),a.end() #define lb lower_bound #define ub upper_bound #define owo ios_base::sync_with_stdio(0);cin.tie(0); #define MOD (ll)(998244353...
#include <bits/stdc++.h> using namespace std; int main() { int N, M, A, B; cin >> N >> M; vector<vector<int>> graph(N); for (int i = 0; i < M; i++) { cin >> A >> B; A--, B--; graph.at(A).push_back(B); graph.at(B).push_back(A); } vector<bool> checked(N,false); vector<int> colors(N,-1), b...
#include <iostream> #include <string> #include <stdio.h> #include <math.h> #include <queue> #include <algorithm> #include <utility> #include <vector> #include <tuple> #include <numeric> using namespace std; int main(int argc, char* argv[]){ int N; cin >> N; vector<int>P(N); for (int i=0; i<N; i++){ cin >> P[i];...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #define ll long long int a[200010], b[200010]; ll d[200010]; int main() { int n; scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d", &a[i]); } for(int i = 0; i < n; ++i) { scanf("%...
#include<iostream> #include<ctype.h> using namespace std; int main(void) { char S,T; cin >> S; cin >> T; if(S == 'Y') { T = toupper(T); } cout << T << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main () { char S, T; cin >> S >> T; if (S == 'Y') { T = T - 0x20; cout << T << endl; return 0; } if (S == 'N') { cout << T << endl; return 0; } }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define rep3(i, s, n) for (int i = (s); i > (int)(n); i--) #define all(v) v.begin(), v.end() #define pb push_back #define sz(x) ((int)(x).size()) typedef long l...
#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<ll, ll>; const ll INF = ll(1e18) + 5; struct edge { ll to, cost; }; int main() { ll N, M; cin >> N >> M; vector<vector<edge>> g(N); rep(i, M) { ll A, B, C; ...
#include<bits/stdc++.h> #define ll long long using namespace std; int main(){ ios::sync_with_stdio(0); ll a,b,x,y; cin>>a>>b>>x>>y; if(a<=b) cout<<min(x+(b-a)*y,(b-a)*2*x+x)<<endl; else cout<<min(x+(a-b-1)*y,(a-b-1)*2*x+x)<<endl; return 0; }
#include<bits/stdc++.h> #include<tuple> typedef long long ll; #define INF 9999999999 #define mod 1000000007 using namespace std; typedef pair<ll,ll>du; ll dp[5][105],a,b,x,y; int main(){ ll i,j,k; ios::sync_with_stdio(0); cin>>a>>b>>x>>y; for(ll i=0;i<=100;i++) dp[1][i]=dp[0][i]=INF; dp[0][a...
#include<cstdio> #include<iostream> using namespace std; #define N 2005 #define ll long long const int mod=1e9+7; int n,m; string s; ll sum1[N][N],sum2[N][N],sum3[N][N]; int dp[N][N],map[N][N]; int main() { scanf("%d%d\n",&n,&m); for (int i=1 ; i<=n ; i++){ cin>>s; for (int j=1 ; j<=m ; j++) map[i][j]=s[j...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) #define rep1(i, n) for (int i = 1; i <= (int)(n); ++ i) #define MP make_pair using namespace std; typedef long long LL; typedef pair<int, int> PII; const int MOD = 1e9 + 7; int N; LL a[3005], dp[3005], dp2[3005]; LL sum[3005]; int main() ...
#define _DEBUG #include "bits/stdc++.h" #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,a4,x,...) x #define debug_1(x1) cout<<#x1<<": "<<x1<<endl #define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl #define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl #define ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; int main() { FastIO; int n , a , b; cin >> n >> a >> b; cout << n-a+b; return 0; }
#include <bits/stdc++.h> using namespace std; // 総数を1000000007(素数)で割った余り const long long mod = 1e9 + 7; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs ve...
#include <bits/stdc++.h> #define pan(i,l,r) for(int i=l ; i < r; i++) #define ll long long int #define pb push_back #define PI 3.141592653 #define pll pair<ll,ll> #define V vector #define F first #define S second #define INF INT_MAX using namespace std; ll lcm(ll a, ll b){ return (a / __gcd(a, b)) * b;} void solv...
#include<bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; int main(){ ios::sync_with_stdio(0), cin.tie(0); int a, b , c; cin >> a >> b >> c; cout << 21 - (a + b + c) << '\n'; }
#include<bits/stdc++.h> #define ll long long int #define pii pair<int,int> #define F first #define S second #define mod 1000000007 using namespace std; ll add(ll a,ll b){ return ((a%mod)+(b%mod))%mod; } ll mul(ll a,ll b){ return ((a%mod)*(b%mod))%mod; } ll sub(ll a,ll b){ ll curr=((a%mod)-(b%mod))%mod; if(curr<0) curr...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; #define INF 1e9 #define rep(i, n) for(int i = 0; i < n; i++) #define repr(i, n) for(int i = n; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i < n; i++) #define all(x) (x).begin(),(x).end() int main() { int A,B; cin ...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll n ; cin >> n; vector<ll> v(n); for(ll i=0; i<n; i++) cin >> v[i]; sort(v.rbegin(),v.rend()); ll suff[n+10]; suff[n-1] = v[n-1]; for(ll i=n-2; i>=0; i--) { suff[i] = suff[i+1] + v[i]; ...
#include<bits/stdc++.h> #define ll long long int #define pii pair<int,int> #define pll pair<ll,ll> #define vpii vector< pii > #define vpll vector< pll > #define mpii map<int,int> #define mpll map<ll,ll> #define MOD 1000000007 #define all(v) v.begin(),v.end() #define s(v) v.size() #define test ll t;cin>>t;while(t--) #de...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MOD=1000000007; #define INF 1LL<<30 #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() int did[202020]; vector<int> ret; int main() { int n; cin>>n; vector<int> p(n),r(n); rep(i,n){ ci...
#include<bits/stdc++.h> #define lint long long #define st first #define nd second #define INF 0x3f3f3f3f #define N 28 using namespace std; lint log5(lint n){ lint ans = 0; while(n > 0){ ans++; n/=5; } return ans; } int bb(const vector<lint> &pot5, lint val){ if(val > pot5.back())...
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <map> using namespace std; # define rep(i,a,b) for(int i=(a); i<=(b); ++i) # define drep(i,a,b) for(int i=(a); i>=(b); --i) typedef long long int_; inline int readint(){ int a = 0; char c = getchar(), f = 1; for(;...
#include <iostream> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <algorithm> #include <iomanip> #include <math.h> #include <string.h> #include <cstdio> #include <tuple> #include <numeric> #include <functional> using namespace std; using ll = long long; usi...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx,avx2,fma") typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef ve...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include <bits/stdc++.h> using namespace std; const int N = 50 + 9; pair<int, int> a[N]; int x[N]; int main(){ int n, m, q; scanf("%d %d %d", &n, &m, &q); for (int i = 1; i <= n; ++i){ scanf("%d %d", &a[i].first, &a[i].second); } sort(a + 1, a + n + 1); for (int i = 1; i <= m; ++i){ ...
#pragma GCC optimize("Ofast") //#pragma GCC target ("sse4") #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> #i...
#include <iostream> using namespace std; using ll = long long; int mod = 1e9 + 7; char s[2008][2008]; ll ans[4][2008][2008]; ll dp[2008][2008]; int main() { int n, m; cin >> n >> m; dp[1][1] = 1; for (int i = 1; i <= n; i++) cin >> s[i] + 1; for (int i = 1; i <= n; i++) { for (int j = 1; j ...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x)...
//#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> using namespace std; using ll=long long; int main(void) { ll N, M; cin >> N >> M; vector<string> S(N); for (ll i = 0; i < N; i++) { cin >> S[i]; } ll a = 1; ll b = 0; for (ll i = 1; i < N; i++) { ll count = 0; for (ll j = 0; j < ...
#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 <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mii map <int, int> #define mll map <ll, ll> #define pii pair <int, int> #define pll pair <ll, ll> #define vi vector <int> #define vd vector <double> #define vll vector <ll> #define fi first #define se second #define si set ...
#include <bits/stdc++.h> #define mod 1000000007 #define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define vi vector<int> #define vl vector<ll> #define REP(s, e) for (auto i = s; i <= e; i++) #define show(s) cout<<s<<" " #define MAXI 2147483647 #define MAXL 9223372036854775807 #define FOR(a,b) for (ll i = a...
#include<bits/stdc++.h> using namespace std; int main(){ int N;cin>>N; vector<long> A(N); for(int i=0;i<N;i++) cin>>A.at(i); map<long,vector<int>> x; long cnt=1,m=0; x[0].push_back(-1); for(int i=0;i<N;i++){ m+=cnt*A[i]; x[m].push_back(i); cnt*=-1; } long ans=0; for(auto [c,v]:x){ m...
#include <bits/stdc++.h> #define ll long long #define map unordered_map #define set unordered_set #define l_l pair<ll, ll> #define P pair<ll, ll> #define vll vector<ll> #define mll map<ll, ll> #define mp make_pair #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##...
// https://atcoder.jp/contests/abc207/editorial/2153 #include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<double> a(N),b(N),c(N),d(N); for(int _=0; _<2; _++){ for(int i=0; i<N; i++) cin >> a[i] >> b[i]; int x = 0, y = 0; for(int i=0; i<N; i++){ ...
/* OVERKILLED */ // #pragma GCC optimize("Ofast,unroll-loops") // #pragma GCC target("avx,avx2,sse,sse2") #include <array> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include<climits> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include...
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define LCM(a, b) (a) / __gcd((a), (b)) * (b) #define log_2(a) (log((a)) / log(2)) #define ln '\n' using namespace std; using LL = long long; using...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++) #define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--) #define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++) #define ALL(x) (x).begin(),(x).end() #define MOD 10000000...
#include <bits/stdc++.h> using namespace std; using ll = long long; void Yes() {cout << "Yes\n";} void No() {cout << "No\n";} void YES() {cout << "YES\n";} void NO() {cout << "NO\n";} int main() { ios::sync_with_stdio(false); cin.tie(0); string s, t; cin >> s >> t; if (s == "Y") t[0] += 'A' - 'a'; cout << t << ...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ceil(x) static_cast<ll>(ceil(x)) #define floor(x) static_cast<ll>(floor(x)) #define pow(x, y) static_cast<ll>(pow(x, y)) #defi...
#include <bits/stdc++.h> using namespace std; int n,x,v[1020],z; int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>x; z+=v[x]++; } if(z!=0){ cout<<"No"; }else{ cout<<"Yes"; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = (1LL << 60); #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) int main() { ll n; cin >> n; vector<pair<ll, ll>> x(n), y(n); rep(i, n) cin >> x[i].first >> y[i].first; rep(i, n) { x[i].second = i; ...
#include <bits/stdc++.h> #define rep(i,n) for(long long i = 0; i < (long long)(n); i++) #define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i) #define REP(i,s,t) for(long long i=s;i<t;i++) #define PER(i,s,t) for(long long i=s;i>t;--i) #define all(x) x.begin(),x.end() #define sp(n) setprecision(n) typedef long...
#include <bits/stdc++.h> #define endl "\n" using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> PP; #define overload4(_1, _2, _3, _4, name, ...) name #define overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < n; ++i) #define rep2(i, n) for (ll i = 0; i < n; ++i) #...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> pii; int main(){ ll k, n, m; cin >> k >> n >> m; vector<int> a(k), b(k); vector<pair<double, ll>> v(k); rep(i, k) cin >> a[i]; ll sum = 0; rep(i, ...
#include <bits/stdc++.h> using namespace std; #define int long long using vec_int = vector<int>; using P = pair<int,int>; using T = tuple<int,int,int>; using ll = long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int charToInt(char c){ char zero_num = '0'; return (int)c - (int)zero_num; } signed ...
#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<ll, ll>; void solve(long long N, std::vector<long long> a, std::vector<long long> b) { ll maxA = 0; ll maxC = 0; rep(i, N) { maxC = max(maxC, a[i] * b[i]); maxC...
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; typedef long long ll; typedef pair<ll, ll> p; vector<p> v; const int maxn=1e6+10; ll a[maxn], b[maxn]; ll k, n, m; int main() { ll sum=0; cin>>k>>n>>m; for(int i=0; i<k; i++){ cin>>a[i]; b[i]=a[i]*m/n; sum+=b[i]; ...
//vec[i]の範囲外エラー表示 #define _GLIBCXX_DEBUG //includeとusing #include <bits/stdc++.h> using namespace std; //型名省略 template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using P = pair<T,T>; template <class T> using M = map<T,T>; template <class T> using S = set<T>; template <class...
#include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <stack> #include <queue> #include <array> #include <bitset> #include <cstdio> #include <string> #include <vector> #include <random> #include <chrono> #include <utility> #include <numeric> #include <cstdlib> #include <cstring> #incl...
#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; using ll = long long int; using ld = long double; #define pow(n,m) powl(n,m) #define sqrt(n) sqrtl(n) const ll MAX = 5000000000000000000; const ll MOD = 0; random_device rd; mt19937 mt(rd()); int main(){ ll N,M; cin >> N >> M; vector<string> S(M),ans(N),T; ma...
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<cmath> using namespace std; int main(){ int N,Q; cin >> N >> Q; vector<unsigned long long> A(N); vector<unsigned long long> low(N); for (int i = 0; i < N; i++) { cin >> A[i]; low[i]=A[i]-i-1; }...
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; typedef long long ll; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } vector<int> v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; v.resize(n); for (auto& x : v) { cin >> x; }...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
//in dp prefix suffix sum helps.. #include<iostream> #include<vector> #include<string.h> #include<algorithm> #include<iomanip> #include<cmath> #include<stack> #include <iterator> #include <map> #include<list> #include <fstream> #include<unordered_map> #include<set> #include<queue> #define int long long #define double ...
#include <bits/stdc++.h> using namespace std; int gcd(long long a, long long b) { if (a % b == 0) return b; else return gcd(b, a%b); } int lcm(long long a, long long b) { return a * b / gcd(a, b); } int main() { int N; cin >> N; long long x = 2; for (int i = 3; i < N+1; i++) { x = lcm(x, i); }...
#include<bits/stdc++.h> using namespace std; const int mxn=3e3+3; int n,m; int par[mxn]; inline int find(int x){return par[x]==x?x:par[x]=find(par[x]);} inline void uni(int x,int y){par[find(x)]=find(y);} set<int>s1,s2; int main(){ ios_base::sync_with_stdio(false); cin>>n>>m; for(int i=1;i<=n+m;++i)par[i]=i; uni(1,...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; const int maxn = 2e5+5; #define mod 1000000009 void solve(){ int n,m; cin >> n>> m; vector<int> a(m); for(int i=0;i<m;i++){ cin >> a[i]; } if( m==0){ cout << 1 << endl; return; } sort(a.begin(),a.end()); vector...
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #pragma GCC optimize(2) #include<set> #include<map> #include<cmath> #include<stack> #include<queue> #include<random> #include<bitset> #include<string> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<unordere...
#include<bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; void read(int &x){ static char c; while(!isdigit(c=getchar())); x=c^48; while(isdigit(c=getchar()))x=(x*10)+(c^48); } void read(ll &x){ static char ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define __ ios_base::sync_with_stdio(false);cin.tie(NULL); #define bs 97 #define mx 4000007 int main() { __ ll s , p ; cin >> s >> p ; ll i ; ll ans = 0 ; for (i = 1 ; i * i <= p ; i++) { if (...
#include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <utility> #include <algorithm> #include <cmath> #include <climits> #include <iomanip> #include <queue> #include <stack> #include <ctype.h> using namespace std; typedef long long ll; const int INF = (1<<30)-1; const ll LINF...
#include <iostream> using namespace std; using ll = long long; int main() { ll K; cin >> K; ll res = 0; for (int a=1; a<=K; ++a) { for (int b=1; b<=K/a; ++b) { ll prod = a*b; res += K/(a*b); } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> bool cmin(T &a, U b) { return a > b && (a = b, true); } template <typename T, typename U> bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); string S; cin >...
#include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #inc...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define f(x, m) for(auto x : m) #define cpu() ios::sync_with_stdio(false); cin.tie(nullptr) #define pb push_back #define pii pair<int,int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #d...
#include<bits/stdc++.h> #include <iterator> #include <iostream> #include <numeric> #include <math.h> #define ll long long #define ull long #define mpa make_pair #define pb push_back #define ff first #define pii pair<ll,ll> #define dd double #define trace(x) cerr << #x << " : " << x << endl #define ss second #define boo...
#include <bits/stdc++.h> using namespace std; typedef long long ll; using pll = pair<ll, ll>; #define rep(i, n) for(ll i = 0; i < n; i++) #define rrep(i, m, n) for(ll i = m; i > n; i--) #define Rep(i, m, n) for(ll i = m; i < n; i++) #define all(vec) vec.begin(), vec.end() #define lmax(x, y) max<ll>(x, y) #define lmin(x...
#include<bits/stdc++.h> using namespace std; using P=pair<int,int>; using ll=long long; template<class T> using heapq = priority_queue<T,vector<T>,greater<T>>; template<class T> bool chmax(T &a,const T b) {if (a<b) {a=b;return true;} else return false;} template<class T> bool chmin(T &a,const T b) {if (a>b) {a=b;retur...
#include <iostream> #include <cstring> using namespace std; int main() { string str,s; cin>>str; for(int i=str.size()-1;i>=0;i--) { if(str[i]=='0') cout<<"0"; if(str[i]=='6') cout<<"9"; if(str[i]=='8') cout<<"8"; if(str[i]=='9') cout<<"6"; if(str[i]=='1') cout<<"1"; } return 0; }
#include <bits/stdc++.h> #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--) inline int read() { int x=0,f=1;char c=getchar(); while(c<48||c>57){if(c=='-')f=-1;c=getchar();} while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f; } using namespac...
#include <bits/stdc++.h> #define rep(i, n) for (decltype(+n) i = 0; i < (n); i++) using namespace std; int main() { int N, M; cin >> N >> M; vector<int> a(M), b(M), c(N); rep(i, M) { cin >> a[i] >> b[i]; a[i]--, b[i]--; } for (int &x: c) cin >> x; vector<vector<int>> e(N); rep(i, M) { if (...
/** * author: otera **/ #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60; #define rep(i, n) for(int i = 0; i < n; ++ i) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++)...
//#pragma GCC optimize("Ofast", "unroll-loops") //#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4", "avx") #ifdef __APPLE__ # include <iostream> # include <cmath> # include <algorithm> # include <stdio.h> # include <cstdint> # include <cstring> # include <string> # include <cstdlib> # include <vector> # inclu...
#include<bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define deb(...) #endif #define int long long int void solve() { int n; cin >> n; vector<int>v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } vector<int>pref(n); int sum = 0; for (int i = 0; i <...
#pragma GCC optimize ("trapv") #include <bits/stdc++.h> #include<algorithm> #include <vector> #include<cstring> #include<cmath> #include<cstdlib> #include<string.h> using namespace std; #define pb push_back #define all(v) v. begin(),v. end() #define rep(i,n,v) for(i=n;i<v;i++) #define per(i,n,v) for(i=n;i>v;i--) #defi...
#include <bits/stdc++.h> #define lowbit(x) ((x)&(-(x))) #define mkp make_pair #define pb push_back using namespace std; typedef long long ll; typedef pair<int,int> pii; int main() { int n,s,d; scanf("%d%d%d",&n,&s,&d); int ans=0; for(int i=1;i<=n;i++) { int x,y; scanf("%d%d",&x,&y); if(x<s && y>d) ans|=1;...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i) static const ll INFTY = 1L << 62L; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, s, d; cin >> n >> s >> d; ll x[n], y[n]; rep(i, 0, n) { ...
#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> using namespace std ; using ll = long long ; us...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ cin.tie(0); ios::sync_with_stdio(0); int t; cin >> t; rep(i,t){ int n; cin >> n; map<int,int> mp; rep(i,n){ int a; cin >> a; mp[a] ^= 1; } bool even = true; for(auto [a,v]: mp) if(v) even = false; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vc<vc<T>>; template<class T> using vvvc = vc<vvc<T>>; template<class T> using vvvvc = vvc<vvc<T>>; template<class T> using PQ = priority_queue<T>; template<class T> using invPQ = pri...
#include <bits/stdc++.h> // #define x first // #define y second #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long LL; typedef pair<int, int> PII; const int N = 1e5 + 20; int n, m, k; LL a[N], b[N], c[N], mi[N], mx[N]; bool check(LL mid) { for(int i = 1; i <= k; ...
// // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/`---'\___ // .' \\| |// '. // / \\||| : |||// \ // / _||||| -:- ||||...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n,m,cnt; struct Obstacle { int x,y; bool operator<(const Obstacle rhs) const { if(x==rhs.x) { return y<rhs.y; } return x<rhs.x; } }a[200005]; int lenn[200005];//Maximum x you can go with y=i int lenm[200005];//Maximum y you can go with ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pint; typedef pair<ll,ll> pll; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<string> vstr; typedef vector<pint> vpint; typedef vector<pll> vpll; #define vint2(v,n,m,init) vector<vector<int>> v(...
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <string> using namespace std; int main() { // cinを高速にするためのおまじない cin.tie(0); ios::sync_with_stdio(false); ///////////////////// // Write code below long long int N,A,B,ans; cin >> N >> A >> B; ans =...
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; using namespace chrono; #define ll long long #define ld long double #define mod 1000000007 #define pb push_back #define inf 1000000000000000000 #define ff firs...
#include<bits/stdc++.h> using namespace std; #define ll long long int a[2000005], b[2000005],c[2000005]; int main() { int n; cin >> n; for(int i=1;i<=n;i++) { cin >> a[i]; b[a[i]]=i; c[i] = a[i]; } unordered_map<int,int> mp; vector<int>v; for(int i=1;i<=n;i++) { ...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <map> #include <queue> #include <iomanip> #include <set> #include <tuple> #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 std...
#include <bits/stdc++.h> #define endl "\n" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; constexpr int N = 1e5 + 5; constexpr int mod = 1e9 + 7; constexpr int LOG = 18; template<typename T> void dout(const T& x) { cout << x << ' '; } // change separator! template<typ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; #define FOR(i, a, b) for (int i = a; i <= (b); i++) #define F0R(i...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::en...
#include <iomanip> #include <iostream> #include <unordered_map> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; unordered_map<int64_t, double> memo; double dfs(int a, int b, int c) { if (a == 100 || b == 100 || c == 100) { return 0.0; } int64_t key = 10000 * a + 100 * b + c; if (memo.c...
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define all(v) v.begin(),v.end() #pragma gcc optimize("O3") #pragma gcc optimize("Ofast") #pragma gcc optimize("unroll-loops") using namespace std; const int INF = 1e9; const int TMX = 1 << 18; const long long llINF = 1e16; const long long ...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main(){ double R, X, Y; cin >> R >> X >> Y; double distance = sqrt(X*X+Y*Y); int count = ceil(distance / R); if(count == 1 && distance != R) count++; cout << count << endl; }
//khodaya khodet komak kon # include <bits/stdc++.h> /* // ordered_set # include <ext/pb_ds/assoc_container.hpp> # include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; # define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ using namespace std; typedef lo...
#include <iostream> #include <assert.h> #include <vector> #include <unordered_map> #include <queue> #include <climits> #include <cmath> #include <algorithm> #include <iomanip> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; constexpr ll MOD = 1000000007...
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265358979323 #define ll long long int #define vi vector <int> #define vl vector <ll> #define all(v) (v).begin(),(v).end() #define pb push_back #define ff first #define ss second #define MOD 1000000007 const ll mod = 1e9 + 7; ll power(ll a, ll b) { //a^b ...
//#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<map> #include<cmath> #include<cctype> #include<vector> #include<set> #include<queue> #include<algorithm> #include<sstream> #include<ctime> #include<cstdlib> #define X first #define Y second #define L (u<<1) #define...
#include <bits/stdc++.h> #define F first #define S second #define rep(i, a, b) for(int i = (a); i < (b); ++i) #define per(i, a, b) for(int i = (b)-1; i >= (a); --i) #define bck(i, a, b) if ((i) >= (a) && (i) < (b)) #define trav(x, a) for (auto &x : (a)) #define sz(a) (int)(a).size() #define all(x) (x).begin(), (x).end(...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) (int)(a.size()) #define all(a) a.begin(),a.end() #define lb lower_bound #define ub upper_bound #define owo ios_base::sync_with_stdio(0);cin.tie(0); #define MOD (ll)(998244353) #define INF (ll)(1e18) #defin...
// Problem : A - ReLU // Contest : AtCoder - AtCoder Beginner Contest 183 // URL : https://atcoder.jp/contests/abc183/tasks/abc183_a // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Problem : E. Tree Queries // Contest : Codeforces - Codeforces Round...
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; using ll=long long; using P=pair<ll,ll>; template<class T> using V=vector<T>; #define fi first #define se second #define all(v) (v).begin(),(v).end() const ll inf=(1e18); const ll mod=998244353; //const ll mod=1000000007; const vector<int> dy={-1...
// Problem: C - Shuffle Permutation // Contest: AtCoder - AtCoder Regular Contest 107 // URL: https://atcoder.jp/contests/arc107/tasks/arc107_c // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; #define ff ...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define vi vector<int> #...
/*author @dhanush*/ #include <bits/stdc++.h> using namespace std; #define ll long long #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define pb push_back #define all(x) x.begin(), x.end() #define se second #define fi first ll MOD = 1e9 + 7; const ll N = 200000 + 10; vector...
#include<bits/stdc++.h> using namespace std; using LL=long long; using P=pair<int,int>; using T=tuple<int,int,int>; constexpr int mod=1000000007; constexpr int inf=1e9; int in(){ int x; scanf("%d",&x); return x; } struct graph{ vector<vector<int>>e; vector<int>used; int cnt=0; graph(int n){ ...
#include <bits/stdc++.h> using Int = long long; // clang-format off #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) #define RREP_(i, a_, b_, a, b, ...) for (Int i = Int(b) - 1, low##i = (a); i >= low##i; i--) #def...
#include<bits/stdc++.h> #define LL long long using namespace std; LL n,ans; int main() { cin>>n; n*=2; for(LL i=1;i*i<=n;i++) { if(n%i==0) { LL a=i,b=n/i; if(a%2!=b%2)ans+=2; } } cout<<ans; return 0; }
#include<iostream> #include<iterator> #include<algorithm> #include<climits> #include<map> #include<set> #include<cmath> #include<numeric> #include<string> #include<sstream> #include<cstdio> #include<vector> #include<bitset> // #include <atcoder/segtree> #define ll long long using namespace std; int main() { ll n,...
#include <iostream> #include <queue> using namespace std; using ll = long long; int n; priority_queue<ll> q; void solve() { q.push(0); ll res = 1, before = q.top(), now; q.pop(); while (q.size() > 0) { now = q.top(); q.pop(); if (before > now) { res = re...
#pragma warning(disable: 4996) #include <string> #include <vector> #include <iostream> #include <cstdio> #include <sstream> #include <fstream> #include <math.h> #include <algorithm> #include <map> #include <bitset> #include <queue> using namespace std; typedef long long ll; #define rep(i,n) for (int i = 0; i < (n); i+...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll b,c; scanf("%lld%lld",&b,&c); ll cnt=0; if(b<=0){ cnt=c+1; c--; if(b==0)cnt--; if(c>0&&b<0)cnt+=min(-2*b-1,c-1); }else { cnt=c+(c==1?1:0); cnt+=min(2*b-1,c-1); }printf("%lld\n",cnt); }
#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>; ll INF = 1e18; int main() { int n; cin >> n; vector<ll> a(n); ll m = 0; rep(i,n){ ll x, y; cin >> x >> y; a[i] = 2 * x + y; m += x; } sort(a.be...
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define ALL(obj) obj.begin(),obj.end() #define SORT(obj) sort(obj.begin(),obj.end()) #define pb(obj) push_back(obj) #define rep(i,n) for(int i=0; i<n; i++) typedef long long ll; ll const MOD=1e9+7; const ll INF = 9000000000000000000; vecto...
#include <iostream> #include <bits/stdc++.h> #define ll long long int #define max_value 0x3f3f3f /*freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);*/ using namespace std; const int inf=1e9+7; void solve(){ double r,x,y; cin>>r>>x>>y; double z=sqrt(x*x+y*y); if(z==r) cout<<"1"<<e...
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; vector<vector<tuple<int,long,long>>>g(n+1); for(int i=0;i<m;i++){ int a,b,c,d; cin>>a>>b>>c>>d; g[a].emplace_back(b,c,d); g[b].emplace_back(a,c,d); } auto w=[](long t,long d){ int l=sqrt(d)-t-10; l=max(l,0); int m=...
//#define MULTICASES #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,a,b) for(i=(a);i<=(b);++i) #define per(i,a,b) for(i=(a);i>=(b);--i) #define REP(i,a,b) for(i=(a);i< (b);++i) #define PER(i,a,b) for(i=(a);i> (b);--i) #define ERR(...) fprintf(stderr,__VA_ARGS__) inline void ac(); int m...
#include <bits/stdc++.h> #define ls (rt<<1) #define rs (rt<<1|1) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int N=4e5+10; const int INF=0x3f3f3f3f; int a[N],n; pii pa[N]; int mx[N<<2],lazy[N<<2]; int main() { auto push_down=[&](int rt){ if(lazy[rt]){ lazy[ls]+=la...
#include<iostream> #include<string> #include<vector> #include<set> #include<iomanip> #include<algorithm> #include<cmath> #include<bitset> #include<queue> #include<stack> #include<utility> #include<cstdlib> #include<cstdio> #include<map> #include<unordered_set> #include<unordered_map> #include<list> #include<tuple> usin...
#include <iostream> #include<vector> #include<string> #include<algorithm> #include<iomanip> #include<map> #include<random> #include<complex> #include<math.h> #include<functional> #include<stack> #include<queue> #include<unordered_map> #include<set> #include<numeric> #include <cassert> using namespace std; #define rep(i...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long ll; typedef pair<double,double> P; t...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int64_t> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int64_t maxA = 0; int64_t lastC = 0; for (int i = 0; i < n; i++) { int64_t b; cin >> b; maxA = max(a[i], max...
#include <iostream> #include <vector> #include <string> using namespace std; int main() { int T; cin>>T; for (int i=0; i<T; i++) { int N; cin>>N; string S[3]; for (string &s: S) { cin>>s; s = s+s; } auto check = [&](string...
//BY: YASH JAIN, CF: BitSane #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; #define May_the_fork_be_with_...
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <memory> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <sstream> #include <string> #include <functional> #include <queue> #inc...
#include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) ...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll=long long; using ld=long double; using pll=pair<ll, ll>; //using mint = modint1000000007; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) #define PI acos(-1) #define oo 2e18 template<typenam...
#include <iostream> #include <string> #include <utility> #include <stack> #include <vector> #include <queue> #include <algorithm> #include <map> #include <climits> #include <set> #include <cmath> #include <numeric> #include <cfloat> #include <iomanip> using namespace std; int a[50][50]; const long long MOD = 998244353;...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; using Graph = vector<vector<int>>; #define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i)) #define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i)) #define all(x) (x).begin(),(x).end() #define out(y,x,h,w) (y...
//#pragma GCC optimize ("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define pb push_back #define F first #define S second #define ins insert #define mp ma...
#include <bits/stdc++.h> #define eprintf(args...) fprintf(stderr, args) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) const int mxn = 2e5 + 5; int n, a[mxn], b[mxn]; std::map <int, std::vector <int> > oa, ob; int s[mxn]; void update(int x, int v) { for (++ x; x < mxn; x += x & -x) s[x] += v; } int query(i...
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1050; vector<int> g[N][26]; bool vis[N][N]; int dp[N][N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; #define FOR(i, a, b) for (int i = a; i <= (b); i++) #define F0R(i...