code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<bits/stdc++.h> #define int long long #define ld long double #define all(x) x.begin(),x.end() #define fr(i,n) for(int i=0;i<(int)n;i++) #define ff first #define ss second #define tc int t;cin>>t;while(t--) #define FILE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout) #define pb push_back #define...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define ud unsigned int #define ll long long #define ull unsigned long long #define MAX_INF 0x3f #define MAX_INF_VAL 0x3f3f3f3f #define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f //#define pi 3.141592653589 #define eps 1e-9 #define F(x) ((x)/3+((x)%3==1?0:tb)) #define G(x) ...
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n, k; string s; cin >> n >> k >> s; vector<vector<int>> dp(k + 1, vector<int>(n)); vector<vector<int>> op{ {0, 1, 0} , {1, 1, 2} , {0, 2, 2} }; vector<int> rem(k + ...
#include <iostream> #include <algorithm> #include <stdio.h> #include <bits/stdc++.h> #include <queue> #include <math.h> #include <bitset> #include <map> #include <vector> #include <cstdio> #include <climits> #define white 0 #define gray 1 #define black 2 #define LIMIT (1<<30) #define MOD 1000000007 //#define MOD 998244...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int sz = 1e5+1; const int md = 1e9+7; int A[sz]; int B[sz]; // int n; void solve(){ string a,b;cin>>a>>b; int p=0,q=0; for(auto c:a) p += (int)(c-'0'); ...
/** * author: tomo0608 * created: 18.02.2021 21:47:19 **/ #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; typedef pair<int,int> pii; typedef pair<long long, l...
#include <bits/stdc++.h> #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##_len=(b);i<i##_len;++i) #define MSVC_UNKO(x)x #define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__)) #define all(c)c.begin(),c.end() #define write(x)cout<<(x)<<'...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define mp make_pair #define mod 1000000007 ll gcd(ll a,ll b) { if (b == 0) return a; return gcd(b, a % b); } ll ncr(ll n,ll k) { ll C[n + 1][k + 1]; ll i, j; for (i = 0; i <= n; i++) { f...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; reverse(s.begin(),s.end()); for(int i=0;i<s.length();i++) { if(s[i]=='6') s[i]='9'; else if(s[i]=='9') s[i]='6'; } cout<<s<<"\n"; return 0; }
#include<bits/stdc++.h> int main(){ using namespace std; unsigned long N; cin >> N; unsigned long t{1}, f{1}; for(unsigned long i{0}; i < N; ++i)if([]{string s;cin >> s;return s;}()[0] == 'O'){ (t *= 2) += f; }else{ (f *= 2) += t; } cout << t << endl; return 0; }
#include "bits/stdc++.h" #include <random> #include <chrono> #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;++i) #define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;--i) #define REP(i, n) FOR(i,0,...
#include <iostream> #include <string> #include <algorithm> #define MAX_H (100) #define MAX_W (100) char map[MAX_H][MAX_W]; int main(void) { // input int H, W, X, Y; std::cin >> H >> W >> X >> Y; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { std::cin >> map[i][j]; } } // proces...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; int main() { string s; cin >> s; int count = 0; for (int i = 0; i <= 8; i++) { if (s[i] == 'Z' and s[i + 1] == 'O' and s[i + 2] == 'N' and s[i + 3] == 'e') { count++; } ...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define FAST ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); //(a/b)%m =((a%m)*pow(b,m-2)%m)%m void solve(){ int n; cin>>n; cout<<(100 - (n%100))<<"\n"; return; } int main(){ FAST int T=1; //cin>>T; while(T--){...
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < (n); i++) using namespace std; using ll = long long; using P = pair<ll, ll>; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; const int mod = 1000000007; //const int mod = 998244353; vector<vector<int>> to; vector<int> used, col, vs; ll...
#include<bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; string s; cin >> s; int point = x; for(int i=0; i<s.size(); i++) { if(s[i] == 'x' and point!=0) point--; if(s[i] == 'o') point++; } cout << point << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { bool ok = true; for (int x = i; x > 0; x /= 10) { if (x % 10 == 7) { ok = false; } } for (int x = i; x...
#include <iostream> #include <cstdio> #include <new> #include <cmath> #include <cstdlib> #include <algorithm> #include <iomanip> #include <vector> #include <stdio.h> #include <string> using namespace std; typedef long long ll; const long long INF = 1LL << 60; //最小値を取り出す関数 template<class T> inline bool chmin(T& a, T b)...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define totori signed template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} ll dx[4]={0,1,-1,0}; ll dy[4]={1,0,0,-1}; templ...
#include <bits/stdc++.h> using namespace std; int N, W, S, T; long long P, A[200001]; void SET(int S, int T, long long P) { A[S] += P; A[T] -= P; } void GET(int W) { long long foo = 0; for (int i = 0; i <= 2e5; i++) { foo += A[i]; if (foo > W) { cout << "No"; exit(EXIT_SUCCESS); } } ...
#include <bits/stdc++.h> using namespace std; #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 take(a, n) ...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = (int)1e9; const ll INFL = (ll)1e15; const int MOD = 1e9 + 7; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; int main() { ll t; cin >> t; ll l, r; r...
#include <bits/stdc++.h> #define range(i, a, b) for(int i = (a); i < (b); i++) #define rep(i, a) range(i, 0, a) using namespace std; int main() { int n, m; cin >> n >> m; vector <int> a(n); vector <vector <int>> pos(n); rep (i, n) { cin >> a[i]; pos[a[i]].push_back(i); } i...
#include<bits/stdc++.h> #define rep(a,b,c) for(register int a=(b);a<=(c);++a) #define dow(a,b,c) for(register int a=(b);a>=(c);--a) using namespace std; const int MaxN=1000000+5; struct Connector { int fa[MaxN]; inline void Initalize(const register int len) { rep(i,1,len) fa[i]=i; } inline int getf(const regi...
///* ***Bismillahir Rahmanir Rahim*** */ /// bujsilam ar proti index value gcd ber korte hbe ///pore je oi gcd mod oita mathaia sen ni #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double dl; typedef unsigned long long ull; #define pb push_ba...
#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,m,n) for(ll i=ll(m); i<ll(n); i++) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VP vector<pair<ll,ll>> #define VPP vector<pair<int,pair<int,int>>> #define VLL vecto...
#include <iostream> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair <int,int> pii; typedef pair<ll,ll> pll; /*bool compare_function(const pair<int, int> a, const pair<int, int> b...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define N 500100 #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 int long long using namespace std; const int md = 1000000007; int n=0; int a[100001]; set<int> Set; signed main() { cin >> n; for (int i=0; i<n; i++){ cin >> a[i]; Set.insert(a[i]); } int prev = 0; int res = 1; for (auto s : Set) { res*=((s-prev+1)%md); res%=md; pre...
#include<bits/stdc++.h> using namespace std; #define ll long long map<ll,ll>a; vector<ll>v; int main() { ios::sync_with_stdio(false); ll n,num; cin>>n; for(int i=1;i<=n;i++) { cin>>num; if(a[num]==0)v.push_back(num); a[num]++; } ll res=((n-1)*n)/2; for(int i=0;i<v.size();i++) { if(a[v[i]]>1)res-=((a[v[...
#include<bits/stdc++.h> using namespace std; const int N=4e5+5; int n,f[N],stk[N],top; struct pt { int val,i; }a[N]; bool cmp(pt p,pt q) {return p.val<q.val;} int main() { scanf("%d",&n); for(int i=1;i<=2*n;++i)scanf("%d",&a[i].val),a[i].i=i; sort(a+1,a+2*n+1,cmp); for(int i=2*n;i>n;--i)f[a[i].i]=1; for(int i=1;...
#include <iostream> using namespace std; int main() { int T; cin >> T; for (int t = 0; t < T; t++) { int N; cin >> N; string S1, S2, S3; cin >> S1 >> S2 >> S3; cout << 1; for (int i = 0; i < N; i++) cout << 0; for (int i = 0; i < N; i++) cout << 1; cout << endl; } }
#include <bits/stdc++.h> #define N 500005 #define pb push_back #define mk make_pair #define fi first #define se second using namespace std; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { int s = 0, x = i; for (int j = 2; j * j <= i; ++j) { while (x % j == 0) ++s, x /= j; } if (...
// C++(GCC 9.2.1) #include <bits/stdc++.h> using namespace std; #define repex(i, a, b, c) for(int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for(int i = a; i >= b; i--) int ans[101010]; int main(){ // 1. 入力情報. int N; scanf("%d", ...
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<cmath> #include<chrono> using namespace std; /*unsigned int rnd() { static unsigned int y=2463534242; y^=y<<13; y^=y>>17; return y^=y<<5; }*/ /* unsigned int rnd() { static unsigned int x=123456789,y=362436069,z=521...
#include <iostream> #include <algorithm> #include <vector> #include <map> using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> x(n), y(n), r(n); for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i]; vector<vector<bool>> field(10000, vector<bool>(10000)); vector<i...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int N; cin >> N; vector <vector<int>> p(N, vector<int>(2)); vector <double> store(N); rep(i, N) cin >> p[i][0] >> p[i][...
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; double square(double x) { return x * x; } int main() { vector<array<double, 2>> set1; vector<array<double, 2>> set2; int n; cin >> n; if (n == 1) { cout << "Yes" << endl; return 0; } for (int i = 0;...
/* Code for problem A by cookiedoth Generated 10 Apr 2021 at 03.05 PM █▒▒▒▒▒▒▒▒▒ 10% ███▒▒▒▒▒▒▒ 30% █████▒▒▒▒▒ 50% ███████▒▒▒ 70% ██████████ 100% ~_^ =_= ¯\_(ツ)_/¯ */ #include <iostream> #include <fstream> #include <vector> #include <set> #include <map> #include <bitset> #include <algorithm> #include <iomanip> #i...
#include <bits/stdc++.h> using ll = long long; #define FOR(i, k, n) for(ll i = (k); i < (n); i++) #define FORe(i, k, n) for(ll i = (k); i <= (n); i++) #define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--) #define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--) #define REP(i, n) FOR(i, 0, n) #define REPr(i, n) FORre(i, ...
/* author : BHUPATHI07 */ #include<bits/stdc++.h> using namespace std; int main() { int x , y ; cin>> x >>y; if(x==y) cout<<x<<"\n"; else cout<<abs(3-(x+y))<<"\n"; }
#include <iostream> #include <iomanip> using namespace std; int main(){ double a, b; cin >> a >> b; b=100*(a-b)/a; cout << fixed << setprecision(12) << b; }
#include<iostream> using namespace std; int main(){ long long int i, n,s,p,count=0; cin>>n>>s>>p; //max1=max(y,w); long long int a[n],b[n]; for(i=0;i<n;i++ ){ cin>>a[i]>>b[i]; if(a[i]<s && b[i]>p){ count=1; cout<<"Yes"; break; } } if(count==0){ cout<<"No"; } }
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define rrep(i,n) for(int i=n-1;i>=0;--i) #define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} #define MAX_N 100001 #define i197 1000000007 using namespace std; typedef long long ll; typedef pair<ll,ll> P1; typedef pair<int,int> Pi; typede...
#include<bits/stdc++.h> #define pb push_back #define ll long long #define ld long double #define mod 1000000007ll #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.precision(25); using namespace std; ll gcd(ll a, ll b) {if(a == 0) return b; return gcd(b % a, a);} ll lcm(ll a, ll b) {retu...
#include <bits/stdc++.h> using namespace std; #define int long long // #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 pf push_front #def...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main() { int N; cin >> N; ll mod = 1e9+7; set<ll> st; for (int i = 0; i < N; i++) { ll A; cin >> A; st.insert(A); } ll pre = 0; ll ans = 1; for (ll n : st) { ...
#include<bits/stdc++.h> #define pi 3.141592653589793238 #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #defin...
#include <bits/stdc++.h> template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define irep(n) for (int i=0; i < (n); ++i) #define irepf1(n) for (int i=1; i <= (n); ++i) #define jrep(n) for (int j=0; j < (n); ++j) #define jrepf1(n) for (int j=1; j <= (n); ++j) #define krep(n) for (int k=0; k < (n); ++k) #define krepf1(n) for (int ...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define test lli t;cin>>t;while(t--) #define vll vector<lli> #define vpll vector<pair<lli,lli>> #define prq priority_queue<lli> #define psq priority_queue<lli,vector<lli>,greater<lli>> #...
#include<bits/stdc++.h> using namespace std; #define fi(a,b) for(int i=a;i<b;i++) #define fj(a,b) for(int j=a;j<b;j++) #define ff first #define ss second #define ll long long #define ld long double #define ull unsigned long long #define bp(x) __builtin_popcount(x) #define pr(x) for(auto it: x) cout<<...
//Common Header Simple over C++11 #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_poli...
#include <iostream> #include <stdio.h> #include <vector> #include <list> #include <algorithm> #include <string.h> #include <stack> #include <map> #include <set> using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; vector<bool> a(n, false); for (int i = 0; i < n; i++) { ...
#include<bits/stdc++.h> #define mod 1000000007 #define pi pair<int, int> #define ll long long int #define pll pair<ll, ll> #define ppll pair<ll, pll> #define vi vector<int> #define vll vector<ll> #define vpi vector<pi> #define vpll vector<pll> #define vppll vector<pair<ll, pll>> #define vvll vector<vector<ll>> #define ...
/* author : sgupta_2001 */ #include<bits/stdc++.h> using namespace std; using db = double; using ll = long long; using ld = long double; using ull = unsigned long long; //containers #define sz(x) int((x).size()) #define bg(x) begin(x) #define all(x) bg(x), end(x) #define rall(x) x.rbegin(), x.rend() #define sor(...
#include <iostream> #include <string> #include <vector> #include <utility> using ll=long long; using namespace std; int main(){ int N,M; cin>>N>>M; vector<int> A(M); vector<int> B(M); for(int i=0;i<M;i++){ cin>>A[i]>>B[i]; A[i]--;B[i]--; } int K; cin>>K; vector<int>...
/* हरे कृष्ण हरे कृष्ण कृष्ण कृष्ण हरे हरे हरे राम हरे राम राम राम हरे हरे */ #include<bits/stdc++.h> using namespace std; #define pb emplace_back #define pob pop_back typedef long long int lli; #define test lli t; cin>>t;...
#include <bits/stdc++.h> using namespace std; int main(){ string S; cin >> S; for (int i = 0; i < 12; i++){ auto T = S; reverse(T.begin(), T.end()); if (S == T){ puts("Yes"); return 0; } S = '0' + S; } puts("No"); }
#include<bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; auto f = [&](string s){ string t= s; reverse(all(t)); return s==t; }; string s=to_string(n); if(f('0'+s) || f("00"+s) || f("000" ...
#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 mid ((l+r)>>1) #define lc (x<<1) #define rc (x<<1|1) #define fan(x) (((x-1)^1)+1) #define max M...
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define cs const #define fr first #define se second #define ls (now<<1) #define rs (now<<1|1) #define mid ((l+r)>>1) #define mp make_pair #define pb push_back #define ppb pop_back #define low(i) (i&(-i)) #define par pair<int,int> ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i,a,n) for(int i=a;i<n;i++) #define per(i,a,n) for(int i=a;i>=n;i--) #define pb push_back #define mp make_pair #define mem(a,b) memset(a,b,sizeof(a)) ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);} ll lcm(ll a,ll b){return a...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef pair<int, ll> pil; typedef vector<pii> vii; typedef vector<pil> vil; typedef vector<...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin>>n; if(n<=6) cout<<n; else { int c=0; for(int i=7;i<=n;i++) { int te=i,r,f=0; while(te>0) { r=te%10; te/=10; if(r==7) {f=1; break;} } if(f==1) {c++; continue;} ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#include<bits/stdc++.h> #include<string> #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <fstream> #include...
#include <cstdio> #include <algorithm> using namespace std; int main() { long long a, b; scanf("%lld%lld", &a, &b); if(b>=2*a) { printf("%lld", b / 2); return 0; } long long gcd = b - a; while(gcd) { int down, up; if(a%gcd==0) down = a; ...
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif #include "bits/stdc++.h" using namespace std; #define all(x) (x).begin(), (x).end() #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define un_map unordered_map #define rep(i,a,n) for (int i = a; i < n; ++i) #define rrep(i,a,n) for (int i = a; i >= n; --i) #d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define REP(i,n) for (ll i = 0; i < n; ++i) #def...
#include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <stdio.h> #include <algorithm> #include <set> #include <string> #include <map> #include <vector>//sort法 昇順 std::sort(v.begin(),v.end()); 降順 std::sort(v.begin(),v.end(),std::greater<int>()); #include <queue>//待ち行列 / 最大値から priority_queue...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <algorithm> #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; //using Graph = vector<vector<pair<ll,ll>>>; const int mod =1e+9+7; const int dy[4]={0,1,0,-1...
#include<bits/stdc++.h> #define int long long using namespace std; int read() { int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w; } int X,Y; map<int,int> mp; int Dfs(int x) { if(x<=X) return X-x; if(mp[...
#include<bits/stdc++.h> #define rep(i,l,r) for(int i=(l);i<=(r);++i) using namespace std; typedef vector<int> vi; typedef pair<int,int> pii; int rd(){ int f=1,x=0;char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return f*x; } int ...
//计算几何题 //二维平面上两个点集,判断是否能通过平移和绕原点旋转整个点集使得两个点集完全相同, //先考虑将所有点进行平移,使得接下来只要进行旋转就能使得两点集完全相同 //重心 //绕原点旋转 //actan2 //遍历 #include <bits/stdc++.h> using namespace std; #define int long long #define INF 0x3f3f3f3f // #define swap(a, b) (a ^= b ^= a ^= b) // #define max(x,y) ((x)>(y)?(x):(y)) // #define min(x,y) ((x)<(y)?(x):(y...
#define _DEBUG #include "bits/stdc++.h" //#include <atcoder/all> #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x #define debug_1(x1) cout<<#x1<<": "<<x1<<endl #define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl #define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "...
#include <bits/stdc++.h> #define MOD 998244353LL using namespace std; typedef long long ll; typedef pair<int,int> P; int h,w; int fie[501][501]; int flag[1001]; int main(void){ scanf("%d%d",&h,&w); for(int i=0;i<h;i++){ string s; cin >> s; for(int j=0;j<w;j++){ if(s[j]=='R'){ fie[i][j]=1; }else if(s...
/*input */ #include <bits/stdc++.h> #define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i)) #define down(i,b,a) for(int (i) = (b);i>=(a);--i) #define bits(x,i) (((x) >> (i)) & 1) #define mid ((l+r)/2) #define pr pair<int,int> using namespace std; const int N = 1005; int a[N], n; int main(){ ios_base::sync_with_stdio(0...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9+7; char cAA, cAB, cBA, cBB; long long f[1005]; int main(){ int N; scanf("%d", &N); scanf(" %c %c %c %c", &cAA, &cAB, &cBA, &cBB); if(cAA == 'A' && cAB == 'A'){ printf("1"); return 0; }else if(cBB == 'B' && c...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) {for(auto i: x){cout << i << " ";} cout << endl;} #define isin(x,l,r) ((l) <= (x) && (x) < (r)) using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template<t...
#include <cstdio> #include <algorithm> #define N 1010 #define ll long long #define fo(x, a, b) for (int x = (a); x <= (b); x++) #define fd(x, a, b) for (int x = (a); x >= (b); x--) using namespace std; int n, m, zf = 0, a[N << 1]; inline int calc(int l, int r) { return (l + r) * (r - l + 1) / 2; } int main() { scan...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n",(x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define isYes(x) printf("%s\n",(x) ? "Yes" : "No") #define isIn(x,y,h,...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define test() int t;cin>>t;for(int test=1;test<=t;test++) #define pb pus...
#include <bits/stdc++.h> #define fi first #define se second #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++) #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define IT iterator #define V vector #define TP template <class o> #define TP...
#include<bits/stdc++.h> using namespace std; #define ll long long #define M1 1000000007 #define M2 998244353 int main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ///////////////////////////// int maxn = 62; int a,b; ll k; cin>>a>>b>>k; // Pre-Compute nCr values; vector<vector<ll>>nCr(m...
// // // File Creation Date: // Author: Gourav(https://github.com/GouravKhunger) #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<ll> vll; typedef set<int> si; typedef priority_queue...
#include<bits/stdc++.h> using namespace std; #define ll long long #define n_l '\n' #ifndef ONLINE_JUDGE #define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return ...
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") #pragma GCC option("arch=native","tune=native","no-zero-upper") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; #define INF 2147483647 #define infL (1LL<<60) #define inf (1<<30) #define inf9 (1000000000) #define MOD 1000...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i) #define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i) #define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 60) -123456789; #define fastio cin.tie(0); ios_base::s...
#include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #define all(s) begin(s), end(s) #define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sz(s) int(s.size()) #define ENDL '\n' #define vv(type, name, h, ...) vec...
#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...
// Hail god Yato #include <bits/stdc++.h> using namespace std; #define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); typedef long long ll; const ll MOD = 998244353; const ll INF = 1e18; const ll MAX = 52; // // ll frac[52]; void dfs(int idx, vector<int> &vis, vector<vector<int>> &g, int &cnt){ if(vis[id...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define sorts(s) sort(s.begin(), s.end()) #define sortu(s) sort(s.begin(), s.end(), greater<>()) typedef long long int ll; using Graph = vector<vector<int>>; int main(void) { //int i = 0, j = 0, k = 0; ll N; ...
#include <algorithm> #include <iostream> #include <tuple> #include <unordered_map> #include <utility> #include <vector> using namespace std; struct Event { int time, index; bool start; inline bool operator<(const Event& other) const { return make_tuple(time, start, index) \ < make_tuple(other.time, ot...
#include<bits/stdc++.h> using namespace std; ///******************************** C o n t a i n e r ********************************/// typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<pii> vii; typed...
#include <bits/stdc++.h> using namespace std; int main(void){ int n,a; cin>>n; std::deque<int> deq; for (int i=0;i<n;i++) { cin>>a; deq.emplace_back(a); } int max_count=0,ans=0,tmp=0; for (int i=2;i<=1000;i++) { int count=0; for (int j=0;j<n;j++) { ...
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll N; cin >> N; ll sum = 0; for (int i = 0; i < N; i++) { ll A, B; cin >> A >> B; sum += (B * (B + 1) / 2) - ((A - 1) * A / 2); } cout << sum << endl; return 0; }
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define rrep(i,n) for(int i = (n)-1; i >= 0; i--) #define rep1(i,n) for(int i = 1; i <= (n); i++) #define rrep1(i,n) for(int i = (n); i > 0; i--) #define ll long long #define pi pair<int, int> #define pll pair<ll, ll> #define MOD 1000000007 #defin...
#include <bits/stdc++.h> using namespace std; #define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int long long #define endl '\n' #define vi vector<int> #define pii pair<int, int> #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define fill(a,b...
#include <bits/extc++.h> using namespace std; using namespace __gnu_cxx; using ll = long long; int main() { ll n; cin >> n; ll exp = 1,p = 0,a = 1000000000000000000; while(exp <= n){ a = min(a,p+n/exp+n%exp); exp *= 2; p++; } cout << a << endl; }
#include<iostream> #include<set> #include<vector> using namespace std; typedef long long li; #define rep(i,n) for(int i=0;i<(n);i++) #define df 0 template<class T> void print(const T& t){ cout << t << "\n"; } template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << ...
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "unordered_map" #include "unordered_set" #include "iomanip" #include "cmath" #include "random" #include "bitset" #include "cstdio" ...
#include <bits/stdc++.h> #pragma region my_template struct Rep { struct I { int i; void operator++() { ++i; } int operator*() const { return i; } bool operator!=(I o) const { return i < *o; } }; const int l_, r_; Rep(int l, int r) : l_(l), r_(r) {} Rep(int n) : Rep(0, n) {} I begin() const...
#include <bits/stdc++.h> //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //#include <atcoder/all> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i,n) for(ll i=0;i<(n);++i) #define OREP(i,n) for(ll i=1;...
// 2020-11-21 21:45:27 // 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> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i,x,n) for(int i = x; i < n; ++i) #define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it) typedef long long ll; ll n,m,k,x,y,p=1e9+7,invm; void mult(vector<vector<ll>>& a, vecto...
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long #define MOD 1000000007 ll pw(ll a, ll n) { ll ret = 1; while(n) { if (n&1) ret=ret*a%MOD; a=a*a%MOD; n>>=1; } return ret; } ll inv(ll a) { return pw(a, MOD-2); } int N, M, K; vector<vector<ll> > V, A, g; ll deg[101]...
#include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long #define ld long double #define MOD 1000000007 #define vec vector<int> #define vecll vector<ll> #define pb push_back #define f(i,l,n) for(int i=l;i<n;i++) #define fll(i,l,n) for(ll i=l;i<n;i++) #define regstuff ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dbg.cpp" #else #define out(...) 42 #endif void solve () { int64_t a, b, c; cin >> a >> b>> c; a *= a; b *= b; c *= c; if (a + b < c) cout <<"Yes\n"; else cout<<"No\n"; } int main() { ios::sync_wit...
#include <bits/stdc++.h> #define DEBUG if(0) #define lli long long int #define ldouble long double using namespace std; int main() { int k; while (~scanf("%d", &k)) { lli ans = 0; for (lli a = 1; a <= k; a++) for (lli b = 1; a*b <= k; b++) for (lli c = 1, hehe = a*b; hehe*c <= k; c++) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f(ll x, ll y) { ll g = __gcd(x, y); x /= g; return x * y; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; ll p = 1; for (int i = 1; i <= n; i++) p = f(p, i); cout << p + 1 << "\n"; }
#include <algorithm> #include <bitset> //#include <cmath> //#include <complex> #include <cctype> #include <cstdio> #include <cstdint> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <climits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include ...
// #define LOCAL #define _USE_MATH_DEFINES #include <array> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include <stack> #include <list> #include <set> #include <map> #include <unordered_set> #incl...
#include<iostream> #define ll long long using namespace std; ll n,a,b,c; const ll inf=1e18; ll ksm(ll x,ll n){ ll res=1; while(n){ if(n&1)res=res*x; x=x*x; n/=2; } return res; } int main(){ scanf("%lld",&n); ll mi=inf; for(int i=0;i<63;i++){ ll now=ksm(2,i); if(now>n)continue; a=n/now; c=n%now; m...
#include<bits/stdc++.h> // 54 68 "Baklol, Take it easy" using namespace std; using ll = long long int; using ld = long double; #define rep(x, k, n) for(int x = (k); x <= (n); ++x) #define rept(x, k, n) for(int x = (k); x < (n); ++x) #define repr(x, k, n) for(int x = (k); x >= (n); --x) #define pb ...
#include<bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0) void err() { cout << "\033[39;0m" << endl; } template<template<typename...> class T, typename t, typename... A> void err(T<t> a, A... x) { for (auto v: a) cout << v << ' ';...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} int dx[4]={0,1,0,-1}, dy[4]={1,0,...
#include <bits/stdc++.h> using i64 = long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::set<std::tuple<int, int, int>> s; std::vector<std::pair<int, int>> a(n); for (auto &[x, y] : a) { std::cin >> x >> y; } sort(a.begi...
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define db(a) cout << fixed << #a << " = " << a << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; vector<int> A(N), B(M); for (int &a: A) c...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vl = vector<ll>; using vvl = vector<vl>; using pl = pair<ll, ll>; const ll INF = ll(1e18); const ll mod = ll(998244353); const double pi = acos(-1); #define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i)) #define rrep0...
#include<iostream> #include<cmath> #include<vector> #include<set> #include<unordered_set> #include<queue> #include<unordered_map> #include<algorithm> using namespace std; #define endl '\n' #define gap ' ' #define Max LLONG_MAX #define Min LLON...
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <string> #define amax(a, b) a = max(a, b) #define amin(a, b) a = min(a, b) using ll = long long; using P = std::pair<int, bool>; #define fi first #define se second struct floor { int id; bool used; bool in; bool has...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define chmin(x,y) x = min((x),(y)) #define chmax(x,y) x = max((x),(y)) #define popcount(x) __builtin_popcount(x) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; const int INF = 1e9; const ...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; typedef long long int lld; const lld N = 200043; const lld MOD = 1000000007; lld add(lld x, lld y) { x =((x%MOD)+(y%MOD))%MOD; while(x >= MOD) x -= MOD; while(x < 0) x += MOD; return x; } ll...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int,int>; #define rep(i,n) for (ll i = 0; i < (ll)(n); ++i) int main() { string S; cin >> S; if(S.size()<=3){ sort(S.begin(), S.end()); do{ int n = stoi(S); if(n%8 == 0){ ...
#pragma GCC optimize ("-O3") #include<bits/stdc++.h> typedef long long ll; using namespace std; #define f(i,x,n) for(ll i=x;i<n;i++) #define pb push_back #define mp make_pair #define debug(x) cout<<x<<"\n"; #define lb lower_bound #define ub upper_bound #define bs binary_search #define MOD 1000000007 ll n,a,b,c,k,d,m,x,...
/* Priyansh Agarwal*/ #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<algorithm> #include<string.h> #include<unordered_map> #include<vector> #include<unordered_set> #include<set> #include<map> #include<queue> #include<stack> #include<map> #include<chrono> u...
#include<iostream> #include<vector> #include<string> using namespace std; void print(vector<bool> x){ for (bool b: x){ cout << b << " "; } cout << endl; } void flip(string& s){ string t; for (char l: s){ t = l + t; } s = t; return; } int main(){ int n; cin >> n...
#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...
//kaihatsu #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int x = 1e9; for (int i = 1; i <= x; ++i) { int sum = (i * (i + 1)) / 2; if (sum >= n) { cout << i; break; } } return 0; }
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using ll = long long; using namespace std; using P = pair<int,int>; int main(){ int n; cin >> n; if(n%2 == 0) cout << "White" << endl; else cout << "Black" << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++) #define long long ll using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>; using P = pair<int, int>; int main(){ d...
#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=a;i<=b;i++) using LL = long long; const int Nmax=2e5+9; LL N,x,Up,Dn,Lv; int cnt[9],digit,ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N; cnt[1]=9; REP(i,2,6) cnt[i]=cnt[i-1]*10; x=N; while ((x/1...
#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 bit(s, i) ((1 << i) & s ? 1 : 0) #define bits...
#include<set> #include<queue> #include<bitset> #include<cmath> #include<ctime> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define MAXN 805 #define ENDL putchar('\n') #define LL long long #define DB double #define lowbit(x) ((-x) & (x)) #define INF 0x3...
/* By: Anurag Rai CF: Raag07 CC: call_me_raag */ #include<bits/stdc++.h> #define FIO std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define REP(it, a, b) for(int it = a; it < b; ++it) #define all(X) (X).begin(), (X).end() #define int long long int #define ff first #define ss second #de...
///Bismillahir Rahmanir Rahim #include<bits/stdc++.h> #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define mp make_pair #define pb push_back #define cy cout<<"YES"<<endl #define cn cout<<"NO"<<endl using namespace std; const ll inf=1e18; const int mod=1e9+7; const...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mkp make_pair #define vi vector<int> #define pii pair<int,int> #define FI(n) FastIO::read(n) #define FO(n) FastIO::write(n) #define ull unsigned long long #define mst(a,b) memset(a,b,sizeof(a)) #define foR(i,k,j) for(int i=(k);i>=(j);i--) #define...
#include <bits/stdc++.h> using namespace std; #define ll long long #define PI acos(-1) #define rep(i, n) for (int i = 0; i < (n); i++) int main() { ll r, x, y; cin >> r >> x >> y; int ans = 0; double d = sqrt(x * x + y * y); if (d >= r) { while (d > 0) { d -= r; ...
// Problem: C - Squared Error // Contest: AtCoder - AtCoder Beginner Contest 194 // URL: https://atcoder.jp/contests/abc194/tasks/abc194_c // Memory Limit: 1024 MB // Time Limit: 2000 ms // Date: 2021-03-09 12:52:00 // --------by Herio-------- #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef ...
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; const int mod=998244353; #define ll long long #define pb push_back int a[maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int ans=0; int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) ...
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #define pb push_back #define mp make_pair #define fir first #define sec second const int N = 1e6 + 5; using namespace std; int cas, n; char s[3][N], T[N]; template < typename T > inline T read() { T x = 0, w = 1; char c = getchar(); whi...
#include<bits/stdc++.h> #include<iostream> #include<map> #include<math.h> #include<string> #include<string.h> #include<vector> #include<queue> #include<algorithm> #include<set> #include<stack> #define _GLIBCXX_DEBUG #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() using namespace std; using ...
///in the name of ALLAH #include<bits/stdc++.h> using namespace std; typedef uint64_t ll; ll dp[201][12]; ll nCr(ll n,ll r) { if(n==r) return 1; if(r==1) return n; if(r==0) return 1; if(dp[n][r])return dp[n][r]; return dp[n][r]=nCr(n-1,r)+nCr(n-1,r-1); } int main() { ll n; cin>>n; cout<<...
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int ans=0; for(int i=0;i<=9999;i++) { bool val[10]={false}; int x=i; for(int j=0;j<4;j++) { val[x%10]=true; x/=10; } bool flag=true; for(int j=0;j<10;j++) { if(s[j]=='o'&&!val[j])flag=false; if(s[j]=='x'&&val[j]...
#include<bits/stdc++.h> using namespace std; #define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define ll long long #define ld long double #define endl "\n" #define ff first #define ss second #define imn IN...
#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),i##end=(b);i<i##end;i++) #define REP(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++) #define RFOR(i,a,b) for(int i=(a),i##end=(b);i>i##end;i--) #define RREP(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i--) typedef long long LL; LL ans[2]; char s[5]; int main() { i...
#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 ll long long #define db double #define el "\n" #define ld long double #define rep(i,n) for(int i=0;i<n;i++) #define rev(i,n) for(int i=n;i>=0;i--) #define r...
#include<bits/stdc++.h> using namespace std; #define ull unsigned long long #define mp make_pair #define ll long long #define pb push_back #define hell 998244353 void update(vector<int>&bit, int id, int val, int n) { id++; while(id<=n) { bit[id] = bit[id]^val; id += id&(-id); } } int g...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define ll long long #define ar array const ll mxN=3e5; const int mod=1e9+7; const ll INF=1e18; #define what_is(x) cerr << #x << " is " << x << endl; ll a,b,c,n,k,m,x,y,h,l,r,t; void solve(){ cin>>n; cin>>c; vector<ar<ll,3>> a(n); set<ll...
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; typedef pair<int,int> pii; typedef pair<long long, int> pli; #define rep...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> #include<cstring> #include<bitset> 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 <= (...
// https://atcoder.jp/contests/abc185/tasks/abc185_f #include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++) #define DEBUG 0 #if DEBUG #define _GLIBCXX_DEBUG #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.s...
#include <bits/stdc++.h> #define err(args...) {} #ifdef DEBUG #include "_debug.cpp" #endif using namespace std; using ll = long long; using ld = long double; template <typename T> using lim = numeric_limits<T>; template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; ...
#include<cstdio> #include<cstring> #include<algorithm> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fd(i,b,a) for(int i=b;i>=a;i--) #define efo(i,u,v) for(int i=BB[u],v=B[BB[u]][1];i;v=B[i=B[i][0]][1]) #define mset(a,x) memset(a,x,sizeof(a)) template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;} tem...
#include <bits/stdc++.h> #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x #define dump_1(x1) cerr << #x1 << ": " << x1 << endl #define dump_2(x1, x2) \ cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl #define dump_3(x1, x2, x3) \ ce...
#include <bits/stdc++.h> template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i...
/* © 2020-10-29 12:18:32 IvanBorquez All Rights Reserved */ #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #defin...
#include <stdio.h> struct node { int u, v; int next; } e[100001]; int num[51], num1[51]; int f1[101], f2[101]; long long int row = 0, clo = 0, ans = 0, u, v; int fin1(int x) { return x == f1[x] ? x : (f1[x] = fin1(f1[x])); } int fin2(int x) { return x == f2[x] ? x : (f2[x] = fin2(f2[x])); } void merg1(i...
#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 ll long long #define db double #define el "\n" #define ld long double #define rep(i,n) for(int i=0;i<n;i++) #define rev(i,n) for(int i=n;i>=0;i--) #define r...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < n; ++i) using Graph = vector<vector<int>>; struct Edge { int to; int cost; Edge(int t, int c) : to(t), cost(c) {} }; using edge = struct { long long to; long long cost; }; template <class T> inl...
//全力以赴 #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define PI 3.141592653L #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const ll INF = (ll)1e18; const int N = 2e5 + 5; const ll MOD = 1e9+7; int parent[N]; const int dx[4] = {+1, 0, -1, 0}; const int dy[4]...
#include <bits/stdc++.h> using namespace std; int main() { int A,B; cin >> A >> B; cout << (double)(A-B) / A * 100 << endl; }
#pragma GCC optimize("O3") // #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define per(i, b, a) for(int i = b - 1; i >= a; i--) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int...
#pragma GCC optimize(2) #include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define mp make_pair #define pb push_back #define visit asdf const int N=2e5+5; int n; int a[N],b[N],c[N],p[N]; vector< vector<int> > v; bool visit[N]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); ...
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } usin...
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m; int a[N], b[N]; int f[N][N]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= m; ++i) scanf("%d", &b[i]); memset(f, 0x3f, sizeof f); f[0][0] = 0; for (int i = 1; i <= n; ++i) f...
#include<bits/stdc++.h> #define ll long long using namespace std; //memset(dp, 0, sizeof(dp)); vector<int> l(200005); unordered_map<int, unordered_map<int, int>> h; int n, m; void dfs(int c) { for(auto &i : h[c]) { if(l[i.first] > 0) { continue; } if(i.second == l[c]) { l[i.first] = l[c] % n + 1; ...
#include<bits/stdc++.h> #define watch(x) cout << (#x) << " is " << (x) << endl #define endl "\n" typedef long long ll; using namespace std; int static fast = [](){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }(); // freopen("input.txt", "r", stdin); int main() { int n, x, y, z;; cin >> ...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,n,s; cin>>n>>a>>b; s=(n-a)+b; cout<<s<<endl; return 0; }
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #d...
#include<bits/stdc++.h> #define reg register typedef long long ll; using namespace std; inline int qr(){ int x=0,f=0;char ch=0; while(!isdigit(ch)){f|=ch=='-';ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} return f?-x:x; } const int N=1e5+100,mod=1e9+7; int n; int a[N],f[N],g[N]; struct ma...
#include<bits/stdc++.h> #define int ll #define sz(x) int((x).size()) #define all(x) (x).begin(),(x).end() using namespace std; using ll = long long; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; const int mod = int(1e9) + 7; int A[100100]; pi dp[100100][2]; signed...
//cd /mnt/f/UbuntuEnvironment //My life was going great until I stumble upon this question ); ): #include<bits/stdc++.h> using namespace std; #define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); long long MOD = 1000000007; //1e9+7 long long INF = 1e18; typedef long long ll; typedef long double ld; #d...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i,x,n) for(int i = x; i < n; ++i) #define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it) typedef long long ll; ll gcd(ll a, ll b){ return b?gcd(b,a%b):a; } ll ncr(ll n, ll r){ ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define sz(x) int(x.size()) using namespace std; int main() { int n; string s; cin >> n >> s; string t; for (char c : s) { t += c; if (sz(t) >= 3 && t.substr(sz(t) - 3, 3) == "fox") { rep(_, 3) ...
//@formatter:off #include<bits/stdc++.h> #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #defi...
#line 1 "A.cpp" #include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);} template<typename T,typename... Ts> auto make_v(siz...
#include <bits/stdc++.h> #define all(V) V.begin(),V.end() #define pi 3.1415926535897932384626 #define fi fixed<<setprecision(13) #define ll long long #define rep(i, n) for (int i = 0; i < (ll)(n); i++) #define Rep(i, n) for (ll i = 1; i <=(ll)(n); i++) #define reps(i,k,n) for (ll i = (ll)k; i < (ll)(n); i++) #define m...
#include <bits/stdc++.h> using namespace std; #define MOD 998244353 long long pows(long long a, long long b) { long long left = b; long long ans = 1; long long ks = a; while (left > 0) { if (left%2 == 1) ans = ans*ks%MOD; left /= 2; ks = ks*ks%MOD; } return ans; } long long mod_inv(long long ...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);++i) using namespace std; template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;} template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);put...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 1; while (x * (x + 1) < n * 2) { x++; } cout << x << "\n"; }
#include <algorithm> #include <bits/stdc++.h> #include <sys/ucontext.h> using namespace std; using ll = long long; #define rep(j ,i, n) for (int i = j; i < (int)(n); i++) int main(){ ll a = 1; ll n; cin>>n; rep(0,i,10000000){ ll c = i * (i+1) / 2; if(c >= n){ cout<<i<<endl; ...
#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 all(v) (v).begin(),(v).end() #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; retur...
#include <bits/stdc++.h> #define INF 1000000000000 #define MOD 1000000007 //10^9+7:合同式の法 #define MOD2 1000007 #define MOD3 998244353 using namespace std; typedef long long ll; /* 0のアスキー "48" */ //マクロ #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<...
// // main.cpp // test // // Created by wyzwyz on 2021/5/13. // #include<cstdio> #include<cctype> #define maxn 505505 template<class T> inline T read(){ T r=0,f=0; char c; while(!isdigit(c=getchar()))f|=(c=='-'); while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar(); return f?-r:r; } template<...
#include<bits/stdc++.h> #define pi 3.141592653589793238 #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #defin...
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FastIO ios_base::sync_with_st...
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<long long> A; long long a; for (long long i=0; i<N; i++) { cin >> a; A.push_back(a); } long long pos = 0, pos_max = 0; long long move = 0, move_max = 0; for (int i=0; i<N; i++) { move += A[i]; ...
#pragma GCC optimize("Ofast","inline","-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,mmx") #include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/hash_policy.hpp> #define int long long using namespace __gnu_pbds; using namespace std; int x,y; map<int,int> mp,vis; inline int dfs(int...
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() #pragma GCC optimize("Ofast") using namespace std; namespace FastIO { struct Pre { char ptr[10000 * 4]; int rd[1 << 16]; int tenpow[4]; conste...
#include <bits/stdc++.h> using namespace std; // #define int long long typedef pair<int, int> pii; #define ll long long #define ar array const ll mxN=300; const int mod=1e9+7; const ll INF=1e18; #define what_is(x) cerr << #x << " is " << x << endl; void solve(){ int n,t; cin>>n>>t; int a[n]; for(int i=0;i<n;i+...
#include<bits/stdc++.h> #define DONTSYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now! #define TEST unsigned long long T; cin>>T; while(T--) //loop over each testcase #define endl "\n" #define fori(a,start,end) for(i...
#include<bits/stdc++.h> using namespace std; int main(){ long long N; cin >> N; vector<long long> ans_front; vector<long long> ans_back; for(int i=1;i<sqrt(N);i++){ if(N%i==0){ ans_front.push_back(i); ans_back.push_back(N/i); } } if(sqrt(N) - (int)sqrt(N) ==0){ ans_front.push_back(sqrt(N)); } for(i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL<<62 #define inf 1000000007 int main() { ll n; cin>>n; map<ll,ll>q; for(ll i=1;i*i<=n;i++){ if(n%i==0){ q[i]++; q[n/i]++; } } for(auto itr=q.begin();itr!=q.end();itr++){ ll now=itr->first; cout <<now<<endl; } // yo...
#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> // 1. dp typedef long double ld; #define int long long #define gcd __gcd #define endl "\n" #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define mod2 998244353 #define maxe *m...
#include <bits/stdc++.h> // #include <atcoder/all> // #include "icld.cpp" using namespace std; using ll = long long int; using vi = vector<int>; using si = set<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using ss = string; using db = double; template<typename T> using minpq = priority_queue <T,vector...
#include<bits/stdc++.h> #define mp make_pair #define fi first #define se second #define pb push_back #define endl "\n" #define rep(i,j,k) for(int i=j;i<=k;i++) #define dec(i,j,k) for(int i=j;i>=k;i--) const int mod = 1e9+7; const int N = 3e5+5; using namespace std; #define debug(args...) { string _s = #args; replace(_...