code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> using namespace std; #define ll long long #define MAX_SIZE 1000000000 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b,c; cin >> a >> b >> c; a -= b; if(b<=0){ cout << "0" << endl; return 0; }else{ cout << a+c << end...
#include <iostream> using namespace std; int main(int argc, const char * argv[]) { int N,A,B; cin >> N >> A >> B ; cout << ((N+B)-A) << "\n"; return 0; }
#include <bits/stdc++.h> // #include <atcoder/all> // #include "icld.cpp" using namespace std; using ll = long long int; using vi = vector<int>; using si = set<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using ss = string; using db = double; template<typename T> using minpq = priority_queue <T,vector...
#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) using ll = long long; int mod = (ll)1e9 + 7; #define PI acos(-1) typedef pair<int, int> pairs; const int ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define endl '\n' #define ull unsigned long long #define ll long long #define ul unsigned long #define ld long double #define PI 3.1415926535...
#include <iostream> using namespace std; int main() { char x,y; cin>>x>>y; if(x=='Y'){ y=toupper(y); } else{ y=tolower(y); } cout<<y<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define f first #define s second #define ld long double const int nax=205; map<int,int> vis,dp; int x,y; int find(int v) { if(vis[v]) return dp[v]; vis[v]=1; dp[v]=1e18; int& res=dp[v]; res=min(res,abs(v...
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ LL X,Y; cin>>X>>Y; if(X>Y){ cout<<(X-Y)<<endl; return 0; } LL L=0, LV=Y, R=1, RV=Y+1; LL ans=Y-X; rep(i,70){ ans=min(ans,abs(LV-X)+L); ans=min(ans,a...
#include <bits/stdc++.h> int main() { int n; std::cin >> n; std::vector<int> a(n), b(n), c(n); for (int i = 0; i < n; ++i) std::cin >> a[i]; for (int i = 0; i < n; ++i) std::cin >> b[i]; for (int i = 0; i < n; ++i) std::cin >> c[i]; for (int i = 0; i < n; ++i) --a[i], --b[i], --c[i]; // Bを基準に考える // a...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N); vector<int> C(N); rep(i, N) { cin >> A.at(i); } rep(i, N) { cin >> B.at(i); } rep(i, N) { cin >> C.at(i); } int6...
#include <bits/stdc++.h> #include <climits> using namespace std; template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>; using ld = long double; #define ll long long using ull = unsigned ll; using PLL = pair<ll, ll>; using VLL = V<ll>; using VB = V<bool>; using VVB = VV<bool>; using VVLL = VV<ll...
#include <bits/stdc++.h> using namespace std; //using Graph = vector<vector<long long>>; using Graph = vector<vector<int>>; const long long INF = 1LL <<59; const long long Mo=1000000007; //vector<long long> seen; vector<int> seen; long long dfs(const Graph &G, int v, long long cnt) { seen[v] = cnt; //判定だけならcn...
#include <bits/stdc++.h> #define ADD(a, b) a = (a + ll(b)) % mod #define MUL(a, b) a = (a * ll(b)) % mod #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) #define rep(i, a, b) for(int i = int(a); i < int(b); i++) #define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--) #define all(a) (a).begin(), (a...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstddef> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef set<int> si; typedef set<ll> sl; typedef queue<int> qi; typedef queue<ll> ql; typedef stack<int> sti; typedef deque<int> dqi; typedef priority_queue<int> pqi;...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n);i++) using ll = long long; const ll INF = 1e9+7; using P = pair<int,int>; int main(){ string s; int k; cin >> s >> k; rep(i,k){ string g1 = s; string g2 = s; sort(g1.begin(), g1.end(), greater<in...
#include <iostream> #include <vector> #include <bits/stdc++.h> #define ll long long using namespace std; //take care of long long //fast I/O auto optimizer = []() { // makes I/O fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); return 0; }(); int main() { ll t=1; //cin>>t; while(t--) { ll a,b...
#include <bits/stdc++.h> using namespace std; #define int long long #define M (int)(1e9 + 7) int ar[100005][26]; int N; int sum(int r, int l) { int res[26] = {0}; for (; r > 0; r -= (r & -r)) { for (int j = 0; j < 26; j++) { res[j] += ar[r][j]; } } int res1[26] =...
//#define _GLIBCXX_DEBUG //#include "atcoder/all" //using namespace atcoder; #include <bits/stdc++.h> #define int long long #define ll long long using ull = unsigned long long; using namespace std; #define Dump(x) \ if (dbg) { \ cerr << #x << " = " <<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=(a);i<=(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll(b);i--) #define ALL(x) (x).begin(),(x).end() #define MAX(x) *max_element(ALL(x)) #defin...
#include <vector> #include <functional> using namespace std; template<typename T> class SegmentTree { int n; function<T(T,T)> op; vector<T> V; T q(int l, int r) { if (l >= r) return V[0]; T a = q((l+1)/2, r/2); if (l%2 != 0) a = op(a, V[l]); ...
#include <cstdio> #include <iostream> #include <cassert> #include <string> #include <algorithm> #include <cstring> #include <utility> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #include <cmath> #include <deque> #include <unordered_map> #define IOS ios_base::sync_with_stdio(0); cin...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> t(n); for (auto& x : t) cin >> x; constexpr int M = 1000001; vector<int> dp(M, 0); dp[0] = 1; for (auto x : t) { for (int i = M - 1; i >= 0...
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin>> #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeo...
#include <bits/stdc++.h> using namespace std; void __print(int x) {cout << x;} void __print(long x) {cout << x;} void __print(long long x) {cout << x;} void __print(unsigned x) {cout << x;} void __print(unsigned long x) {cout << x;} void __print(unsigned long long x) {cout << x;} void __print(float x) {cout << x;} void...
/* Author : Hocky Yudhiono 1/23/2021 7:55:58 PM 1. You can sort the query if offline! 2. Don't bring the dp remaining state when dfsing on DP on Tree. 3. Try to reverse (Think from the back) if you stuck. 4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs. 5. Try to reduce a problem, think of it whe...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX_N = 2e5+2; int n; pair<ll,ll> p[MAX_N]; int m; ll t[MAX_N],axis[MAX_N]; int q; ll A[MAX_N], B[MAX_N]; pair<ll,ll> ans[MAX_N]; struct query { ll a, b, id; bool operator<(const query& other) const { return a < other.a;...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1001001001; const long long LINF = 1001002003004005006; const double PI = acos(-1); int d4r[] = {1, 0, -1, 0}; int d4c[] = {0, 1, 0, -1}; int d8r[] = {1, 1, 0, -1, -1, -1, 0, 1}; int d8c[] = {0, 1, 1,...
#include <bits/stdc++.h> using namespace std; int main(){ string a; cin>>a; int a1 = a.length(); for(int i=0 ; i<a1-1 ;i++){ swap(a[i] , a[i+1]); } cout<<a<<endl; return 0; }
// Problem : A - Rotate // Contest : AtCoder - AtCoder Beginner Contest 197(Sponsored by Panasonic) // URL : https://atcoder.jp/contests/abc197/tasks/abc197_a // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #define int long long...
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout) using namespace __gnu_pbds; using namespace std; using ld = long double; using ll = long long; int n, m; int main(){ //IO("input.txt", "output.txt...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <vector> #include <numeric> #include <iostream> #include <random> #include <map...
#include<bits/stdc++.h> #define int ll #define sz(x) int((x).size()) #define all(x) (x).begin(),(x).end() #define x first #define y second using namespace std; using ll = long long; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; signed main() { ios::sync_with_s...
#include "bits/stdc++.h" using namespace std; using li = long long; const char newl = '\n'; template <class T> vector<vector<T>> vv(const unsigned int n, const unsigned int m, const T x) { return vector<vector<T>>(n, vector<T>(m, x)); } template <class T> vector<vector<vector<T>>> vvv(const unsigned int n, const unsign...
//https://atcoder.jp/contests/agc048/tasks/agc048_b //B - Bracket Score #include <bits/stdc++.h> using namespace std; const int MAXN=2e5+4; long long a[MAXN]; long long b[MAXN]; int main() { ios::sync_with_stdio(false); int n; cin>>n; for (int i=1; i<=n; i++) { cin>>a[i]; } for (...
#include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> #define f(i,a,b) for( int i=a;i<=b;++i) #define ff(i,a,b) for( int i=a;i>=b;--i) #define debug(x) cerr << #x << " : " << x << " " << endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pai...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
//#pragma GCC optimize "trapv" #pragma GCC optimize("Ofast") #pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> #define ll long long int #define fab(a,b,i) for(ll i=a;i<b;i++) #define pb push_back #define db long double #define mp make_pair #define endl "\n" #define f ...
#include <bits/stdc++.h> using namespace std; #define repr(i,a,b) for (int i=a; i<b; i++) #define rep(i,n) for (int i=0; i< n; i++) #define PI 3.14159265359 const long long INF = 1LL << 60; long long MOD = 1000000007; long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; } long long lcm (int a, in...
#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 ...
#include<bits/stdc++.h> #define maxn 1000005 #define inf 0x7fffffffffff #define mod 1000000007 #define mst(a,x) memset(a,x,sizeof(a)) #define up(l,r,i) for(LL i=l;i<=r;i++) #define down(l,r,i) for(LL i=l;i>=r;i--) #define in(l,r,a) for(LL i=l;i<=r;i++)cin>>a[i] #define out(l,r,a) for(LL i=l;i<=r;i++)cout<<a[i]<<" " #de...
/* Solution By: Ashish Kudar */ /* When you get down to nothing.. */ #include<bits/stdc++.h> #define sync ios_base::sync_with_stdio(0);cin.tie(NULL); #define ll long long #define ull unsigned ll #define ld long double #define pii ...
#include <bits/stdc++.h> #include <unordered_map> #define eps 1e-8 #define PI 3.141592653589793 #define bsize 512 #define ll long long #define ull unsigned long long #define pii pair<int,int> #define vi vector<int> #define vii vector<vector<int>> #define pb push_back #define bs 1000000007 using namespace std; int m...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1e9; const long long inf = 1LL<<60; //cout << fixed << setprecision(10) << << endl; bool solve(int left, vector<int> &res, int n, vector<int> &p, vector<int> &ip) { if ((int)res.size() == n-1) { for (int i=0; i<n; i++...
/// ~~~~~Bismillah'hir Rah'manir Rahim~~~~~ /// /* " Allah(SWT) blesses with knowledge whom he wants. " */ /* " Indeed with Hardship, comes Ease. " */ #include<bits/stdc++.h> using namespace std ; #define Fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ULL unsigned long long #d...
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <utility> #include <tuple> #include <cmath> #include <numeric> #include <set> #include <map> #include <array> #include <complex> #include <iomanip> #include <cassert> #include <random> #include <chrono> using ll = lon...
//switch between terminal and editor: ctrl + ` #include"bits/stdc++.h" #define endl '\n' using namespace std; typedef long long ll; // #define comparator_datatype pair<int,pair<ll,ll>> #define loop(i,x,n,u) for(ll i = x;i < n;i+=u) #define rloop(i,x,n,u) for(ll i = x;i > n;i-=u) #define mod 1000000007 #define read(X,...
#include <algorithm> #include <array> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <stri...
#include <bits/stdc++.h> #define For(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rFor(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rep(i, n) For((i), 0, (n)) #define rrep(i, n) rFor((i), (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef un...
#include <bits/stdc++.h> #define index(i, n) for (long long i = 0; i < n; i++) #define index1(i, n) for (long long i = 1; i <= n; i++) #define range(i, a, b) for (long long i = a; i < b; i++) #define indexD(i, n) for (long long i = n - 1; i >= 0; i--) #define index1D(i, n) for (long long i = n; i >= 1; i--) #define ra...
#include <bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ #define pii pair<int,int> #define fi first #define pb push_back #define si second #define int long long #define mod 1000000007 //998244353 #define fast ios_base::sync_with_stdio...
#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>; template <class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; } template <class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; } const int ...
#include <bits/stdc++.h> #include <iostream> //#include <algorithm> // #include <iomanip> #define ll long long #define map unordered_map #define set unordered_set #define l_l pair<ll, ll> #define P pair<ll, ll> #define vll vector<ll> #define mll map<ll, ll> #define mp make_pair #define rep(i, n) for (int i = 0, i##_le...
//#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma warning(disable : 4996) // ////#define ATCODER //#ifdef ATCODER //#include<atcoder/all> //using namespace atcoder; //#endif #include <algorithm> #include <utility> #include <vector> #include <limits.h> #include ...
#include <iostream> using namespace std; int a, b; void swap(int &a, int &b) { if (a > b) { int temp = a; a = b; b = temp; } } void solve() { cin >> a >> b; swap(a, b); int diff = b - a; if(diff >= 3) cout << "No" <<endl; else cout << "Yes" << endl; } ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<ll(n);i++) int main(){ int X,Y; cin>>X>>Y; if(X>Y){ if((X-Y)<3){ cout<<"Yes"; } else{ cout<<"No"; } } else{ if((Y-X)<3){ cout<<"Yes"; } else{ cout<<"No"; }...
//@formatter:off #include<bits/stdc++.h> #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #defi...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define pb push_back #define F first #define S second #define um map <ll,ll> #define rep(i,z,n) for(int i=z;i<n;i++) #define repi(i,z,n) for(int i=z;i<=n;i++)...
#include<bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(int)(x);i<(int)(y);i++) #define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl; #define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);} const long mod=1e9+7; const int siz=1e5; const int inf=1e9; int main(){ string s; cin>>s; int n...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() #define m0(x) memset(x,0,sizeof(x)) int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1...
#include<bits/stdc++.h> #define ll long long int #define pll pair<ll,ll> #define vpll vector< pll > #define mpll map<ll,ll> #define MOD 1000000007 #define all(v) v.begin(),v.end() #define s(v) v.size() #define test ll t;cin>>t;while(t--) #define vec vector<ll> #define read0(v,n) for(int i=0;i<n;i++)cin>>v[i]; #define r...
// Problem: E - Train // Contest: AtCoder - AtCoder Beginner Contest 192 // URL: https://atcoder.jp/contests/abc192/tasks/abc192_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <clim...
#include<bits/stdc++.h> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i...
#include <iostream> #include <cmath> #include <string> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <tuple> #include <utility> #include <functional> #include <set> #include <map> #include <bitset> #include <list> #include<iomanip> using namespace std; using ll = long long; using UL...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using P = pair<int, int>; int main(){ ll a,b,c; cin>>a>>b>>c; ll mod = 998244353; a = (a-1+1)*(1+a) / 2; a %= mod; b = (b - 1 + 1) * (1 + b) / 2; b %= mod; c = (c - 1 + 1...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int X,Y,Z; cin >>X>>Y>>Z; cout<<(Y*Z-1)/X<<endl; }
#include <bits/stdc++.h> using namespace std; #define INF 1e18 typedef pair<long long, int> iPair; const int maxN = 1e5; vector<pair<int,pair<int,int> > > adj[maxN]; void shortestPath(int n, int src,int dest) { priority_queue< iPair, vector <iPair> , greater<iPair> > pq; vector<long long> dist(n, IN...
// Author: HarshKumar #include <bits/stdc++.h> using namespace std; #define ll int64_t const ll N = 1e6 + 6, M = 1e9 + 7; const ll INF = (1LL << 62) - 1; vector<vector<tuple<ll, ll, ll>>> G; vector<ll> dijkstra(ll v) { vector<ll> ans(G.size(), INF), vis(G.size()); ans[v] = 0; priority_queue<pair<ll, ll>> q...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fs first #define sc second #define MP make_pair #define pb push_back #define sz(x) (int)x.size() #define sqr(x) ((x) * (x)) mt19937 rng(chrono::steady_clock::now()....
#include <bits/stdc++.h> using namespace std; #define repr(i, a, b) for (int i = a; i < b; i++) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef pair<ll,ll> P; #define mod 1000000007 ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} ll lcm(ll x,ll y) {return x/gcd(x,y)*y;} int main(){ ll ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> 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 vec2(name,i,j,k) vector<vector<ll>> name(i,vect...
#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 co(x) cout << x << endl #define cosp(x) cout << x << " " #define INF 1e18 using ll = long long; using ull = unsigned long long; int main(){ int N; cin >> N; vector<int>A(N); int a,j...
//{{ /* * Created at: 06/27/21 18:02:59 * * FB: https://facebook.com/tgbaodeeptry * From Viet Nam with Love :D * */ #include <bits/stdc++.h> using namespace std; #define fast_io() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define REP(i, a, b) for (int i = int(a); i < int(b); ++i...
#define _USE_MATH_DEFINES #include<iostream> #include<iomanip> #include<vector> #include<string> #include<algorithm> #include<cmath> #include<stack> #include<queue> #include<set> #include<map> #include<climits> #include<bitset> #include<unordered_map> #include<unordered_set> #include<random> #include<list> #include<fun...
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for(int i=(a); i<=(b); ++i) #define ROF(i, a, b) for(int i=(a); i>=(b); --i) #define make_unique(a) sort(all((a))), (a).resize(uni...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using Graph = vector<vector<int>>; using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const int IINF = 1LL << 29; const long long INF = 1LL << 60; template<class T> inline ...
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int) (x).size()) typedef pair<int, int> pii; typedef double ll; const int maxn = 2000 + 5; template<class T> void print(T & x){ cout << x; } template<class T,class U> void print(pair<T,U> & p){cout << "("; print(p.first); cout << ", "; print(p.second); cout ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; void solve() { ll n; cin >> n; ll pw5 = 5; int cnt5 = 1; while (n >= pw5) { ll cur = n - pw5; int cnt = 0; while (cur > 0 && cur % 3 == 0) cur /= 3, cnt++; if (cur == 1 && cnt > 0) { cout << cnt << ' ' << cnt5 << endl; r...
#include <iostream> #include <string> using namespace std; int main() { int i, j, n; string S, test; string ZONe = "ZONe"; cin >> S; n = 0; for(i=0; i<9; i++) { test = ""; for(j=i; j<i+4; j++) { test += S[j]; } if(test == ZONe) n++; } cout <<...
#include "bits/stdc++.h" using namespace std; const int N = 2e5 + 7; vector<int> adj[N]; bool good, vis[N]; long long net; int a[N], b[N]; void dfs(int i) { net += a[i] - b[i]; vis[i] = true; for (int x : adj[i]) if (!vis[x]) dfs(x); } int main() { ios::sync_with_stdio(0); cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) struct UnionFind { // 自分の親の頂点を管理する vector<int> par; UnionFind(int n) : par(n, -1) {} // 初期化 // 頂点xの根の頂点を返す int root(int x) { // 再帰構造 // 自分の根は親の根と等しい if (par[x] < 0) return x...
#include<bits/stdc++.h> using namespace std; long long soma(long long x){ return x*(x+1)/2; } void solve(){ int n; cin >> n; long long res =0 ; for(int i = 0; i < n; ++i){ long long a, b; cin >> a >> b; res += soma(b) - soma(a-1); } cout << res; } int main(){ ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5+5; int int_min = -2147483648; int int_max = 2147483647; int n; char s1[N], s2[N], s3[N]; void solve() { cin >> n; scanf("%s", s1), scanf("%s", s2), scanf("%s", s3); for(int i = 0; i < n; i++) putchar('1'); for(int i = 0; i < n; i++) putchar('0')...
#include<bits/stdc++.h> #define f first #define s second #define pb push_back #define M (L+R)/2 #define N 500009 #define inf 99999999999 #define ll long long #define mod 1000000007 #define sz size(); using namespace std; ll n, a, b, ans, sum; int main(){ ios::sync_with_stdio(0); cin>>n; a=1; for(int i=1; i<=...
#include <iostream> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <array> #include <algorithm> #include <utility> #include <numeric> #include <functional> #include <cmath> using namespace std; using ll = long long; using ull = unsigned long long; template <class .....
#include <bits/stdc++.h> #define st first #define nd second #define PQ priority_queue #define MP make_pair using ll = long long ; using namespace std; using pii = pair<int,int>; using pli = pair<ll, int>; using pil = pair<int, ll>; using pll = pair<ll, ll>; const int N = 0; const int MOD = 1e9 + 7; int mult(int x, int...
#include <bits/stdc++.h> #define ll long long #define B break #define C continue #define fi first #define se second #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define gc getchar #define pc putchar #define kg putchar(' ') #define hh putchar('\n') #define mem(a,b) memset(a,b,s...
#include<bits/stdc++.h> using namespace std; #define ll long long #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define all(v) v.begin(),v.end() const int mod = 1e9 + 7; ll dp[(1 << 18)][18]; int main (){ fast_io; ll n, m; cin >> n >> m; vector<vector<int> > constr...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stack> #include <queue> #include <cmath> #include <tuple> #include <cstdio> #include <bitset> #include <sstream> #include <iterator> #include <numeric> #include <map> #include <cstring> #include <set> #include <functional> #include <...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){ return a/gcd(a,b)*b;} int main(){ ll n; cin>>n; ll ans=1; for(ll i=2;i<=n;++i){ ans=lcm(i,ans); } cout<<ans+1<<"\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) const ll mod = 1e9 + 7; int main(){ int n; cin >> n; vector<int>a(n+1); for(int i=2;i<=n;i++)a[i]=i; for(int i=2;i<=n;i++){ for(int j=i+1;j<=n;j++){ if(a[j]%a[i]==0)a[j]/=a[i]; } ...
#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> 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...
// D - Happy Birthday! 2 #include <bits/stdc++.h> using namespace std; #define vec vector using vi = vec<int>; #define rp(i,s,e) for(int i=(s);i<(e);++i) #define sz(a) int(a.size()) int N; vi A(200); vec<vi> B(200); void print(int n, vi v){ cout<< n <<" "; rp(i, 0, n) cout<< v[i] << (i<n-1? " ":"\n"); } void dfs(in...
#include <iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> #include<stack> #include<queue> #include<math.h> using namespace std; typedef long long ll; #define int long long #define double long double typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; t...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include <bits/stdc++.h> using namespace std; long long dp[1 << 20]; int main() { int n,m; cin >> n >> m; vector<tuple<int,int,int> > v; for (int i = 0; i < m; ++i) { int x,y,z; cin >> x >> y >> z; v.push_back({x, y, z}); } dp[(1 << n) - 1] = 1; for (int i = ...
#include <bits/stdc++.h> using namespace std; #define MAX_N 1005 #define MAX_M 1005 int dp[MAX_N][MAX_M]; int main() { int N, M; cin >> N >> M; vector<int> A(N), B(M); for (auto &i : A) cin >> i; for (auto &i : B) cin >> i; for (int i = 0; i <= N; ++i) { for (int j = 0; j <= M; ++j) dp[i][j] = ...
/* author : dunk_066 */ #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int mod=1e9+7; #define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define all(c) c.begin(),c.end() #define pb push_back #define vi(a,x) vector<int>a(x) #define vl(a,x) vector<ll>a...
#include<iostream> #include<vector> #include<algorithm> #include<iomanip> #include<utility> #include<iomanip> #include<map> #include<queue> #include<stack> #include<cmath> #include<cstdio> #define rep(i,n) for(int i=0; i<(n); ++i) #define pai 3.1415926535897932384 #define NUM_MAX 2e18 #define NUM_MIN -1e9 using nam...
#include <iostream> #include <cstdio> #include <vector> #define N 55 using namespace std; typedef long long ll; ll n, ans = 1e18, a[N]; bool vpr[N]; vector<ll> pr; ll gcd(ll p, ll q) { if (q == 0) return p; return gcd(q, p % q); } void f(ll p, ll q) { ll i; if (q >= ans) return; if (p == pr.size()) { for (i =...
#include<bits/stdc++.h> using namespace std; #define ll long long const int inf=1e9+7; const int maxn=2e5+10; ll co[maxn][2]; struct Matrix { ll matrix[3][3]; void make(int op) { memset(matrix,0,sizeof(matrix)); matrix[2][2]=1; matrix[0][1]=(op==1)?1:-1; matrix[1][0]=(op==1)?-1:1; } void make(int op,ll ...
#include<bits/stdc++.h> int main(){ using namespace std; unsigned long N; cin >> N; vector<pair<long, long>> pts(N); for(auto&& [x, y] : pts)cin >> x >> y; unsigned long M; cin >> M; vector<tuple<long, long, unsigned long, unsigned long>> co{{0, 0, 0, 1}}; for(unsigned long i{0}, a,...
#include <cmath> #include <queue> #include <cstdio> #include <cstring> #include <algorithm> #define N1 200500 #define inf 0x3f3f3f3f #define ll long long using namespace std; ll maxn=1e10; int n; char a[N1]; int main() { // freopen("a.txt","r",stdin); scanf("%d",&n); scanf("%s",a); if(n==1) { ...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define f(i, b) for (int i = 0; i < b; i++) #define fr(i, a, b) for (int i = a; i >= b; i--) #define vt vector #define all(v) v.begin(), v.end() const ll M = 998244353; using namespace std; ll s(ll n, ll k) { ll C[k+1]; memset(C, 0, sizeo...
#include <bits/stdc++.h> using namespace std; int main() { int n,N; cin >> n; N = pow(2,n); vector<int> vec(N); vector<int> vec2(N); for(int i = 0;i<N;i++){ int A; cin >> A; vec.at(i) = A; } vec2 = vec; while(vec.size()!=2){ for(int i = 0;i<N/2;i++){ if(vec.at(i)<=vec.at(i+1)){ ...
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> #include<chrono> #include<iomanip> #include<map> #include<set> using namespace std; using ll = long long; using P = pair<ll,ll>; using TP = tuple<ll,ll,ll>; void init_io(){ cin.tie(0); ios::sync_with_stdi...
#include <bits/stdc++.h> #define _max(x, y) ((x > y) ? x : y) #define _min(x, y) ((x < y) ? x : y) using namespace std; typedef long long ll; template <typename T> inline void red(T &x) { x = 0; bool fg = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') fg ^=...
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; char win(char a,char b){ if (a == 'R' && b == 'P') return b; if (a == 'P' && b == 'S') return b; if (a == 'S' && b == 'R') return b; else return a; } int main(){ int n,k; cin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll>vl1; typedef vector<vl1> vl2; vl1 veka(11); vl1 niz(11); vl1 kata(11); vl1 hepa(11); struct struka {ll val; ll ind;}; typedef vector<struka> vs; vs sutra(11); bool compa(struka& a, struka& b) { if(a.val==b.val) return a.ind<b.ind;...
#include<bits/stdc++.h> using namespace std; using ll=int64_t; int main(){ ll N; cin>>N; ll idx=sqrt(2*N); list<pair<ll, ll> > num; for(int i=1; i<=idx; i++){ if(((2*N)%i)==0){ ll j=(2*N)/i; ll base= i-j+1; if(base%2==0){ if(j-1>=0) num.push_back({base/2, j-1}); if(i-1>=0)...
#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; int n; char s[nax]; int a[nax]; vector<vector<int> > cols; void solve(){ cin >>...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; vector<int> a(n + 1); cin >> n >> s; for (int i = 0; i < n + 1; ++i) { scanf("%d", &a[i]); } int l = 1, r = 10005; while (l + 1 < r) { int m = (l + r) / 2; bool ok = true; for (int i = 1; i <= n; ++i) { in...
#include<bits/stdc++.h> #define fp(i,a,b) for(int i=a,i##_=(b)+1;i!=i##_;++i) #define fd(i,a,b) for(int i=a,i##_=(b)-1;i!=i##_;--i) #define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout) namespace IO{ //In char ss[1<<17],*_A=ss,*_B=ss; #define gc() (_A==_B&&(_B=(_A=ss)+fread(ss,1,1<<17,stdin)...
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define pii pair<int, int> #define endl '\n' #define vi vector<int> #define vvi vector<vi> #define vvvi vector<vvi> #define vvvvi vector<vvvi> #define vl vector<ll> #define vvl vector<vl> #define vld vector<ld> #define pii pair<int, int> #de...
#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 ...
#include <cstdio> int rint() { int x = 0, fx = 1; char c = getchar(); while (c < '0' || c > '9') { fx ^= (c == '-' ? 1 : 0); c = getchar(); } while ('0' <= c && c <= '9') { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); } if (!fx) return -x; return x; } int main() { int A = rint(), B = rint(); printf("%lg\...
#include <iostream> using namespace std; #include <vector> #include <set> #include<string> #include <algorithm> #include <cmath> #include <climits> typedef long long ll; typedef unsigned long long ull; //AtCoder Begginer Contest 196 D int main(void) { ll n; cin >> n; ll ans; for (ll i = 0; i < 10000000; i++) ...
#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long N; cin >> N; int ans = 0; for (long long i = 1, pwr = 10; ; i++) { if (i%pwr == 0) pwr *= 10; if (i + pwr*i > N) break; ans++; } cout << ans << '\n'; return...
#pragma GCCoptimize("O3", "unroll-loops") #include <cstring> #include <iostream> using namespace std; using ll = long long; const int MAXN = 102; const int MAXC = 122505; ll k, mod, table[MAXN][MAXC], ret[MAXN]; int n, now; void calc() { memset(table, 0, sizeof(table)); table[0][0] = 1; for (int i = 1; ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mit map<int,int>::iterator #define sit set<int>::iterator #define itrm(g,x) for(mit g=x.begin();g!=x.end();g++) #define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) #define ltype int #define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++) #define r...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <numeric> #include <cmath> #include <unordered_map> #include <queue> #include <deque> using namespace std; using ll = long long; void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head;...
/*** author: yuji9511 ***/ #include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; using lpair = pair<ll, ll>; using vll = vector<ll>; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> # define N 110 int a[N], n,i,j,k=2e9;; int abs(int x) { return x>=0?x:-x; } int min(int x,int y) { return x<y?x:y; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); scanf("%d%*s",&n); n+...
#include <cstdio> #include <cstring> #include <cmath> #include <cassert> #include <vector> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <iostream> #include <numeric> /* debug macros */ #ifdef WAFDAYO #define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<...
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; int n,m,sum,ans=1; int power(int a,int b){ int ret=1; while(b){ if(b&1) ret=1ll*ret*a%mod; a=1ll*a*a%mod; b>>=1; } return ret; } int main(){ scanf("%d%d",&n,&m); for(int i=1,x;i<=n;i++){ scanf("%d",&x); ...
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c)) #define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c)) #defin...
#include <bits/stdc++.h> using namespace std; void Main(); using i8 = int8_t; /* -128 ~ 127 */ using u8 = uint8_t; /* 0 ~ 255 */ using i16 = int16_t; /* -32,768 ~ 32,767 */ using u16 = uint16_t; /* 0 ~ 65,535 */ using i32 = int32_t; /* -2,147,483,648 ~ 2,147,483,647 */ using u32 = uint32_t; /* 0 ~ 4,294,967,295...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; //#define ACL #ifdef ACL #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #if __has_include("acl-all.h") #include "acl-all.h" //on Wandbox using namespace atcoder; #endif #endif //#ifdef ACL typedef long...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; const int inf = 1e9; int n; int x[20], y[20], z[20]; int dist[20][20]; int dp[1 << 20][20]; int rec(int bit, int v) { if (dp[bit][v] != -1) return dp[bit][v]; if (bit == (1 << v)) { return dp[bit][v] = dist[0][v]; } in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<(n);i++) const ll INF = 1LL<<60; int main(){ ll n,k; cin>>n>>k; string s; cin>>s; map<char,ll> rcp; rcp['R']=1; rcp['S']=2; rcp['P']=3; string ns=s; ll knum=300; k=k+1; while(k!=1){ k--; ...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DU...
//...Bismillahir Rahmanir Rahim. . . #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; // typedefs... typedef double db; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vect...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pii pair<double, double> #define F first #define S second int main() { ios_base :: sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> faltu(n+1); while (k --) { int x; ...
#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 tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define scn(n)...
/*GIVE ME AC!!!!!!*/ #include<bits/stdc++.h> #define ll long long #define MOD 1000000007 #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int n; cin>>n; vector<pair<string,int>>v(n); rep(i,n){ string t; cin>>t; if(t[0]=='!'){ t.erase(0,1); v[i]=make_pair(t,1); ...
#include <bits/stdc++.h> using namespace std; int N; string S[200000]; map<string, int> str; int main() { scanf("%d", &N); for (int i = 0;i < N;i++) { cin >> S[i]; str[S[i]] = 0; } for (int i = 0;i < N;i++) { if (S[i][0] != '!') { str[S[i]] = 1; } } ...
/* ___ ___ ___ ___ ___ ___ ___ _____ ___ ___ ___ / /\ /__/\ / /\ /__/\ / /\ /__/\ / /\ / /::\ / /\ / /\ / /\ / /::\ ...
#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 tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define scn(n...
#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> /******...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <complex> #include <queue> #include <set> #include <unordered_set> #include <list> #include <chrono> #include <random> #include <iostream> #inc...
#include <iostream> #define int long long int using namespace std; int32_t main() { int n; cin >> n; int arr[n]; for(int i = 0; i < n; i++) cin >> arr[i]; int oranges = 0; for(int i = 0; i < n; i++) { int small = arr[i]; for(int j = i; j < n; j++) { small = min(small, arr[j]); oranges = max(oranges,...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define S second #define F first #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vll vector<long long int> #define vld vector<long double> #define pll pair<long long int,long long int> /* unordered_map<int,int>mp; mp.reserve...
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T& x, T y){ if(x > y){ x = y; return tr...
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; using namespace std; const int M = 1e9 + 7; struct mint { int value; mint() : value(0) {} template <class T> mint(T x) : value(x % M) { if (value < 0) value += M; } mint &operator-=(mint oth) { value -...
//@formatter:off #include<bits/stdc++.h> #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #defi...
#include "bits/stdc++.h" #include <chrono> #include <random> #define lli long long int using namespace std; #define mod 1000000007 #define mod1 998244353 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define INF 1000000000 #define common cout << "Case #" << w+1 << ": " #define MAXN 20...
#include <bits/stdc++.h> using namespace std; #define LL long long //#define MOD 1000000007 #define MOD 998244353 #define INF 1000000000000000000 #define VE vector #define VL vector<LL> #define VVL VE<VL> #define VVVL VE<VVL> #define LD long double #define PB push_back #define POB pop_back #define FOR(i,a,k) for(LL i=a...
#include<iostream> main(){ int x,y; scanf("%d%d",&x,&y); printf("%d",(6-x-y)%3); }
#include <bits/stdc++.h> #include<string> #include<queue> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ int H, W, X, Y; cin >> H >> W >> X >> Y; vector<string> S(H); rep(i, H) cin >> S.at(i); int ans = 1; for(int i = 1; i < H; i++){ if(X + i <= H && S.at(...
#include<bits/stdc++.h> using namespace std; int main(){ int h,w,x,y; cin>>h>>w>>x>>y; x--;y--; swap(x,y); vector<string> s(h); for(int i=0;i<h;i++){ cin>>s[i]; } int ans=1; for(int i=1; x+i<w && s[y][x+i]!='#' ;i++)ans++; for(int i=1; x-i>=0 && s[y][x-i]!='#' ;i++)ans++...
#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 1000000007 using namespace std; using ll = long long; int main() { int N, Q; cin >> N; vector<int> A(N), T(N); REP(i, 0, N) cin >> A[i] >> T[i]; cin >> Q; vector<ll> X(Q);...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) typedef pair<int,int> P; typedef long long ll; const int INF = 1001001001; const ll INFL = 1e17; const int MOD = 1e+9+7; int main(){ int n,k; ll ans = 0; cin >> n >> k; vector<vector<int>> t(n,vector<int>(n)); fo...
#include <bits/stdc++.h> //#include <atcoder/all> #ifndef LOCAL #pragma GCC target("arch=skylake-avx512") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string t...
#include <iostream> #include <string> #include <vector> #include <deque> #include <queue> #include <algorithm> #include <iomanip> #include <set> #include <map> #include <bitset> #include <cmath> #include <functional> using namespace std; #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define REV(i,n) for(ll (i) = (...
#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 #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> #define M 1000000007 ...
#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 rep(i,n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { ll n; cin >> n; ll ans = 0; int commaCnt = 1; bool exist = false; if (n >= 1000){ exist = true; } while(exist){ ll maxNum = pow(1000, commaCnt + 1) - 1; if(n > m...
#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; int main(){ int a,b,x,y; cin>>a>>b>>x>>y; if(a==b){ printf("%d",x); } else if(a>b){ int ans1=(a-b+a-b-1)*x; int ans2=(a-b-1)*y+x; printf("%d",min(ans1,ans2)); } else{ int ans1=(b-a+1+b-a)*x; int ans2=(b-a)*y+x; printf("%d",min(ans1,ans2)); } }
#include<bits/stdc++.h> using namespace std; int a,b,x,y,f[110][110]; int main(){ scanf("%d%d%d%d",&a,&b,&x,&y); memset(f,0x3f,sizeof(f)); f[a][0]=0; f[a][1]=x; if(a<b){ for(int i=a+1;i<=b;i++){ for(int j=0;j<=1;j++) f[i][j]=min(f[i-1][j]+y,f[i-1][j^1]+x+y); ...
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define EPS 1e-9 #define F first #define S second #define debug(x) cout<<x<<endl; #define repi(i,x,n) for(int i=x;i<n;i++) #define rep(i,n) repi(i,0,n) #define lp(i,n) repi(i,0,n) #define repn(i,n) for(int i=n;i>=0;i--) #define...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define mp make_pair #define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); #define ff first #define ss second #define INF (ll) (1e9) #define mod (ll) (1e9 + 7) #define endl "\n" #define tt ll testcase; ci...
#include<bits/stdc++.h> using namespace std; #define MAXN 200005 #define lowbit(x) (x&-x) #define reg register #define mkpr make_pair #define fir first #define sec second typedef long long LL; typedef unsigned long long uLL; const int INF=0x3f3f3f3f; const int mo=998244353; const LL jzm=2333; const int iv2=499122177; c...
/* /^--^\ \____/ / \ _____ _ __ __ ____ _ ____ ____ _____ | || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_ _| \__ __/ |_| |_|/_/\_\|____...
/* Author : */ #include <bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define pb push_back #define ll long long #define rep(i,n) for(ll i=0;i<n;i++) #define rep1(i,n) for(ll i=n-1;i>=0;i--) #define repi(i,n) for(ll i=1;i<=n;i++) #define...
#include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <random> #include <iomanip> #include <functional...
#include <bits/stdc++.h> using namespace std; int n,m; vector<int> adj[21]; int vis[21]; vector<int> nxt[21]; int par[21]; void dfs(int x) { vis[x]=1; for (int y : adj[x]) if (!vis[y]) { nxt[x].push_back(y); par[y]=x; dfs(y); } } int color[21]; int solve(int x) { int r = 0; ...
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<vector> //#define puts sdf using std::vector; //using std::cout; //using std::endl; using std::sort; using std::swap; using std::min; using std::max; int read(){//int 无负数 int h=0;char c=getchar(); while(c<'0'||c>'9')c=getchar(); whi...
/* weak weak we ak we akwea weak we weak weak we ak weak weak we ak we weakweak we ak wea ak we akwe wea we ak we ak we akwe wea we ak we ak we akwe wea eak weak ...
#include <bits/stdc++.h> //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //#include <atcoder/all> using namespace std; #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a; i > -1; --i) #define REP(i, a, b) for (int i = (int)a; i ...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; typedef long long ll; typedef vector<ll> vint; typedef vector< vector<ll> > vvint; #define rep(i,n) for(ll i=0;i<n;i++) #define repf(i,f,n) for(ll i=f;i<n;i++) #define repr(i,n) for(ll i=n-1;i>=0;i--) #define mp make_p...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007 #define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL); #define all(v) (v).begin() , (v).end() #define sumof(v) accumulate(all(v), 0LL, plus<ll>()) #define maxof(v) max_element(all(v)) #define minof(v) min_element(all(v...
#include <bits/stdc++.h> #define ll long long #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; int cnt = 0; rep(i,n) { int tmp = i + 1; int f = 1; string o; while (tmp) { o.push_back((char)(tmp % 8 + '0')); tmp /= ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod=1e9+7; vector<ll> p(3e5),r(3e5); ll find(ll a){ if(p[a]==a) return a; return p[a]=find(p[a]); } void join(ll a,ll b){ a=find(a); b=find(b); if(r[a]==r[b]){ r[a]++; } if(r[a]>r[b]){ p...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using vt = vector<T>; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define pb p...
/** * author: FromDihPout * created: 2021-06-05 **/ #include <bits/stdc++.h> using namespace std; const int MAX_DEPTH = 2e5 + 5; int t; vector<vector<int>> adj; vector<vector<int>> depth; vector<int> tin, tout; void dfs(int u, int d) { depth[d].push_back(t); tin[u] = t; t++; for (int v : adj...
#include <bits/stdc++.h> #include <bits/extc++.h> #define double long double #define rbtree __gnu_pbds::tree<int,__gnu_pbds::null_type,less<int>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> #define int ll #define IOS ios_base::sync_with_stdio(false);cin.tie(0); #define pb push_back #define ALL...
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; int main() { ll a,b,x,y; std::cin >> a>>b>>x>>y; vector<vector<ll>> dis(200,vector<ll>(200,1000000000)); for (int i = 0; i < 100; i++) { dis[i][i+100] = dis[i+100][i] = x; if(i>0)dis[i]...
#include <bits/stdc++.h> using namespace std; vector<int> ar[2001]; set<pair<int,int>> s; int visited[2001]; void dfs(int x,int source) { visited[x]=1; for(auto it:ar[x]) { if(!visited[it]) { s.insert({source,it}); dfs(it,source); } } } void solve() { int t=1; //cin>>t; while(t--) { int n,m,i; cin>>n...
#include "bits/stdc++.h" using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using vll=vector<ll>; using vvll=vector<vll>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<(n);i++) #define sor(v) sort(v.begin(),v.end()) #define rev(v) reverse(v.begin(),v.end()) #define pb push_ba...
#include <bits/stdc++.h> //#include <atcoder/all> #define rep(i, n) for (int i=0; i < (n); i++) using namespace std; //using namespace atcoder; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> P; const int INF = 1 << 30; const ll LINF = 1LL << 61; const int NIL = -...
#include <vector> #include <array> #include <stack> #include <queue> #include <list> #include <bitset> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <algorithm> #include <numeric> #include <iostream> #include <iomanip> #include <string> #include <chrono> #include <random> #inc...
#include <bits/stdc++.h> using namespace std; int main(){ string a; cin >> a; int p=0; int c = a.size(); for(int i=0; i < c;i++){ if(a[i]=='.') p = i; } if(p!=0) a = a.substr(0,p); // a.substr(0,(a.size()-p)); cout << a << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, l, n) for (int i = (l); i < (n); i++) template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; r...
#include <bits/stdc++.h> #define DEBUG if(0) #define lli long long int #define ldouble long double using namespace std; const int maxX = 2e5 + 1; int divCount[maxX]; int main() { int a, b; while (~scanf("%d %d", &a, &b)) { memset(divCount, 0, sizeof(divCount)); for (int i = a; i <= b; i++) { f...
#include <bits/stdc++.h> using namespace std; int findMaxGCD(int arr[], int n) { int high = 0; for (int i = 0; i < n; i++) high = max(high, arr[i]); int count[high + 1] = {0}; for (int i = 0; i < n; i++) count[arr[i]]++; int counter = 0; for (int i = high; i >= 1; i--) ...
#define _USE_MATH_DEFINES #include <iostream> #include <cstring> #include <regex> #include <cmath> #include <algorithm> #include <vector> #include <list> #include <map> #include <unordered_set> #include <queue> #include <unordered_map> #include <set> #include <cassert> #include <climits> #pragma GCC optimize("O3") u...
#include<bits/stdc++.h> using namespace std; int main() { string s; deque<char> ans; cin >> s; int sw,i,size; sw=0; size=s.size(); for(char c: s) { if(c=='R') sw++; else{ if(ans.size()==0) ans.push_front(c); else if(sw%2==0) {if(c==ans.back()) ans.pop_back(); else ans.push_b...
#include <bits/stdc++.h> using namespace std; int main(){ int H, W; while(scanf("%d%d", &H, &W) > 0){ int A[H][W], min_A = 110; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ scanf("%d", &A[i][j]); min_A = min(min_A, A[i][j]); } } int ans = 0; for(int i = 0; i < H; i++...
#include <iostream> #include <iomanip> #include <algorithm> #include <array> #include <cassert> #include <optional> #include <utility> #include <vector> template <class InputIterator> std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_ar...
#include <cstdio> #include <algorithm> using namespace std; int n,a[31],f[31][31];long long ans=1e15; void dfs(int las,int sum) { if(las==n) { ans=min(ans,1ll*sum); return; } for(int i=las+1;i<=n;i++) dfs(i,sum^f[las+1][i]); } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int ...
#include<bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i = (a); i < (b); i++) #define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--) #define rep(i,n) FOR(i,0,n) #define PB push_back #define SZ(a) (int)a.size() #define ALL...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VP...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #include <bitset> #define ll long long #define rep(i, n) for(int i = 0; i < n; i++) using namespace std...
#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> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef OJ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt","w",stderr); #endif int n; cin>>n; string a; cin>>a; if(a[0]!=a[a.size()-1...
#pragma GCC optimize("Ofast") //#pragma GCC target ("sse4") #include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<stack> #i...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { int n,m; int vdnhgbdrhg; cin>>n>>m; vector<pair<int,int>>a(m); for(int i=0;i<m;i++) { cin>>a[i].first>>a[i].second; } int k; cin>>k; vector<pair<int,int>>b(k); for(int j=0;j<k;j++) { ...