code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> using namespace std; #define debug(x) cout << #x << " is " << x << endl typedef long long ll; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; int n, ans; string S, T; vector<int> a, b; int main() {...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; // #define int long long #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i) #define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps...
#include <bits/stdc++.h> using namespace std; template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); } template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); } template<typename T = int, T mod = 1'000'000'007, ...
#include <bits/stdc++.h> using namespace std; int main() { int T=1, caseIdx=0; //cin >> T; while (T--) { caseIdx++; long r, x, y, ans=0; cin >> r >> x >> y; double d = sqrt(x*x + y*y); ans = ceil(d/r); if (ans==1 && d != r) ++ans; cout << ans ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) int main(){ int n; string s; int q; cin >> n; cin >> s; cin >> q; vector<int> T(q); vector<int> A(q); vector<int> B(q); rep(i, q){ cin >> T[i] >> A[i] >> B[i]; } rep(i, q ...
/*Jai Shree Ram*/ // Never Give Up #include<bits/stdc++.h> #include<unordered_map> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi ...
#include<bits/stdc++.h> using namespace std; int m1(int n) { string s; s=to_string(n); sort(s.begin(),s.end()); n=stoi(s); return(n); } int m2(int n) { string s2; s2=to_string(n); sort(s2.begin(),s2.end(),greater<int>()); n=stoi(s2); return(n)...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; set<int> st1, st2; for (int i = 0; i < n; i++) { int a; cin >> a; st1.insert(a); } for (int i = 0; i < m; i++) { int b; cin >> b; st2.insert(b); } vector<int> ans; for (auto i : st1) { if...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=(n)-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue<x...
#include <bits/stdc++.h> #define PRINT(x) cerr<<#x<<'='<<x<<endl #define NL(x) " \n"[(x)] #define sz(x) int((x).size()) #define all(x) begin(x),end(x) #define mid (l+r)/2 #define fi first #define se second #define pb push_back #define endl '\n' #define lld long long #define pii pair<int,int> #define pli pair<lld,int> #...
//g++ -std=gnu++14 a.cpp // ./compile_run.sh #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iostream> #include <istream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <tuple> #include <iomanip> #inc...
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using db = double; using ld = long double; template<typename T> using...
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <unordered_map> #include <unordered_set> #include <map> #include <set> #include <climits> #include <string> #include <cmath> #include <stack> #include <functional> #include <list> #include <array> #include <queue> #include <bitset> #...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < (n); i++) #define REPS(i, n) for(int i = 1; i <= (n); i++) #define RREP(i, n) for(int i = (n)-1; i >= 0; i--) #define RREPS(i, n) for(int i = (n); i > 0; i--) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #...
#include <bits/stdc++.h> using namespace std; void fastio() { cin.tie(nullptr); cin.sync_with_stdio(false); } using LL = long long; using LD = long double; const LL MOD = 998244353; const LL INF = LLONG_MAX; const LL N = 3e5+1; #define S second #define F first #define vt vector LL binpow (LL x, LL p, LL m) { L...
#include <iostream> #include <stdio.h> #include <vector> #include <queue> #include <utility> using namespace std; typedef struct edge{ int to; int cost; }Edge; typedef pair<int,int> P; long long INF=250000010; int V; vector<Edge> G[1000000]; long long d[1000000]; void dijkstra(int s){ priority_queue<P,vector<P>...
#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> using namespace std; int T, n; string s1, s2, s3; int main() { std::ios::sync_with_stdio(0); cin >> T; while (T--) { cin >> n; cin >> s1 >> s2 >> s3; for (int i = 1; i <= n; i++) cout << '0'; for (int i = 1; i <= n; i++) cout <...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int T; cin >> T; for (int t = 0; t < T; t++) { int N; string S1, S2, S3; cin >> N >> S1 >> S2 >> S3; if (S1[0] == '0' && S2[0] == '0' && S3[0] == '0') { ...
#include <bits/stdc++.h> #define ll long long using namespace std; int main(){ int n; cin>>n; double a = 1.08 * n; int r = (int)a; if(r < 206){ cout<<"Yay!"<<endl; }else if(r == 206){ cout<<"so-so"<<endl; }else{ cout<<":("<<endl; } }
#line 1 "Contests/AtCoder_abc206/abc206_a/main.cpp" using namespace std; #line 2 "library/bits/stdc++.h" // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include ...
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2 #include <bits/stdc++.h> #include <cstdio> #include <iterator> using namespace std; #define sws \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define vi vector<int> #define vll vector<lo...
#include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back using namespace std; const ll maxn = 1e5 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n = 0; cin >> n; ll x = 1.08 * 1.0 * n; ll c = 206; // cout << x << " " << c << "\n"; if (x < c) ...
#include <bits/stdc++.h> long double EPS = 1e-12; using namespace std; vector<complex<long double>> rotate(vector<complex<long double>> points, const complex<long double>& rot) { for (auto& p : points) { p *= rot; } return points; } bool equals(vector<complex<long double>> points1, vector<complex<long dou...
#include<bits/stdc++.h> #define ln puts("") #define sp printf(" ") using namespace std; typedef long long ll; inline ll read() { ll sum = 0, ff = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') ff = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') sum = sum * 10 + ch - '0', ch = ge...
#include <cstdio> #include <algorithm> using namespace std; const int M = 100005; #define db double int read() { int x=0,f=1;char c; while((c=getchar())<'0' || c>'9') {if(c=='-') f=-1;} while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+(c^48);c=getchar();} return x*f; } int n;db ans,a[M]; db Abs(db x) {return x>0?x:-x;} si...
#pragma GCC optimize("Ofast") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define ff first #define ss second #define ins insert #define sz(x) (int)x.size...
#include <iostream> #include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; const ll INF = 1LL << 60; int main(){ string a, b; cin >> a >> b; int ai, bi; ai = (a[0] - '0') + (a[1] - '0') + (a[2] - '0'); bi = (b[...
#include <bits/stdc++.h> using namespace std; typedef long int lint; typedef long long int llint; #define INF 1073741824 #define LINF 4611686018000000000 #define MOD 1000000007 int digsum(int n) { int ans = 0; while (n) { ans += n % 10; n /= 10; } return ans; } int main() { int...
// Containers #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> // #include "conf.d/say.h" using namespace std; #define ll long long #define pb push_back #define ...
#include<bits/stdc++.h> #define mod 1000000007 #define INF 10000000000000001 #define F first #define S second #define LB lower_bound #define UB upper_bound #define vc vector #define vll vector<long long> #define pll pair<long long,long long> #define pb push_back #define all(v) v.begin(),v.end() #define T ll test;cin>>t...
#include<bits/stdc++.h> using namespace std; int main() { long long int i=1,n,s=0; cin>>n; while(s<n) { s+=i; i++; } cout<<i-1<<endl; return 0; }
#include <math.h> #include <bits/stdc++.h> using namespace std; #define rep(i, l, n) for (int i = (l); i < (n); i++) #define max(p, q) ((p) > (q) ? (p) : (q)) #define min(p, q) ((p) < (q) ? (p) : (q)) using ll = long long; using P = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V...
#include <bits/stdc++.h> using namespace std; int main() { int a,b,c;cin>>a>>b>>c; int ans=a+b+c; int g; g=min(a,b); g=min(g,c); cout << ans-g << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long double r, x, y; cin >> r >> x >> y; long double cnt = sqrtl(x * x + y * y) / r; if (cnt < 1) { // ちょうどrしか動けないため、迂回して2歩 cout << 2 << endl; } else { cout << ceil(cnt) << endl; } }
#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 req(i,n) for(int i = 1;i <=n;i++) #define pai 3.14159265358979323846 const int INF = 1001001001; typedef long long ll; bool punched[3][3]; //using Graph = vector<vector<int>>; const int MOD ...
#include<bits/stdc++.h> #define x first #define y second #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define mem(x,val) memset(x,val,sizeof x) #define pii pair<int,int> #define pb emplace_back #define ar array #define int long long #define FOR(i, a, b) for(int i = a; i < b; i++) #define M 1000000...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define task "BIGROUP" #define pll pair<ll, ll> #define pii pair<pll, ll> #define fi first #define se second using namespace std; const ll mod = 998244353; const ll N = 2e5+5; const int base = 313; ll n, m, t, k, T, ans, siz, tong, a[N], b[N], c[N]; s...
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; ll n; ll d[105][105]; double ans; int main() { scanf("%lld", &n); for(ll i = 0; i < n; i++) { for(ll j = 0; j < n; j++) { scanf("%1lld", &d[i][j]); } } for(ll k = 0; k < n; k++) ...
#include <iostream> #include <string> #include <queue> using namespace std; #define SIZE 101 int main() { int a, b, c; cin >> a >> b >> c; double dp[SIZE][SIZE][SIZE] = { 0 }; dp[a][b][c] = 1; for (int i = a; i < SIZE; i++) { for (int j = b; j < SIZE; j++) { for (int k = c; k < SIZE; k++) { ...
#include <iostream> #include <math.h> #include <algorithm> using namespace std; #define f first #define s second #define ll long long #define mp make_pair #define ull unsigned long long #define p push #define pb push_back double r, x, y; int main() { cin >> r >> x >> y; double dist = sqrt((x * x) + (y * y)); dou...
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") //#include <immintrin.h> //#include <emmintrin.h> #include <bits/stdc++.h> using namespace std; #define rep(i,h,t) for (int i=h;i<=t;i++) #define dep(i,t,h) fo...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, j, k) for(int i = j; i < k; i++) #define print(x) cout << x #define newline cout << endl #define space cout << ' ' #define INF 1000000007 using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>...
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<bitset> #include<cmath> #include<ctime> #include<queue> #include<map> #include<set> #define int long long #define lowbit(x) (x&(-x)) #define mp(x,y) make_pair(x,y) #define lc (x<<1) #define rc (x<<1|1) #define fi first #define se second...
#pragma GCC optimize("O3") #include "bits/stdc++.h" #define sz(x) (int)(x).size() using namespace std; const int64_t INV = int64_t(332748118); const int64_t MOD = int64_t(998244353); const int mxN = int(5e3) + 5; int64_t dp[mxN][mxN]; char arr[mxN][mxN]; int h,w,k; int main() { ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; #define YES cout << "YES" << endl; #define NO cout << "NO" << endl; #define Yes cout << "Yes" << endl; #define No cout << "No" << endl; #define INF INT_MAX #define LLINF LLONG_MAX #define MOD 1000000007 #define PI acos(-1) using ll = long long; using ull = unsig...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1000000007; #define REP(i, n) for (ll i = 0; i < (n); i++) #define REP2(i, x, n) for (ll i = x; i < (n); i++) #define PR(x) cout << (x) << "\n" #define PS(x) cout << (x) << " " #define PRYES(x) PR((x) ? "Yes" : "No") const lo...
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<vector> #include<functional> #include<algorithm> #include<stdlib.h> #include<string> #include<string.h> #define _USE_MATH_DEFINES #include<math.h> #include<deque> #include<set> #include<map> #include<queue> #include<list> #include<iostream> #include <bitset> us...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::en...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using V = vector<int>; using VV = vector<V>; using VVV = vector<VV>; using VL = vector<ll>; using VVL = vector<VL>; using VVVL = vector<VVL>; template<class T> using VE = vector<T>; template<class T> using P = pair<T, T>;...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5; int main(){ vector<pair<int,int>>ans; int n,m;cin>>n>>m; int x=m; if((m>0&&x+2>n)||m<0){ cout<<"-1\n"; return 0; } ans.emplace_back(1,4*x+3); for(int i=0;i<n-1;i++){ ans.emplace_back(4*i+2,4*i+4); } for(auto& i:ans){ ...
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int n; cin>>n; vector<int> a(n),b(n); for(auto& x:a) cin>>x; for(auto& x:b) cin>>x; reverse(a.begin(),a.end()); priority_queue<int,vector<int>,greater<int>> q; for(int i=0;i<n;i++) { ...
#include <bits/stdc++.h> using namespace std; // template {{{ #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1) #define whole(f, x, ...) ([&](decltype((x)) container) { return (f)( begin(container), end(container), ## ...
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; #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 NEXT(i, u) for (int i = h[u]; i; i = e[i].u) const int INF = 2e9; const int K = 1e5 + 7; int Max(const int &a, const int &b) {return...
#include <algorithm> #include <array> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <set> #include <vector> #define ALL(container) container.begin(), container.end() using namespace std; using ll = long long; int score(const string &s) { auto cnt = vector<int>(10); iota(...
// C - Collinearity #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; #define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i) int main(){ int n; cin>>n; vi X, Y; rp(i, 0, n){ int x, y; cin>>x>>y; X.push_back(x); Y.push_back(y); } rp(a, 0, n-1) rp(b, a+1, n) rp(c, 0, n)...
#include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl #define rall(a) (a).rbegin(),(a).rend() const int INF = 2e9; using namespace std; using Graph = vector<vector<int>>; typedef pair<int,int> P; typedef long long ll; int main(){ in...
#include<bits/stdc++.h> using namespace std; const int N = 105; int n, k, MOD; void sub(int& x, int y){ x-=y; if(x<0)x+=MOD; } void add(int& x, int y){ x+=y; if(x>MOD)x-=MOD; } int dp[N][N*N*N]; void solve(){ dp[0][0]=1; for(int i=1;i<=n;++i){ int up=k*(i+1)*i/2; for(int j...
#line 1 "main.cpp" /** * @title Template */ #include <iostream> #include <algorithm> #include <utility> #include <numeric> #include <vector> #include <array> #include <cassert> #include <iomanip> #line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp" #line 4 "/Users/kodamankod/Desktop/cpp_pro...
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <cmath> #include <set> #include <map> #include <stack> #include <queue> #include <unordered_set> #define ll long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll, ll> using namespace std; const int mod = 9...
#include <bits/stdc++.h> using namespace std; // 2の27乗=1億3千万 #define rep(i, n, N) for (int i = n; i < (int)(N); i++) #define ascending(array) sort(array.begin(), array.end()); #define descending(array) sort(array.rbegin(), array.rend()); #define log(name, message) cout << name << " = " << message << endl #define out(c...
#include <bits/stdc++.h> using namespace std; #define int long long const int inf=1e18+3; const int mix=1e6+5; int n,m,fx,ty,cn; int hea[mix],nxt[mix],tor[mix]; int len[mix],kai[mix],dis[mix]; priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q; bool vis[mix]; inline void Build(){ int a,...
#include <bits/stdc++.h> using namespace std; typedef long long i64; typedef unsigned long long ui64; typedef vector<i64> vi; typedef vector<vi> vvi; typedef pair<i64, i64> pi; #define pb push_back #define sz(a) i64((a).size()) #define all(c) (c).begin(), (c).end() #define REP(s, e, i) for(i=(s); i < (e); ++i) inlin...
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1000000010 #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(in...
//author: hitch_hiker42; #include<bits/stdc++.h> using namespace std; //solution: #define int int64_t #define span(a) begin(a), end(a) void hike() { int n, k; cin >> n >> k; int cost[n + 1][n + 1]; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= n; ++j) cin >> cost[i][j]; } vector<int> path(n - 1); ...
#include <bits/stdc++.h> #define DEBUG if(0) #define lli __int128 #define ldouble long double using namespace std; /* (2x + 2y)n + x <= t < (2x + 2y)n + x + y range = y (max 500) (p + q)n + p <= t < (p + q)(n + 1) range = q (max 500) try all combinations of mod (500^2) t - (2x + 2y)n - x == remY t - (2x + 2y)n =...
#include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <numeric> #include <iostream> #include <iomanip> #include <utility> #include <set> #include <tuple> #include <cctype> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> using namespac...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> v...
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second const int mod=1000000007; using namespace std; void A(){ int a,b;cin>>a>>b; int x=0; if(b>=8&&a+b>=15){cout<<1;return;} if(b>=3&&a+b>=10){cout<<2;return;} if(a+b>=3){cout<<3;return;} cout<<4; } void B(){ } void C(){ } void D(){ } int m...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define T int t; cin>>t; while(t--) #define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) #define PI 3.141592653589793238462643383 #define pb push_back #define all(s) s.begin(),s.end() int main (){ fast; int h,w; ...
/************************************************************************* > File Name: 1.cpp > Author: Knowledge_llz > Mail: 925538513@qq.com > Blog: https://blog.csdn.net/Pig_cfbsl > Created Time: 2020/10/10 20:03:44 ************************************************************************/ #include<bits/stdc+...
//****************************Template Begins****************************// // Header Files #include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<utility> #include<set> #include<unordered_set> #include<list> #include<iterator> #include<deque> #include<queue> #include<stack> #include<set> #...
#include<bits/stdc++.h> #define int long long const int p=1e9+7; using namespace std; int n,a[4000],sum[4000],f[3008][3008],cnt[3008][3008],ans; signed main() { scanf("%lld",&n); for(int i=1; i<=n; i++) { scanf("%lld",&a[i]); sum[i]=sum[i-1]+a[i]; } cnt[1][0]=1; for(int i=1; i<=n; i++) { for(int j=1; j<=i;...
#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 <bits/stdc++.h> using namespace std; #define int long long #define inf (int)(1e18) signed main(){ int N, i, ans = 0; scanf("%lld", &N); vector<int> V(2 * N); for(i = 0; i < 2 * N; i++){ scanf("%lld", &V[i]); ans += V[i]; } priority_queue<int, vector<int>, greater<int>> pq; for(i = 0; i < N; i++){ ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF=2e18; ll clamp(ll x,ll min,ll max) { if(x>max) { return max; } if(x<min) { return min; } return x; } int main() { ll n; cin>>n; ll low=-INF; ll high=INF; ll bias=0; for(ll i=1;i<=n;i++) { ll a,t; cin>>a>>t; if(1==t) ...
#include <bits/stdc++.h> using namespace std; #define fo(a,b) for(int64_t a=0;a<b;a++) #define sor(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define ll int64_t #define mod 1000000007 #define vl vector<int64_t> #define vc vector<char> #define vs vector<string> #define np(vec) next_permutation(...
#include <iostream> using namespace std; unsigned long long n,cn; int s,cnt,nrcif,cf[19],i,r,j; int main() { cin>>n; cn=n; while(cn) { cf[++cnt]=(cn%10)%3; s+=cf[cnt]; cn/=10; nrcif++; } r=s%3; if(r==0) { cout<<0; return 0; } int c...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<int> num(3); while (n) { num[n % 10 % 3]++; n /= 10; } int x = (num[1] + num[2] * 2) % 3; int k = num[0] + num[1] + num[2]; if(x == 0){ cout << 0 << endl; } else if (x == 1) { if (...
#include <bits/stdc++.h> using namespace std; int main(){ int H, W; while(scanf("%d%d", &H, &W) > 0){ char S[H][W+1]; for(int i = 0; i < H; i++){ scanf("%s", S[i]); } int ans = 0; for(int i = 1; i < H; i++){ bool at_side = false; for(int j = 0; j < W; j++){ if(S[i-1][j] ==...
#include <bits/stdc++.h> using namespace std; const int dx[]={1,-1,0,0}; const int dy[]={0,0,1,-1}; int n,m; char c[15][15]; bool vis[15][15]; int main() { cin>>n>>m; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>c[i][j]; } } int ans=0; for(int i=1;i<n-1;i++) { for(int j=1;j<m-1;j++) { if(c[...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <set> #include <cmath> #include <stdio.h> #include <list> #include <numeric> #include <stack> #include <queue> #include <tuple> #include <bitset> #include <map> #include <math.h> #include <cstring> //ceil(a/b) (a + (b - 1))/ b usin...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ vector<ll>v1; ll n; cin>>n; ll a[n],b[n]; for(ll i=0;i<n;i++){ cin>>a[i]; cin>>b[i]; ll res=a[i]+b[i]; v1.push_back(res); } ll res1=*min_element(a,a+n); ll res2=*min_element(b,...
// Problem: B - Many 110 // Contest: AtCoder - AtCoder Regular Contest 110(Sponsored by KAJIMA CORPORATION) // Time: 2020-12-05 17:30:21 // 私に忍び寄るのをやめてください、ありがとう #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <utility> #include <algorithm> #include <cmath> #include <climits> #include <iomanip> #include <queue> #include <stack> using namespace std; typedef long long ll; const int INF = (1<<30)-1; const ll LINF = 1e18; #define r...
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define PI 3.14159265359 #define pb push_back #define mp make_pair #define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define IG cin.ignore(numeric_limits<streamsize>::max(),'\n'); #define ll long long int #define ull unsigned long lo...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; ++i) #define ll long long template <typename T> bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;} const ll MOD = 1e9+7; const ll LINF = 1...
#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 int #define mp(a,b) make_pair(a,b) #define vi vector<int> #define mii map<int,int> #define mpi map<pair<int,int>,int> #define msi map<string,int> #...
#include <bits/stdc++.h> #define ll long long #define vec vector #define pii pair<int, int> using namespace std; const long long MAXVAL = (long long) 1e18 + 1; //const long long MOD = 1000000007ll; const long long MOD = 998244353ll; const int INF = 1000000001; long long poww(int x, long long pow) { if (pow == 0l...
#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 = 2e5+5; const int MOD = 1e9 + 7; const i...
#include <iostream> #include <algorithm> #include <tuple> #include <vector> #include <string> #include <queue> #include <cmath> #include <set> #include <map> #include <cassert> using namespace std; using ll = long long; struct UnionFind { vector<int> par; UnionFind (int n) : par(n, -1){} int root(int x){ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll n, x; cin >> n >> x; vector<ll> v(n); vector<ll> p(n); rep(i, n) cin >> v.at(i) >> p.at(i); ll ans = -1; x *= 100; ll sum = 0; rep(i, n) { ...
//#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<map> #include<cmath> #include<cctype> #include<vector> #include<set> #include<queue> #include<algorithm> #include<sstream> #include<ctime> #include<cstdlib> #define X first #define Y second #define L (u<<1) #define...
#include <bits/stdc++.h> #define ll long long int #define ld long double #define f first #define s second #define pb push_back #define eb emplace_back #define mk make_pair #define mt make_tuple #define MOD 1000000007 #define fo(i,a,b) for(i=a;i<b;i++) #define foe(i,a,b) for(i=a;i<=b;i++) #define all(x) x.begin(), x.end...
/* Credit_Card_CRD */ #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 <alg...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for(ll i = 0; i < (ll)(n); ++i) #define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i) 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=...
//#undef DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; const ll llinf = (1ll<<61)-1; #define sz(a) int(a.size()) #define all(x) begin(x), end(x) #ifdef DEBUG const int DEBUG_END = 26; #define DOS cout #include <debug.h> #else #define bug(args...) void() #define cbug(a, args...) #endif #defin...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define Rep(i,n) for(int i = 1; i <= n; i++) #define sz(x) int(x.size()) #define All(v) v.begin(), v.end() #define rAll(v) v.rbegin(), v.rend() #define YesorNo(a) printf(a ? "Yes\n" : "No\n") #define endl '\n' #define fi first #de...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a,b,c; cin>>a>>b>>c; ll ans,m=998244353; ll x=(a*(a+1)/2); ll y=(b*(b+1)/2); ll z=(c*(c+1)/2); ll d=((x%m)*(y%m))%m; ll e=((d%m)*(z%m))%m; cout<<e; //951633476 }
#include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std; using ll = long long; int main(){ ll k,n,m; cin >> k >> n >> m; vector<ll> a(k); vector<ll> b(k); for(int i = 0;i < k;i++){ cin >> a[i]; } for(int i = 0;i < k;i++){ b[i] = (m * a[...
#include<iostream> #include<vector> #include<algorithm> //#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define sort(a) sort(a.begin(),a.end()) #define reverse(a) reverse(a.begin(),a.end()) int main(){ ios::sync_with_stdio(false); ...
#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 rsort(a) {sort(all(a));reverse(all(a));} #define pb emplace_back #define eb emplace_back #define lb(v,k) (lower_bou...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=3e5+500; int gti(void) { char c=getchar(); int ret=0,st=1; for (;!isdigit(c)&&c!='-';c=getchar()); if (c=='-') st=-1,c=getchar(); for (;isdigit(c);c=getchar()) ret=ret*10+c-'0'; return ret*st; } int cnt[N]; int main(void) { int n=gt...
#include<set> #include<ctime> #include<cstdio> #include<cctype> #include<vector> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; const int N=1e4+7; int read(){ char c; int x=0,f=1; while(!isdigit(c=getchar())) f-=2*(c=='-'); while(isdigit(c)){ x=x*10+f*(c-48); c=getchar(); } ret...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include <bits/stdc++.h> using namespace std; template <unsigned long long mod> class modint { public: unsigned long long v; modint(const long long x = 0) : v(x % mod) {} modint operator+(const modint rhs) { return modint(*this) += rhs; } modint operator-(const modint rhs) { return modint(*this) -= rhs; } modint...
// // main.cpp // Atcoder1 // // Created by Hamske on 2020/09/17. // Copyright © 2020 Author. All rights reserved. // #include <iostream> #include <vector> #include <queue> #include <algorithm> #include <string> #include <sstream> using namespace std; //#define pb push_back //#define mp make_pair #define fi firs...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #define RE...
#include <iostream> using namespace std; int main() { int A,B; cin>>A>>B; int x=(2*A+100)-B; cout<<x; return 0; }
#include <bits/stdc++.h> using namespace std; using namespace chrono; #define ll long long #define print(a) \ for (auto x : a) \ cout << x << " "; \ cout << endl #define print_upto(a, n) \ for (ll i = 1; i <= n; i++) \ cout << a[i] << " "; \ cout << endl #define ...
/* @author : ashnove */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define lld long double #define F first #define S second #define Th third // #define endl "\n" #define nl cout << endl; #define pb push_back #define f(i, a, b) for (ll i = a; i < b; i++) #define what_is(x) cerr << #x <<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mii map <int, int> #define mll map <ll, ll> #define pii pair <int, int> #define pll pair <ll, ll> #define vi vector <int> #define vd vector <double> #define vll vector <ll> #define fi first #define se second #define si set ...
#include<bits/stdc++.h> using namespace std; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args&&... args) { const char ...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define N 200100 #define MOD 1000000007 //998244353 #define ll long long #define rep(i, n) for(int i = 0; i < n; ++i) #define rep2(i, a, b) for(int i = a; i <= b; ++i) #define rep3(i, a, b) for(int i = a; i >= b; --i) #define eb emplace_back #de...
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i<(n); ++i) #define all(a) a.begin(), a.end() using namespace std; using P = pair<int, int>; using ll = long long; using vi = vector<int>; using vv = vector<vi>; //const int mod = 1000000007; const int mod = 998244353; struct UnionFind{ vector<int> d; Un...
#include <iostream> #include <vector> #include <numeric> #include <algorithm> #include <climits> constexpr int SINT_MAX = std::numeric_limits<int>::max(); constexpr int SINT_MIN = std::numeric_limits<int>::min(); using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; using vll = ve...
// atcoder/abc186/F/main.cpp // author: @___Johniel // github: https://github.com/johniel/ #include <bits/stdc++.h> #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) using namespace std; template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ...
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define DEBUG #define i...
#include <bits/stdc++.h> using namespace std; int main(){ int T, ans, howlong; string S, Spoint, comppoint; cin >> T; for(int i = 0; i < T; i++){ cin >> S; howlong = S.size(); if("atcoder" < S){ ans = 0; }else{ for(int j = 0; j < howlong; j ++){ Spoint = S.at(j); if(...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ll long long int main(){ int n; cin >> n; vector<string> s(n); for(int i=0;i<n;i++){ cin >> s.at(i); } ll int ans = 1; for(int i=0;i<n;i++){ if(s.at(i) == "OR"){ ll a = pow(2,i+1); ans += a; } } cou...
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <iomanip> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #define rep(i,n) for(int i=0;i<n;i++) #define repn(i,n) for(int i=1;i<=n;i++) #def...
#include<bits/stdc++.h> using namespace std; #define ll long long #define dd double #define endl "\n" #define pb push_back #define all(v) v.begin(),v.end() #define mp make_pair #define fi first #define se second #define vll vector<ll> #define pll pair<ll,ll> #define fo(i,n) for(int i=0;i<n;i++) #define fo1(i,n) for(int...
#include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<string> #include<sstream> #include<queue> #include<list> #include<stack> #include<bitset> #include<cmath> #include<map> #include<functional> #define int long long #define IO ios::sync_with_stdio(false) #define ll int using namespace std;...
#include<bits/stdc++.h> #define fo(i,n) for(int i=0;i<n;i++) #define dsort(arr,n) sort(arr, arr + n, greater<int>()) #define vsortd(a) sort(a.begin(), a.end(), greater<double>()) #define vsort(a) sort(a.begin(), a.end()) #define dbg(x) cout<<#x<<'='<<(x)<<endl; #define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<...
#define _CRT_SECURE_NO_WARNINGS #define _SCL_SECURE_NO_WARNINGS #include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <que...
#include <bits/stdc++.h> #define endl "\n"; #define inf 1000000000000000; using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int,int>; using pl = pair<ll,ll>; using pd = pair<db,db>; using vi = vector<int>; using vii = vector<pi>; using vll = vec...
#include <bits/stdc++.h> #include <cstdlib> #include <algorithm> using namespace std; int main() { long k; string s, t; cin >> k; cin >> s >> t; int c[10] = {0}; int d[10] = {0}; for(int i = 0; i < 4; i++){ int ss = s[i] - '0'; int tt = t[i] - '0'; c[ss]++; ...
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <stack> #include <math.h> #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define ...
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int t, n; cin >> t >> n; bool vis[100005]; for (int i = 0; i < 100005; i++) vis[i] = false; for (int i = 0; i <= 100000; i++) { int x = ((100+t)*i)/100; ...
#include <bits/stdc++.h> using namespace std; int main(){ long long t, N; cin >> t >> N; long long n = 100 * N / t; if(100 * N % t != 0) n++; n += (N - 1); cout << n << endl; }
#include <bits/stdc++.h> #define IO ios::sync_with_stdio(NULL) #define sc(z) scanf("%d", &(z)) #define _ff(i, a, b) for (ll i = a; i <= b; ++i) #define _rr(i, a, b) for (ll i = b; i >= a; --i) #define _f(i, a, b) for (ll i = a; i < b; ++i) #define _r(i, a, b) for (ll i = b - 1; i >= a; --i) #define mkp make_pair #defin...
#include<bits/stdc++.h> #define rep(i,n) for (int i=0; i<n; i++) #define REP(i,x,n) for (int i=x; i<n; i++) #define P pair<int,int> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; #define T tuple<int, int, int> const int MAX_N = 2e5; vvi G(MAX_N); void reveal(int v, int cnt...
#include <bits/stdc++.h> using namespace std; int main(){ int N, M, Q; cin >> N >> M >> Q; vector<pair<int, int>> VW(N); for(int i=0; i<N; i++){ int w, v; cin >> w >> v; VW[i] = {v, w}; } sort(VW.rbegin(), VW.rend()); vector<int> X(M); for(int i=0; i<M; i++) cin ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define FOR(i,n,m) for(int i=(n);i<(m);i++) #define REP(i,n) for(int i=0;i<(n);i++) #define REPR(i,n) for(int i=(n);i>=0;i--) #define all(vec) vec.begin(),vec.end() using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; us...
#include <bits/stdc++.h> using namespace std ; const int MAX = 2004 ; int arr[MAX] ; int n ; map<int , int>mp ; vector<int>v ; void factorize(int x) { for(int i = 1 ; i * i <= x ; ++i) { if(x % i == 0) { mp[i] = __gcd(mp[i] , x) ; v.push_back(i) ; if(x / i != i) mp[x / i] = __gcd(mp[x / i] , x)...
#include <bits/stdc++.h> using namespace std; using namespace chrono; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif int main() { int64_t n; cin >> n; vector<int64_t> cs(n), as(n - 1), bs(n - 1); for (auto &&c : cs) { cin >> c; c--; } for (int64_t i = 0; i < n - 1; i...
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<vector> #include<functional> #include<algorithm> #include<stdlib.h> #include<string> #include<string.h> #define _USE_MATH_DEFINES #include<math.h> #include<deque> #include<set> #include<map> #include<queue> #include<list> #include<iostream> #include <bitset> us...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #include <chrono> using namespace std; #define forr(i,n) for(int i = 0 ; i < n ; i++) #define forr1(i,n) for(int i = 1 ; i <= n ; i++) #define pb push_bac...
#pragma region Region_1 #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() using ll = long long; using ...
#include<bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #define endl "\n" #define pb push_back #define ll long long #define d1(x) cerr << #x << "--> " <...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <set> using namespace std; long long int L, R; long long int ans = 0; int p[1000006]; vector<int>V; long long int num[1000006]; int c[1000006]; vector<int> PRIME(int k) { vector<int> ret; for (auto y : ...
#include<iostream> #include<queue> using namespace std; int main() { string s,t; long long n , ans=0 , sone=0 , tone=0 , erase=0; cin>>n>>s>>t; queue<int> que; for(int i=0;i<n;i++) { if(s[i]=='1'&&erase>0){ ans+=i-que.front(); que.pop(); erase-- , s[i]='0'; } if(s[i]=='1') sone++; if(t[i]=='1'...
#include <bits/stdc++.h> #include <time.h> #define rep(i, n) for(int i=0;i<(int)(n);i++) #define ALL(a) (a).begin(),(a).end() using namespace std; using ll=long long; typedef pair<int,int> P; bool LOCAL_TEST = false; int h[30][30],v[30][30]; double priority[30][30]; vector<string> paths; map<int,char> mp; inline void...
// Problem: B - Abbreviate Fox // Contest: AtCoder - AtCoder Regular Contest 108 // URL: https://atcoder.jp/contests/arc108/tasks/arc108_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #define ll long long #define pii pair<int,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; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937/*_64*/ rng(chrono::ste...
#include "bits/stdc++.h" #define rep0(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var)) #define rep1(var,cnt) for(int (var)=1; (var)<(int)(cnt); ++(var)) #define repi(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var)) #define Yn(flag) cout<<(flag?"Yes":"No") #define pre(var) cout<<fixed<<setprecision(var...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define rep2(i,n) for (int i=1; i<(n); i++) using ll = long long; using P = pair<int,int>; int main() { int a,b,x,y; cin >> a >> b >> x >> y; int fast = min(y,2*x); int dist = abs((2*b+1)-(2*a)); int ans = (dist/2)*fast+x; ...
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 2e5+8, inf = 1e18+9, mod = 998244353; struct node { int a; char c; } a[maxn]; int n, m; void solve() { int i, j; cin >> n; n *= 2; for (i = 1; i <= n; i++) cin >> a[i].a >> a[i].c; sort(a + 1, a + n + 1, [](node &o...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define min3(a, b, c) min(a, mi...
#include <bits/stdc++.h> #include<tuple> #pragma GCC optimize("Ofast") using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vecto...
/** * Dont raise your voice, improve your argument. * --Desmond Tutu */ #include <bits/stdc++.h> using namespace std; const bool ready = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); return true; }(); using ld=long double; const ld PI = acos((ld)-1); using ll= ...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define x1 first #define y1 second #define frb(i,a,b) for(ll (i)=(a);(i) <= (b); (i)+=(i)&-(i)) #define rfrb(i,a) for(ll (i)=(a);(i) > 0;(i)-=(i)&-(i)) #define fr(i,a,b) for(ll (i) = (a); (i) <= (b); (i)++) #define rep(i,c) for(auto ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1000000007; // const int MOD = 998244353; struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() { return mint(-x); } mint operator+=(mint rhs) { x += rhs.x; if (x >= MOD) x -= MOD; return *this; } ...
#include<bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; void E(){ int n; cin>>n; vector<int> elems; ll sum = 0; ll res = 0; for(int i = 0; i < n; i++){ int elem; cin>>elem; sum += elem; elems.push_back(elem...
#include<bits/stdc++.h> #define ll long long #define mod 998244353ll using namespace std; ll mem[5003][5003], inv; char str[5003][5003]; int n, m; ll dp(int x, int y) { if(x==n-1 && y==m-1)return 1; if(x==n || y==m)return 0; if(mem[x][y]!=-1)return mem[x][y]; if(!str[x][y])mem[x][y]= (((2ll*(dp(x+1, y)...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb p...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; using namespace __gnu_pbds; #define endl "\n" #define fi first #define se second #define pb push_back...
//Codeforcesで128bit整数を使いたいとき //→__int128_tを使う&GNU C++17 (64)で提出する //インクルードなど #include <iostream> // cout, endl, cin // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, mak...
/**So..a**/ #include<bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long int #define B_ begin() #define E_ end() #define all(a) a.begin(), a.end() #define NL_ "\n" #define F first #define S second #define FF first.first #define FS first.second #de...
// Problem: D - Cooking // Contest: AtCoder - AtCoder Beginner Contest 204 // URL: https://atcoder.jp/contests/abc204/tasks/abc204_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> #define ll long long int #define vl vector<ll> #define pl pair<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<vi> vvi; typedef vector<pll> vll; typedef vector<vl> vvl; #define fori(i, n) for (in...
// #include "pch.h" #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <string> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <ctime> #include <cassert> #include <fstream> #include <stack> #include ...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int N, A[105], B[105]; int out_pos[205]; int IN[205], OUT[205]; bool dp[205]; int check[205]; int tmp_in[205], tmp_out[205]; /*bool IsPossible(int I, int J, int K) { for (int i = I; i <= J; i++) { check[i] = 0; t...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <map> #include <queue> #include <iomanip> #include <set> #include <tuple> #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std...
#include<bits/stdc++.h> #include <functional> using namespace std; int H, W; int dp[2009][2009], score[2009][2009]; char c[2009][2009]; int main() { cin >> H >> W; for(int i=1; i<=H; i++) { for(int j=1; j<=W; j++) { cin >> c[i][j]; if(c[i][j] == '+') score[i][j] = 1; ...
#include <bits/stdc++.h> using namespace std; __attribute__((constructor)) void fast_io() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { int r, c; cin >> r >> c; vector<int> a(r * (c - 1)), b((r - 1) * c), dist(2 * r * c, INT_MAX); for (int i = 0; i < r; ++i) fo...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++) #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend...
#include <iostream> #include <string> #include <vector> #include <queue> #include <utility> #include <algorithm> #include <cmath> #include <map> using ll=long long; using namespace std; int main(){ int N; cin>>N; N*=2; vector<ll> A(N); for(int i=0;i<N;i++){ cin>>A[i]; } vector<ll>...
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define pb push_back #define endl '\n' #define snd second #define fst first #define fastio cin.tie(NULL),cout.sync_with_stdio(true) //typedef long long int ll; typedef unsigned long long int ull; typedef vect...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define int long long #define ll long long #define all(v) v.begin(...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; vector<vector<ll>> prod_mat(vector<vector<ll>> a1, vector<vector<ll>> a2){ vector<vector<ll>> m(3, vector<ll>(3)); for(int i=0; i<3; ++i){ for(int j=0; j<3; ++j){ for(int k=0; k<3; ++k){ m[i][j] += a1[i][k] ...
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sz(x) int(x.size()) #define...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0 ; i < (n); i++) using namespace std; int main() { int n; cin >> n; int a[n], b[n]; REP(i, n) cin >> a[i] >> b[i]; int res = 1e6+1; REP(i, n) REP(j, n) res = min(res, (i==j) ? a[i]+b[j] : max(a[i],b[j])); cout << res << '\n'; return 0; }
#include<iostream> #include<iomanip> #include<algorithm> #include<stack> #include<queue> #include<string> #include<cmath> #include<vector> #include<map> #include<cstdio> #define pb push_back using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; const int maxN = 1e6 + 1; con...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x...
#include<bits/stdc++.h> #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <set> #include <algorithm> #define ll long long using namespace std; ll mod = 1e9+7; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll n,x; cin >> n >> x; x*=100; ll i=1; ll ans=0; ...
#include <bits/stdc++.h> using namespace std; using ll = long long;//大きなint型 using P = pair<int,int>;//pair型の型エイリアス #define rep(i,n) for (int i = 0; i < (n); ++i)//iをnまですすめる。 int main(){ int n; int sum = 0; cin >> n; vector<int> a(n),b(n); rep(i,n){ cin >> a.at(i); } rep(i,n){ ...
#include<bits/stdc++.h> #define ll long long int #define mod 1000000009 #define pb push_back #define mp make_pair #define endl '\n' #define N 100005 using namespace std; int a[N],p[N]; //https://www.geeksforgeeks.org/program-decimal-octal-conversion/ int decToOctal(int n) { int f= 1; // array to store octal nu...
#include <bits/stdc++.h> using namespace std; #define ar array #define ll long long const int MAX_N = 1e5 + 1; const ll MOD = 1e9 + 7; const ll INF = 1e9; void solve() { int a,b,c; cin >> a >> b >> c; if (a==b){ cout << "=\n"; return; } if(c%2==0){ if(abs(a)==abs(b)){ ...
#include<iostream> #include<cstring> #include<cmath> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<deque> #include <algorithm> using namespace std; #define mem(a,b) memset(a,b,sizeof a) #define PII pair<int,int> #define ll long long #define ull unsigned long long #define ft fir...
/*input */ #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #inclu...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x, y, a, b; cin >> x >> y >> a >> b; ll exp = 0; while (x * (a - 1) < b) { if (x >= LONG_LONG_MAX / a) { break; } x *= a; if (x >= y) { cout << exp << endl; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #ifdef ENABLE_DEBUG #define dump(a) cerr<<#a<<"="<<(a)<<endl #define dumparr(a,n) cerr<<#a<<"["<<(n)<<"]="<<(a[n])<<endl #else #define dump(a) #define dumparr(a,n) #e...
#include <bits/stdc++.h> using namespace std; template<int M> struct static_mint { static_assert(0 < M, "Module must be positive"); int val; static_mint() : val() {} static_mint(long long x) : val(x % M) { if (val < 0) val += M; } static_mint pow(long long n) const { static_mint ans = 1, x(*this); for (; ...
#include <iostream> using namespace std; int main(void) { int n, i, j, min2; int m = 0; int a[100010], p[100010], x[100010], min[100010]; scanf("%d", &n); for(i= 0; i < n; i++) { scanf("%d%d%d", &a[i], &p[i], &x[i]); if(x[i] - a[i] > 0) { m++; min[m] = p[i]; } } if(m == 0){puts("-1"); retur...
#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; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T, typename U> using ordered_m...
#include<bits/stdc++.h> using namespace std; int main(){ int N,i,sum=0; cin >> N; for(i = 1;sum < N;){ sum += i; i++; } cout << i - 1 << endl; }
// time-limit: 2000 // problem-url: https://atcoder.jp/contests/abc198/tasks/abc198_a /* ++[---------->+<]>.-[------>+<]>-.++++++++.+++++.-[->+++++<]>-.-[--->++<]>--.+.[--->+<]>---.[->+++<]>++.++++++.-------.++++++.--[--->+<]>.-[->+++<]>-..+++++++++++++.[----->++<]>.------------.+[----->+<]>.--------.+++++++++++++.----...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18; void print() { cout << endl; } template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);} void print0() {} template...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define F first #define S second typedef long long ll; typedef vector< int > vi; typedef vector< ll > V; typedef unordered_map<int, int > mp; #define debug cout << -1 << e...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; #define fi first #define se second #define pb push_back #define pf push_front #define mp make_pair const int N = 2e5 + 5; const int MOD = 1e9 + 7; const int INF = 2e9; const int dr4[] = {1, -1, 0, 0}; const int dc4[] = {0,...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { // your code goes here ll n; cin>>n; set<ll> output; for(ll i = 1; i*i <= n; i++){ if((n%i)!=0){ continue; } else { output.insert(i); output.insert(n/i); } } for(auto itr: output) cout<<itr<<endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; string s; cin >> s; auto reduce = [&](vector<int> &v) -> void { for (int i = 1; i < v.size(); i++) { v[i - 1] = (6 - v[i - 1] - v[i]) % 3; } v.pop_back(); }; vector<int> a(s....
#include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" using namespace std; #pragma GCC optimize("O3","unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC target("avx2") #define sync ios_base::sync_with_stdio(0); ci...
/************************************************************************* > File Name: a.cpp > Author: Amano Sei > Mail: amano_sei@outlook.com > Created Time: 2020年11月15日 星期日 21时00分49秒 ************************************************************************/ #include <cstdio> int main(){ int x; ...
#include<bits/stdc++.h> #define maxn 100005 #define mod 1000000007 using namespace std; long long check(long long k) { return (k+1)*k/2; } int main() { long long n; cin>>n; long long now=0; for (long long step=1<<30;step>=1;step=step>>1) if (check(now+step)<=n+1) now+=step; cout<<(n+1-now)<<endl; }
//header{{{ #pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/tag_and_trait.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace __gnu_pbds; using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define...
#include<iostream> using namespace std; int main() { int A,B,temp,X=0,Y=0; cin >> A >> B; temp = A + B; X = temp /2; Y = A - X; cout << X << " "<< Y <<endl; return 0; }