code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) ...
#pragma GCC optimize(2) //#include <bits/stdc++.h> #include <iostream> #include <set> #include <cmath> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <utility> #include <map> #define rush() int T; while(cin>>T) while(T--) #define ms(a,b) memset(a,b,sizeof ...
#pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int N; string S; string X; void input(void){ cin >> N >> S >> X; } map<pair<int, int>, int> memo; bool canTWin(int i, int m){ if (i == N) return (m == 0); if (memo[{i, m}] ...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mk make_pair #define fi first #define se second #define mset(a,b) memset(a, b, sizeof(a)) #define dbg(x) cout << "...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define ff first #define ss second #define pb push_back #define pii pair <ll , ll> #define vi ...
#include <iostream> #include <iomanip> #include <algorithm> #include <bitset> #include <string> #include <cmath> #include <complex> #include <numeric> #include <cassert> #include <vector> #include <array> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <utility> #define PI 3....
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int64 i = 0;i < (n);i++) #define FOR(i, a, b) for(int64 i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_...
#include<bits/stdc++.h> #define ll long long using namespace std; int main(){ ll N,sum=0; cin>>N; vector<ll> A(N),B(N); for(ll &i:A)cin>>i,sum+=i; for(ll &j:B)cin>>j; ll M=N/2; vector<ll> C(M),D(M); for(ll i=0;i<M;i++)C[i]=B[i*2]-A[i*2]; for(ll i=0;i<M;i++)D[i]=B[i*2+1]-A[i*2+1]; sort(C.rbegin(),C....
// __________________ // | ________________ | // || ____ || // || /\ | || // || /__\ | || // || / \ |____ || // ||________________|| // |__________________| // \###################\ // \###################\ // \ ____ \ // \_______\___\_______\ // An AC a ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl using lint = long long; typedef pair<lint,lint> P; const bool debugFlag=true; const lint linf=1e18+7; const lint inf=1e9+7; co...
#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG //checks for container overflows #pragma GCC optimize "trapv" //to chcek for int overflow #pragma -Wduplicated-cond //dupilcate conditions #endif #include "bits/stdc++.h" using namespace std; using namespace chrono; typedef unsigned long long int ull; typedef long long ll; #d...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i) mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); template <typename T> inline void chkmax(T &x, T y)...
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <algorithm> #include <utility> #include <deque> #include <stack> #include <bitset> using namespace std; typedef long ...
#include"iostream" #include"cstdio" #include"cmath" #include"cstring" #include"algorithm" #include"stack" #include"queue" using namespace std; #define read(x) scanf("%d",&x) #define readl(x) scanf("%lld",&x) #define ll long long #define ull unsigned long long #define MOD 998244353 #define MAXN 200005 char c[200005]...
#include<bits/stdc++.h> #define MAX 1000000007 #define MOD 998244353 #define ll long long int #define fo(i,a,n) for(int i=a;i<n;i++) #define ull unsigned long long int #define pb push_back #define eb emplace_back #define in insert #define cl clear #define ld long double #define mp make_pair #define ii pair<int,int> con...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; cout << N-1 << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i, n) FOR(i,n,0) #define OF64 std::setprecision(40) const ll MOD = 1000000007; const ll INF = (ll) 1e15; ll modpow(ll n, ll r, ll mod) { ll ret = 1; ...
#define LOCAL #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2") #define IOS ios::sync_with_stdio(false);cin.tie(0) #define all(x) x.begin(), x.end() #define ff first #define ss second #define LLIN...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (int)(n); i++) #define REP(i,n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define debug(var) do{cout << #var << " : "; view(var);}while(0) template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;ret...
#include<iostream> #include<algorithm> #include<cmath> #include<iomanip> using namespace std; int N_MAX=11000; typedef pair<int,int> P; typedef pair<int,P> PP; int main() { int n,i,j,k=0; PP b[N_MAX]; // 枝データ int c[N_MAX]; // 頂点iの属する集合番号 int nc[N_MAX]; // 集合jの要素数 int pc[N_MAX]; // 集合jの先頭の要素番号 int pi[N_MAX];...
#include <bits/stdc++.h> using namespace std; int n, rs = 0; map<int, int> M; void add(int key, int value) { M[key] = __gcd(M[key], value); } int main() { #ifdef ACM freopen("input", "r", stdin); #endif cin >> n; int x, minV = 2e9; for (int i = 1; i <= n; i++) { cin >> x; minV = ...
#include <bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::valu...
#include <iostream> using namespace std; int main() { int n,w; cin>>n>>w; cout<<n/w; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; int mn = min(a, b), mx = max(a, b); vector<int> ans; ll s1 = 0, s2 = 0; for(int i = 0; i < mx; i++) { ans.push_back(i + 1); ...
#include<bits/stdc++.h> using namespace std; #define int long long typedef long long ll; long long t,n,m,k,ccnt,pos=0,sum=0,minn2=INT_MAX,sum2,cnt=0,cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,cnt6=0,cnt7=0,a[2000005],x1,y7,x2,y2,x3,y3,aaa,bbb; long long vis1[1005][1005],vis2[1005][1005],b[1000005],c[1000005],c3[2005][2005],c4[...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#include <iostream> #include<cmath> #include<iomanip> using namespace std; typedef long long int LL; LL x[100000]; int main(void){ cout<<setprecision(16); LL n,i,j; LL ans; long double dans; cin>>n; for(i=0;i<n;i++)cin>>x[i]; ans=0; for(i=0;i<n;i++)ans+=abs(x[i]); cout<<ans<<en...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) //debug用出力関数 dout("n",n); void dout(string s, int n) { cout << s << ":" << n << endl; return; } int main() { int n,ans = 100000; cin >> n; vector<int> a(n); vector<int> b(n); vector<int> c(n); rep(i,n){ ...
#include "bits/stdc++.h" #define FI first.first #define SE first.second #define TH second #define fi first #define se second #define th second using namespace std; template<typename T> string to_string(const vector<T>& vc, int w) { if(vc.empty()) return ""; if(w + 1 == vc.size()) return to_string(vc[w]); return to...
#include <bits/stdc++.h> using namespace std; typedef long long ll; pair <ll,ll> extgcd(ll a,ll b) { if (b==0) return {1,0}; pair<ll,ll> u=extgcd(b,a%b); return {u.second,u.first-a/b*u.second}; } ll gcd(ll x,ll y) { if(y==0) return x; return gcd(y,x%y); } void solve () { ll n,s,k; cin>>n>>s>>k; if (s%gcd(n,k)...
#include <bits/stdc++.h> using namespace std; int main(){ long n, q; cin >> n >> q; long a[n], k[q]; long b[n]; vector <pair <long, long>> v; vector <long> ans(q); for(int i = 0; i < n; i++){ cin >> a[i]; if(i == 0) b[i] = a[i] - 1; else b[i] = b[i - 1] + a[i] - a[i ...
#include<ctime> #include<cstdio> #include<cctype> #include<algorithm> using namespace std; const int N=50+5; int read() { char c; int x=0,f=1; while(!isdigit(c=getchar())) f-=2*(c=='-'); while (isdigit(c)){ x=x*10+(c-48)*f; c=getchar(); } return x; } struct bag{ int w,v; bag(int a=0,int b=0){ w=a; v=b...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,s,d,x,y; cin>>n>>s>>d; int f=0; while(n--){ scanf("%lld%lld",&x,&y); if(x<s&&y>d) f++; } if(!f) printf("No\n"); else printf("Yes\n"); }
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define rep(i,n) for(int i=0; i<(n); i++) #define all(v) v.begin(),v.end() int main() { int x, y, z; cin >> x >> y >> z; int ans = 1000*1000; while (ans * x >= z * y) ans--; cout << ans << endl; }
#include <bits/stdc++.h> #define ll long long using namespace std; const ll mod = 1e9 + 7; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin >> n >> m; vector<int> a(n); vector<int> b(m); for(int &x:a) cin >> x; for(int &x:b) cin >> x; int h1, h2; h1 = h2 = 0; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define _GLIBCXX_DEBUG typedef long long int ll; typedef long double ld; const int inf = 1e8; const ll llinf = 1e18; const double PI = acos(-1); #define yes "Yes" #define no "No" #define all(n) n.begin(), n.end() templa...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define BE(x) x.begin(), x.end() int main() { string s; cin >> s; ll ans = 0; vector<int> v(26, 0); int len = s.length(); v[s[len-1]-'a']++; v[s[len-2]-'a']++; char prev = '0'; int x = len; for (int i = len-3; ...
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<int> prime_number; vector<int> used(N+1); for (int i=2; i<=N; i++){ if (used.at(i)==0){ prime_number.push_back(i); int num = 2*i; while (num<=N){ ...
#include<bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { T f = 1; x = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; x *= f; } template <typename T> void write(T x) { if (x < 0) { putchar...
#include <bits/stdc++.h> using namespace std; int main(){ int N,K,A; cin >> N >> K; string S; for(int i=0;i<K;i++){ S=to_string(N); sort(S.begin(), S.end()); A=stoi(S); reverse(S.begin(), S.end()); N=stoi(S)-A; } cout << N << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) #define vec std::vector using ll = long long; template<class T> std::istream &operator >> (std::istream &is, std::vector<T> & v) { for(T &x : v) is >> x; return is; } int main() { vec<string> s(3); cin >> s; set<...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> //#include <atcoder/all> //using namespace atcoder; using namespace std; #define all(v) v.begin(), v.end() using in = long long; #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 Yes cout<<"Yes"<<endl #def...
#include <bits/stdc++.h> using namespace std; // clang-format off using ll = int64_t; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v) cin >> a; return is; } template <class T> istream& operator>>(istream& is, vector<pair<T, T>>& v) { for (auto& a : v) cin >> a.first >> ...
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { ll R,X,Y; cin>>R>>X>>Y; ll count=0; ll r=0; while(r<X*X+Y*Y){ if(R*R>X*X+Y*Y){ count=2; break; } count++; r=(count*R)*(count*R); } cout<<count<<endl; }
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; #define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr) //:/ #define pb push_back #define mp make_pair #define nt _ll128 #define ld long double long double PI =3.14159265; using ll = long long; const ll modo=998244353; const ll ms=2e5...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = int64_t; using P = pair<ll, ll>; template <class T> using V = vector<T>; template <class T> class Matrix { public: int h, w; V<V<T>> data; Matrix(int h_, int ...
#include <iostream> using namespace std; int main(){ long long a, b, c; cin >> a >> b >> c; int c_mod = c % 4; if(c_mod == 0) c_mod = 4; int b_mod = b % 4; if(b_mod == 0) b_mod = 4; int a_down = a % 10; int b_res = 1; int a_res = 1; for(int i = 0; i < c_mod; i++){ b_res *= b_mod; } b...
#include <iostream> #include <sstream> #include <string> #include <list> #include <vector> #include <queue> #include <algorithm> #include <climits> #include <cstring> #include <cmath> #include <stack> #include <iomanip> #include <tuple> #include <functional> #include <cfloat> #include <map> #include <set> #include <arr...
#include <iostream> #include <vector> #include <utility> #include <algorithm> using namespace std; typedef long long ll; ll pow (ll a, ll n) { if (n==0) return 1; if (n==1) return a; ll tmp = pow (a, n/2); ll tmp2 = tmp*tmp; if (n%2) return tmp2*a; return tmp2; } int main () { ll N; cin >> N; ll tmp ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ string n;cin>>n; ll X = (ll)n.size(); string S; ll Q = stoll(n); if(Q<10){ cout<<0<<endl; return 0; } if(X%2==1){ n=""; for(ll i=0;i<X-1;i++){ n+='9'; } } ll Y = (ll)n.size(); str...
#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(a) (a).begin(),(a).end() #define LL long long #define MAX_H 10000 #define MAX_W 10000 int n; int x[200],y[200],r[200]; int a[200],b[200],c[200],d[200]; std::mt19937 mt; std::random_de...
#include <bits/stdc++.h> //#include <atcoder/all> #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using namespace std; //using namespace atcoder; const int mod = 1000000007; const int INF =1e9+1; int main(){ int n;cin>>n; vector<int> p(n); rep(i,n)cin>>p[i]; int maxP=0; vector<...
#include <iostream> #include <random> #include <cmath> #include <queue> #include <utility> #include <vector> #include <algorithm> #include <stack> #include <cassert> using namespace std; const int SIZE = 30; const int INF = 99999999; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const char dc[4] =...
#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 drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++) #define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(i...
// https://atcoder.jp/contests/abc182/tasks/abc182_f #include <bits/stdc++.h> using namespace std; using ll = int64_t; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++) #define DEBUG 1 #if DEBUG #define _GLIBCXX_DEBUG #define DUMP(a) REP(_i, a.size()) cout << a[_...
#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<unordered_map> #include<vector> #include<unordered_set> #include<set> #include<map> #include<queue> #include<stack> #include<string> //Required Headers using namespace std; #define PI 3.1415926535897932384626 #define sp(x,y) f...
#include <iostream> #include <queue> #include <utility> using namespace std; int main() { int N; cin >> N; int P[N]; for (int i = 0; i < N; i++) cin >> P[i]; bool flag = true; bool flag_[N - 1]; for (int i = 0; i < N - 1; i++) flag_[i] = false; int now = 0; queue<int> Que; for (int i = 0; i < N...
#include<vector> #include<cstdio> using namespace std; int n,per[200010],ori[200010],mn=1e9; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&per[i]),ori[per[i]]=i; vector<int> ans; for(int i=n;i;--i) { if((ori[i]^i)&&mn>ori[i]) { mn=ori[i]; for(int j=ori[i];j<i;++j) ans.push_back(j),(per[j...
#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 chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) using ll = long long; using PAIR = pair<int, int>; using PAIRLL = pair<ll, ll>; using vi = vector<int>; using vvi = vec...
#include<bits/stdc++.h> #define LL long long #define DB double #define pb push_back #define mkp make_pair #define LB lower_bound #define UB upper_bound #define rint register int #define MS(x,y) memset(x,y,sizeof(x)) #define rep(i,a,b) for(rint i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(rint i=a,i##end=b;i>=i##...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> using namespace std; int main() { int N; cin >> N; N*=2; vector<pair<long long, int>> dogs; vector<int> color = vector<int>(3); color[0] = color[1] = color[2] = 0; int odd1=-1, odd2=-1; for(int i=0; i < N; i++) ...
#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;...
//#define _GLIBCXX_DEBUG //#include<bits/stdc++.h> //* #include<vector> #include<iostream> #include<queue> #include<algorithm> #include<math.h> #include<iomanip> #include <numeric> //*/ using namespace std; #define ll long long #define yes {cout<<"Yes"<<endl;return 0;} #define no {cout<<"No"<<endl;return 0;} #define ...
#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 n; struct xyr { int x; int y; int r; }; struct sq { int x1; int y1; int x2; int y2; int s; }; vector<xyr> ad; vector<sq> ans; vector<bool> okArea; clock_t s...
#include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cst...
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> #include <set> #include <map> #include <queue> #include <deque> #include <bitset> #include <math.h> #include <random> #include <chrono> #include <assert.h> using namespace std ; using...
#include<bits/stdc++.h> using namespace std; const int maxn = 100005; #define inf 1e9 int N, M, w[maxn]; int dis[10][10], ans = inf; struct Data{ int l, v; Data(){} Data(int l, int v){ this -> l = l, this -> v = v; } }d[maxn]; struct segment_tree{ static const int maxn = 100005; int rt, np, lc[maxn...
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <array> #include <numeric> //#include <atcoder/all> using namespace std; //...
#include <iostream> #include <vector> #include <math.h> #include <algorithm> #include <queue> #define REP(i, n) for(int i = 0; i < n; i++) using namespace std; int H, W, A, B; //--------------------------------------------------------------------------------------------------- bool used[16][16]; int dfs(int x, int ...
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_sta...
#include <bits/stdc++.h> #include <fstream> using namespace std; #define all(a)a.begin(),a.end() using ll=long long; const int INF = 1<<30; const ll INFll =1LL<<62; //const int mod= int(1e9)+7; const int mod=998244353; using P = pair<int,int>; using Pl= pair<ll,ll>; using ld=long double; using V=vector<int>; using Vl=...
#include<bits/stdc++.h> using namespace std; using ll = long long; ll n, m, dp[2010][2010]; char s[2011][2011]; void solve() { scanf("%lld%lld", &n, &m); for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1); memset(dp, 63, sizeof(dp)); dp[n][m] = 0; for (int i = n; i > 0; i--) for (int j = m; j > 0; j--) { if...
#include<bits/stdc++.h> #define MAXN 5000+10 #define MOD 998244353 using namespace std; int n,m; long long DP[MAXN][2]; long long a[MAXN][2]; int main() { scanf("%d%d",&n,&m); long long Sum = 0; for(int i=1;i<=m;i++) { memset(a,0,sizeof(a)); memset(DP,0,sizeof(DP)); a[0][0] = 1; long long l = i-1; lon...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int N=105; ll n,x,a[N],dp[N][N][N]; ll k,ned; ll cal(int i,int c,int mod){ if(i==n){ if(c==k && mod==ned)return 0; return -1e9; } if(dp[i][c][mod]!=-1)return dp[i][c][mod]; ll sol=cal(i+1,c,mod); if(c+1<=...
#include <bits/stdc++.h> #define fi first #define se second using namespace std; const int N=2*1e5+5; typedef pair<long long, long long> ii; long long n, m, a=1, b; ii pw(long long n) { if (!n) return {0, 1}; ii p=pw(n/2); p.fi=p.fi*p.fi*m+2*p.fi*p.se+p.se*p.se/m;p.fi%=m; p.se=p.se*p.se%m; ...
/* © 2021-05-01 07:01:01 Franco1010 All Rights Reserved */ // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #...
#include <cstdio> #define ll long long using namespace std; int n,m;ll p[5010],g[5010][5010],ans; const ll mod=998244353; int main() { scanf("%d %d",&n,&m); p[0]=1; for(int i=1;i<=n;i++) p[i]=p[i-1]*m%mod; for(int i=0;i<=m;i++) { g[i][0]=1; for(int j=1;j<=n;j++) g[i][j]=g[i][j-1]*i%mod; } ans=p[n]*n%mod...
#pragma region head #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using pi = pair<int, int>; using pll = pair<ll, ll>; template <class T> using vv = vector<vector<T>>; #define _roverload(_a1, _a2, _a3, name, ...) name #define _rep(i, n) repi(i, 0, n)...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define Test int T;cin>>T;while(T--) #define ls lower_bound #define up upper_bound #define bs bina...
#include <iostream> #include <stdio.h> #include <vector> //martin02 using namespace std; int main() { int a, b; scanf("%d %d", &a, &b); vector<int> v(a + b, 0); for (int i = 0; i < a; i++) { v.at(i) = i + 1; } for (int i = a; i < a + b; i++) { v.at(i) = -1 * (i - a + 1); } if (a * (a + 1) / 2 - b * (b ...
// Template begins #include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <stdio.h> #include <math.h> #include <iomanip> #include <queue> #include <string.h> #include <string> using namespace std; #define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #defi...
#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>>; //Cの計算 C[i][j]でiCjを得る void combination(vector<vector <long long> > &v){ for(int i = 0;i <v.size(); i++){ v...
#include <bits/stdc++.h> using namespace std; namespace ftr { vector<int> prime; void run_sieve(int n) { assert((int) prime.size() == 0); prime = vector<int>(n, 1); prime[0] = prime[1] = 0; for (int i = 2; i < n; i++) { if (prime[i]) { for (int j = i + i; j < n; j += i) { prime[j] = 0; ...
#include <bits/stdc++.h> using namespace std; //begin of def #define fastio ios_base::sync_with_stdio(false);cin.tie(0) #define endl '\n' using lli = long long int; using ulli = unsigned long long int; using Ld = long double; using pii = pair<int, int>; using pll = pair<lli, lli>; using pld = pair<Ld, Ld>; #define ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>; #define FOR(i,a,n) for(int i=(a);i<(n);++i) #define eFOR(i,a,n) for(int i=(a);i<=(n...
#include<bits/stdc++.h> using namespace std; #define int long long int dp[60][2]; int two_power(int x) { int mul=1; for(int i=0;i<x;i++) mul*=2; return mul; } int32_t main() { ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); dp[0][1]=1,dp[0][0]=0; int n;cin>>n; vector <string> s(n+1); ...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define all(x) x.begin(),x.end() #define SZ(x) ((in...
#include <bits/stdc++.h> template <typename T> inline void rd(T& x) { int si = 1; char c = getchar(); x = 0; while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar(); while(isdigit(c)) x = x * 10 + c - 48, c = getchar(); x *= si; } template <typename T, typename... Args> inline void rd(T& x, Args&... args) { rd(x...
#pragma GCC optimize(3) #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <queue> #include <algorithm> #define maxn 200010 using namespace std; int read() { int x=0,w=1; char ch=getchar(); while((ch>'9'||ch<'0')&&(ch!='-')) ch=getchar(); if(ch=='-') { w=-1; ch=getchar(); } w...
#include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; template<typename A, typ...
#include <bits/stdc++.h> #define rep(i,n) for (ll i = 0; i < (n); ++i) #define All(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() //reverse #define strall(v) (v).cbegin(),(v).cend() //const_itterator #define IN(a, b, x) (a<=x&&x<b) using namespace std; using ll = long long; using Pair = pair<int,int...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define endl '\n' typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const ll linf = 0x3f3f3f3f3f3f3f3f; int g(string a) {...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;++i) #define irep(i,a,b) for(int i=int(a);i<(int)b;++i) #define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i) #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vector<ll>> #define vvp vector<vector<pair<ll,ll>>> #...
#include <bits/stdc++.h> #define ll long long int #define w(t) int t; cin>>t; while(t--) #define F first #define S second #define pb push_back #define mp make_pair #define pii pair<int,int> #define mii map<int,int> #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define REP(i,n) for (ll i = 0; i < n; ++i) #def...
#include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std; const int N = 200; int a[N], b[N], c[N], d[N]; int main() { int n; cin >> n; for (int _ = 0; _ < 2; _ ++) { for (int i = 0; i < n; i ++) cin >> a[i] >> b[i]; int x = 0, y = 0; fo...
#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() long long n,ans; string s,t; set<int> s1; template<typename T> void fin(T a){ cout<<a<<endl; exit(0); } const int INF=1e9; void f(int idx){ if(idx==n-1)fin(-1); int p=*s1.upper_bound(idx); ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define eprintf(...) fprintf(stderr, __VA_ARGS__) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) int main() { int n; string s, t; cin >> n >> s >> t; vector <int> vs, vt; rep(i, n) ...
#include <bits/stdc++.h> #define endl "\n" using namespace std; #define int long long int #define watch(x) cout << (#x) << " is " << (x) << "\n" #define watch2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n" #define INF LLONG_MAX template<typename ... T> void print(const T& ... t) { initializer_list<...
#include <iostream> #include <iomanip> #include <vector> #include <set> #include <string> #include <queue> #include <algorithm> #include <map> #include <cmath> #include <numeric> #include <list> #include <stack> #include <cstdio> #include <cstdlib> #include <cstring> #include <tuple> #include <deque> #include <complex>...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define e(v) sort(v.begin(), v.end()) #define rev(v) reverse(v.begin(), v.end()) #define out(s) cout << s << endl #define decimal10(s) cout << fixed << setprecision(10) << s << endl; typedef long long ll; using Graph = vector<...
#include<bits/stdc++.h> #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstream> #include<algorithm> /******...
/* I love the sound you make when you shut up. */ #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; /*----typedefs--------*/ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; using ll = long long; using p...
#include <bits/stdc++.h> using namespace std; template <typename T> struct binary_indexed_tree{ int N; vector<T> BIT; binary_indexed_tree(int n){ N = 1; while (N < n){ N *= 2; } BIT = vector<T>(N + 1, 0); } void add(int i, T x){ i++; while (i <= N){ BIT[i] += x; i += i & -i; } } T sum(int ...
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <cstring> #include <bitset> #include <array> using namespace std; typedef long long ll; const int maxn=2e5+5, mod=998244353, maxp=305, Log=30; inline ...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <iomanip> #include <queue> #include <map> using namespace std; using ll = long long int; using P = pair<int, int>; int main(){ int n, m; cin >> n >> m; vector<int> a(n); for(auto &p: a) cin >> p; ...
#include <iostream> #include <sstream> #include <string> #include <list> #include <vector> #include <queue> #include <algorithm> #include <climits> #include <cstring> #include <cmath> #include <stack> #include <iomanip> #include <tuple> #include <functional> #include <cfloat> #include <map> #include <set> #include <arr...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; using vv = vector<vector<int>>; const int INF = (int)1e9; const LL LINF = (LL)1e18; int main(){ int N; string S, X; cin >> N >> S >> X; reverse(S.begin(), S.end()); reve...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long INF = 1LL<<60; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #define rep(i, n) for(...
/* Stay motivated and keep working hard */ #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pb push_back #define cntbit __builtin_popcount #define fr first #define mem(arr, val) m...
#include<iostream> #include<string> using namespace std; int main() { string s; cin>>s; if(s[0]==s[1]&&s[1]==s[2]) { cout<<"Won"; return 0; } else { cout<<"Lost"; return 0; } }
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define sz(x) (int)x.size() #define f first #define s second #define bug cout << "ok\n"; #define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout); #define speed io...
#include<bits/stdc++.h> using namespace std; #define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define ll long long #define ld long double #define endl "\n" #define ff first #define ss second #define imn IN...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int main() { fast; string s; cin>>s; for(int i=0;i<s.size();i++) { if(s[i]!='.') { cout<<s[i]; } else { break; } } }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#include <bits/stdc++.h> using namespace std; #define fr(i,n) for(int i = 0; i<n; i++) #define sz(v) (int)(v.size()) #define prin(a) cout << #a << " = " << a << endl #define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl #define all(v) (v).begin(),(v).end() typedef long long ll; #def...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; 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, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } r...
#include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define fast_az_fuk 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 pb push_back #define pf push_front #define dll deque<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> v(1 << n); for (int i = 0; i < (1 << n); i++) cin >> v[i]; array<int, 2> ar1 {-1, 0}; for (int i = 0; i < (1 << (n - 1)); i++) { ...
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <stack> #include <set> #include <bitset> #include <functional> #include <cassert> using namespa...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll =long long; using vi = vector<ll>; using vc = vector<char>; using vs = vector<string>; using P = pair<ll , ll>; using vp = vector<P>; #define rep(i, n) for (long long int i = 0; i < n; i++) #define rep2(i, s, n) f...
#include <iostream> #define rep(i,n) for(int i=0; i < (n);++i) using namespace std; using ll = long long; using P = pair<int,int>; template <class _T> inline bool chmax (_T& a,_T b){if(a<b){a=b;return true;}return false;} template <class _T> inline bool chmin (_T& a,_T b){if(a>b){a=b;return true;}return false;} const...
#include <bits/stdc++.h> /// 500 485 462 A4 using namespace std; typedef long long int ll; typedef complex<double> point; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second #define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.t...
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define test int t;cin>>t;while(t--) #define REP(i,n) for (int i = 1; i <= n; i++) #define MOD 1000000007 #define MOD2 998244353 #define ll long long #define ld long double #define int ll #define pb push_...
#include <bits/stdc++.h> #include <iostream> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; int main() { int N; cin >> N; map<int, int> a; int x = 1e9; int X = 0; for (int i = 0; i < N; i++) { int tmp; cin >> tmp; a[tm...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main(){ int t; cin >> t; ll N; cin >> N; ll count=0; ll ans=0; vector<int> A(100); for(int i=0;i<100;i++){ A[i]=0; } for(ll i=0;i<100;i++){ if(i*t/100!=(i+...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, N) for (ll i = 0; i < N; i++) int main() { int m=1000000007; ll n; cin >> n; vector<ll> a(n); rep(i,n) cin >> a[i]; vector<vector<ll>> f(n+2,vector<ll>(2)); f[0][0]=0; f[0][1]=1; rep(i,n){ f[i+1][0]=f[i][1]%m; f[i+1][1]=(f[i][0...
#include<bits/stdc++.h> #include<vector> #include<math.h> #include<algorithm> #include<stack> #include<list> #include<queue> #include<set> #include<string> #include<string.h> #include<map> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") //#pragma GCC optimization("unroll-loops") #define ll long long ...
#include <iostream> #include <algorithm> #include<cmath> #include<cstring> #include<cstdio> #include<cstdlib> #include<vector> #include<iomanip> #include<ctime> #include<set> #include<map> #include<queue> #include<stack> #include<bitset> #define sqr(x) ((x)*(x)) #define fz1(i,n) for ((i)=1;(i)<=(n);(i)++) #define fd1(i...
#include <bits/stdc++.h> using namespace std; #define ll long long int #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> #define ld long double #define ff first #...
// Author: wlzhouzhuan #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pb push_back #define fir first #define sec second #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = l; i >= r; i--) #define mset(s...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5 + 5, INF = 0x3f3f3f3f; int main(){ ll n; cin >> n; int res = 0; for(int i = 1; i <= 1000000; i ++ ){ int ans = 0, x = i; while(x){ ans ++; x /= 10; } if(i ...
#include <bits/stdc++.h> using namespace std; #define int long long template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } string s; int n; int is_ok(int i, int c, int d){ if(i == n){ return (c...
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int N = 1000 + 5, mod = 1e9 + 7; int n, m, a[N], b[N], dp[N][N]; int solve(int idx_a, int idx_b){ if(idx_a == n) return m - idx_b; if(idx_b == m) return n - idx_a; if(dp[idx_a][idx_b] != -1) return dp[idx_a][...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define fon(i,n) for(int i=0;i<n;i++) #define fo(i,n) for(int i=1;i<=n;i++) #define pb push_back #define mp make_pair #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll ,ll> #define vii vector<int> #define vll vector<ll>...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back using namespace std; template <class T = int> using V = vector<T>; template <class T = int> using VV = V<V<T>>; using ll = lo...
#include <bits/stdc++.h> using namespace std; #define PRINT_YesNo(condition) cout<<((condition)?"Yes":"No")<<endl #define PRINT_YESNO(condition) cout<<((condition)?"YES":"NO")<<endl #define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr) #define SET_PRECISION(x) cout<< fixed << setprecision((x)) #define REP(i, ...
#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...
#pragma GCC optimize ("Ofast") #define _USE_MATH_DEFINES #include <bits/stdc++.h> #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define FORD(i, a, b) for (int i=(a); i>(b); i--) #define PPC(x) __builtin_popcount(x) #define MSB(x) (63 - __builtin_clzll(x)) #define SZ(x) ((int)(x).size()) #define HASK(S, x) (S.find(x)...
// International Master sm0016 #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define raftaar ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; const ll MOD1=1000000007; const ll MOD2= 998244353; const int N=1e6+6; int main(){ raftaar int ...
#include <iostream> using namespace std; int main(){ int a,b;cin>>a>>b; for(int c = b; ; c--) if((a + c - 1) / c < b / c){ cout << c << endl; return 0; } }
#include <bits/stdc++.h> using namespace std; int main(){ long long l,ans=1;cin>>l;l--; int d[5][2]{{2,8},{3,4},{5,2},{7,1},{11,1}}; for(long long i=0;i<11;i++){ ans*=l-i; for(int j=0;j<5;j++){ while(ans%d[j][0]==0&&d[j][1]>0){ ans/=d[j][0]; d[j][1...
#include<bits/stdc++.h> using namespace std; //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vect...
#include<bits/stdc++.h> using namespace std; #define endl "\n" //#define int long long #define rep(i,j,k) for(int i=j;i<k;i+=1) #define rrep(i,j,k) for(int i=n-1;i>=0;i-=1) #define sorti(v) sort(v.begin(),v.end()) #define sortd(v) sort(v.begin(),v.end(),greater<int>()) #define mm map<int,int> #define vv vector<int> #d...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef pair<int, int> P; const int INF = 5e6; int di[4] = {1, 0, -1, 0}; int dj[4] = {0, 1, 0, -1}; int main() { int h, w; cin >> h >> w; vector<string> s(h); rep(i,h) cin >> s[i]; // vector dist(h, vector(w,...
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; long long A[400010] = {}; long long sum = 0; long long mn = 0; for(int i = 0; i < N * 2; i++){ cin >> A[i]; sum += A[i]; } priority_queue<long long, vector<long long>, greater<long l...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #d...
/* { ###################### # Author # # Gary # # 2021 # ###################### */ #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #define II(a,b) make_pair(a,b) ...
#include<bits/stdc++.h> using namespace std; const int maxn=200005; int n,ql,qr,lst,s,t; vector<int>edge[maxn]; int dist[maxn],par[maxn],dep[maxn],que[maxn],ans[maxn]; bool bad[maxn]; void bfs(int s){ for(int i=1;i<=n;i++)dist[i]=-1; dist[s]=0; ql=1;qr=0; que[++qr]=s; while(ql<=qr){ int x=que[ql++]; for(int ...
#include <bits/stdc++.h> using namespace std; #define ALL(c) (c).begin(),(c).end() #define PB push_back #define IN(x,c) (find(c.begin(),c.end(),x) != (c).end()) #define REP(i,n) for (int i=0;i<(int)(n);i++) #define FOR(i,a,b) for (int i=(a);i<=(b);i++) #define INIT(a,v) memset(a,v,sizeof(a)) #define SORT_UNIQUE(c) (so...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#i...
#include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <bitset> #include <iomanip> #include <cmath> #include <set> #include <unordered_set> #include <functional> #include <map> #include <unordered_map> #include <string> #include <tuple> using namespace std; using ll = long...
#include<bits/stdc++.h> using namespace std; #define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define mod 1000000007 #define endl "\n" #define test ll t; cin>>t; while(t--) typedef long long int ll; vector<ll>as; ll check(ll n){ if(n<1){ return -1; } for(int i=0;i<as.size();i++){ ...
#include<bits/stdc++.h> #define inf 1e18 #define endl "\n" #define mp make_pair #define pb push_back #define loop(i,x,y) for(int i = x; i < y ; i++ ) #define all(x) (x).begin(),(x).end() #define in(n) int n; cin>>n; #define inarr(arr,n) vector<int>arr(n); for(int i = 0; i < n ; i++){cin>>arr[i];} #define maploop(...
#include<bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x){ x=0;bool f=false;char ch=getchar(); while(!isdigit(ch)){f|=ch=='-',ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} x=f?-x:x; return ; } template <typename T> inline void write(T x){ if(x<0) x=-x,put...
#include <bits/stdc++.h> #include <cmath> #include <limits> using namespace std; long long INF = (1LL<<62); typedef long long LL; LL f(LL X, LL x){ LL u = max(X, x); LL v = min(X, x); LL r = u % v; if(r == 0) return v; return f(v, r); } int main(int argc, char* argv[]){ cin.tie(0); ios::sync_with_stdio(false)...
#include <bits/stdc++.h> using namespace std; #define ffor(i, a, b) for (int i = a ; i <= (int) b ; i++) #define rfor(i, a, b) for (int i = (int) b ; i >= a ; i--) #define vec vector #define PB push_back #define MP make_pair #define MT make_tuple #define F first #define S second using ll = long long int;...
#include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<n;++i) #define rrep(i, n) for(ll i=n-1;i>=0;--i) #define rep1(i, n) for(ll i=1; i<=n; ++i) #define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();++itr) #define ALL(a) (a).begin(),(a).end() template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}} ...
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define Test(tt) cout << "Case #" << tt << ": " using namespace std; int main() { #ifdef HOME ifstream cin("A.in"); ofstream cout("A.out"); #endif int i; ios::sync_with_stdio(false); cin.ti...
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. ******************************************...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; #define ll long long #define INF INT_MAX #define FIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL); #define mod 1000000007ll #define forn(i,n) for(in...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <x86intrin.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define V vector #define sz(x) int(x.size()) template <type...
#include <bits/stdc++.h> #define mk make_pair #define fs first #define sc second using namespace std; typedef long long ll; typedef long double ld; // please, read the question correctly (do you need set or multiset)??? const int N=2000010; //check the limits, dummy int a[N]; int n, m; vector<int> pos[N]; int main(){ ...
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <iomanip> #include <functional> #include <deque> #include <stack> #include <queue> #include <bitset> #include <map> using namespace std; typedef long long ll; #define rep(i,n) for (ll i = 0; i < (ll)(n); i++) #define ...
#ifndef BZ #pragma GCC optimize "-O3" #endif #include <bits/stdc++.h> #define ALL(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i < (r); ++i) using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; /* ll pw(ll a, ll b) { ll ans = 1; while (b) { while...
#include <bits/stdc++.h> using namespace std; #define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR(i,m) for(int i = 0 ;i < m ;i++) #define mem(a ,b) memset(a, (b) , sizeof(a)) #define all(cont) cont.begin(),cont.end() #define mp make_pair #define pb push_back #define F f...
#include <bits/stdc++.h> using namespace std; #ifndef aa #define trace(...) #define endl '\n' #endif #define pb push_back #define ub upper_bound #define lb lower_bound #define fi first #define se second #define int long long typedef long long ll; typedef long double ld; #define double long double #define pii pair<int...
#include <bits/stdc++.h> using namespace std; // using mint = long double; // using mint = modint998244353; // using mint = modint1000000007; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> T; typedef pair<ll, vector<ll>> Pd; const ll INF = 1e18; const ll fact_table = 820000; priority_queue<ll> p...
#include <iostream> #include <vector> //#include <string> #include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used //#include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; /...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; using vpi = vector<pair<int, int>>; using pl = pair<ll, ll>; using vl = vector<ll>; #define all(v) (v).begin(), (v).end() #define ar array #defin...
#include <bits/stdc++.h> #define rep(i,n) for (ll i = 0; i < (ll)(n); i++) #define rrep(i,a,b) for (ll i = (a); i < (ll)(b); i++) #define rng(x) (x).begin(), (x).end() #define pb push_back #define eb emplace_back #define fr first #define sc second using namespace std; template <class T, class U> inline bool chmax(T &a...
#include <bits/stdc++.h> #define ln '\n' #define all(dat) dat.begin(), dat.end() #define loop(i, to) for (int i = 0; i < to; ++i) #define cont(i, to) for (int i = 1; i <= to; ++i) #define circ(i, fm, to) for (int i = fm; i <= to; ++i) #define foreach(i, dat) for (__typeof(...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define REP(i,k,n) for(long long i=k;i<(long long)(n);i++) #define all(a) a.begin(),a.end() #define pb emplace_back #define eb emplace_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bo...
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << p.first << ',' << p.second << ')'; return os; } ...
#include <iostream> #include <cmath> using namespace std; int main(){ int minimum; cin >> minimum; for (int i = 0; i < 3; i++){ int temp; cin >> temp; minimum = min(minimum, temp); } cout << minimum << endl; }
/*** ..*.*... \O/..*..* *.....*...|....*... *......../.\....*..* */ #include<bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << min(min(min(a, b), c), d); }
// Author: wlzhouzhuan #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pb push_back #define fir first #define sec second #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = ...
/** * created: 16/01/2021, 14:27:24 **/ #include <bits/stdc++.h> using namespace std; const int max_n = 1111, inf = 1000111222; int n, cnt[max_n][max_n]; vector<string> ans; int c2(int n) { return n * (n - 1) / 2; } bool get_bit(int mask, int pos) { return (mask >> pos) & 1; } void check() { for (s...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author NikuKyabe */ #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> #define rep(i,N) for(int i=0;i<(N);i++) #define rrep(i, n) for (int i = (int)n-1; i >= 0; --i) #define FOR(i,a,b) for(int i=(a);i<(b);i++) using namespace std; const long long INF = 1e12; const int inf = 1e9; const int mod = 1e9+7; typedef long long ll; typedef pair<ll,int> P; typedef set<int> S...
#include<bits/stdc++.h> #define N 200005 #define re register #define ll long long #define P 998244353 using namespace std; int n,m,K,q,u; inline void Rd(int &res){ re char c;res=0;bool f=0; while(c=getchar(),c<48)(c=='-')&&(f=1); do res=(res<<3)+(res<<1)+(c^48); while(c=getchar(),c>47); f&&(res=-res); } int f[25][...
#include<iostream> #include<cstdio> #include<map> using namespace std; #define N 100012 inline int sgn(int x){return (x==0)?0:((x>0)?1:(-1));} inline int Abs(int x){return (x>0)?x:(-x);} int n,L,a[N],b[N],c[N],la[N];bool fl=true;map<int,int>mp;long long ans=0; inline void Fin(int l,int r) { if(l+1>=r)return;int i,ql=l...
#include <bits/stdc++.h> using namespace std; #define int long long int #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define endl "\n"; #define rep(i, a, b) for (int i=a; i<b; i++) #define pre(i, a, b) for (int i=a; i>=b; i--) const int MAX_N = 1e5+5; const int MOD = 1e9 + 7; const i...
// ###### Fri Mar 5 20:57:40 IST 2021 #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define forn(ii, a, b) for (int ii = a; ii < b; ii++) #define scan(any) for (auto &i : any) cin >> i; #define debug(x) cerr << #x << " " << x << " -- \n" #define ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n,cap,m,t; cin>>n>>m>>t; cap = n; vector<ll> A(m); vector<ll> B(m); for(int i=0; i<m; i++) cin>>A[i]>>B[i]; ll Time = 0, i=0; while(i<m){ cap -= A[i] - Time; //cout<<cap<<endl; ...
// Problem: B - Smartphone Addiction // Contest: AtCoder - AtCoder Beginner Contest 185 // URL: https://atcoder.jp/contests/abc185/tasks/abc185_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Problem: A - ABC Preparation // Contest: AtCoder - AtCode...
#include <iostream> using namespace std; using ll = long long; template<class T> void SO(T& ve){sort(ve.begin(),ve.end());} template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());} //atcoder 0,19,3,14,4,5,17 -96 ll ceil(double x); ll gcd(ll a, ll b); int main(){ cin.tie(0); ll n; cin>>n; for(ll i=1;i<=n;i++){...
#include <bits/stdc++.h> int n; int main(){ scanf("%d",&n); for (int i=0;i<n;i++) printf("%d %d\n",(i*2)%n+1,(i*2+1)%n+1); }
//BISMILLAHIR RAHMANIR RAHEEM //ALLAH IS WATCHING ME // Shoeb Akibul Islam // Dept of ICE, NSTU #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> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #d...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pl; #define all(a) (a).begin(),(a).end() #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for(ll i = 0;i < (n);i++) #define rep2(i,n) for(ll i = 0;i < (n);i++) #define rep3(i,a,b) for(ll i = (a);i < (b);i++) #define ...
#include <bits/stdc++.h> #define ll long long int #define pb push_back #define st first #define nd second #define pii pair<int,int> #define mp make_pair #define pll pair<long long,long long> using namespace std; const int nax = 105; vector<int> adj[nax]; set<pair<pii, int> > s; set<pair<pii, int> > zostaly; int n,m;...
#include "bits/stdc++.h" //#include "atcoder/all" using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #...
#define _USE_MATH_DEFIMES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <ioman...
#include<bits/stdc++.h> using namespace std; #define en '\n' #define endl '\n' #define ll long long signed #define pb push_back #define append push_back #define all(v) (v).begin(),(v).end() #define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k) #define fori(a) for(int i=0; i<a; i++) #define forj(a) fo...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; const int N = 210; PII path[N]; int a[N]; int s[N]; bool st[N]; void print(int x, bool flag) { stack<int> sta; while(x != 0) { sta.push(path[x].second); x = path[x].first; } if (!flag) ...
#include <bits/stdc++.h> using namespace std; namespace tensor { template<typename T, int N, int...args> struct static_tensor : std::array<static_tensor<T, args...>, N> { static_tensor() : std::array<static_tensor<T, args...>, N>() {} void fill(const T &val) { for (int i = 0; i < N; i++) { (*this)[i].fil...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int INF = 1e+15; int...
#include<bits/stdc++.h> using namespace std; #define int long long #define print(x) cout << "[" << #x << ": " << x << "]"; #define println(x) cout << "[" << #x << ": " << x << "]\n"; #define pb push_back #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define INF 1e18 + 5 #define MOD 1e9 + 7 ...