code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> #define loop(s, e, i) for (int i = s; i < e; ++i) #define print(s) cout << s << endl; #define DIV 1000000007 using namespace std; typedef long long ll; typedef unsigned long long ull; const ll INF = 1e18+7; ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ ll floordiv(ll a, ll b) { retu...
#include<bits/stdc++.h> using namespace std; long long n,a; int main() { cin>>n>>a; for(int i=1;i<=a;i++) { if(n%200==0) n=n/200; else n=n*1000+200; } cout<<n; }
#include <bits/stdc++.h> #define speedup \ ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr), \ cout.precision(12) using namespace std; #ifndef ONLINE_JUDGE #define eprintf(...) fprintf(stderr,__VA_ARGS__), fflush(stderr...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int #define ld long double #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define intarr(arr, n) ll arr[n]; for (ll i = 0; i < n; i++) cin >> arr[i] #define inpvec(v,n) for(ll i=0;i<n...
#include <bits/stdc++.h> #include <algorithm> using namespace std; //typedef long long int ll; typedef unsigned long long int ll; //typedef pair<ll, ll> pd; const int mod = 1e9 + 7; //#define int long long int gcd(int a, int b){ if (b == 0) return a; return gcd(b, a % b); } void solve(){ ...
#include <iostream> #include <deque> #include <climits> int search(int lhs, const std::deque<int>& rhs) { if (rhs.size() == 0) { return lhs; } int min = INT_MAX; for (int i = 1; i <= rhs.size(); i++) { int n = 0; auto copied = rhs; for (int j = 0; j < i; j++) { ...
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> typedef long long LL; const LL inf = 2e18; using namespace std; int T, x, y, p, q; LL ans; LL gcd(LL a, LL b) { if (!b) return a; return gcd(b, a % b); } LL exgcd(LL a, LL b, LL &x, LL &y) { LL g = a; ...
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<<endl #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<long long, long long> pl; #define all(x) (x).begin(), (x).end() #define each(x, a) for (auto& x : a) #define rep(i, b, e) for (int i=(b); i<(e); ++i) #define repi(i, b, e, c) for (int i=(b); (c)>0?i<(e):i>(e); ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define x first #define y second #define LL long long #define LD long double #define y1 ___y1 #define next ___next #define left ___left #define right ___right #define pii pair<int, int> #define pll pair<LL, LL> #define vi vector<int...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define forn(i,x,n) for(int i = x;i <= n;++i) typedef pair<int,int> pii; #define forr(i,x,n) for(int i = n;i >= x;--i) #define Angel_Dust ios::sync_with_stdio(0);cin.tie(0) #define x first #define y second const int N = 105,MOD = 1e9+7; pii edges[N * ...
#include <iostream> #include<bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define endl "\n" #define vi vector<int> #define vii vector<pair<int,int>> #define pb push_back using namespace std; using ll = long long; const ll mod = 1e9+7; ll fac[1000001]; void pre(){ fac[0]=fac[1]=1; for(int i=2;i<=100000...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll n,i; cin>>n; std::vector<ll> v1; std::vector<ll> v2; ll x; for(i=0;i<n;i++) { cin>>x; v1.push_back(x); } for(i=0;i<n;i++) { cin>>x; v2.push_back(x); } ll sum=0; for(i=0;i<n;i++) { sum=sum+v1[i]*v2[i]; } if(sum==0...
/////////////////////////////// /// Let's Get AC!!! /// /////////////////////////////// #include<bits/stdc++.h> using namespace std; typedef long long ll; #define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i] #define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl #define rep(i, ...
#include <algorithm> #include <iostream> #include <stack> #include <queue> #include <math.h> #include <cmath> #include <string> #include <iterator> #include <map> #include <set> #include <iomanip> #include <vector> #include <cstdint> #include <time.h> using namespace std; using ll = long long; using ld = long double; u...
#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 <cstdio> namespace Main { namespace Source { typedef unsigned int uint; static inline const uint qpow(uint b, uint e, const uint mod) { uint r(1); while (e) { if (e bitand 1) r = 1ull * r * b % mod; b = 1ull * b * b % mod, e >>= 1; ...
// Problem : D - Sky Reflector // Contest : AtCoder - AtCoder Regular Contest 113 // URL : https://atcoder.jp/contests/arc113/tasks/arc113_d // 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 #define IOS std::...
#include <iostream> using namespace std; int main(void) { int x, y; cin >> x >> y; int result = abs(x - y); if (result < 3) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int int fact(int a){ int b=1; for(int i=2;i<=a;i++){ b*=i; } return b;} int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,m; cin>>n>>m; cout<<n/m<<endl; return 0; }
/* ALLAH IS ALMIGHTY ******BISMILLAHIR RAHMANIR RAHIM.****** ALLAH IS ALMIGHTY ``````````````````````````````` AUTHOR: ANISUR RAHAMAN BSMRSTU(SHIICT) ...
//#include <bits/stdc++.h> #include <iostream> #include <iomanip> #include <math.h> #include <cmath> #include <algorithm> #include <climits> #include <functional> #include <cstring> #include <string> #include <cstdlib> #include <ctime> #include <cstdio> #include <vector> #include <stack> #include <queue> #include <dequ...
#include <iostream> #include <algorithm> #include <stack> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #define aldgebu return #define ff first #define sc second #define pb push_back #define pii pair <int,int> #define ll long long int #define pll pair<ll,ll> #defin...
#include "bits/stdc++.h" using namespace std; using LL = long long; constexpr int N = 1e5 + 5; int main() { cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; cout << s[1] << s[2] << s[0] << endl; }
#include <bits/stdc++.h> using namespace std; #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() 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) { ...
#include<bits/stdc++.h> using namespace std; int main() { double a,b; cin>>a>>b; cout<<(a-b)/a*100; }
using namespace std; #include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define ll long long int #define nl "\n" #define forf(i,a,n) for(ll i=a;i<=n;i++) #define forb(i,b,n) for(ll i=b;i>=n;i--) #define pb push_back #define vll vector<ll> #define all(qw) qw.begin(),qw.end() #define ...
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; int main(){ int a,b; cin>>a>>b; if(a==b){ for(int i=1;i<=a;i++) cout<<i<<" "; for(int i=1;i<=a;i++) cout<<(-1)*i<<" "; } else { if(a>b){ for(int i=1;i<=a;i++) cout<<i<<" "; int remaining = 0; for(int i=1;i...
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define pb push_back #define eb emplace_back #define fi first #define se second using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<ll, ll>; template <class T> using V = vector<T>; template <class T> inline void chmin...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; typedef long long ll; int main() { int N, M, X; cin >> N >> M; vector<bool> A(1001, false), B(1001, false); rep(i, N) { cin >> X; A[X] = true; } rep(i, M) { cin >> X; ...
#include<bits/stdc++.h> using namespace std; #define int long long const int mod=1000000007; int a[3005],s[3005],sum[3005][3005],dp[3005][3005]; signed main() { int n,i,j,ans=0; cin>>n; for(i=1;i<=n;i++) { cin>>a[i]; s[i]=s[i-1]+a[i]; } for(i=1;i<=n;i++) { for(j=i;j>1;j--) { dp[i][j]=sum[j][s[i]%j]; ...
#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 <iostream> #include <cmath> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #inc...
/// kazuki08 /* #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/...
#include<bits/stdc++.h> using namespace std; #define int long long #define ull unsigned long long #define ll long long #define M 998244353 #define pb push_back #define p_q priority_queue #define pii pair<ll,ll> #define vi vector<ll> #define vii ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, w; cin >> n >> w; vector<ll> imos(2e5 + 10, 0); for (int i = 0; i <n; i++) { ll s, t, p; cin >> s >> t >> p; imos.at(s) += p; imos.at(t) -= p; } for (int i = 1; i < 2e5 + 10; i++) imos.at(i) += imo...
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b){ return a*b/gcd(a,b); } ll Solve(ll n){ ll ans = 1; for (ll i=2;i<=n;++i){ ans = lcm(i,ans); }return ans + (ll)1; } int main(){ ll n;scanf("%lld",&n); printf...
#include <bits/stdc++.h> using namespace std; int main() { string S, T; cin >> S; bool isReversed = false; for(int i=0; i<S.size(); i++) { if(S[i] == 'R') { isReversed = !isReversed; } else { if(!isReversed) { if(!T.empty() && T[T.size()-1] == S[i]) { T.erase(T.size()-1)...
#include<bits/stdc++.h> #define rep(i,n,m) for(int i = (n); i <(m); i++) #define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--) #define DEBUG #if defined DEBUG #define TRACE( format, ... ) printf( "%d\t" format, __LINE__, __VA_ARGS__ ) #define TRACES( format, ... ) printf( "%d\t:" format, __LINE__) #else ...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) using ll = long long; using P = pair<int,int>; using edge = struct { int to; int cost; }; const int INF = 1e9; int n,m; vector<int> a,b,c; vector<vector<edge>> g; void solve(int s) { vector<int> d(n+5, INF); priority_queue<P, vect...
#include <iostream> #include <vector> #include <tuple> #include <deque> #include <set> #include <map> #include <cmath> #include <string> #include <iomanip> #include <algorithm> #define int long long #define all(x) (x).begin(), (x).end() #define allr(x) (x).rbegin(), (x).rend() using namespace std; const int INF = 1e1...
#include <bits/stdc++.h> #define int long long #define double long double using namespace std; int dp[1<<17][17]; int x[20],y[20],z[20]; int dis[18][18]; int n; signed main(){ scanf("%lld",&n); for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&x[i],&y[i],&z[i]); for(int i=1;i<=n;i++){ dis[i][i]=0; for(int j=...
#include<bits/stdc++.h> #include<vector> #include<set> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define T int t, q=0; scanf("%d", &t); while(q++<t) #define ll long long #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ll x,y,z,a=0,b=0,c=0,d=0,sum,ans...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef vector<ll> vl; #define pb ...
//Never stop trying #include "bits/stdc++.h" using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) typedef long long ll; #define int ll typedef string str; typedef long double ld; typedef pair<int, int> pi; #define fi first #define se second typedef vector<int> vi; typedef vector...
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define lowbit(x) ((x) & -(x)) using namespace std; using ll = long long; using pii = pair<int, int>; constexpr double eps = 1e-8; constexpr int NINF = 0xc0c0c0c0; constexpr int INF = 0x3f3f3f3f; constexpr ll mod = 1e9 + 7; constexpr ll...
#include <bits/stdc++.h> #include <vector> #include <locale> #include <string> #include <stdio.h> #include <math.h> using namespace std; int main() { int a1, a2, a3; cin >> a1 >> a2 >> a3; if(a3-a2 == a2-a1) cout << "Yes" << endl; else if(a2-a3 == a3-a1) cout << "Yes" << endl; else if(a3-a1 == a1-a2) cout <...
#include <bits/stdc++.h> using namespace std; #define __hh__ ios_base::sync_with_stdio(false); cin.tie(0); #define ll long long #define all(x) (x).begin(),(x).end() #define vi vector<int> #define vl vector<long long> #define vs vector<string> #define vd vector<double> #define vvi vector<vector<int>> #define vvl vector<...
#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; using ll = long long; ll N, C; vector<pair<ll, ll>> imosu; int main() { cin >> N >> C; imosu.push_back(make_pair(0, 0)); ll a, b, c; for (int i = 0; i < N; ++i) { cin >> a >> b >> c; imosu.push_back(make_pair(a, c)); imosu.push_back(make_pair(b+1, -c...
#include <bits/stdc++.h> #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define INF 9999999999999999 #define rep(i,m,n) for(ll i = m;i < n;i++) #define rrep(i,m,n) for(ll i=m-1;i>=n;i--) #define pb(n) push_back(n) #define UE(N) N.e...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long int ull; #define pii pair<ll,ll> #define vi vector<ll> #define vii vector<pii> #define endl "\n" #define pb push_back #define sq(a) ((a)*(a)) #define sz(x) (ll)(x).size() #define all(x) (x).begin(), (x).end() #define rall(a) ...
#include <algorithm> #include <iostream> #include <iterator> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<long long> h(n); for (int i = 0; i < n; i++) { cin >> h[i]; } vector<long long> w(m); for (int i = 0; i < m; i++) { cin >> w[i]...
/* Three things which are very important -- Violence - Speed - Momentum */ #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 oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_updat...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; std::ostream& operator << (std::ostream& dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value<0?-value:value; char buffer[128]; char* d = std::end(buffer); do { ...
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; cout<<s[1]<<s[2]<<s[0]<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; #define ll long long int #define mp make_pair #define pb push_back #define ff first #define ss second #define fast ios_base::sync_with_stdio(false);cin.tie(0); #define MOD 1000000007 #define ll_MAX 19223372036859 #define endl "\n" ll fast_expo(ll x,ll p){ if(p==0) ret...
#include<bits/stdc++.h> using namespace std; #define gc() getchar() #define pc(a) putchar(a) #define int long long inline int read() { int x=0,f=1; char c=gc(); while(c>'9'||c<'0') { if(c=='-') f=-f; c=gc(); } while(c>='0'&&c<='9') x=x*10+c-'0',c=gc(); return x*f; } int nnu[25]; inline void write(long long ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using cd = complex<ld>; vector<int> primes({2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ve...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define fi first #define se second #define ll long long #define tp top() #define fr front() #define vi vect...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long double x0,y0,r; cin>>x0>>y0>>r; //问题转换为,圆内的点,满足(x-X0)^2+(y-Y0)^2 <= R^2的解中, // 整数解的个数 //可以固定x,求解y的有效数值 //x的范围:当y=y0时,[x0-r,x0+r]; int xmin = ceil( x0-r ); in...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int to_int(string s){ bool f=false; if(s[0]=='-'){ f=true; s=s.substr(...
#include<bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define MAX 1000000000 #define ff first #define ss second #define mp make_pair #define pb push_back #define pii ...
#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> using namespace std; #define pp pair<int,int> #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++) #define ll long long #define ld long double #define all(a) (a).begin(),(a).end() #define mk make_pair ll mod=998244353; int inf=1000001000; ll INF=1e18+...
#include <bits/stdc++.h> using namespace std; #define __hh__ ios_base::sync_with_stdio(false); cin.tie(0); #define ll long long #define all(x) (x).begin(),(x).end() #define vi vector<int> #define vl vector<long long> #define vs vector<string> #define vd vector<double> #define vb vector<bool> #define vc vector<char> #de...
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define pb push_back typedef long double ld; #define fi first #define se second #define PI 3.14159265358979323846264338327950288419716939937510 #define mp make_pair #define vvl vector<vector<ll>> #define vll vector<ll> #def...
#include<bits/stdc++.h> #define x first #define y second #define PII pair<int,int> #define LL long long using namespace std; const int N=2010; int n,m; int h[N],e[N],ne[N],idx; int ans; bool st[N]; void add(int a,int b){ e[idx]=b,ne[idx]=h[a],h[a]=idx++; } void dfs(int u) { st[u]=true; for (int i=h[u];~i...
#include<bits/stdc++.h> // no of bits to store no 2e5 is 19 // 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai using namespace std; #define int long long #define mod 1000000007 #define MOD 1000000007 #define MAX 1000000000 #define inf ...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb push_back #define mp make_pair #define ff first #define ss second #define all(x) x.begin(), x.end() #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout <<...
#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 ...
// Problem: C - Swaps 2 // Contest: AtCoder - AtCoder Regular Contest 120 // URL: https://atcoder.jp/contests/arc120/tasks/arc120_c // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcc,abm,mmx,avx,avx2,tune=native") #inc...
/* * C. ORXOR.cpp * Created : 28/03/21 10.54.57 */ #include <bits/stdc++.h> using namespace std; void run_case(){ int n; cin >> n; vector<long long> v(n); for(long long &i : v){ cin >> i; } long long res = LLONG_MAX; for(int i = 0; i < (1 << (n - 1)); i++){ long long Or = 0; ...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define lli long long int #define tc int t;cin>>t;while(t--) #define all(x) x.begin(),x.end() #define f first #define s second #define pb push_back #define pi pair<int,int> #define pll pair<lli,lli...
#include<bits/stdc++.h> using namespace std; #define int long long #define vi vector<int> #define vvi vector<vector<int>> #define pii pair<int,int> #define vpii vector<pair<int,int>> #define pqueue priority_queue #define umap unordered_map #define uset unordered_set #define bits(x) __builtin_popcount((x)) #define gcd(x...
#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define sor(v) sort(v.begin(),v.end()) #define rev(s) reverse(s.begin(),s.end()) #define L long long int main() { int m; cin >> m; static const int n = m; vector<vector<L>> v(n); rep(i, n) { L x, c; cin >> x >> c; c--; v[c].p...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=1.5e6; int n, m, a[mxN], cnt[mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i=0; i<n; ++i) cin >> a[i]; for (int i=0; i<m; ++i) ++cnt[a[i]]; int cur=0; while(cur<n&&cnt[cur]) ...
#include<bits/stdc++.h> using namespace std; #define ll long long bool isPrime(ll n) { //Corner case: if(n<=1) return false; if(n<=3) return true; //This optimizes the complexity: if(n%2==0||n%3==0) return false; for(ll i=5;i*i<=n;i=i+6) { if(n%i==0||n%(i+2)==0) return false; } return true; } int main...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using n...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define ppb pop_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define pii pair...
#include<iostream> #include<cstdio> using namespace std; int main() { long long a,b,c,mod=998244353; cin>>a>>b>>c; a=(a+1)*a/2%mod; b=(b+1)*b/2%mod; c=(c+1)*c/2%mod; cout<<a*b%mod*c%mod; return 0; }
#include <cmath> #include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <vector> #include <map> #include<cstdio> #include<functional> #include <bitset> #include <iomanip> #include <cctype> #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i,a,b) for(int i=int(a...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; int main(){ string s; cin >> s; vvi eight(125, vi(10)); eight[0][0] = 3; for(int i ...
#include<bits/stdc++.h> #define REP(i,n) for (int i = 1; i <= n; i++) #define mod 1000000007 #define pb push_back #define ff first #define ss second #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define lli long long int #define INF 1000000000 #define endl '\n' using namespace std; typedef long...
#include <bits/stdc++.h> using namespace std; class UnionFind { private: int N; vector<int> PS; public: UnionFind() : N(0) {} UnionFind(int n) : N(n), PS(n, -1) {} bool unite(int a, int b) { int x = root(a), y = root(b); if (x == y) return false; if (-PS.at(x) < -PS.at(y)) swap(x, y); PS.at(...
#include<iostream> #include<iterator> #include<algorithm> #include<climits> #include<map> #include<set> #include<numeric> #include<string> #include<sstream> #define ll long long using namespace std; int main() { int h, w; cin >> h >> w; multiset<int> s; for (int i = 0; i < h*w; ++i){ int x; ...
#include <bits/stdc++.h> //#include <atcoder/all> typedef long long ll; using namespace std; //using namespace atcoder; #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) for(ll i = 0; i < (ll)n; i++) #define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++) #define REP(...) _overload(__VA_ARGS__, _rep...
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define pb push_back #define eb emplace_back #define fi first #define se second using namespace std; using ll = long long; using P = pair<ll, ll>; template <class T> using V = vector<T>; template <class T> inline void chmin(T &a, const T &b) { a = min(a, ...
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i,n) for(int i=0;i<(int)(n);i++) #define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++) #define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(i...
//https://atcoder.jp/contests/abc186/tasks/abc186_e //E - Throne #include <bits/stdc++.h> using namespace std; //如果提交到OJ,不要定义 __LOCAL #define __LOCAL typedef long long ll; ll reduce(ll a, ll mod) { return (a%=mod)<0?a+mod:a; } //finds x, y such that ax + by = gcd(a, b) ll euclidEx(ll a, ll b, ll &x, ll &y) { ...
#include<iostream> #include<cstdio> #include<algorithm> #include<queue> #include<cstring> using namespace std; int n,a[50],ans = 2147483645; inline int read() { int s = 0,w = 1; char ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-') w = -1; ch = getchar();} while(ch >= '0' && ch <= '9'){s = s * 10 +...
#include <iostream> int main() { int X, Y, Z; std::cin >> X >> Y >> Z; auto ans = (Z * Y - 1) / X; std::cout << ans << std::endl; return 0; }
#pragma region templates //#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; t...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; int main() { ll n; cin >> n; if( n%3==0 ){ cout << 0 << endl; return 0; } vector<int> a; do { a.pus...
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef unsigned long long ull; typedef unsigned uint; typedef long long ll; #define G getchar() int read() { int x=0; bool flg=false; char ch=G; for (;!isdigit(ch);ch=G) if (ch=='-') flg=true; for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48); return ...
#include "bits/stdc++.h" using namespace std; using ll=int64_t; using ld=long double; using ull=unsigned long long; template <class T> using grid=vector<vector<T>>; #define ALL(x) x.begin(),x.end() #define rep(iter,from,to) for(ll iter=from;iter<to;++iter) const ll MOD=1e9+7; const ll INF=1e17; //#####################...
// 2020-10-17 20:19:18 // clang-format off #include <bits/stdc++.h> #ifdef LOCAL #include "lib/debug.hpp" #else #define debug(...) 1 #endif #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define rep(i, n) REP(i, 0, (n)) #define repc(i, n) REPC(i, 0, (n)) #define REP(i, n, m) for (int i =...
#include <bits/stdc++.h> #define ll long long #define maxn 10006 using namespace std; ll read() { ll x = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) x = 10 * x + ch - '0'; return x * f; } void print(ll x) { ...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define lli long long int #define tc int t;cin>>t;while(t--) #define all(x) x.begin(),x.end() #define f first #define s second #define pb push_back #define vi vector<int> #define vll vector<lli> #d...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0;i < (n);i++) using namespace std; using ll = long long; using pii = pair<int,int>; const int INF = 2e9; int main(){ int n; cin >> n; vector<bool> flag(n+1); int num = 0; rep(i,n){ int a; cin >> a; flag[a] = true; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int N; cin >> N; int ans; ans = (N - 1) / 100 + 1; cout << ans << endl; }
#include<bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second #define ick cout << "ickbmi32.9\n" using namespace std; struct edge{ double w = 1; int t = 0; }; edge r[30][30], d[30][30]; int dx[]{0, 0, 1, -1}; int dy[]{1, -1, 0, 0}; char mv[]{'R', 'L', 'D', 'U'}; int g...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define NUM 2520 #define INF (1LL<<50) #define DEBUG 0 #define mp(a,b) make_pair(a,b) #define SORT(V) sort(V.begin(),V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) # VariableName #de...
#include<bits/stdc++.h> using namespace std; using ll=int64_t; template <typename T> void rVec(vector<T> &vec, const int &n){ vec.resize(n); T temp; for(T &i: vec){ cin >> i; } } template <typename T> void printVec(vector<T> &vec){ for(T &i: vec){ cout << i << " "; } cout <<...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; constexpr ll MOD = 1e9 + 7; //constexpr ll MOD = 998244353; //constexpr ll MOD = ; ll mod(ll A, ll M) {return (A % M + M) % M;} constexpr ll INF = 1LL << 60; template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return tru...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (n); i++) #define REP(i, s, n) for (long long i = (s); i <= (n); i++) #define repr(i, n) for (long long i = (n - 1); i >= 0; i--) #define REPR(i, s, n) for (long long i = (s); i >= (n); i--) #define all(v) (v).begin(), (v).end() ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // -------------------------------------------------------- template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; vector<vector<ll>> p(n, vector<ll>(5)); for (int i = 0; i < n; ++i) { cin >> p[i][0]; cin >> p[i][1]; cin >> p[i][2]; cin >> p[i][3]; cin >> p[i][4]; } l...
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define ll long long int #define pii pair<int,int> #define pll pair<long long int,long long int> #define pci pair<char,int #define mii map<int,int> #define mll map<long long int,long long int> #define mci map<char,int> #define umi...
/* * @Author: LetMeFly * @Date: 2021-03-20 20:07:22 * @LastEditors: LetMeFly * @LastEditTime: 2021-03-20 20:19:10 */ #include <bits/stdc++.h> using namespace std; #define mem(a) memset(a, 0, sizeof(a)) #define dbg(x) cout << #x << " = " << x << endl #define fi(i, l, r) for (int i = l; i < r; i++) #define cd(a) sca...
#pragma warning (disable:4996) #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define ll long long #define REP(i, n) for(int i = 0; i < n; i++) #define SET(a) ll a = 0; (void)scanf("%lld", &a); #define NMAX 100000 //提出前に変更 100000 #define MMAX 20 //int countDifference(char*, char*, int); ...
#include <bits/stdc++.h> #include <unordered_map> using namespace std; int x[10000]; int main() { int n; int cnt=1; int i,j; int lowest=1000000000; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&x[i]); lowest=min(x[i],lowest); } unordered_map<int,int> memo; for(i=0;i<n;i++) { for(j=1;j*j<=x[i]&&j<lowes...
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define INF (ll)1e18 #define mod 998244353 #define maxn 400010 ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b; priority_queue<ll> pq; void add(ll x) { pq.push(-x); ...
#include<bits/stdc++.h> using namespace std; #define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i) #define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--) #define PII pair<int,int> #define eb emplace_back #define pb push_back #define fi first #define se second #define PQ priority_queue #define lb lower_bound #def...
#include <bits/stdc++.h> using namespace std; #define rep(i,l,r) for(int i = (l); i <= (r); ++i) typedef long long ll; void fast() { ios::sync_with_stdio (0); cin.tie (0); cout.tie (0); } int a[2]; int main() { fast(); cin >> a[0] >> a[1]; int c; cin >> c; int p = c; while (a[p] >= 0) { --a[p]; p ^= 1; } ...
#include<bits/stdc++.h> using namespace std; int n,a[202020],b[202020],c[202020]; int tr[202020]; void gx(int x) { while(x<=n) { tr[x]++; x+=(x&(-x)); } } int gt(int x) { int ans=0; while(x>0) { ans+=tr[x]; x-=(x&(-x)); } return ans; } int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; a[i]+...
#include<bits/stdc++.h> using namespace std; #define For(i,a,b) for(int i=(a),(i##i)=(b);i<=(i##i);++i) #define rep(i,n) for(int i=0,(i##i)=(n);i<(i##i);++i) #define Fodn(i,a,b) for(int i=(a),(i##i)=(b);i>=(i##i);--i) #define pln puts("") #define il inline #define pb push_back() #define ff first #define ss second using...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define all(v) begin(v), end(v) #define sz(v) v.size() #define INF 1e18+999999 #define EPSILON 1e-14 template <typename T> bool chmax(T &a, cons...
#include<bits/stdc++.h> using namespace std; using int64 = long long; const int mod = 1e9 + 7; // const int mod = 998244353; const int64 infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10)...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define pb push_back #define pob pop_back #define S s...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define mod 998244353 #define MOD 1000000007 #define rep(i, n) for(ll i=0; i<(ll)(n); i++) // aのn乗を求める(modp) int modPow(ll a, ll n, ll p) { if (n == 0) return 1; // 0乗にも対応する場合 if (n == 1) return a % p; if (n % 2 == 1) return (a * modPow(a, n - 1,...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <long long> vll; typedef vector <pair<ll,ll>> vpll; #define f(i,a,b) for(ll i=a ; i<b ; i++) ll a[140000]; void arr(){ a[1]=1; f(i,1,17){ ll l=(1L<<i),r=(1L<<(i+1)); f(j,l,r) a[j]=i+1; } } int main(){ ...
#include <iostream> #include <vector> #include <utility> #include<algorithm> #include <string> #include <map> #include <cmath> #include <random> #include <tuple> #define ll long long using namespace std; int main(){ ll b; cin >> b; ll n = 100000; vector<int> pri = {2}; for(int i = 3;i < 100000;i ++){ i...
#include<iostream> #include<vector> #include<string> #define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i) #define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; template<typename T> inline bool chmax...
//I still luve you Kashish <3 #include<bits/stdc++.h> using namespace std ; #define int long long #define pb push_back #define F first #define S second #define P push #define nl "\n" #define vvi vecto...
#include<bits/stdc++.h> using namespace std; int main(){ int n; vector<int> v; vector<bool> vis; cin >> n; vis.assign(n , false); v.assign(n, 0); int input; for(int i = 0; i < n; i++) { cin >> input; v[i] = input; } long long int count = 0; for(int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int ans = 0; for (int i = 0; i<N; i++) { int A=0; cin >> A; if (A > 10) { ans = ans + A - 10; } } cout << ans << endl; }
#include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; using ll = long long; #...
#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(){ int N; cin>>N; int a; l...
# include <iostream> # include <utility> # include <iterator> # include <string> # include <stdio.h> # include <map> # include <unordered_map> # include <algorithm> # include <queue> # include <vector> # include <climits> # include <cstring> # include <set> # include <unordered_set> # include <sstream> # include <deque...
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define int long long vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}; int ans = 1000000000000000000ll; int N; int arr[100]; void fun(int cur, int val) { bool flag = true; for( int i=0; i<N; i++ ) { ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<ll> vl; typedef pair<ll, ll> pll; #define St first #define Nd second #define Pb push_back #define print_pair(p) "{" << (p).St << ", " << (p).Nd << "} " #define list_format(i, n)...
#include<bits/stdc++.h> using namespace std; #define fr(i,t) for(i=0;i<t;i++) #define fr1(i,r,t) for(i=r;i<t;i++) typedef long long int lli; typedef unsigned long long int ulli; #define inf LONG_MAX #define ff first #define ss second double pie=3.14159265358979323846; #define dbug(x) cout<<#x<<"="<<x<<endl; #define db...
/** * author: kuins_air * created: 07.05.2021 22:26:12 **/ #include <bits/stdc++.h> using namespace std; #define rep(i, r, n) for(int i = r; i < n; i++) int H, W, A[101][101]; int main() { cin >> H >> W; rep(h, 0, H) rep(w, 0, W) cin >> A[h][w]; int m = 101; rep(h, 0, H) rep(w, 0, W) { ...
#include <bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int h, w; cin >> h >> w; vector<vector<int>> grid(h, vector<int>(w, 0)); vector<vector<int>> hor(h, vector<int>(w, 0)); vector<vector<int>> ver(h, vector<...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<int,int,int> using Graph = vector<vector<int>>; int main(){ ll N; cin >> N; ll v[2*N]; ll sum = 0,loss = 0; rep(i,2*N){ cin >> v[i]; sum += v[i]; ...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mp make_pair #define pb push_back #define eb emplace_back #define test(x) cout << "Line(" << __LINE__ << ") " #x << ' ' << x << endl #define printv(x) {\ for (auto i : x) cout << i << ' ';\ cout << endl;\ } #define pii pair <int, int> #de...
#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> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define f(i,a,b) for(ll i = a; i < (ll) b ; i++ ) #define af(i,a,b) for(ll i = a; i >= (ll) b ; i--) #define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k ) #define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k) #define f...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const...
#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++) using namespace std; int main() { int N, X; cin >> N >> X; vector<vector<int>> Alc(N, vector<int>(2)); rep(i, N) cin >> Alc[i][0] >> Alc[i][1]; bool flag = false; i...
#pragma region head #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using pi = pair<int, int>; using pll = pair<ll, ll>; template <class T> using vv = vector<vector<T>>; #define _roverload(_a1, _a2, _a3, name, ...) name #define _rep(i, n) repi(i, 0, n)...
#include<bits/stdc++.h> using namespace std; int main () { int N ;cin>>N; string s ;int y;cin>>y>>s; int i; for(i=0;i< s.length();i++){ if(y!=0){if(s[i]=='o') {y=y+1;} else ...
#include<bits/stdc++.h> using namespace std; int k,fact[5]; long long sol; int main() { scanf("%d",&k); fact[1]=1; fact[2]=3; fact[3]=6; for(int i=1;(i*i*i)<=k;i++) { for(int j=i;(j*j)<=k/i;j++) { int lim = (k / i) / j; for (int z = j; z <= lim; z++) { ...
#include <iostream> using namespace std; int main() { int m,a=1,b=1,c=1,k=0; cin >> m; for(int a=1;a<=m;a++){ for(int b=1;a*b<=m;b++){ for(int c=1;a*b*c<=m;c++) k++; } } cout << k; }
#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 vector ...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long ans = 0; cin >> n; vector<int> t(n); vector<double> l(n); vector<double> r(n); for (int i = 0; i < n; i++) { cin >> t.at(i) >> l.at(i) >> r.at(i); } for (int i = 0; i < n; i++) { switch (t.at(i)) { case 1: break; case 2...
#include <bits/stdc++.h> #define ll long long #define lll long long #define mp make_pair #define pb push_back ll inf = 1000000000000000000; #define deci(n) fixed << setprecision(n) #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define umll unordered_map<ll, ll> #define mll map<ll, ll> //#define f first //#de...
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<ll> a[3]; bool comp(vector<ll> &x, vector<ll> &y){ return ((int)x.size()&1)<((int)y.size()&1); } int main(){ int n; scanf("%d", &n); for (int i=0;i<n*2;i++){ char col; ll val; scanf("%lld %c", &val, &co...
#include <bits/stdc++.h> using namespace std; int main(){ int a{},b{},c{}; cin>>a>>b>>c; if (a > b){ cout<<"Takahashi"<<endl; } if (a < b){ cout<<"Aoki"<<endl; } if (a == b){ if (c == 0){ cout<<"Aoki"<<endl; }else{ cout<<"Takahashi"<<endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define WIDTH 30 #define HEIGHT 30 #define Que 1000 #define rep(i, n) for(int i=0;i<(n);i++) int main() { vector<int> Si(1000), Sj(1000), Ti(1000), Tj(1000); auto t1 = chrono::high_resolution_clock::now(); rep(j, Que) { auto t2 = chrono::high_resolution_clock::...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define pb push_back #define eb emplace_back #define endl '\n' #define all(x) x.begin(), x.end() #define...
#include <iostream> #include <cfenv> #include <cmath> using namespace std; int main(){ int N; int x; cin >> N; for(int i =0; i < N + 1; i++){ x += i; if(x >= N ){ cout << i << endl; break; } } }
#include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long #define LL unsigned long long #define vec(x) vector<x> #define emb(x) emplace_back(x) #define fall(x) x.begin(),x.end() #define rfall(x) x.rbegin(),x.rend() #define fo(a,b) for(int i=a; i < b; i++) #define fset(x) setprecision(...
#include <stdio.h> #include <algorithm> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long llong; void ABrick(std::istream& in, std::ostream& out) { int n, w; in >>...
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 4000000000000000000 //オーバーフローに注意 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; #define SIZE 55 ll A[SIZE],maxi[SIZE]; ll dp[SIZE][2]; int main(){ ll N,price; sca...
// Problem: Blocks on Grid // Date: #include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n,m; int a[101][101]; cin >> n >> m; int minn=101; for(int i=1;i<=n;++i) fo...
//Let's join Kaede Takagaki Fan Club !! #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; //#define int long long typedef long long ll; typedef pair<int,int> P; typedef pair<int,P...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> using namespace std; typedef long long ll; #define LLINF (1LL<<60) template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); } template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); } //TSPここから struct TSP...
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; vector<vector<int>> adj_list(n); vector<vector<bool>> adj_matrix(n, vector<bool>(n, 0)); for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; --u; --v; adj_list[u].push_b...
#include <bits/stdc++.h> using namespace std; void fail(){ cout << -1 << '\n'; exit(0); } int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); int n, l; cin >> n >> l; long long ans = 0; vector<int> a(n+2), b(n+2); for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> b[i]; ...
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include <bits/stdc++.h> #include <cmath> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const int dx[4] = {1,0,-1,0}; const int dy[4] = {0,1,0,-1}; #define rep(i,n) for(int i=0;i<n;i++) #define FOR(i,in,fn)...
#include <bits/stdc++.h> #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define show(x) cout << (#x) << " : " << x << endl; #define ll long long #define ull unsigned long long #define ld long double #define pow power #defi...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long double lb = 0; long double rb = 2e9 + 9; long double p = 1.0 / (long double) n; auto f = [&](long double x) { long dou...
#pragma GCC optimize ("Ofast") #pragma GCC optimization ("unroll-loops, no-stack-protector") #pragma GCC target ("avx") #pragma GCC target ("avx2") #pragma GCC target ("fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define fastio ios_bas...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9; const ll inf64 = 1e18; int main() { #ifdef DEBUG freopen("input.txt", "r"...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define all(x) x.begin(),x.end() #define SZ(x) ((in...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; int main() { ll n; cin >> n; ll x = 1000; ll ans = 0; while(n-x+1 >= 1) { ans += n-x+1; x*=1000; } cout << ans << endl; return 0; }
#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> oset; #define sim template < class c #define ris return * this...
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <queue> #include <cmath> #include <algorithm> #define ll long long #define rep(i, a, b) for (int i = a; i <= (int)b; i ++) #define per(i, a, b) for (int i = (int)a; i >= b; i --) template < typename T > void read(T & x) { x = 0; int...
#include<bits/stdc++.h> using namespace std; int main(){ int H,W,k; cin >> H >> W >> k; int h[k],w[k]; char c[k]; char masu[H + 1][W + 1]; for(int i = 0 ; i < H ; i++){ for(int j = 0 ; j < W ; j++){ masu[i][j] = '-'; } } for(int i = 0 ; i < k ; i++){ cin >> h[i] >> w[i] >> c[i]; ...
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) using ll = long long; #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl const int mod = 1e9 + 7; void solve() { int n; cin >> ...
#define _USE_MATH_DEFINES #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <string> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <iostream> #include <fstream> #include <chrono> using namespace std; const int DIV = 998244353; void ...
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i < (n); i++) using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); ll t,N; cin>>t>>N; ll ct=N/t; ll gen = 100*ct; // gen--; ct *=t; ll l=gen+1 + ((gen+1)*t)/100, r=gen+((gen*t)/100); cerr << ct << endl; cerr << gen << end...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) (int)(a.size()) #define all(a) a.begin(),a.end() #define lb lower_bound #define ub upper_bound #define owo ios_base::sync_with_stdio(0);cin.tie(0); #define INF (ll)(1e18) #de...
#include <bits/stdc++.h> using namespace std; long long n,q,a[200005],t[200005],z; struct name { long long x,i; }f[200005]; int cmp1(struct name f1,struct name f2) {return f1.x < f2.x;} int cmp2(struct name f1,struct name f2) {return f1.i < f2.i;} int main () { scanf ("%lld",&n); for (int i = 1;i <= n;++...
#include<ctime> #include<cstdio> #include<cctype> #include<algorithm> #define le(p) ((p)<<1) #define ri(p) ((p)<<1|1) #define ll long long using namespace std; const ll N=1e6+7; const ll ninf=-5e18; ll read() { char c; ll x=0,f=1; while(!isdigit(c=getchar())) f-=2*(c=='-'); while (isdigit(c)){ x=x*10+(c-48)*f; ...
#pragma warning(disable:4996) #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; typedef long long ll; typedef double db; typedef pair<int, int> pii; int main() { //freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); ll n; while (cin >> n) { int a[18] = { ...
#include <bits/stdc++.h> #define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) #define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout) #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (i...
/*---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---XXX---*/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; // #define kyoa_a #define rep(i, a, b) for(int i = a; i < (b); ++i) #define rrep(a, b, ...
#include <bits/stdc++.h> using namespace std; #define int long long const int nax=5005,mod=998244353; int dp[15][nax],f[nax],invf[nax],pw[30]; int mul(int x,int y) { return x*y%mod; } int nck(int n,int r) { if(r<0 || r>n) return 0; return (f[n]*invf[n-r]%mod*invf[r]%mod); } int expo(int a,int b) { int res...
#include <algorithm> #include <iostream> #include <vector> #include <map> using namespace std; typedef long long ll; typedef pair<int, int> P; const ll MOD = 998244353; long long modpow(long long x, long long n){ long long res = 1; long long mul = x; while(n){ if(n % 2) res = res * mul % MOD; ...
#include<bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = (a); i < (b); ++i) #define trav(a, x) for(auto& a : x) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define endl '\n' typedef long long ll; typedef pair<int,int> pii; typedef...
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 200005; int n; int pos[N][2], ans[2]; int32_t main(int32_t argc, char const *argv[]) { int n; cin >> n; for (int i = 0; i < n; ++i) { int x, c; cin >> x >> c; if (!pos[c][0]) pos[c][0] =...
#pragma GCC optimize("O3") #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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> // find_by_order(k): It returns to ...
#line 1 "main.cpp" #include <iostream> #include <vector> using namespace std; void solve() { int n, k; cin >> n >> k; vector<vector<int>> graph(n); for (int i = n - 1; i--;) { int u, v; cin >> u >> v; --u, --v; graph[u].push_back(v); graph[v].push_back(u); ...
#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...
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ms(s, n) memset(s, n, sizeof(s)) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i) #define...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; cout<<(1<<n)-1<<endl; for(int i=1;i<1<<n;i++){ for(int j=0;j<1<<n;j++){ if(__builtin_popcount(j&i)&1) cout<<'B'; else cout<<'A'; } cout<<endl; } }
#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...)); } int main(){ ios::sync_with_stdio(false); cin.tie...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define rng(a) a.begin(),a.end() #define rrng(a) a.rbegin(),a.rend()...
#include <bits/stdc++.h> using i64 = int64_t; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::vector<int> s; int n; std::cin >> n; ++n; for (int i = 1; i < n; ++i) { std::string foo; std::cin >> foo; s.push_back(foo == "AND" ? 1 : 0); ...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a; long long ans = 1; for(long long i = 1; i <= n; ++i){ string s; cin >> s; if(s == "OR"){ans += (long long)pow(2, i);} } cout << ans << endl; }
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //~ while (clock(...
#pragma GCC optimize ("Ofast") #pragma GCC target("avx2") #pragma GCC optimize("unroll-loops") #include <x86intrin.h> #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //gp_hash_table<key, int, chash> table; #define PI 3.141592653589793L #define FAST ios::sync_with...
#pragma GCC optimize ("O2") #pragma GCC target ("avx") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) ...
#include <bits/stdc++.h> #include <algorithm> #include <unordered_map> #define ull unsigned long long #define int long long #define ll long long #define fr(i, n) for (int i = 0; i < n; i++) #define frf(i, j, n) for (int i = j; i <= n; i++) #define frd(i, n) for (int i = n; i >= 0; i--) #define mp(i, j) make_pair(i, j) ...