code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <algorithm> #include <cassert> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef lo...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb emplace_back #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0); #define LL_MAX LLONG_MAX #define ub(v,x) upper_b...
#include <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 C = complex<double>; int main() { ll n; cin >> n; set<ll> s; for (ll a = 2; a * a <= n; ++a) { ll x = a * a; while (x <= n) { s.insert(x); x *= a; } } cout << ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "/debug.h" #else #define db(...) #endif #define all(v) v.begin(), v.end() #define pb push_back using ll = long long; const int NAX = 2e5 + 5, MOD = 1000000007; int64_t solveCase(int64_t N) { // TODO: edit here set<int64_t> ss; for (int64...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() ll ans = 0; void Main(){ using P = pair<int, int>; int a, b, x, y; cin >> a >> b >> x >> y; a--; b--; vector<vector<P>> graph(200); For(i,0,100...
#include<iostream> #include<bits/stdc++.h> #define int long long int using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int a,b,x,y; cin>>a>>b>>x>>y; ...
/**Bismillahir Rahmanir Rahim.**/ /* Md.Fagun Molla 18ICTCSE006 BSMRSTU(SHIICT) */ #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; using ll = long long; using db = double; ///***************...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int N; int main() { //45 200 , out -> 90 cin >> N; vector <int> S(N); for (int i=0; i < N; ++i) { cin >> S[i]; } sort(S.begin(), S.end()); int count; count = 0; for (int i=0; i < N; ++i) { i...
#include <iostream> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <utility> #include <string> #include <sstream> #include <algorithm> #include <random> #include <cstdio> #include <cstdlib> #in...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<int,int,int> using Graph = vector<vector<int>>; ll mod = 998244353; int main() { ll N,M; cin >> N >> M; vector<Pr> br; rep(i,M){ ll x,y; cin >> x...
#include<bits/stdc++.h> using namespace std; int main() { int a, b, x, y; cin >> a >> b >> x >> y; if(a == b) { cout << x << '\n'; return 0; } cout << x + min(abs(a - b), abs(a - (b + 1))) * min(2 * x, y) << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; #define Rep(i,j,n) for(int i=j; i<n; i++) #define rep(i,n) for(int i=0; i<n; i++) #define PI 3.14159265359 #define INF 1000100100//0000000 #define MOD 1000000007 #define all(x) (x).begin(),(x).end() typedef long long ll; #define P pair<int, int> //#define P pair<ll, ll> //#...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n; cin >> n; int res=0; for(int...
#ifdef Icry #include "debug.h" #else #include <bits/stdc++.h> #define debug(args...) #endif using namespace std; int main() { #ifdef Icry auto begin = std::chrono::high_resolution_clock::now(); #endif ios_base :: sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector...
#include <bits/stdc++.h> using namespace std; #define int int64_t #define rep(i, a, b) for(int i = a; i < b; ++i) int debug = 0; int n, y, corr = 1, x[100]; main() { cin >> n; rep(i, 0, n) { cin >> x[i]; int d = 2, ispr = 1; while (d * d <= x[i]) { if (x[i] % d == 0) { ...
#include<bits/stdc++.h> /* shinchanCoder Here!! */ using namespace std; #define endll "\n" #define pb push_back #define all(x) begin(x), end(x) #define allr(x) rbegin(x), rend(x) #define forn(i,n) for(ll i=0;i<(n);i++) #define sz(x) (int)(x).size() #define ff first #define ss second #define mpr make_pair #de...
#include <bits/stdc++.h> using namespace std; int N, M, K; int dis[18][100001]; int c[18]; vector<int> g[100001]; const int ALL = (1 << 18) - 1; const int INF = 1000000; int dp[ALL + 1][18]; int solve(int mask, int last) { if (dp[mask][last] != -1) { return dp[mask][last]; } int & res = dp[mask][...
#include <bits/stdc++.h> using namespace std; #define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); } #define pb push_back #define ll long long #define vi vector<int> #define vll vector<long long> #define mp make_pair #define infi INT_MAX #define infl LONG_LON...
// Problem: D - Opposite // Contest: AtCoder - AtCoder Beginner Contest 197(Sponsored by Panasonic) // URL: https://atcoder.jp/contests/abc197/tasks/abc197_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) /* WINNERS NEVER QUIT AND QUITTERS NEVER WIN!! Falling down ...
#include <bits/stdc++.h> using namespace std; int main() { double N, x0, y0, xn2, yn2; cin >> N >> x0 >> y0 >> xn2 >> yn2; complex<double> a(x0,y0), b(xn2, yn2), c, d; c = (a+b)/2.0; d = c + (a-c)*polar(1.0, M_PI*2.0/N); cout << d.real() << ' ' << d.imag() << endl; return 0; }
#include <bits/stdc++.h> #define lli long long int #define ulli unsigned long long int #define ld long double #define pb push_back #define endl "\n" #define mod 1000000007 #define vi vector<lli> #define precision(x,y) fixed<<setprecision(y)<<x #define sort(a) sort(a.begin(),a.end()) #define getsetbits(n) __buil...
#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; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; //typedef tree<int, null_type, l...
#include<stdio.h> #include<stdlib.h> #include<bits/stdc++.h> //Do DEBUG OR NOT #define DEBUG #ifdef DEBUG #define debug(var) do{std::cout << #var << " : ";view(var);}while(0) template<typename T> void view(T e){std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){for(const auto& e : v...
#include<bits/stdc++.h> #define SORT(v) sort(v.begin(),v.end()) #define si(n) scanf("%d",&n) #define sii(n,m) scanf("%d %d",&n,&m) #define sl(n) scanf("%lld",&n) #define sll(n,m) scanf("%lld %lld",&n,&m) #define ss(cad) scanf("%s",cad) #define all(v) (v).begin(), (v).end() #define PB push_back #define fst first #defin...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if ...
#include <bits/stdc++.h> #define readFast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define fin cin #define ll long long #define sz(x) (int)(x).size() #define all(v) v.begin(), v.end() #define output(x) ((int)x && cout << "YES\n") || cout << "NO\n"; using namespace std; #ifdef LOCAL #define read() ifstrea...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 62; int mod = 1000000007; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int A[4]; rep(i, 4) cin >> A[i]; sort(A, A+4); ...
#include<iostream> #include<algorithm> using namespace std; bool cmp(int x,int y){ return x>y; } int main() { int n; cin>>n; int ans=0; int a,b,max=0,min=1100; for(int i=0;i<n;i++){ cin>>a; if(a>=max) max=a; } for(int i=0;i<n;i++){ cin>>b; if(b<=min) min=b; } if(max>min) ans=0; else{ ans=min-max+1...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for(int i = 0; i < N; i++) cin >> A.at(i); bool change = false; if(N == 1) cout << A.at(0) << endl; else { int mod; int j; int max; int min; for( ; ; ) { max = A.at(0); ...
#include <bits/stdc++.h> using ull = unsigned long long int; using ll = long long; using ld = long double; using pii = std::pair<int,int>; using pll = std::pair<ll, ll>; using vi = std::vector<int> ; using vvi = std::vector<vi> ; using vll = std::vector<ll>; using vvll = std::vector<vll>; using vd = std::vector<double...
/*input 18 0 */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; //order_of_key #of elements less ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define f first #define s second #define pb push_back #define all(x) x.begin(), x.end() #define mp(x, y) make_pair(x, y) #define sz(li) (int) (li).size() #define endE(li) li[sz(li) - 1] #define vi vector<int> #define vl vector<l...
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iostream> #include <istream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <tuple> #include <iomanip> #include <random> #include <math.h> #include <stdi...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i < n; ++i) using namespace std; typedef long long ll; const int INF = 100100100; int main() { ll n; cin >> n; ll ans=0; if(n>=1000) ans+=n-999; if(n>=1000000) ans+=n-999999; if(n>=1000000000) ans+=n-999999999; if(n>=1000000000000) ans+=n-99...
#include<bits/stdc++.h> #define l(i,a,n)for(int i=a;i<n;i++) #define pb push_back #define in insert #define mp make_pair #define lw(v) sort(v.begin(),v.end()); #define hi(v) sort(v.begin(),v.end(),greater<long long>()); #define all(v) v.begin(),v.end() #define filein freopen ("input.txt", "r", stdin) #define fileout fr...
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i,n) for (int i=0;i<(int)(n);i++) #define codefor int test;scanf("%d",&test);while(test--) #define INT(...) int __VA_ARGS__;in(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;in(__VA_ARGS__) #define yes(ans) if(ans)p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define ...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <stack> #include <tuple> #include <deque> #include <array> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> ...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll i=0;i<(ll)n;i++) #define dump(x) cerr << "Line " << __LINE__ << ": " << #x << " = " << (x) << "\n"; #define spa << " " << #define fi first #define se second #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() using ld =...
#include<bits/stdc++.h> #define ll long long int #define lb long long double #define mp make_pair #define MOD 1000000007 #define pb push_back #define ppi pair<ll,pair<ll,ll>> #define F(i,n) for(ll i=0;i<n;i++) #define w(t) ll t;cin >> t;while(t--) using namespace std; vector<ll> divisor; void getDivisors(ll n) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; const int INF = 1e9; const ll LINF = 1e18; template <class T> void get_uni...
#include<bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops,fast-math") #include <ext/pb_ds/tree_policy.hpp> // #include<ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; //using namespace __gnu_pbds; #define pb push_back #define ...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn #define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa #define db(x) cout << #x << " = " << x << endl #define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用 #define all(x) (x).begin(), (...
#include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ int x=0, y=0; cin>>x>>y; int ans=0; if(x==y){ ans=x; }else{ ans=3-x-y; } cout<<ans<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; const auto maxn = int(1e5 + 5); struct edge { int to, c, next; edge(int v, int tag, int nxt) : to(v), c(tag), next(nxt) {} }; auto ans = vector<int>(maxn, -1); auto visited = vector<bool>(maxn, false); auto es = vector<edge>(); auto head = vector<int>(maxn, ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb p...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define vll vector<ll> #define pll pair<ll,ll> #define vpll vector<pll> #define ub upper_bound #define lb lower_bound #define all(v) ((v).begin()),((v).end()) #define allr(v) ((v).rbegin()),((v).rend()) #define...
#include <iostream> using namespace std; int main(){ int n,w; cin >> n >> w; cout << n/w; }
#include <bits/stdc++.h> #define mp std::make_pair #define pb push_back #define fr first #define se second typedef std::pair<int, int> pii; typedef std::vector<int> vi; typedef long long ll; template<class T> inline T max(const T &x, const T &y) { return x > y ? x : y; } template<class T> inline T min(const T &x, co...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ff first #de...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) begin(v), end(v) using namespace std; using P = pair<int,int>; using ll = long long; using vi = vector<int>; using vll = vector<ll>; ll ll_pow(ll a, ll n) { ll ans = 1; for(ll i = 0; i < n; i++) ans *= a; return ans; } ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define vi vector<ll> #define pb push_back #define ff first #define ss second #define inf 2e18 #define ull unsigned long long #define pi acos(-1.0) #define mod 1000000007 #define lop0(n) for(ll i=0;i<n;i++) #define lop(j,n) for(ll j=0;j<n;j++) #define l...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < (t); ++i) #define dsrep(i,t,s) for(int i = (t)-1; i >= (s); --i) #define rng...
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<stack> #include<string> #include<map> #include<set> #include<tuple> #include<cmath> #include<iomanip> using namespace std; typedef long long ll; typedef vector<ll> v; typedef vector<vector<ll>> vv; #define MOD 1000000007 #define INF 10...
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <vector> #include <map> #include <queue> #include <set> #include <cmath> #include <queue> #include <unordered_map> #include <unordered_set> #include <sstream> #include <iomanip> using namespace std; using VI = vector <int>; using VV...
#include <bits/stdc++.h> using namespace std; long long n, k, d = 1, i = 3, j = 1, u; bool f = 0; int main() { cin >> n >> k; if (k > (n * n * n + 1) / 2) { k = n * n * n + 1 - k; f = 1; } while (k > d) { k -= d; i++; if (i < n + 3) d = (i - 2) * (i - 1) / 2; else d = (i - 2) * (i - 1) / 2 - ...
#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 // 1-indexed const int N = 1000010; ve...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdio> #include <cmath> #include <tuple> #define int long long #define rep(i, n) for(i = 0; i < n; i++) using namespace std; const int DEPTH = 19...
# include<bits/stdc++.h> # define ll long long # define mod 1073741824 using namespace std; int main(){ // int t; // cin>>t; // while(t--){ // cout<<"\n"; // } int n; cin>>n; if( (108 * n) / 100 == 206){ cout<<"so-so"; } else if( (108 * n) / 100 < 206){ ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define rep(i,n) for(ll i=0;i<ll(n);i++) #define REP(i,k,n) for(ll i=k;i<ll(n);i++) #define all(a) a.begin(),a.end() #define eb emplace_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bound(all(v),k)-v.begin()) #de...
#include<bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD=1000000007; const ll MODA=998244353; ll vx[4]={0,1,0,-1}; ll vy[4]={1,0,-1,0}; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) long long gcd(long long a,long long b){ ll gcdmax=max(a,b); ll gcdmin=min(a,b); whi...
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define VI vector<int> #define VL vector<ll> #define MX vector<VI > #define all(x) x.begin(), x.end() #define IOS cin.tie(0)->sync_with_stdio(0) using namespace std; struct segt{ int N = 1; VI seg; void add(int i){ for(i ...
#include <iostream> #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> #in...
#include<bits/stdc++.h> #define N 200005 #define Mod 998244353 #define MOD(x) (x>=Mod)&&(x-=Mod) #define Ms(a,b) memset(a,b,sizeof a) #define db(x) cerr<<#x<<"="<<x<<endl; #define db2(x,y) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl; #define db3(x,y,z) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl; using namespa...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #define vpii vector<pair<int,int>> #define vpll vector<pair<ll,ll>> #define fr(i,k,n) for (int i = k; i < n; ++i) #define fri(i,k,n) for (int i = k; i >= n...
/*Read the problem carefully before starting to work on it*/ #include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //using namespace boost::multiprecision; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; typedef lo...
#include <algorithm> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <str...
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<sstream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> #include<t...
#include <stdio.h> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <cstdio> #include <vector> #include <string> #include <bitset> #include <cctype> #include <cstdlib> #include <cstring> #include ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const int inf = 1 << 29; const ll infll = 1LL << 60; const int mod = 1000000007; const int mod9 = 998244353; template<class T> bool chmin(T& a, T b){ if(a > b){ a = b; return true; } else ...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); vector<int> A(3); rep(i, 3) cin >> A[i]; sort(A....
#include <bits/stdc++.h> using namespace std; #define int long long int N; char S[100'100]; int dp[100'100]; int mn[222]; signed main() { cin.tie(0)->sync_with_stdio(false); memset(dp, 0x3F, sizeof dp); memset(mn, 0x3F, sizeof mn); dp[0] = 0; cin>>N; cin >>(S + 1); for (int i = 1; i <= N; ++...
//Har Har Mahadev using namespace std; #include <bits/stdc++.h> #define booga cerr << "booga" << endl #define int long long #define ld long double #define pb push_back #define mp make_pair #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define safai(...) Clearing_out(__VA_ARGS__) temp...
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<vector> #include<string.h> #include<math.h> #include<map> #include<iomanip> #include<queue> using namespace std; using ll = long long; using ull = unsigned long long; const ll inf = 1e9 + 7; int main(){ cin.tie(0); ios::sync_with...
#include <bits/stdc++.h> #define ll long long int #define all(x) x.begin(),x.end() #define pii pair<int,int> #define io ios_base::sync_with_stdio(false); cin.tie(NULL); #define N 105 using namespace std; int a[N][N]; void solve(){ int n,m,mn=1e9; cin>>n>>m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++)...
#include <bits/stdc++.h> using namespace std; int main() { int H,W; cin >> H >> W; vector<int>A(H*W); for(int i=0; i<H*W; i++) { cin >> A.at(i); } sort(A.begin(),A.end()); int a=0; for (int i=0; i<H*W; i++) { a+=A.at(i)-A.at(0); } cout << a << endl; }
/* Arthor: Ender_zzm E-mail: zzm_ender_wiggin@outlook.com Blog: oi.ender-zzm.pro */ #include <bits/stdc++.h> using namespace std; inline int Isdigit(char c) { if (c < '0' || c > '9') return 0; return 1; } template <class T> T read(){ register T x = 0, flag = 1; register char ch; while (!Isdigit(ch = ge...
#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>; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> a[i][j]; int mn = 1e9; rep(i, h) rep(j, w) mn = min(mn, a[...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> // #include <atcoder/all> // g++ main.cpp -std=c++17 -I . using namespace std; // using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return tru...
/* made by amunduzbaev */ //~ #include <ext/pb_ds/assoc_container.hpp> //~ #include <ext/pb_ds/tree_policy.hpp> #include "bits/stdc++.h" using namespace std; //~ using namespace __gnu_pbds; #define ff first #define ss second #define vv vector #define pb push_back #define mp make_pair #define ub upper_bound #define...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef pair<int, int> pii; #define ll long long #define fi first #define se second #define mp make_pair #define pb push_back #define ALL(v) v.begin(), v.end() #define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) #define FORN(a, b, c) for (int(...
#include <bits/stdc++.h> #define FAST_IO ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cout << setprecision(15); #define ll long long int #define rep(i, n) for (ll i = 0; i < (n); i++) #define repp(i, k, n) for (ll i = k; i < (n); i++) using namespace std; ll mPow(ll a, ll n, ll mod) { ll ans = 1; whi...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define x first #define y second #define FOR(i, m, n) for (ll i(m); i < n; i++) #define DWN(i, m, n) for (ll i(m); i >= n; i--) #define REP(i, n) FOR(i, 0, n) #define DW(i, n) DWN(i, n, 0) #define F(n) REP(i, n) #define FF(n) REP...
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <map> #include <cmath> using namespace std; #define int long long main() { int n; int mod = 998244353; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++){ cin >> v[i]; } sort(v.begin(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; #define int ll #define pb push_back #define F first #define S second #define _sz(x) ((int)x.size()) #define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) int dx[4] = {-1,0,1,0}; int dy...
#include <bits/stdc++.h> #define INF 1e9 #define eps 1e-6 typedef long long ll; using namespace std; int n; int main(){ cin >> n; if(n % 2 == 0) puts("White"); else puts("Black"); return 0; }
#include<bits/stdc++.h> using namespace std; int n,m,a[100005],c[21]; long long ans; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1;i<=n;i++){ string s; cin>>s; for(int j=0;j<m;j++)if(s[j]=='1')a[i]|=1<<j; c[__builtin_popc...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n,m; cin>>n>>m; int res = 0; for(int i=1;i<=n;i++){ string s; cin>>s; int cnt = 0; for(int j=0;j<s.length();j++){ if(s[j] == '1'){ cnt++; } ...
#include <bits/stdc++.h> //#include <atcoder/modint> //#include <atcoder/math> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for(int i = 0; i < n; i++) #define REPP(i, n) for(int i = 1; i <= n;...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define INF LONG_MAX/3 //#define DIV 1000000007 //#define DIV 998244353 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, con...
// Template #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <iomanip> #include <tuple> #include <utility> #include <queue> #include <set> #include <map> #include <array> #include <cassert> #include <cmath> #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (int) (n); i++) #define reps(i, n) for (int i = 1; i <= (int) (n); i++) #define all(a) (a).begin(), (a).end() #define uniq(a) (a).erase(unique(all(a)), (a).end()) #define bit(n) (1LL << (n)) #define dump(a) cerr <...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author aryssoncf */ // Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp #include <utility> #include <vector> #include <random> #include <chrono> #include <cassert> #...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a.at(i); int ans = 0; int k = 0; for(int i = 2; i <= 1000; i++){ int cnt = 0; for(int j = 0; j < n; j++){ if(a.at(j) % i == 0) cnt++; } if(k < cnt){ a...
#include <bits/stdc++.h> #define rep(i, n) for(int i=0;i<(int)(n);i++) #define ALL(a) (a).begin(),(a).end() using namespace std; using ll=long long; typedef pair<int,int> P; int main(){ int a,b,c; cin>>a>>b>>c; cout<<(a*a+b*b<c*c ? "Yes" : "No")<<endl; }
#include <bits/stdc++.h> // #include <atcoder/modint> // #include <atcoder/dsu> // #include <atcoder/segtree> // #include <atcoder/fenwicktree> // #include <atcoder/math> // using namespace atcoder; using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<lo...
#include<bits/stdc++.h> #define int long long int using namespace std; signed main(){ // freopen("input.txt", "r", stdin); map<int, string> m; int n, a, c; string b; cin>>n; for(int i=0; i<n; i++){ cin>>b>>a; m[a]=b; } a=1; for(auto i=m.rbegin(); i != m.rend(); i++ ){...
#include<algorithm> #include<iostream> #include<vector> #define mp make_pair #define pb push_back #define fo(i,n) for(int i=0;i<(n);i++) using namespace std; void solve(){ int n; cin>>n; vector<pair<int ,string>> names(n); fo(i,n){ cin>>names[i].second>>names[i].first; } sort(names....
#include<bits/stdc++.h> using namespace std; int main(){ long long N; cin >> N; int A = 1; long long pow3 = 1; while(pow3 < N){ pow3 = pow3*3; long long res = N - pow3; int B = 0; while(res > 0){ if(res%5 == 0){ res = res/5; B++; if(res == 1){ cout <...
#include<bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 mrand(42); #define ii for(int i=1;i<=n;++i) #define ji for(int j=1;j<=n;++j) #define jj for(int j=1;j<=m;++j) #define ij for(int i=1;i<=m;++i...
#include <bits/stdc++.h> #define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x) #define all(v) (v).begin(), (v).end() using namespace std; #define forn(i,n) for (int i = 0; i < (n); ++i) #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i) using ll = long long; int mod = (ll)1e9 + 7; #define PI ...
#include <bits/stdc++.h> using namespace std ; typedef long long ll ; map <ll , ll> cnt ; int n , h ; int main(){ cin >> n ; for (int i = 0 ; i < n ; i++){ cin >> h ; cnt[h] ++ ; } ll ans = 0 ; for (auto i : cnt){ ans += i.second * (n- i.second) ; } cout << ans/2 << "\n" ; }
#include <bits/stdc++.h> #define x first #define y second using namespace std; typedef pair<int, int> PII; const int N = 1010, M = 4010; int h1[N], h2[N], e[M], ne[M], w[M], n, m, idx; int f[N][N]; PII q[N * N]; int ans = 1e9; void add(int h[], int a, int b, int c) { e[idx] = b, w[idx] = c, ne[idx] = h[a], h[...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define P pair<int,char> #define Tp tuple<int,int,int> using Graph = vector<vector<P>>; int main(){ int N,M; cin >> N >> M; int a,b; char c; Graph g(N+1); rep(i,M){ cin >> a >> b >> ...
//#include <atcoder/all> #include <bits/stdc++.h> using namespace std; #define rep2(x,fr,to) for(int x=(fr);x<(to);x++) #define rep(x,to) for(int x=0;x<(to);x++) #define repr(x,fr,to) for(int x=(fr);x>=(to);x--) #define all(c) c.begin(),c.end() #define sz(v) (int)v.size() typedef long long ll; typedef vector<int> ...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 998244353 using namespace std; using ll = long long; template<int M> class ModInt { public: ll value; constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; } co...
#include<bits/stdc++.h> #define it register int #define ct const int #define il inline using namespace std; typedef long long ll; #define rll register ll #define cll const ll typedef double db; #define rdb register db #define cdb const db typedef long double ldb; typedef unsigned long long ull; #define pb push_back #de...
#include <iostream> #include <vector> #include <algorithm> std::vector<std::vector<int>> children, list; std::vector<int> in, out, depth; int timer; void dfs(const int u) { in[u] = timer++; list[depth[u]].push_back(in[u]); for (const int v : children[u]) { depth[v] = depth[u] + 1; dfs(v); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; //int:2*10**9 typedef long double ld; typedef pair<ll,ll> P; #define REP(i,n) for(ll i = 0; i<(ll)(n); i++) #define FOR(i,a,b) for(ll i=(a);i<=(b);i++) #define FORD(i,a,b) for(ll i=(a);i>=(b);i--) #define pb push_back #define MOD 1000000007 //998244353...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; typedef long long LL; typedef pair <int, int> P; const int N = 2e5 + 5; int n, a[N], b[N], c[N]; LL ans, res; int main(...
#include <bits/stdc++.h> #define loop(s, e, i) for (int i = s; i < e; ++i) #define print(s) cout << s << endl; #define DIV 1000000007 using namespace std; typedef long long ll; typedef unsigned long long ull; const int INF = 1e9+7; ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ ll floordiv(ll a, ll b) { retu...
/***************************** * Author :: Πρασαννα Κ. Ροι * *****************************/ /*********************************** * Unus pro omnibus, omnes pro uno * ***********************************/ #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namesp...
#include <bits/stdc++.h> using namespace std; stack<char> st; int n; string s; int main() { ios::sync_with_stdio(0); cin >> n >> s; for(int i = 0; i < n; i++) { if(st.size() < 2) { st.push(s[i]); continue; } char c = st.top(); st.pop(); if(s[i] == 'x' && c == 'o' && st.top() == 'f') { st.pop(); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector <ll> vi; typedef pair<ll,ll> pll; #define mp make_pair #define pb push_back #define N ((ll)(4e5 + 55)) #define INF ((ll)1e18+18) #define bismillah {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);} ll mod = 998244353; ll M(ll x)...
//In the name of Allah :) #include <bits/stdc++.h> using namespace std; string to_string(char c) { return string(1,c); } string to_string(bool b) { return b ? "true" : "false"; } string to_string(const char* s) { return (string)s; } string to_string(string s) { return s; } template<class A> string to_string(complex<A> ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ul; typedef long long ll; #define printV(v) for(int i = 0;i < v.size();++i)cout << v[i] << endl int main() { int A,B; cin >> A; cin >> B; int X = (A + B) / 2; int Y = (A - B) / 2; cout << X << " " << Y << endl; }
#include <bits/stdc++.h> using namespace std; using int64 = long long; constexpr int DEBUG = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { int c1 = (2 * i + 1) % n + 1; int c2 = (2 * i + 2) % n + 1; cout << c1 << " " << c2 << endl; } ...
#include <bits/stdc++.h> #define clr(x) memset(x,0,sizeof(x)) #define For(i,a,b) for (int i=(a);i<=(b);i++) #define Fod(i,b,a) for (int i=(b);i>=(a);i--) #define fi first #define se second #define kill _z_kill #define y0 _z_y0 #define y1 _z_y1 #define x0 _z_x0 #define x1 _z_x1 #define pb push_back #define mp(x,y) make_...
#include<bits/stdc++.h> using namespace std; #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define MOD 1000000007 #define MOD1 998244353 #define INF 1e18 #define nline "\n" #define pb push_back #define ppb pop_back #define mp make_pair #define ff first #define ss second #define PI 3.14...
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long #define ull unsigned ll #define ld long double #define mod 1000000007 #define pb push_back #define pf push_front #defin...
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using ll = long long; using lint = long long; typedef vector<long long> vint; typedef pair<long long, long long> pint; #define INF INT32_MAX / 2 #define INF64 INT64_MAX / 2 #define EPS 0.001 #define EPS14 1.0E-14 #define REP(i, n) for (int i = 0; i < n...
//#define _GLIBCXX_DEBUG #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() #define rall(v) v.rbegin(), v.rend() using ll = int64_t; using ull = uint64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<...
#include<bits/stdc++.h> using namespace std; struct fastio{fastio(){cin.tie(nullptr);ios_base::sync_with_stdio(false);std::cout<<std::fixed<<setprecision(10);}}oitsaf; template<class T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;} template<class T>std::ostream&oper...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n; cin >> n; vector<ll> a(1<<n); for(int i = 0;i < 1<<n;i++)cin >> a[i]; vector<vector<pair<ll,ll> > > p(n+1); for(int i = 0;i < 1<<n;i++)p[0].push_back(make_pair(a[i],i)); ll d = 0; while(1){ if(p[...
/* Hey why peeping here -_'_-? I believe on myself and I will achieve this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific Todo: https://codeforces.com/problemset?tags=1500-2300 */ #include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < int(n); ++i) #define all(o) (o).begin(), (o).end() #define...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i = 0; i < (long long)(n); i++) typedef long long ll; int main() { ll A,B,K; cin>>A>>B>>K; int f=A;int g=B; string s=""; rep(i,A+B)s+='n'; rep(i,A+B){ int x=0; int y=0; for(int j=0;j<i;j++){ ...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ff first #de...
#include <bits/stdc++.h> #include <string> typedef long long ll; typedef long double ldb; typedef double db; using namespace std; #define ff first #define ss second #define pb push_back #define pf push_front #define ins insert #define mp make_pair #define len(s) s.length() #define forp(i, a, b) for (ll i = a; i <= b;...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int,int>; using PIL = pair<int,ll>; using PLI = pair<ll,int>; using PLL = pair<ll,ll>; using Graph = vector<vector<int>>; using Cost_Graph = vector<vector<PIL>>; template<class T> bool chmin(...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #ifndef JHELPER1_COMMON_H #define JHELPER1_COMMON_H #include <algorithm> #include <cassert> #include <functional> #include <iostream> #include <map> #include <memory> #includ...
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; float x=1.08*n; x=round(x); if(x<206.0) { cout<<"Yay!"<<endl; } else if (x>206.0) { cout<<":("<<endl; } else if(x==206.0) { cout<<"so-so"<<en...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; #define mcfor(i, L, R) for(ll i = ll(L); i < ll(R); i++) #define mcford(i, L, R) for(ll i = ll(L-1); i >= ll(R); i--) #define mcrep(i, N) for(ll i = 0; i < ll(N); i++) #define mcrepd(i, N) for(ll i = ll(N-1); i >= 0; i...
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #include "_DEBUG.hpp" #endif #define int long long const long long inf = 2e18; const int mod = 1e9 + 7; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; } template <class T> vector<T> make_vec(s...
/* これを入れて実行 g++ code.cpp ./a.out */ #include <iostream> #include <cstdio> #include <stdio.h> #include <vector> #include <string> #include <cstring> #include <queue> #include <deque> #include <stack> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <unordered_set...
#include <iostream> #include <string> #include <vector> #include <list> #include <set> #include <queue> #include <functional> #include <algorithm> #include <cmath> using namespace std; typedef int64_t ll; int main(int argc, char *argv[]) { ll b, c; cin >> b >> c; //b = -1e18; //c = 1; ll pmin = b - (c / 2); l...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define MV 200001 #define LMV 21 #define ff first #define ss second #define pb push_back #define eb emplace_back #define emp emplace #define mp make_pair #define ins in...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <cstring> #include <cstdlib> #include <cmath> using namespace std; using ll = long long; map<ll, ll> mp; ll f(ll x, ll y) { auto it = mp.find(y); if (it != mp.end()) return it->second; if (x >= y) return ...
//Think simple yet elegant. #include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define all(v) v.begin(),v.end() #define F first #define S second #define pb push_back #define mp make_pair #define pi pair<int,int> #define REP(i,n) for(int i=0...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure using namespace __gnu_pbds; //Policy Based Data Structure using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //Policy Based Data Structure #define p...
#include <bits/stdc++.h> #include <time.h> #define rep(i, n) for(int i=0;i<(int)(n);i++) #define ALL(a) (a).begin(),(a).end() using namespace std; using ll=long long; typedef pair<int,int> P; bool LOCAL_TEST = false; int h[30][30],v[30][30]; double priority[30][30]; vector<string> paths; map<int,char> mp; inline void...
// coded by zeffy #pragma GCC optimize("O3","unroll-loops","omit-frame-pointer","inline") //Optimization flags #pragma GCC option("arch=native","tune=native","no-zeroupper") //Enable AVX #pragma GCC target("avx","popcnt") //Enable AVX #include <x86intrin.h> //SSE Extensions #include <bits/stdc++.h> using namespace st...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <queue> using namespace std; typedef long long ll; int main(){ int L; cin >> L; L = L - 1; ll div = 11*10*9*8*7*6*5*4*3*2; ll ans = L; for(int i=1;i<11;i++){ ans = ans*(L-i)/(i+1); //cout << a...
#include <bits/stdc++.h> #define fi first #define se second #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++) #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define IT iterator #define V vector #define TP template <class o> #define TPP...
#include <bits/stdc++.h> #define ll long long int #define pb push_back #define umap unordered_map #define mod 998244353 #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define MN(a,b,c) min(a,min(b,c)) #define MX(a,b,c) max(a,max(b,c)) #define pr1 ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxl=3e5+10; const int mod=1e9+7; int n,m,k,cnt,tot,cas,ans; int a[maxl]; bool vis[maxl]; char s[maxl]; inline ll qp(ll a,ll b) { ll ans=1,cnt=a; while(b) { if(b&1) ans=ans*cnt%mod; cnt=cnt*cnt%mod; b>>=1; } return ans; } inl...
#include <bits/stdc++.h> using namespace std; // modint template<int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() const { return MOD; } constexpr Fp operator - () const noexcept { return val...
#include <bits/stdc++.h> #define se second #define sz(x) (int)(x.size()) #define ll long long #define rep(i,x,y) for(int i = x; i <= y; ++i) #define repr(i,x,y) for(int i = x; i >= y; --i) #define pb push_back #define mp make_pair #define fi first #define ull unsigned ll #define pi 3.14159265358979 using name...
#include<bits/stdc++.h> using ll = int_fast64_t; using P = std::pair<ll,ll>; using PP = std::pair<ll,P>; #define REP(i,b,e) for(int i=b; i<e; i++) #define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");} #define fi first #define se second const int MOD = 1e9+7; int dx[] = {0, 1, 0, -1, 1, 1, -1, ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for(int(i) = 0; (i) < (n); ++(i)) #define REPR(i, n) for(int(i) = (n); (i) >= 0; --(i)) #define FOR(i, n, m) for(int(i) = (n); (i) < (m); ++(i)) // clang-format off template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = ...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_...
#include <bits/stdc++.h> #include <algorithm> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int main() { int N; int64_t ans = -1; cin >> N; vector<vector<int64_t>> v(N, vector<int64_t>(3)); rep(i, N) { rep(j, 3) cin >> v.at(i).at(j); v.at(i).at(0) *= 2; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef std::vector<std::vector<int64_t> > Graph; #define rep(i, n) for (int64_t i = 0; i < n; ++i) #define rep2(i, n) for (int64_t i = 1; i <= n; ++i) #define repb(i, l, n) for (int64_t i = l; i < n; ++i) #define repb2(i, l, n) for (int64_t i = l; i...
#include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define mp make_pair #define fi first #define se second #define REP(i,j) for(int i=0;i<j;i++) #define REPA(i,j) for(int i=1;i<=j;i++) #define FORN(i,j,k) for(int i=j;i<k;i++) #define vi vector<int> #define vvi vector<vi > #define p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define sz(v) int((v).size()) #define all(x) (x).begin(), (x).end() #define forn(i, n) for (int i = 1; i <= int(n); ++i) //출처: https://codeforces.com/blog/entry/68809 void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long ...
#include<bits/stdc++.h> using namespace std; int n,m,a,b,ans; bool f[30][30]; void dfs(int x,int y,int z) { if(y==m+1) { x++; y=1; } if(z==a) { ans++; return; } if(x==n+1) return; if(f[x][y]) dfs(x,y+1,z); else { if(!f[x][y+1]&&y+1<=m) { f[x][y+1]=true; dfs(x,y+2,z+1); f...
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define dl double long using namespace std; const int N = 1e6 + 7; const long long mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n,m; int a,b; int c[20]; ll d[(1 << 16)]; ll nd[(1 << 16)]; bo...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxl=3e5+10; int n,m,k,tot,cnt; int a[maxl];ll b[maxl],ans[maxl]; char s[maxl]; bool vis[maxl]; inline void add(int i,int x) { while(i<=n) b[i]+=x,i+=i&-i; } inline ll sum(int i) { ll ret=0; while(i) ret+=b[i],i-=i&-i; return ret; ...
#include<bits/stdc++.h> using ll= long long; #define REP(i,n) for(ll i=0;i<ll(n);i++) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define ALL(x) x.begin(),x.end() #define INF (int)1e9 //10^9:∞ #define LLINF (long long)1e12 #define MOD (int)1e9+7 //10^9+7:合同式の法 #define PI 3.141592653589 #define PB push_back #define fi ...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define For(x,y) for(int x = 0; x < y; x++) int a[3]; int main(){ ios::sync_with_stdio(0), cin.tie(0); For(i, 3) cin >> a[i]; sort(a,a+3); if(a[2] - a[1] == a[1] - a[0]) cout << "Yes"; else cout << "No"; }
#include <bits/stdc++.h> #include <string> #include <map> #include <set> #include <queue> #include <deque> #include <vector> #define loop(i,a,b) for (int i = (a); i <= (b); i++) #define loopr(i, a, b) for(int i = (a); i >= (b); i--) #define pb(a) push_back(a) #define pf(a) push_front(a) #define mp(a,b) make_pair(a,b) #...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define FOR(i, a) for(int i = 0; i < (a); ++i) #define rrep(i, a, b) for(int i = a; i >= (b); --i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (in...
#include <bits/stdc++.h> //#include <atcoder/all> //using namespace atcoder; //#include <boost/multiprecision/cpp_int.hpp> //#include <boost/multiprecision/cpp_dec_float.hpp> //using namespace boost::multiprecision; using namespace std; #pragma region Macros using ll = long long; #define int ll using pii = pair<int, i...
#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...
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector>...
#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...
// atcoder/abc190/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 <bits/stdc++.h> #define N 200000 #define MAX 1000000000 #define E 0.00000001 #define MOD 1000000007 #define INF 0x3f3f3f3f #define LEFT(x) (2 * x) #define RIGHT(x) (2 * x + 1) #define PAR 0 #define IMPAR 1 using namespace std; int n, m; map<int, vector<int>> columns; map<pair<int,int>, int> dp; int getI(i...
// DeNsE - EcLiPsE // // WHAT is DEAD may NEVER die // #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <unordered_map> #include <cmath> #include <iomanip> #include <set> #include <cstring> #include <stack> #include <sstream> #include <queue> #include <unordered_set...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define f1 first #define s2 second #define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); #define debug(x...) cerr << "[" << #x << "]: " << x << "\n"; typedef long long ll; typedef long double ld; typedef pair<int, in...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i) #define rr...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <queue> #include <stack> #include <tuple> #include <cmath> #include <iomanip> #include <map> #include <cstring> #include <functional> #include <cctype> #include <locale> #define ll long long #define rep(i,n) for(int i=0...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define pll pair<ll,ll> #define ldb double template<typename T>void ckmn(T&a,T b){a=min(a,b);} template<typename T>void ckmx(T&a,T b)...
#include <bits/stdc++.h> #include <random> using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define FOR(i, begin, end) for(lint i=(begin),...
#include <bits/stdc++.h> using namespace std; #define ll long long ll d=1e9+7; ll pw(ll x,ll y,ll p){ if(x==0&&y==0)return 1; ll r=1; x=x%p; if(x==0)return 0; while(y>0){ if(y&1)r=(r*x)%p; y=y>>1;x=(x*x)%p; } return r; } int main() { //freopen("test.in","r",stdin);cout<<endl<<end...
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int,int> II; typedef tuple<int,int,int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int,int> MAPII; typedef unordered_set<int> SETI; template<class T> using VV=vector<vector<T>>; // minmax te...
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #incl...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> acum; bool check_median(int median, int K, vector<vector<int>> &A){ int N = A.size() - 1; acum.assign(N+1, vector<int>(N+1, 0)); for(int i = 1; i <= N; i++){ for(int j = 1; j <= N; j++){ acum[i][j] = A[i][j] <= median; acum[...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) //方向を決定する演算子的なもの int di[] = {-1, 0, 1, 0}; // int dj[] = {0, -1, 0, 1}; // int main() { int H, W, X, Y; cin >> H >> W >> X >> Y; --X; //配列変数の関係上デクリメント --Y; //同様 //H行W列のマスの入力 vector <string> s(H); rep(i, H) cin >...
#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<vector> #include<algorithm> int main() { int n; std::cin >> n; std::vector<int> t(n),l(n), r(n); for (int i = 0; i < n; i++) { std::cin >> t[i] >> l[i] >> r[i]; } int count = 0; for (int i = 0; i < n-1; i++) { for (int j = i + 1; j < n; j++) { //printf("%d %d %d %d\n",l[i],l[...
#include <bits/stdc++.h> using namespace std; #define maxn 105 string arr[maxn]; bool vis[maxn]; int n; int dfs(int x) { int ret = 1; vis[x] = true; for(int y = 0; y < n; y++) { if(!vis[y] && arr[y][x] == '1') { ret += dfs(y); } } return ret; } int main() { cin >...
/* -*- compile-command: "g++ --std=c++17 -o sol sol.cpp" -*- */ #include <iostream> #include <vector> #include <string> #include <set> #include <stack> #include <limits.h> #include <math.h> #include <memory> #include <cstring> #include <algorithm> #include <unordered_set> using namespace std; static auto speedup = ...
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <cassert> #include <cfloat> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #...
#include<bits/stdc++.h> using namespace std; class Abc { public: int solve(int n) { int temp=0,temp1=0,p=0,q=0,f=0; p=n,q=n; while(p>0 && q>0) { temp=p%10; if(temp==7) { f=1; break; } temp...
#include<bits/stdc++.h> #define _USE_MATH_DEFINES using namespace std; #define ll long long int #define ld double #define pb push_back #define rep(i , j , n) for(ll i = j ; i < n ; i++) #define pre(i , j , n) for(ll i = j ; i >= n ; i--) #define all(x) x.begin(), x.end() typedef pair<int, int> pii; typedef pair<l...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil ...
#include <bits/stdc++.h> using namespace std; #include <algorithm> #define ll long long int #define pb push_back #define fo(i, n) for (int i = 0; i < n; i++) #define vct vector<long long int> const ll INF = 1e18; const ll NINF = -1e18; #define f first #define s second int main() { ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; //#define int long long //#pragma GCC optimize("Ofast") //#pragma comment(linker, "/stack:200000000") //#pragma GCC targe...
/* Author: EnderDeer Online Judge: Luogu */ #include<bits/stdc++.h> #define int long long #define mem(x) memset(x,0,sizeof(x)) #define mod 998244353 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'...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#include <atcoder/all> #define F first #define S second #define int long long #define ll long long //#define int unsigned long long #define pb push_back //#define double long double using namespace std; using namespace _...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; template<class S, class T> inline S max_L(S a,T b){ return a>=b?a:b; } inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf,...
// Parasparopagraho Jīvānām #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace __gnu_pbds ; using namespace __gnu_cxx ; using namespace std ; typedef long long ll ; t...
#include <iostream> #include <string> using namespace std; int main(){ int i,n; cin >> n; string s; cin >> s; if(s[0]!=s.back()){ cout << 1 << endl; return 0; } char c = s[0]; for(int i=0;i<s.size();i++){ if(s[i]!=c && s[i + 1]!=c){ cout << 2 << endl; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FO...
#include<bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <chrono> // using namespace std::chrono; // using namespace __gnu_pbds; #define ff first #define ss second #define int long long #define double long double #define pb ...
#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),i##end=(b);i<i##end;i++) #define REP(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++) #define RFOR(i,a,b) for(int i=(a),i##end=(b);i>i##end;i--) #define RREP(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i--) typedef long long LL; const int maxn=1000+5; std::queue<st...
#include<bits/stdc++.h> //#include <atcoder/all> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define rep(i,n)for(int i=0;(i)<(int)(n);i++) #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++) #define ALL(a) (a).begin(),(a).end() #define pb push_back #define fi first #...
#include <bits/stdc++.h> using namespace std; constexpr int N = 1000000; bool is_radical[N + 1]; bool prime[N + 1]; int pf[N + 1]; int main() { long long cur, ans, l, r, n, d; scanf("%lld%lld", &l, &r); memset(is_radical, true, sizeof(is_radical)); memset(prime, true, sizeof(prime)); prime[0] = prime[1] = fa...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> ii; ll x; map<ll, ll> sv; ll f(ll y){ if (sv.find(y) != sv.end()) return sv.find(y)->second; sv[y] = 0LL; ll &ans = sv[y]; if (y>x){ if (y&1){ ll ri = (y+1LL); ll le = (y-1LL); ll directtarget = y-x; return an...