code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> using namespace std; #define SZ(a) ((int)(a).size()) typedef long long int64; int main() { #ifdef LOCAL freopen(".a.in", "r", stdin); #endif ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); string s, t; cin >> s >> t; if (s[0] == 'Y') { if (t[0] >= 'A' && t[0] <= 'Z'...
#include<bits/stdc++.h> using namespace std; int main() { char S,T; cin >> S >> T; if(S=='Y') { if(T=='a') { cout<<'A'<<endl; return 0; } if(T=='b') { cout<<'B'<<endl; return 0; } if(T=='c') { cout<<'C'<<endl; return 0; } } else {...
#include<iostream> #include<vector> #include<string> using namespace std; vector<string> f(int n){ if(n == 1) return vector<string>{"AB"}; vector<string> ans = f(n - 1); int sz = ans.size(); for(int t = 0; t < sz; ++t){ ans[t] = ans[t] + ans[t]; string s = ans[t]; int siz = s.size...
#include <iostream> #include <string> using namespace std; using ll = long long; int main(){ ll N; cin >> N; for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){ cout << i - 1 << endl; return 0; } }
#include<iostream> #include<cstdio> using namespace std; #define M 100009 #define endl "\n" #define pb push_back #define ll long long int #define mod7 1000000009 int main() { /* #ifndef inout freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int n; cin >> n; if (n % 2 == 0) { ...
#include <bits/stdc++.h> using namespace std; long long solve(long long N){ vector<int>A; while(N){ A.push_back(N%10); N/=10; } const int INF=1<<29; int res=INF; for(int bit=0;bit<(1<<A.size())-1;bit++){ int sum=0,con=0; for(int i=0;i<A.size();i++){ if(bit&(1<<i)){ con++; } else sum += A[i];...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define ll long long #define rep(i,n) for(ll i = 0; i < (n); ++i) #define REP(i,x,n) for(ll i = (x); i < (n); ++i) #define P pair<ll,ll> #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() const ll mod = 1e9+7; const ll INF =...
#include <iostream> #include <string> #include <map> #include<vector> #include <cmath> using namespace std; #define ll long long vector<int> in; vector<int> adj[200001]; bool visited[200001]; void dfs(int x) { visited[x] = true; in.push_back(x); for(int next : adj[x]) { if(!visited[next]) dfs(next);...
#include <bits/stdc++.h> using namespace std; int n, m; int f[105][105], pw[105]; char s[105]; inline int get(char ch) { if(ch == 'P') return 0; if(ch == 'R') return 1; return 2; } inline int check(int a, int b) { if(a == 0) return b == 2 ? 2 : 0; if(a == 1) return b == 0 ? 0 : 1; return b == 1 ? 1 : 2; } int...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,k; char str[205],tmp[205]; char F(char x,char y){ if(x==y)return x; if(x=='S'&&y=='P')return x; if(x=='P'&&y=='R')return x; if(x=='R'&&y=='S')return x; return y; } int main(){ cin>>n>>k>>str+1; for(int j=1;j<=n;j++)str[j+n]=str[j]; for(int...
#include<bits/stdc++.h> using namespace std; # define ll long long # define read read1<ll>() # define Type template<typename T> Type T read1(){ T t=0; char k; bool vis=0; do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9'); while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar(); return vis?-t:t; } # define fre(k...
#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)<<'...
//红太阳zhouakngyang txdy! //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include<bits/stdc++.h> #define Macesuted cout<<"kawaii"<<endl #define MatrixCascade cout<<"npsl"<<endl #define Karry5307 cout<<"nmsl"<<endl using namespace std; #define int long long inline int read() { int su...
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin>> #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeo...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<typename T> using v2 = vector<vector<T>>; template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); } #define F first #define S second void solve(){ ll n; cin >> n; ll lo = 0; ll...
// Author: rifatrraazz // Time: 2021-05-10 10:25:19 // Problem: A - Century // TL: 2000ms ML: 1024MB // URL: https://atcoder.jp/contests/abc200/tasks/abc200_a #include <bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second #define yes cout << "Yes\n" #define no cout << "No\n" ...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<pair<int,int>>ans(n+1); for(int i=1;i<=n;i++){ ans[i].first=i*2%n; ans[i].second=(i*2+1)%n; } for(int i=1;i<=n;i++)cout<<ans[i].first+1<<' '<<ans[i].second+1<<'\n'; }
#include<iostream> using namespace std; int n,i; int main(){ cin>>n; for(i=1;i<=n;++i){ cout<<((i+1)>>1)<<" "<<((i+n+1)>>1)<<endl; } }
#include<bits/stdc++.h> #define ll long long using namespace std; const int p=1e9+7; int n,ans,f[3010][3010],sum[3010]; ll a[3010],s[3010]; int main(){ scanf("%d",&n); int i,j; for(i=1;i<=n;i++)scanf("%lld",&a[i]),s[i]=s[i-1]+a[i]; f[0][0]=1; for(j=1;j<=n;j++){ for(i=0;i<j;i++)sum[i]=0; for(i=0;i<=n;i++){ ...
/*input 12 5 2 5 6 1 2 9 7 2 7 5 5 4 2 6 7 2 2 7 8 9 7 1 8 */ #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 tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ...
// {{{ by unolight #include <bits/stdc++.h> #include <unistd.h> #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-function" #define SZ(x) ((int)(x).size()) #define ALL(x) begin(x),end(x) #define RALL(x) rbegin(x),rend(x) #define REP(i,n) for ( int i=0; i<int(n); i++ ) #define REP...
#include <cstdio> #include <climits> #include <cstdlib> #include <cmath> #include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <utility> #include <queue> #include <deque> #include <stack> #include <map> #include <unordered_map> #include <unordered_se...
#include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; template<typename T> using vec = vector<T>; template<typename T> using mat = vector<vector<T>>; bool debugflag = true; template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (int i = 0; i < ...
/* Author: Zhikun Wang Date: 2021/05/29 */ #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(t...
#include <cstdio> #define abs(x) ((x) < 0 ? -(x) : (x)) int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); if (c & 1) { if (a == b) puts("="); else if (a < b) puts("<"); else puts(">"); } else { a = abs(a), b = abs(b); if (a == b) puts("="); else i...
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; int n = s.size(); bool ok = 1; for(int i = 0; i<n; i++){ if(i&1 && s[i]>='a' && s[i]<='z') ok = 0; else if(i&1^1 && s[i]>='A' && s[i]<='Z') ok = 0; } cout<...
#include<bits/stdc++.h> using namespace std; double PI=acos(-1.0); #define ll long long #define ull unsigned long long #define pii pair<ll,ll> const ll mod=3; ll nn; ll fac[mod+105],inv[mod+105]; void getInv() { fac[0]=fac[1]=inv[1]=1; for(int i=2;i<mod;i++) { fac[i]=fac[i-1]*i%mod; inv[i]=(...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define fr(i,n) for(int i=0;i<n;i++) #define fro(i,j,n) for(int i=j;i<n;i++) #define ifr(i,n) for(int i=n-1;i>=0;i--) int lower_three(int x){ int a=1; while(3*a<x){ a*=3; } return a; } char change(char x,char y){ char list[3]={'R','W','B...
#include <bits/stdc++.h> #define clr(x) memset((x), 0, sizeof(x)) #define all(x) (x).begin(), (x).end() #define pb push_back #define mp make_pair #define For(i, st, en) for(int i=(st); i<=(int)(en); i++) #define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--) #define forn(i,m,n) for(int i=m; i<(int)(n); i++) #defin...
#include <bits/stdc++.h> using namespace std; int main() { int V, T, S, D; cin >> V >> T >> S >> D; if(D < V*T || V*S < D){cout << "Yes" << endl;} else{cout << "No" << endl;} }
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; using ll = long long; using ld = long double; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_nod...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll mod_pow(ll base, ll exp, ll modulus) { base %= modulus; ll result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result; } vo...
#line 1 "/workspaces/compro/lib/template.hpp" #line 1 "/workspaces/compro/lib/io/vector.hpp" #include <iostream> #include <vector> #ifndef IO_VECTOR #define IO_VECTOR template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { int size = v.size(); for (int i = 0; i < size; i++) { ...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int const int mod=1e9+7; const int mxx=1e5+10; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ff first #define ss second vector<int> adj[2222]; bool vis[2222]; int cnt; void dfs(int u){ vis[u]=...
#include <iostream> #include <vector> using namespace std; vector< pair< long long, long long > > prime_factorize(long long N) { vector< pair< long long, long long > > res; for(long long a = 2; a * a <= N; ++a) { if(N % a != 0) continue; long long ex = 0; while(N % a == 0) {...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define rep(i,n) for(ll i=0;i<ll(n);i++) #define REP(i,k,n) for(ll i=k;i<ll(n);i++) #define all(a) a.begin(),a.end() #define eb emplace_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bound(all(v),k)-v.begin()) #de...
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #includ...
#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;...
#include <stdint.h> #include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; #define FOR_N(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) #define FOR_R(i, b, e) for (int64_t i = int64_t(b); i < (int64_t)(e); i++) int main()...
#include <bits/stdc++.h> using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define...
#include <iostream> #include <iomanip> #include <vector> #include <string> #include <set> #include <queue> #include <cmath> #include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using P = pair<int,int>...
#include <iostream> #include <cstdio> #include <stdio.h> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <stack> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #...
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <tuple> #include <utility> #include <vector> #define rep(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; using ll = long long int ; using P = pair<ll,ll>; using Graph= vector<vector<ll>>; struct edge{ll to ; ll cost ;} ; using graph =vector<vector<edge>> ; #define rep(i,n) for (ll i=0; i < (n); ++i) #define rep2(i,n,m) for(ll i=n;i<=m;i++) #defin...
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <complex> #define ll long long #define inf 1e9 + 6 #define sinf 1e15 + 500 #define ld long double #define ull unsigned long long #define poll complex<double> #define line pair<poll, poll> #define pi acos(-1) #define lp(a, b, c, d) for (ll a = b; a < c; a += d...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define min3(a, b, c) min(a, mi...
#include <bits/stdc++.h> using namespace std; #define fr(i,n) for(int i = 0; i<n; i++) #define sz(v) (int)(v.size()) #define prin(a) cout << #a << " = " << a << endl #define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl #define all(v) (v).begin(),(v).end() typedef long long ll; #def...
#include<bits/stdc++.h> #define int long long #define double long double #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define pb push_back #define x first #define y second using namespace std; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; const ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; int n, x[MAXN], y[MAXN], ans; int read() { int sum = 0, fh = 1; char ch = getchar(); while (ch < '0' || ch > '9') {if (ch == '-') fh = -1; ch = getchar();} while (ch >= '0' && ch <= '9') {sum = (sum << 3) + (sum << 1) + (ch ^ 48); ch = getcha...
#include <iostream> #include <string> #include <vector> #include <cmath> #include <map> #include <numeric> #include <iomanip> #include <algorithm> using namespace std; int main(void) { double n, d, h,nd,nh,rus; rus = 0.0; cin >> n >> d >> h; for (int i = 0;i < n;i++) { cin >> nd >> nh; if (((h - nh)*(-1.0)*...
#include <bits/stdc++.h> #ifndef ONLINE_JUDGE #define debug(x) cout << #x << ": " << (x) << endl #else #define debug(x) #endif using namespace std; typedef long long ll; typedef vector<int> vi; const int maxn=1e6+7,inf=0x3f3f3f3f,mod=1e9+7; int main() { ios::sync_with_stdio(false); cin.tie(0); ll b,c; ...
/*#include<bits/stdc++.h> using namespace std; long long b,c,sub,ans; int main() { scanf("%lld%lld",&b,&c); sub=c/2; if(c&1) { ans=(sub+1)*2ll; if(b-sub<=0&&0<=b) ans--; } else { ans=sub*2ll+1; if(b-(sub-1)<=0&&0<=b) ans--; } if(b>0&&b-sub<0) ans-=min(b,sub-b);//max(abs(b),abs(b-sub))-min(abs(b),abs(b-...
#include <bits/stdc++.h> using namespace std; void Main(); using i8 = int8_t; /* -128 ~ 127 */ using u8 = uint8_t; /* 0 ~ 255 */ using i16 = int16_t; /* -32,768 ~ 32,767 */ using u16 = uint16_t; /* 0 ~ 65,535 */ using i32 = int32_t; /* -2,147,483,648 ~ 2,147,483,647 */ using u32 = uint32_t; /* 0 ~ 4,294,967,295...
#include <bits/stdc++.h> #define debug(x) cerr << #x << " = " << x << endl using namespace std; typedef long long LL; const int MAXN = 2E5 + 5; const int MOD = 1E9 + 7; string t; int n; stack<int> s; template <class T> void read(T& x) { x = 0; T f = 1; char ch = getchar(); while (ch < '0' || ch > '9...
#include <bits/stdc++.h> using namespace std; int main() { long long int N,i=0,a; cin>>N; a=log10(i)+1; while(i+i*pow(10,a)<=N){ i++; a=log10(i)+1; } cout<<i-1<<endl; }
#include<bits/stdc++.h> using namespace std; string a; int main() { cin>>a; for(int i=0;i<a.size();i++) { if(a[i]!='.') cout<<a[i]; else break; } return 0; }
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> #include<cstring> #include<algorithm> 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 ...
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define mod 1000000007 #define ad(a,b) a=(a+b)%mod; #define X 5010 ll po(ll x,ll y){ ll res=1; for(;y;y>>...
#include <iostream> using namespace std; int main() { int n; cin >> n; if(n%2 == 0) { cout << "White" << endl; } else { cout << "Black" << endl; } return 0; }
#include <iostream> #include <string> #include <algorithm> #include <deque> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(void){ int n; cin >> n; cout << (n-1)/100+1 << endl; }
#include <bits/stdc++.h> #define INF 1e9 #define INFLL 1ull<<60u using namespace std; #define REPR(i,n) for(int i=(n); i >= 0; --i) #define FOR(i, m, n) for(int i = (m); i < (n); ++i) #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define ALL(a) (a).begin(),(a).end() #define endl "\n" template<class T>b...
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <limits.h> #include <math.h> #include <time.h> #include <queue> #include <stdarg.h> #include <map> #include <unordered_map> #include <vector> #include <algorithm> #include <stack> #include <iostream> #include <numeric> #include <set>...
#include<bits/stdc++.h> using namespace std; inline int Read() { int x = 0, f = 1; char ch = getchar(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();} while(isdigit(ch)) {x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();} return x * f; } double f[105][105][105]; signed main() { for(int i = 99; i >=...
#include<bits/stdc++.h> #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define endl '\n' #define all(A) (A).begin(),(A).end() #define trace1(x) cerr<<#x<<": "<<x<<endl #define trace2(x, y) cerr<<#x<<": "<<x<<"...
//Bismillahir Rahmanir Rahim #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<pair<int, int>> vpi; #define pb push_back...
#include<bits/stdc++.h> using namespace std; #define ll long long #define cases() ll t;cin>>t;while(t--) #define pb push_back #define ff first #define ss second #define light ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); const ll MAX = 1e5+5; const ll INF = 1e18; const ll MOD = 1e9+7 ; int main() { ve...
#include <bits/stdc++.h> using namespace std; using int64 = long long; constexpr int DEBUG = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); int num_cases; cin >> num_cases; for (int case_id = 0; case_id < num_cases; case_id++) { int64 l, r; cin >> l >> r; int64 base_count = r - l - l...
#include <bits/stdc++.h> using namespace std; template <int mod = (int)(1e9 + 7)> struct ModInt { int x; constexpr ModInt() : x(0) {} constexpr ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} constexpr ModInt &operator+=(const ModInt &p) noexcept { if ((x += p.x) >= mod) x -= mo...
#include <bits/stdc++.h> #define F first #define S second #define MAX 10000003 using namespace std; #define ll long long int #include<fstream> #define fast ios_base::sync_with_stdio(false); #define io cin.tie(NULL); #define inp(arr,n) for(ll i=0;i<n;i++){cin>>arr[i];} #define print(arr,n) for(ll i=0;i<n;i++){cou...
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <cmath> #include <set> //#include <bits/stdc++.h> using namespace std; #define endl '\n' #define all(v) v.begin(), v.end() #define front(v) *v.begin() #define back(v) *(--v.end()) #define len(v) v.size() #define int long long using lo...
#include <bits/stdc++.h> #define LL long long #define ULL unsigned long long #define pb push_back #define st first #define nd second #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f template <class T> T read(T &a) { a=0;char x=getchar();bool f=0; for(;x<'0'||x>'9';x=getchar())f|=x=='-'; for(;x>='0'&&x<='...
#include <cstdio> #include <cmath> #include <iostream> #include <iomanip> #include <string> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <deque> #include <stack> #include <tuple> #include <bitset> using namespace std; typedef long long ll; const ll INF = 10000000000000...
#include <bits/stdc++.h> using namespace std; long long f[100]; int main() { f[0] = 0; f[1] = 1; for (int i = 2; i < 100; ++i) { f[i] = f[i - 2] + f[i - 1]; } long long n; scanf("%lld", &n); queue<int> Q; while (n) { int x = upper_bound(f + 1, f + 93, n) - f - 1; ...
#include<bits/stdc++.h> using namespace std; #define N 100005 #define mod 1000000007 #define ll long long vector<int>v; int ans[N]; ll n,a[N]; void add(int x,int p){ for(int i=ans[0];i>x;i--)ans[i+1]=ans[i]; ans[0]++,ans[x+1]=p; } int main(){ scanf("%lld",&n); a[0]=a[1]=1; for(int i=2;i<=90;i++)a[i]=a[i-1]+a[i-2];...
#include <string> #include <iostream> using namespace std; int main() { double n; cin >> n; n *= 1.08; n = (int)(n); if (n == 206) cout << "so-so" << endl; else if(n < 206) cout << "Yay!" << endl; else cout << ":(" << endl; }
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rrep(i,n) for(int i = (n-1);i>=0;--i) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; const int INF=1<<30; //const ll INF=1LL<<60; int ma...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") typedef long long ll; typedef long double ld; #define REP(i,a,b) for (int i = a; i <= b; i++) #...
// https://atcoder.jp/contests/abc201/tasks/abc201_d // if we reach i,j with different path then still the subproblem remain same. #include<bits/stdc++.h> #define M_PI 3.14159265358979323846 #define Speed_UP ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define pb push_back #define ...
#include <bits/stdc++.h> constexpr int DEBUG = 0; using namespace std; using int64 = long long; struct Edge { int s, t; Edge(int s, int t) : s(s), t(t) {} }; vector<vector<Edge>> ReadUndirectedGraph(int n, int m, int offset) { vector<vector<Edge>> graph(n); for (int i = 0; i < m; i++) { int v1, v2; cin >>...
#include <bits/stdc++.h> using namespace std; #define ALL(c) (c).begin(),(c).end() #define PB push_back #define IN(x,c) (find(c.begin(),c.end(),x) != (c).end()) #define REP(i,n) for (int i=0;i<(int)(n);i++) #define FOR(i,a,b) for (int i=(a);i<=(b);i++) #define INIT(a,v) memset(a,v,sizeof(a)) #define SORT_UNIQUE(c) (so...
#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> using namespace std; #define ll long long //ll a[10000007]; // ll binpow(ll a, ll b) { // ll res = 1; // while (b > 0) { // if (b & 1) // res = res * a; // a = a * a; // b >>= 1; // } // return res; // } // void SieveOfEratosthenes(ll n) // {...
#pragma GCC optimize("O3") #include "bits/stdc++.h" #define sz(x) (int)(x).size() using namespace std; const int64_t INV = int64_t(332748118); const int64_t MOD = int64_t(998244353); const int mxN = int(5e3) + 5; int64_t dp[mxN][mxN]; char arr[mxN][mxN]; int h,w,k; int main() { ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mii map <int, int> #define mll map <ll, ll> #define pii pair <int, int> #define pll pair <ll, ll> #define vi vector <int> #define vd vector <double> #define vll vector <ll> #define fi first #define se second #define si set ...
#include <bits/stdc++.h> using namespace std; #define ALL(v) (v).begin(),(v).end() #define REP(i,n) for(int i=0,i_len=n; i<i_len; ++i) template<typename T1,typename T2> bool chmax(T1 &a, T2 b) { if (a<b) { a=b; return 1; } return 0; } template<typename T1,typename T2> bool chmin(T1 &a, T2 b) { if (b<a) { a=b; return ...
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; using ll = long long; using ld = long double; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_nod...
#include <bits/stdc++.h> /*#include <cstdio> #include <algorithm> #include <iostream> #include <cmath> #include <cstring> #include <string>*/ using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn=2e5+10; const int mod=998244353; const int inf=0x3f3f3f3f; int n,T,a[maxn],m; double k[m...
//Code By CXY07 #include<bits/stdc++.h> using namespace std; //#define FILE #define int long long #define debug(x) cout << #x << " = " << x << endl #define file(FILENAME) freopen(FILENAME".in", "r", stdin), freopen(FILENAME".out", "w", stdout) #define LINE() cout << "LINE = " << __LINE__ << endl #define LL long long #...
#include <iostream> #include <vector> #include <algorithm> using namespace std; long long solve(int N, int M, vector<int> A) { A.push_back(0); A.push_back(N + 1); sort(A.begin(), A.end()); vector<int> B; for (int i = 1; i <= M + 1; ++i) { int D = A[i] - A[i - 1] - 1; if (D != 0) { B.push_back(D); } }...
// Template #include "bits/stdc++.h" #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (int)(n); ++i) #define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() using namespa...
/** * author: * created: 15.11.2020 00:57:15 **/ #pragma region Macros #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using P = pair<int,int>; using ll = long long; const int INF = 1001001001; const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; typedef vector<int> vi; typedef vector<vi> v...
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n - 1 << endl; }
// IN THE NAME OF GOD // https://serhatgiydiren.github.io // 2021/05/13 14:07:26 #include <bits/stdc++.h> using namespace std; using namespace chrono; class timer:high_resolution_clock { const time_point start_time; public: timer(): start_time(now()) {} rep elapsed_time() const { return duration_cast<millise...
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; char a[n][m]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>a[i][j]; } } int even=0,odd=0; ...
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <iomanip> #include <string> #include <cmath> #include <algorithm> #include <vect...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<pll> vpll; typedef vector<vpll> vvpll; typedef vector<bool> vbl; typedef vector<vector<bool>> vvbl; void INX(){} template<typenam...
#include<bits/stdc++.h> #define int long long using namespace std; typedef long long ll; const int N=100050; int a[N],b[N],c[N]; int n,m,k; int ans; bool check(int x) { int l=0,r=0; for(int i=1;i<=k;i++) { l+=(m*a[i]-x+n-1)/n; r+=(m*a[i]+x)/n; } if(l<=m&&m<=r) return true; else return false; } void construct...
#include <bits/stdc++.h> #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1)) #define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N #define macro_dispatcher(macro,...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__)) #define macro_dispatcher_(ma...
#include <bits/stdc++.h> long long func(std::vector<std::pair<long long, long long>> &vw, std::vector<long long> &boxsize, int l, int r) { std::vector<long long> box; for (int i = 0; i < (int)boxsize.size(); ++i) { if (i < l || i > r) box.push_back(boxsize[i]); } std::vector<bool> used(box.size(), false);...
#include<iostream> #include<algorithm> #include<cstring> #define debug(a) cout<<#a<<" = "<<a<<endl using namespace std; typedef long long ll; const int N = 5010; const int MOD = 998244353; int n , m; ll C[N]; ll f[N]; ll Q_power(ll a ,ll b){ ll res = 1; while(b){ if(b & 1) res = res * a % MOD; ...
#include <bits/stdc++.h> const long long INF = 1e9; //const long long MOD = 1e9 + 7; const long long MOD = 998244353; const long long LINF = 1e18; using namespace std; #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIB...
#include <iostream> using namespace std; typedef long long ll; const int MOD = 998244353; struct Modint { ll val; Modint (ll _val = 0) : val(_val % MOD) {} Modint operator+ (Modint other) const { return Modint(val + other.val); } void operator+= (Modint other) { val += other.val; val...
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define DEBUG #define i...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; int main() { ll T, N; cin >> T >> N; ll ans = (N * 100 + T - 1) / T + N - 1; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vc<vc<T>>; template<class T> using vvvc = vc<vvc<T>>; template<class T> using vvvvc = vvc<vvc<T>>; template<class T> using PQ = priority_queue<T>; template<class T> using invPQ = pri...
/* include c++ libraries */ #include <iostream> #include <string> #include <vector> #include <algorithm> #include <unordered_map> #include <map> #include <queue> #include <set> #include <bitset> #include <tuple> /* include c-lang libraries */ #include <climits> #include <cmath> #include <cassert> /* include my librar...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#i...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define pii pair<ll,ll> #define inf 1000000000000000000 #define bpc(x) __...
#include <bits/stdc++.h> # define INF32 2147483647 # define INF64 9223372036854775807 # define rep(i,l,n) for(int i=l,i##_end=n;i<i##_end;++i) # define rrep(i,n,l) for(int i=((int)(n)-1),i##_end=l;i>=i##_end;--i) # define erep(i,n) for(auto &i : n) # define ALL(x) (x).begin(), (x).end() # define SZ(x) ((int)(x).size())...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e6+10; const double eps = 0.01; inline ll read() { ll x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();} while (isdigit(ch)){x=x*10+ch-48;ch=getchar();} return x*f; } inline ll pt(ll ans,ll f){ ...
// Problem : C - ORXOR // Contest : AtCoder - AtCoder Beginner Contest 197(Sponsored by Panasonic) // URL : https://atcoder.jp/contests/abc197/tasks/abc197_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Delete the dynamically allocated memory #in...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve() { ll N; cin >> N; vector<ll> X(N); for ( int i = 0; i < N; i++ ) cin >> X[i]; // 素因数分解 O(x^(1/2)) auto PrimeFactor = [](ll x) { map<ll, ll> pr; for ( ll k = 2; k * k <= x; k++ ) { while ( ...
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> using namespace std; using Graph = vector<vector<long long>>; template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } } const long long INF = 1LL << 60; int N; double func (double x, const vector<double> &a) { ...
/*Rabbi Zidni Ilma*/ #include<bits/stdc++.h> using namespace std; #define ll long long #define scl(n) scanf("%lld",&n) #define scll(n,m) scanf("%lld %lld",&n,&m) #define pb push_back #define mp make_pair #define fr first #define sc second #define mod 1000000007 #define read freopen("input.txt","r",stdin) #define write...
#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> //#include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; //#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define rep(i,a,b) for(ll i=a;i<b;i++) #define rev(i,b,a) for (ll i = b - 1; i >= a;...
#include<bits/stdc++.h> using namespace std; #define ll long long ll pwr(ll a, ll b){ ll res=1; while(b>0){ if(b&1) res=res*a; a*=a; b>>=1; } return res; } int main() { ll n; cin>>n; ll a[n],b[n]; ll sum=0; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<n;i++) { ci...
#include <bits/stdc++.h> using namespace std; int arr[801][801], prefix[801][801]; int n, k; bool check(int m){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(arr[i][j] <= m) prefix[i][j] = 1; else prefix[i][j] = 0; prefix[i][j] += prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1]; ...
#include <bits/stdc++.h> using namespace std; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; struct position { int x, y; }; int main() { int h, w; cin >> h >> w; position g = {0, 0}; vector<string> a(h); vector<vector<int>> c(h, vector<int>(w, 1 << 30)); vector<vector<pos...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) #define all(v) v.begin(),v.end() using i64=int64_t; int main() { int n; cin>>n; vector<int> x(n),y(n),r(n); rep(i,n) { cin>>x[i]>>y[i]>>r[i]; } vector<int> a(n),b(n),c(n),d(n); rep(i,n-5) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 50; const int inf = 1e9; inline int lowbit(const int & x) { return x & (-x);} int n, rt; int ls[maxn], rs[maxn]; int a[maxn][maxn]; void check() { for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) a[i][j] = (i == j) ? 0 : inf; for(int i = 1; ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' int main() { ll b,c; cin>>b>>c; if(b==0) cout<<c; else { ll ans=0; if(c%2) { ans+=c-1; if(b>0&&c>1) ans-=1; ans+=2; ans+=2*m...
#include <bits/stdc++.h> #define rep(i, n) for(int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++) #define ALL(v) (v).begin(), (v).end() #define LLA(v) (v).rbegin(), (v).rend() #define SZ(v) (v).size() #define INT(...) \ ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair<int, int>; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; vector<int> a(n), b(m); rep(i, n) cin >> a[i]; rep(i, m) c...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(N), B(M); for (auto &Ai : A) cin >> Ai; for (auto &Bi : B) cin >> Bi; set<int> XOR; for (auto Ai : A) XOR.insert(Ai); for (auto Bi : B) { if (XOR.count(Bi)) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>; using graph = vector<VI>; template<class T = ll> using w_graph = vector<vector<pair...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #pragma GCC optimize ("-O3") #define int long long #define ld long double #define endl "\n" #define rep(i,begin,end) for (__typeof(end) i=begin-(begin>end); i!=(end)-(begin>end); i+=1-2*(begin>end)) #defin...
#include <iostream> #include <algorithm> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <string.h> #include <vector> #include <queue> #include <cmath> #include <complex> #include <functional> #include <numeric> #include <iomanip> #include <cassert> #include <random> #include ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; ++i) #define ll long long template <typename T> bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;} const ll MOD = 1e9+7; ...
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string s; cin >> s; int x = 0, o = 0, q = 0; for (auto &i : s) { if (i == 'x') x++; else if (i == 'o')...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int res = 0; for (int i = 0; i < 10000; i++) { int n = i; vector<int> d(4); for (int j = 0; j < 4; j++) { d.at(j) = n%10; n /= 10; } bool check = true; for (int j = 0; j < 4; j++) { if (s....
#include <iostream> using namespace std; int main(void) { /* code */ /* A,Tの数、C,Gの数がそれぞれ等しい*/ /* 1文字ずつ足していき、最後の文字を含めた部分文字列のみを捜索するDP法 */ int N; string S; int answer = 0; std::cin >> N >> S; for (int i = 0; i < N; i++) { int c1 = 0; int c2 = 0; for (int j = i; j < N; j++) { ...
#include <bits/stdc++.h> #define rep(i, n) for(int i=0; i<(int)(n); i++) #define FILL0(x) memset(x,0,sizeof(x)) #define FILL1(x) memset(x,-1,sizeof(x)) using namespace std; typedef long long ll; typedef pair<ll, ll> P; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<...
// // Created by Kushagra on 30-01-2021. // #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; #define F first #define S second #define PB push_back #def...
#include <iostream> int main(){ int N, S, D; std::cin >> N >> S >> D; int X, Y; long long ans = 0; for(int i=0; i<N; ++i){ std::cin >> X >> Y; if(X<S && Y>D) ans += Y; } std::cout << (ans>0 ? "Yes" : "No") << std::endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> pl; struct edge { ll to; // 辺の行き先 ll weight; // 辺の重み edge(ll t, ll w) : to(t), weight(w) { } }; typedef vector<vector<ll> > Graph; typedef vector<vector<edge> > WGraph; #define rep(i, n) for(...
#include <bits/stdc++.h> using namespace std; const long long N=200005; vector<long long> edge[N]; long long tinggi[N]; long long isi[N]; long long berat[N]; long long a[N]; long long b[N]; void cari(long long a,long long harga,long long par){ berat[a]=isi[a]+harga; int banyak=edge[a].size(); for(int i=0...
#define DEBUG #define OPTIMIZE //#define PBDS //#define INTERACTIVE #include <bits/stdc++.h> using namespace std; const int MAXN = 1e3; const int INF = 0x3f3f3f3f, MOD = 1000000007; const long long LINF = LONG_LONG_MAX; #define INIT(arr, val) fill(arr, arr+(int)(sizeof(arr)/sizeof(arr[0])), val) #define REP(i, lb, ...
#include <bits/stdc++.h> using namespace std; #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define ll long long int main() { SPEED int n; cin >> n; vector<string> clean; unordered_map<string, int> mp; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s[0] == '!') { string...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define mod 1000000000000007 #define ff first #define int long long #define pb push_back void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout....
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp" #define _CRT_SECURE_NO_WARNINGS #pragma target("avx2") #pragma optimize("O3") #pragma optimize("unroll-loops") #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex>...
#include <algorithm> #include <iostream> #include <vector> #include <string> #include <map> #include <cmath> using namespace std; using ll = long long; using ull = unsigned long long; constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF constexpr int INTINF {1000000000};//int = 2*INTINF #define rep(i,n) for(in...
#include<iostream> using namespace std; int main() { int m, h; cin >> m >> h; if(h % m == 0) cout << "Yes"; else cout << "No"; return 0; }
#include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pb push_back #define mp make_pair #define for0(i,n) for(int i=0;i<n;i++) #define for1(i,n) for(int i=1;i<=n;i++) #define w(x) int x;cin>>x...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i =0; i <(n); i++) using ll = long long; int main(){ int a,b; cin >> a >> b; cout << (double)(a-b)/a*100; }
#include<bits/stdc++.h> using namespace std; int main() { double a , b; cin>>a>>b; scanf("%lf%lf" , &a,&b); double ans = (a - b)/a; ans = (ans * 100.0); printf("%.7f" , ans); }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ll> vl; typedef vector<pair<int,int>> vpi; #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++) #define pb push_back #define rev(i,a,b) for(i...
// D - Circle Lattice Points #include <bits/stdc++.h> using namespace std; using ll = int64_t; using dbl = long double; ll MAX = 2e9, scale = 1e4; ll X, Y, R; ll in(){ dbl x; cin>>x; return round(x*scale); } ll lo_bin(ll dy2){ ll ok = X; ll ng = -(MAX + 1); while(ok - ng > 1){ ll x = (ok + ng) / 2; ll dx = ...
#pragma GCC optimize("Ofast") #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 main(){ cin.tie(nullptr); ios::sync_with_stdio(false)...
#include <bits/stdc++.h> #define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++) #define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++) #define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--) #define deb(x) std::cout << #x << " " << x << endl; #define debl(x) std::cout << #x << " " << x << " "; #define all(x) x.beg...
#include <bits/stdc++.h> using namespace std; int v, t, s, d; int main() { cin >> v >> t >> s >> d; if (d >= v * t && d <= v * s) puts("No"); else puts("Yes"); return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a,b,c,d; cin >> a >> b >> c>>d; cout << min({a,b,c,d}) << endl; }
#include <bits/stdc++.h> #define ll long long int #define pii pair<ll,ll> #define vi vector<ll> #define mii map<ll,ll> #define pb push_back #define mp make_pair #define fi first #define se ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define vi vector<int> #define vc vector<char> bool cmp(ll a,ll b) { return a>b; } ll lcm(ll n,ll m) { return (n*m)/__gcd(n,m); } bool status[10000+ 1]; vi v,vp; void siv() { ll N= 10000; for (int i = 2; i*i <= N...
#include <bits/stdc++.h> #define int int #define maxn 800005 #define mod 3 using namespace std; int n; char r[maxn]; char get_char(){ char ch = getchar(); while(ch != 'W' && ch != 'B' && ch != 'R') ch = getchar(); return ch; } int jc[maxn], inv[maxn]; int qpow(int a, int b, int p){ if(b == 0) retu...
#include<bits/stdc++.h> using namespace std; using ll=long long; ll fac3[400005]; ll fac[400005]; ll N; string s; void init_(){ fac3[0]=0;fac[0]=1; for(ll i=1;i<400005;i++){ ll x=0;ll I=i; while(I%3==0){ I/=3;x++; }fac3[i]=fac3[i-1]+x; fac[i]=(fac[i-1]*I)%3; } } i...
#include<bits/stdc++.h> using namespace std; const double phi=(1+sqrt(5))/2; int main(){ long long N; cin>>N; long long T=(long long)(N/(1+phi)-500000); for(int ttt=0;ttt<1000000;ttt++){ if(T+ttt<0)continue; vector<array<long long,2>>A(1); A[0]={N,T+ttt}; for(int i=0;i<130;i++){ if(A[i][0...
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> #include <set> #include <map> #include <queue> #include <deque> #include <bitset> #include <math.h> #include <random> #include <chrono> #include <assert.h> using namespace std ; using...
#include<bits/stdc++.h> using namespace std; using ll = long long; using llu = unsigned long long; using ld = long double; #define CEIL(x, y) (ll)ceil((ld)(x) / (ld)(y)) #define dbgPR(ds) cout << ds.first << ' ' << ds.second #define dbgLST(ds) for(auto it : ds) cout << it << ' ' #define dbgMP(ds) for(auto it : ds) c...
#include <iostream> #include <vector> #include <numeric> #include<cstdlib> #include <map> #include <algorithm> // std::random_shuffle #define INF (1<<30) #define ll long long using namespace std; int main() { int N; cin>>N; ll K; cin>>K; vector<pair<ll,ll>> AB; for(int i=1;i<=N;i++) { ...
#include<bits/stdc++.h> #define LL long long #define dl double template <class T> void rd(T &x){ x=0;T f=1;char ch=getchar(); while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch<='9' && ch>='0'){x=x*10+ch-'0';ch=getchar();}x*=f; } using namespace std; int main(){ // freopen("in.txt","r",st...
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() using ll = long long; using P = pair<int,int>; using mp = map<int,int>; const int MOD = 1e9 + 7; const int INF = 1001001001; int main(){ int k; cin >> k; ll ans = 0; for(int i = 1; i <= k; i++){ for(int j ...
#include<bits/stdc++.h> #define int long long #define pb push_back #define pii pair<int,int> #define F first #define S second #define debug(x) cerr << #x << " = "<< x << "\n" #define shaman ios::sync_with_stdio(0),cin.tie(0); using namespace std; constexpr int inf=1e18,N=400010; vector<int> v[N]; bool vis[N],ok; int DF...
#include<bits/stdc++.h> #define ll long long int #define ld long double #define pi pair<int,int> #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define sz(x) ((int)x.size()) #define ln(x) ((int)x.length()) #define mp make_pair #define pb push_back #define ff first #define ss second #define endl ...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; const int inf = 0x3f3f3f3f; const int N = 4e5 + 10; const int mod = 1e9 + 7; bool vis[N], flag; vector<int> e[N]; int cnt1 = 0, cnt2, idx = 0; int a[N], b[N], c[N]; int find(int x) { return lower_bound(c + 1, c + 1 + i...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define print(x) cout << #x <<" = " << x <<"\n" #define pprint(x) cout << #x <<" = (" << x.first <<", " << x.second <<")\n" #define all(x) x...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;++i) #define REP(i,a,b) for(int i=int(a);i<(int)b;++i) #define irep(i,a,b) for(int i=int(a);i<(int)b;++i) #define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i) #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vec...
#include<bits/stdc++.h> #define int ll #define sz(x) int((x).size()) #define all(x) (x).begin(),(x).end() #define x first #define y second using namespace std; using ll = long long; using pi = pair<int,int>; const int inf = 0x3f3f3f3f3f3f3f3f; const int minf = 0xc0c0c0c0c0c0c0c0; signed main() { ios::sync_with_s...
#include <bits/stdc++.h> #define all(a) (a).begin(), (a).end() using namespace std; using ll = long long int; using pii = pair<ll, ll>; using vi = vector<ll>; template <typename T> void out(const T& t) {cout << t << '\n';} vi vin(int n) {vi res(n); for(auto&i:res)cin>>i; return res;} ll in() {ll x; cin>>x; return x;} ...
#include<bits/stdc++.h> using namespace std; const long mod=998244353; const long Beneath=300000; vector<long> fac(Beneath+1),ifac(Beneath+1); long mpow(long x,long n){ long ans=1; while(n!=0){ if(n&1) ans=ans*x%mod; x=x*x%mod; n= n>>1; } return ans; }; long comb(long a,long b){ if(a==0 && b==...
#include <bits/stdc++.h> using namespace std; #define REP(i,x,n) for(int i=x;i<(int)n;i++) #define rep(i,n) REP(i,0,n) #define sp(p) cout<<setprecision(16)<<fixed<<p<<endl; #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define SORT(a) sort(all(a)) #define RSORT(a) sort(rall(a)) #define UNIQ(a) un...
#include<bits/stdc++.h> #define LL long long #define ull unsigned long long #define F(i,j,k) for(int i=(j);i<=(k);i++) #define DF(i,j,k) for(int i=(j);i>=(k);i--) #define P pair #define dui priority_queue using namespace std; template<typename T>inline void read(T &n){ T w=1;n=0;char ch=getchar(); while(!isdigi...
#include <iostream> #include <vector> #include <limits> #include <cstring> #include <time.h> #include <math.h> #include <algorithm> #include <list> #include <stack> #include <queue> #include <set> #include <unordered_set> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef unsign...
#include<bits/stdc++.h> using namespace std; int n,m,e[25][25],f[1<<19]; vector<int> v; int main() { int x,y; scanf("%d %d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d %d",&x,&y); e[x][y]=e[y][x]=1; } memset(f,0x3f,sizeof(f)); for(int i=1;i<(1<<n);i++) { v.clear(); for(int j=1;j<=n;j++)if(i&(1<<(j-1)))v.p...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #ifdef ENABLE_DEBUG #define dump(a) cerr<<#a<<"="<<a<<endl #define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl #else #define dump(a) #define dumparr(a,n) #endif #...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() #define all(x) (x).begin(),(x).end() #define SORT(x) sort(all(x)) #define SORT_REVERSE(x) SORT(x);reverse(all(x)) double calc_scor...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; /* 実行時MODint : template <int& MOD = 1000000007> static ...
/** template for testing/using the algorithms import(copy-paste the methods ;v) algorithm/s and use here **/ #include <iostream> #include <bits/stdc++.h> using namespace std; ///------------------- algorithm function/s to be placed here start -------------------/// bool isEqual(double a, double b){ ...
#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...
// R SAI KRISHNA #include <bits/stdc++.h> #define for0(i, n) for (int i = 0; i < (ll)(n); ++i) #define for1(i, n) for (int i = 1; i <= (ll)(n); ++i) #define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i) #define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (ll)(n); i >= 1...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(x) ((x).begin()), ((x).end()) #define READ(x) (cin >> (x)) #define WRITE_N(x) (cout << (x) << endl) #define WRITE(x) (cout << (x)) #define WRITE_Y...
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<bool> a(n, false); int r = 0; for (int i = 0; i < n; i++) { int p; cin >> p; if (p >= 0 && p < n) { a[p] = true; } while (r < n && a[r]) { r...
/*Author-Nilesh Chandra(isocyanide7)*/ #include <bits/stdc++.h> using namespace std; #define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); #define ll long long #define dd double #define pb push_back #define ff first #define ss second #define Mp make_pair const ll Mod=1000000007; const ll INF=9999999999...
#include <bits/stdc++.h> using namespace std; int main(){ cout << fixed << setprecision(15); double sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; gy = -gy; double a = (gy - sy) / (gx - sx); double b = sy - a * sx; double x = -b / a; cout << x << endl; }
#include <bits/stdc++.h> #define rep(i, x, y) for (int i = x; i <= y; i++) #define per(i, x, y) for (int i = x; i >= y; i--) #define vi vector<int> #define pb push_back #define mkp make_pair #define fi first #define se second #define gc getchar #define db double #define int long long #define bs bitset #define ll long l...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define pii pair<ll,ll> bool mycomp(pii a,pii b) { if(a.first==b.first) return a.second>b.second; return a.first<b.first; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll k,n,m,sum=0; cin>>k>>n>>m; ll...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,int> P; #define rep(i,n) for(int i=0;i<int(n);i++) #define INF 1e18 #define MOD 1000000007 #define MAXR 100005 template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool chmin(T& a, T...
#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 lli long long int #define llu unsigned long long int #define pb push_back #define rt return 0 #define endln "\n" #define all(x) x.begin(), x.end() #def...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#include <bits/stdc++.h> using namespace std; int a[200100], pos[200100]; int main(){ int i, j, N, ans1 = 0, ans2 = 0; cin>>N; for(i=1; i<=N; i++) { scanf("%d", &a[i]); pos[a[i]] = i; if(a[i] > i) ans2 += a[i] - i; if(a[i] == i) { cout<<-1; return 0; } if(a[i] < i) ans1 += i - a[...
#include <iostream> using namespace std; int main() { int n; cin >> n; string c = "White"; if(n%2==0){ c = "White"; } else{ c = "Black"; } cout << c <<endl; }
#include <iostream> #include <memory.h> #include <cmath> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); char a, b, c; cin >> a >> b >> c; cout << ((a==b && b==c) ? "Won" : "Lost") << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; void fast(){ cin.tie(); cin.sync_with_stdio(); } int main() { fast(); int n; cin>>n; if(n==1) cout<<"0"; else if(n==2) cout<<"1"; else if(n>2) cout<<n-1; return 0;...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define rep(i,j,n) for(int64_t i=j;i<n;i++) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)v.size()) #define br '\n' void resp(int tc) { int x; cin >> x; cout << max(0, x) << br; } int main() { int tc=1; // cin >> tc; w...
// Problem: D - Shipping Center // Contest: AtCoder - Panasonic Programming Contest (AtCoder Beginner Contest 195) // URL: https://atcoder.jp/contests/abc195/tasks/abc195_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // Parsed on: 13-03-2021 18:36:40 IST (UTC+05:30) // Author: Kapil Choudhary // *******************...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define rrep(i, a, b) for (int i = (a); i >= (b); --i) #define PB push_back #define ar2 array<int, 2> typedef long long LL; const LL P = 1e9 + 7; const LL INF = 1e9; const int N = 2e5 + 5; mt19937 rng(time(0)); int T, n...
//Radhe Radhe #include<bits/stdc++.h> #define FASTIO_ ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0); #define ll long long #define mod 1000000007 #define ld long double #define fi first #define se second #define mp make_pair #define pb push_back #define itr(i,n) for(ll i=0; i<n; i++) #define itr_ab(i,a...
#include"bits/stdc++.h" #define rep(i,n) for(ll i=0;i<n;++i) #define ALL(x) x.begin(),x.end() #define MOD 1000000007 #define INF INT_MAX #define FLOAT_ANS setprecision(10) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; retur...