code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include <bits/stdc++.h> using namespace std; #define ll long long #define P pair #define fi first #define se second #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define pb push_back #define eb emplace_back template<class T>void chmax(T &a,T b){if(a<b)a=b;} template<class T>void chmin(T &a,T b...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> #define int long long int #define endl "\n" #define ...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <queue> #include <deque> #include <bitset> #include <iterator> #include <list> #include <stack> #include <map> #include <set> #include <functional> #include <numeric> #include <utility> #include <iomanip> #include <...
// #include "pch.h" #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <string> #include <cmath> #include <bitset> #include <complex> #include <functional> #include <ctime> #include <cassert> #include <fstream> #include <stack> #include ...
#include <bits/stdc++.h> int main(){ int N; std::cin>>N; int A, B, A_max = 0; int B_min = 1000; for (int i = 0; i<N; ++i){ std::cin>>A; if(A>A_max) A_max = A; } for (int i = 0; i<N; ++i){ std::cin>>B; if(B<B_min) B_min = B; } int c = 0; for (int i = A_max; i<=B_min; i++...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define irep(i, n) for (int i = (n); i >= 0; i--) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1 << 25; const int MOD = 1e9+7; int a[1010], b[1010]; int main() { int n; cin >> n; rep(i,n) cin >> a[i...
#include<bits/stdc++.h> // #pragma GCC2 optimize(2) #define cio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); using namespace std; typedef long long ll; vector<ll> v; int main() { // cout<<"kdhfj"<<endl; cio; int a,b,c; cin>>a>>b>>c; if(c%2==0) { int aa=abs(a); int bb=abs(b); if(aa>bb...
#include <bits/stdc++.h> using namespace std; main() { int N, W; scanf("%d %d", &N, &W); printf("%d", N / W); }
#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;} using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; struct part { int v, l; part(int v=0, int l=0): v(v),...
#include<iostream> #include<algorithm> #include<cstring> using namespace std; int n, m, c[10], dl[10], vis[10], ans = 0x3f3f3f3f, lx[10], db[10]; struct judge { int l; int v; }; judge a[100010]; bool tmp(judge x, judge y) { if (x.l != y.l) return x.l < y.l; else return x.v > y.v; } int findl(int x) { ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double vector<vector<int>> edge; vector<int> v; vector<int> d; int dfs(ll now, ll pre, ll target) { int res = 0; int ma = -1, mi = 1000000; int dma = -1, dmi = 1000000; int cnt = 0; for (int nxt : edge[now]) { ...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define task "asd" #define pll pair<ll, ll> #define pii pair<pll, ll> #define fi first #define se second using namespace std; const ll mod = 1e15+7; const ll N = 2e5+5; const int base = 313; ll n, m, t, k, T, ans, siz, tong, a[N], b[N], d[N], c[N], h[N...
#include <bits/stdc++.h> #define int ll #define double long double #define rbtree __gnu_pbds::tree<int,__gnu_pbds::null_type,less<int>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> #define IOS ios_base::sync_with_stdio(false);cin.tie(0); #define pb push_back #define ALL(X) X.begin(),X.end() #de...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll t; cin>>t; while(t--){ ll x; cin>>x; if(x%2==1){ cout<<"Odd"<<'\n'; continue; } if(x>=4 && x%4==0){ cout<<"Even"<<'\n'; continue; } if(x%2==0){ cout<<"Same"<<'\n'; continue; } } }
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> P; const int maxn = 500 + 10; const int M_MAX = 10 * maxn * maxn; const int mod = 1e9 + 7; const LL INF = 0x3f3f3f3f; const double eps = 1e-6; struct edge { int to, cost, next; }e[5000010]; int...
#include <stdio.h> inline int read() { int b = getchar(), c = 0; int m = b == 45; if (m) b = getchar(); while (b > 47) { c = c * 10 + b - 48; b = getchar(); } return m ? - c : c; } int p[200001]; int main() { int a[400002]; int n = read(), m = read(); long s = 0; ...
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; ///Welcome to Nasif's Code #define bug printf("bug\n"); #define bug2(var) cout<<#var<<" "<<var<<endl; #define co(q) cout<<q<<endl; #define all(q) (q).begin(),(q).end() #de...
/* In the name of *Allah* * * Thank You *Parsa* */ #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops, avx, avx2, fma") #include<iostream> #include<algorithm> #include<math.h> #include<string> #include<ios> #include<vector> #include<utility> #include<set> #include<map> #include<numeric> using name...
#include<bits/stdc++.h> using namespace std; const int maxn=2020; int n,m; int fa[maxn]; int fnd(int x) { if(fa[x]==x) { return x; } return fa[x]=fnd(fa[x]); } void merge(int x,int y) { fa[fnd(x)]=fnd(y); } set<int> s1,s2; int main() { cin>>n>>m; for(int i=1;i<=n+m;i++) { fa[i]=i; } merge(1,n); merge(1,n...
#include<bits/stdc++.h> using namespace std; namespace IO { const int buffer_size=1e5+5; char buf[buffer_size],*S,*T; bool flag_EOF; inline char read_char() { if(S==T) T=(S=buf)+fread(buf,1,buffer_size,stdin); return S!=T?*(S++):EOF; } inline int read_int() { ...
#include <stdio.h> #include <string.h> #include <algorithm> int main() { int A, B, W; scanf("%d%d%d", &A, &B, &W); W *= 1000; int ansmin = 0xfffffff; int ansmax = -1; for (int n = 1; n <= 1000 * 1000; n++) { if (A * n <= W && W <= B * n) { ansmin = std::min(ansmin, n); ansmax = std::max(ansmax, n); } ...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define repa(i,a,n) for (long long i = (a); i < (long long)(n); i++) #define Rrep(i,n) for (long long i = (long long)(n)-1; i >= 0; i--) #define Rrepa(i,a,n) for (long long i = (long l...
#include<bits/stdc++.h> #define int long long #define ll long long #define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define fs first #define sd second #define rept(x,n) for(int i=x;i<n;i++) #define rrept(n,x) for(int i=n-1;i>=x;i--) #define all(v) v.begin(),v.end() #define mpit map<int,int>::...
#include <bits/stdc++.h> #define fr first #define se second #define ll long long #define pb push_back using namespace std; const ll INF = 1e16 + 1; const ll N = 2e3 + 5; const ll mod = 1e9 + 7; const long double eps = 1E-7; ll n, m, cnt; int main() { string s; cin >> s; for ( int i=0; i<s.size(); i+=2 ){ if ( s...
#ifdef LOGX #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; /*---------macro---------*/ #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++) #define unless(x) if(!(x)) #define until(...
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> typedef long long ll; typedef std::vector<int> P; typedef unsigned un; ll read() { ll x=0,f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar(); retur...
#include <stdio.h> #define mod 998244353 typedef long long ll; int main(void) { ll i, j, k, n; scanf("%lld%lld", &n, &k); ll dp[n + 1][n + 1]; for(i = 0; i <= n; ++i) dp[i][0] = 0, dp[i][i] = 1; for(i = 2; i <= n; ++i) for(j = i - 1; j; --j) { dp[i][j] = dp[i - 1][j - 1]; if(j * 2 <= i) dp[i][j] += d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0...
#include <bits/stdc++.h> using namespace std; int N, a[505]; void solve() { cin >> N; for (int i = 1; i <= N; i++) cin >> a[i]; vector<int> ans; for (int stp = 1; stp <= N * N; stp++) { bool flg = 1; for (int i = 2; i <= N && flg; i++) flg &= a[i - 1] < a[i]; if (flg) break; int cur = (stp & 1) ? 1 : 2; f...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> #define mkp make_pair #define mkt make_tuple #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) v.begin(), v.end() using namespace...
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define ld long double #define pb push_back #define pf push_front #define pll pair<ll,ll> #define ppl pair<pll,ll> #define plp pair<ll,pll> #define pi 3.14159265358979323846264338327950 const ll MOD=1e9+7; using namespace std; ll n,m,q,x[5...
#include <bits/stdc++.h> using namespace std; // template {{{ #define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1) #define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1) #define whole(f, x, ...) ([&](decltype((x)) container) { return (f)( begin(container), end(container), ## ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; vector<vector<int>> g(n); vector<int> vis(n, -1); vector<bool> dfn(n, false); vector<int> sz(n, 0); vector<vector<int>> adj(n, ve...
// #pragma GCC optimize(2) // #pragma GCC optimize(3) // #pragma GCC optimize("Ofast") #include<iostream> #include<cmath> #include<vector> #include<algorithm> #include<utility> using namespace std; #define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i) #define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--) #defin...
#include <bits/stdc++.h> // #include <atcoder/all> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for(int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; // using namespace atcoder; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}e...
#include <bits/stdc++.h> #define ll long long #define mod 1e9 + 7 using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ll x, y, z; cin >> x >> y >> z; if (ceil(((long double)(y * z) / (long double)x)) == floor(((long doub...
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("O3") #include <bits/stdc++.h> #include <sys/time.h> using namespace std; #define NUM_CAN 20 struct state { int x; int y; int score; string path; set<int> used; }; bool operator< (const state &state1, const state &state2)...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using P = pair<int,int>; constexpr int N = 50; constexpr int Node = 500; int sx, sy, m = 0; double start; int t[50][50]; int p[50][50]; constexpr char dir[4] = {'R','D','L','U'}; constexpr int dx[4] = {0,1,0,-1}; constexpr in...
//Don't act like a loser. //This code is written by huayucaiji //You can only use the code for studying or finding mistakes //Or,you'll be punished by Sakyamuni!!! #include<bits/stdc++.h> #define int long long using namespace std; int read() { char ch=getchar(); int f=1,x=0; while(ch<'0'||ch>'9') { if(ch=='-') ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, a[205]; vector<int> c[205], b; void dfs(int x, int sum) { if (c[sum].size() && b != c[sum]) { cout << "Yes\n"; cout << b.size() << ' '; for (int i : b) cout << i << ' '; cout << "\n"; cout << c[sum].si...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ull unsigned long long #define loops(i, s, n) for (ll i = s; i < (ll)n; i++) #define loop(i, n) loops(i, 0, n) #define ALL(a) a.begin(), a.end() #define pub push_back #define pob pop_back #define mp make_pair #define dump(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var <= (end); var++) #define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--) #define REP(var, length) FOR(var, 0, length - 1) #define RREP(var, length) RFOR(var, length - 1, 0) #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef pair<int,int> Pair; typedef tuple<int,int,int> tpl; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); constexpr int N = 400000; int n; cin >> n; vector<int> a(n), b(n); vector<vector<int>> g(N); vector<int> cnt(N); vector<bool> used(n), visited(N); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i];...
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.h" #define input freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else #define debug(...) 4 #define input 4 #endif using ll = long long; //const int mod = 998244353; const int mod = 1e9 + 7; const int N =...
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; //using namespace atcoder; using ll = long long; typedef pair<ll,ll> P; typedef pair<ll,P> PP; typedef vector<vector<int> > Graph; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } temp...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DU...
#include<bits/stdc++.h> #include<stdio.h> #include<queue> #define ll long long #define ull unsigned long long #define ln "\n" using namespace std; #define dbg(x) cout<<#x<<" = "<<x<<" " #define rep(i,s,n) for(ll i = (s);i<(n);++i) void solve(){ ll n; cin>>n; vector<ll>cnt(n+1,0); for(int i=0;i<n;i++) { cnt[...
#include<bits/stdc++.h> using namespace std; #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); #define ll long long #define ull unsigned long long #define pb push_back #define All(x) (x).begin(),(x).end() #define mp make_pair #define nl "\n" typedef pair<int,int>ii; typedef vector<int>vi; typedef vector<ii>v...
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for(int i = 0; i < (n); i++) #define rrep(i, n) for(int i = (n-1); i >= 0; i--) using namespace std; typedef long long ll; const int MOD = 1000000007; //const int MOD = 998244353; const ll INF = 1LL<<60; const int IINF = 1000000000; template<class T> inlin...
/*{{{*/ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<set> #include<map> #include<queue> #include<bitset> #include<vector> #include<limits.h> #include<assert.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).be...
#include <bits/stdc++.h> using namespace std; int x[200005], c[200005]; vector<int> v[200005]; int main(){ int n; scanf("%d", &n); for(int i=1;i<=n;i++){ scanf("%d%d", &x[i], &c[i]); v[c[i]].emplace_back(x[i]); } int la1 = 0, la2 = 0; long long res1 = 0, res2 = 0; for(int i=...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; // using mint = modint1000000007; // using mint2 = modint998244353; typedef int64_t Int; #define all(x) (x).begin(), (x).end() const double EPS = 1e-10; const Int INF = 1e18; const int inf = 1e9; const Int mod = 1e9+...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string s; cin>>s; cout<<s[1]<<s[2]<<s[0]<<endl; }
#include<string> #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; enum { A_one = 4, A_two = 12, A_three = 24, A_four = 24 }; int main(){ string input; cin >> input; int len = input.size(); int exist = 0; int notSure = 0; int notExist = 0; int res = 0; if (len != 10) { cout << res;...
#include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; set<int> avail, not_avail, unsure; for (int i = 0; i < 10; i++) { if (s[i] == 'o') avail.insert(i); else if (s[i] == 'x') not_avail.insert(i); e...
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; #include "bits/stdc++.h" #define el "\n" typedef long long ll; const int MM = 2e3+1, MOD = 1e9+7; int R, C, dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; pair<int, int> st, ed; vector<pair<int,...
#include<cstdio> using namespace std; const int N=2010,M=1000000007; int h,w,dp[N][N],s[N][N],z[N][N],x[N][N]; char c[N][N]; int main(){ scanf("%d%d",&h,&w); for(int i=0;i<h;++i)scanf("%s",c[i]); dp[0][0]=1; for(int i=0;i<h;++i)for(int j=0;j<w;++j){ if(i||j)dp[i][j]=((long long)s[i][j]+z[i][j]+x[i][j])%M; if(i<...
#include <bits/stdc++.h> /*#include <iostream> #include <algorithm> #include <math.h> #include <iomanip> #include <string> #include <vector> #include <set> #include <sstream>*/ #define ll long long #define fop(i,m,n) for(int i=m; i<n; i++) #define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define X first...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define Pr pair<ll,ll> #define Tp tuple<ll,ll,ll> using Graph = vector<vector<int>>; ll mod = 998244353; //segment tree //1-indexed all class segtree { public: ll n; vector<ll> A; segtree(ll k...
#include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; using ll = long long; #...
#include <bits/stdc++.h> #define speedup \ ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr), \ cout.precision(12) using namespace std; #ifndef ONLINE_JUDGE #define eprintf(...) fprintf(stderr,__VA_ARGS__), fflush(stderr...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define repto(i, n) for(int i = 0; i <= (n); i++) #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) #define _1 first #define _2 second #de...
#include <bits/stdc++.h> using namespace std; // using mint = long double; // using mint = modint998244353; // using mint = modint1000000007; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<ll, vector<ll>> Pd; const ll INF = 2e18; const ll fact_table = 1200008; priority_queue<ll> ...
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << e...
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i<n;i++) #define all(i, v) for(auto& i : v) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; bool solve(v...
#include <bits/stdc++.h> using namespace std; mt19937 rng(time(0)); long long randint(long long a, long long b){ uniform_int_distribution<long long> dist(a, b); return dist(rng); } const int swapXY[] = {0, 2, 1, 4, 3}; long long findScore(long long a, long long b){ long long A = a; long long B = b; ...
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr...
#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; #define M 998244353 #define pi 3.14159265358979323846 #define ll long long #define lld ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #define vpii vector<pair<int,int>> #define vpll vector<pair<ll,ll>> #define fr(i,k,n) for (int i = k; i < n; ++i) #define fri(i,k,n) for (int i = k; i >= n...
// header {{{ // header {{{ using namespace std; #include <bits/stdc++.h> #define CPP_STR(x) CPP_STR_I(x) #define CPP_CAT(x, y) CPP_CAT_I(x, y) #define CPP_STR_I(args...) #args #define CPP_CAT_I(x, y) x##y #define ASSERT(expr...) assert((expr)) using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = ...
#include<bits/stdc++.h> #define maxn 1000005 #define inf 0x3f3f3f3f #define mod 1000000007 #define mst(a,x) memset(a,x,sizeof(a)) #define up(l,r,i) for(LL i=l;i<=r;i++) #define down(l,r,i) for(LL i=l;i>=r;i--) #define in(l,r,a) for(LL i=l;i<=r;i++)cin>>a[i] #define out(l,r,a) for(LL i=l;i<=r;i++)cout<<a[i]<<" " #define...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #...
#include<bits/stdc++.h> #define int long long #define ll long long #define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define fs first #define sd second #define rept(x,n) for(int i=x;i<n;i++) #define rrept(n,x) for(int i=n-1;i>=x;i--) #define all(v) v.begin(),v.end() #define mpit map<int,int>::...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; long long f(int x) { if (x < 0) return 0LL; return 1LL * x * (x + 1) / 2 % MOD; } int main() { int t; scanf("%d", &t); while (t--) { int n, a, b; scanf("%d%d%d", &n, &a, &b); long long c = 1LL * (n -...
/* Clearink */ #include <cstdio> inline void wint ( int x ) { if ( 9 < x ) wint ( x / 10 ); putchar ( x % 10 ^ '0' ); } const int MAXN = 100; int N, K, M, f[MAXN + 1][MAXN * ( MAXN / 2 + 1 ) * ( MAXN >> 1 ) / 2 + 5]; inline void addeq ( int& a, const int b ) { ( a += b ) < M ? 0 : a -= M; } inline void initDP ()...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx,avx2,fma") using namespace std; using namespace __gnu_pbds; typedef int ll; typedef long double ld; typedef pair <ll, ll> pll; #ifdef SINA #d...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) #define repA(i, a, n) for(int i = a; i <= (n); ++i) #define repD(i, a, n) for(int i = a; i >= (n); --i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) memset...
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <vector> #include <string> using namespace std; void solve() { string x; cin >> x; int ans = x[0] - '0'; ans = x.size() * 10; cout << ans << endl; } int main() { int a, b, c, d; cin >> a >> b >> c >> d; vector<int>...
#include <bits/stdc++.h> using namespace std; template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); } template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr)->sync_with_stdio(false); int N = 4; vector<int> A(N); for (int...
#include<iostream> #include<cstdio> #include<map> #include<bitset> #include<algorithm> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<ctime> using namespace std; #define M 500005 #define N 1000005 #define MP make_pair #define debug() cerr<<"Why So Serious?"<<endl typedef long long ll; typede...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define rep(i,n) for(ll i=0; i<n; i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rrep(i,n) for(ll i=n-1; i>=0; i--) #define fi first #define se second #define pcnt __builtin_popcountll typedef long long ll; typedef unsigned long lon...
#include<cstdio> #define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i) using namespace std; template<typename T>void read(T &x) { bool neg=false; unsigned char c=getchar(); for(;(c^48)>9;c=getchar())if(c=='-')neg=true; for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48); if(neg)x=-x; } int n; double ans; int main...
#include<bits/stdc++.h> using namespace std; // ---------- Debugger #define TRACE string to_string(string s) { return '"' + s + '"'; } string to_string(char c) { return '\'' + string(1, c) + '\''; } string to_string(char * s) { return to_string((string) s); } string to_string(const char * s) { ret...
#include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> #include <stack> using namespace std; #def...
// Parasparopagraho Jīvānām #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace __gnu_pbds ; using namespace __gnu_cxx ; using namespace std ; typedef long long ll ; t...
#include<bits/stdc++.h> using namespace std; #define il inline #define ri register int #define ll long long #define ui unsigned int il ll read(){ bool f=true;ll x=0; register char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') f=false;ch=getchar();} while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=g...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; // int64_t using ull = unsigned long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #define REP(i,m,n) for(int i = m; i <= (n); ++i) #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i ...
#include <bits/stdc++.h> using namespace std; #define ls o<<1 #define rs o<<1|1 #define fi first #define se second typedef long long ll; typedef pair<int,int> pii; const int maxn=2e5+10; const int mod=1e9+7; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f3f; void solve(){ int a,b; scanf("%d%d",&a,&b); ...
#include <bits/stdc++.h> using namespace std; int main() { int a,b; cin >> a >> b; cout << (b / (100.0)) * a << endl; return 0; }
#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<bits/stdc++.h> #define ll long long using namespace std; ll xorr[1200020]; ll a[300005]; int query(int at, int L, int R, int l, int r){ if(L>r || R<l)return 0; if(l<=L and r>=R)return xorr[at]; int mid = (L+R)/2; return query(at*2,L,mid,l,r)^query(at*2+1,mid+1,R,l,r); } void update(int at...
using namespace std; #include<bits/stdc++.h> void testcases() { int n,time,pow; cin>>n>>time>>pow; int f=0; while(n>0) { int temp1,temp2; cin>>temp1>>temp2; if(temp1<time && temp2>pow) f=1; n-=1; } cout<<((f==1)?"Yes":"No")<<endl; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); //freopen("in.txt","r",st...
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using vpl = vector<pair<ll, ll>>; using pll = pair<ll, ll>; #define rep(i, k, n) for(ll i = k; i < n; i++) #define pb push_back #define mp make_pair int main(){ ll t; cin >> t; ...
//#pragma GCC optimize(2) #include<bits/stdc++.h> using namespace std; const int N=101000; const int inf=1e9+7; inline long long read(void) { char ch=getchar();long long sum=0;bool f=0; while((ch<'0'||ch>'9')&&ch!='-')ch=getchar(); if(ch=='-'){f=1;ch=getchar();} while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar(...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; string s; ll t = 1; ll f = 1; for(ll i = 0;i < n;i++){ cin >> s; if(s == "AND"){ f = f*2+t; } else { t = t*2+f; } } cout << t << endl; }
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define ll long long #define MOD 1000000007LL //#define MOD 998244353LL #define chmax(a,b) if (a<b)a=b; #define doublecout(a) cout<<setprecision(16)<<a<<endl; using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>;...
#include <bits/stdc++.h> using namespace std; int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0)); using Int = long long; enum { ROW, COL }; int main() { int H, W; cin >> H >> W; vector<string> S(H); for (auto &s : S) cin >> s; vector<int> rows(H), cols(W); vector<vector<int>...
#include<bits/stdc++.h> using namespace std; int in(){ int x; scanf("%d",&x); return x; } char janken(char c1,char c2){ if(c1>c2)swap(c1,c2); if(c1==c2)return c1; if(c1=='P' && c2=='R')return 'P'; if(c1=='P' && c2=='S')return 'S'; if(c1=='R' && c2=='S')return 'R'; } int main(){ int n...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pii pair<ll,ll> #define rep(i,st,en) for(ll i=st;i<en;i++) #define repdown(i,st,en) for(ll i=st;en<i;i--) #define vll vector<ll> #define vd vector<double> #define vb vector<bool> #define vii vector<pii> #define vp vector<pii> #define all(x...
#include <bits/stdc++.h> #define DEBUG(C) cerr << #C << " = " << C << endl; using namespace std; const int MOD = 1e9 + 7; void solve() { const int MAX = 2e5 + 10; int N; long long W; cin >> N >> W; vector<long long> v(MAX); for (int i = 0; i < N; ++i) { int s, t; long long p; ...
#pragma GCC optimize("Ofast") #include <iostream> #include <stdio.h> #include <string> #include <vector> #include <algorithm> #include <cstdlib> #include <cmath> #include <iomanip> #include <cctype> #include <sstream> #include <stack> #include <deque> #include <queue> #include <list> #include <set> #include <map> #incl...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string(string(s)); } string to_string(bool b) { return to_string(int(b)); } string to_string(vector<bool>::reference b) { return to_string(int(b)); } string to_stri...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int a[100010]; int main() { int n; ll m,ans; cin >> n; rep(i,n) cin >> a[i]; if (n==1){ cout << a[0]+1 << endl; return 0; } sort(a, a+n); //a[0:n] を値が小さい順にソート ans=a[0]+1; m=1000000007;...
#include <bits/stdc++.h> using namespace std; #define For(i,n) for(int i = 0; i < n; i++) #define For1(i,n) for(int i = 1; i < n; i++) #define Forn(i,n) for(int i = n-1; i >=0 ; i--) #define FOR(i,f,n) for(int i = f; i < n; i++) #define FORN(i,n,f) for(int i = n; i >= f; i--) #define Forit(it,v) for(auto it = v.begin(...
#include <bits/stdc++.h> using namespace std; // #define LOCAL // 提出時はコメントアウト #define DEBUG_ typedef long long ll; const double EPS = 1e-9; const ll INF = ((1LL<<62)-(1LL<<31)); typedef vector<ll> vecl; typedef pair<ll, ll> pairl; template<typename T> using uset = unordered_set<T>; template<typename T, typename U> usi...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pii; #define f(i,a,b) for(ll i=a;i<b;i++) #define fo(i,a,b) for(ll i = a; i<=b;i+=1) #define rf(i,a,b) for(ll i=a;i>=b;i--) #define vll vector<ll> #define sz(a) ll(a.size()) #define all(v) v.begin(),v.end() #define pb push_ba...
#include<bits/stdc++.h> using namespace std; int a[3]; signed main(){ cin>>a[0]>>a[1]>>a[2]; sort(a,a+3); cout<<a[2]+a[1]<<endl; return 0; }
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author aajisaka */ #include<bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...
#include<iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << (a+b)/2 << " " << (a-b)/2 << endl; return 0; }
#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>; void solve() { int n; string s, t; cin >> n >> s >> t; queue<int> one; rep(i, n) { if (s[i] == '1') one.push(i); } ll ans = 0; // int だと桁が足りない ...
#include <bits/stdc++.h> #define ll long long #define ve vector<ll> #define w(t) ll t; cin >> t; while(t--) using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int a, b, c; cin >> a >> b >> c; if (a == b) cout << c; else if (a == c) cout << b...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; #define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr) //:/ #define pb push_back #define mp make_pair #define nt _ll128 #define ld long double long double PI =3.14159265; using ll = long long; const ll modo=1e9+7; const ll ms=1e5+5; con...
//clear adj and visited vector declared globally after each test case //check for long long overflow //while adding and subs check if mod becomes -ve //while using an integer directly in a builtin function add ll //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod; //Dont keep array name as size or any o...
#include <bits/stdc++.h> // #include "icld.cpp" using namespace std; using ll = long long int; using pii = pair<int,int>; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using ss = string; const int dx[4] = {1,0,-1,0}; const int dy[4] = {0,1,0,-1}; //#define pi 3.14159265358979 #define ...
#include <bits/stdc++.h> using namespace std; #define mp(a,b) make_pair(a,b) #define ff first #define setp(a) setprecision(a)<<fixed #define ss second #define fori(v) for(ll i=0; i<v; i++) #define forj(v) for(ll j=0; j<v; j++) #define fork(v) for(ll k=0; k<v; k++) #define forl(v) for(ll l=0; l<v; l++) #define fort(v) f...
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n,x; string s; cin>>n>>x; cin.ignore(); getline(cin,s); for(int i=0;i<n;i++){ if(x==0){ if(s[i]=='o'){ x=x+1; ...
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' typedef long long ll; typedef unsigned long long ull; typedef pair <int, int> ii; typedef pair <int, ii> iii; int main(){ int n, x; string s; cin >> n >> x; cin >> s; for(auto i : s...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const double TIME_LIMIT = 1.8; const int N = 50; double PROB_REAL = 0.1; vector<int> di = {1, -1, 0, 0}; vector<int> dj = {0, 0, 1, -1}; vector<char> vc = {'D'...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll=int; using ld=long double; using pll=pair<ll, ll>; //using mint = modint1000000007; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) #define PI acos(-1) #define oo 2e18 template<typename T1, ...
#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>; struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_; const int INF = (int)1e9; const ll INFL = (ll)1e18;...
#include<bits/stdc++.h> #include<stdlib.h> #include<algorithm> #include<cmath> #include<map> #include<set> #include<deque> #include<vector> #include<string> #include<cstring> using namespace std; #define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); #define ll long long int main(){ long double r,x,y; c...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int,int>; using pll = pair<ll,ll>; using pld = pair<ld,ld>; using vi = vector<int>; using vll = vector<ll>; using vld = vector<ld>; #define rep(j, m) for (int j = 0; j < (int)(m); j++) #define rep2(i, l, n) for ...
#include <bitset> #include <cassert> #include <iostream> #include <iomanip> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #include <valarray> // alias, using declaration using llint = long long; using ldouble = long double; template ...
/** * Dont raise your voice, improve your argument. * --Desmond Tutu */ #include <bits/stdc++.h> using namespace std; const bool ready = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); return true; }(); using ld=long double; const ld PI = acos(-1); using ll= lon...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX_N = 101; int n; ll x, a[MAX_N]; ll dp[MAX_N][MAX_N][MAX_N]; ll go(int k) { memset(dp,-1,sizeof(dp)); dp[0][0][0]=0; for(int i=0;i<n;++i)for(int j=0;j<=i;++j)for(int m=0;m<k;++m)if(dp[i][j][m]!=-1){ dp[i+1][j][m]=max(dp[i+1][j][m], ...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <utility> #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <limits> #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; template<clas...
#include <bits/stdc++.h> #define int long long using namespace std; using vec_int = vector<int>; using P = pair<int,int>; using T = tuple<int,int,int>; using ll = long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) signed main() { int A, B; cin>>A>>B; vec_int primes = {2,3,5,7,11,13,17,19,23,29,31,3...
#include <bits/stdc++.h> using namespace std; long long INF = 1LL<<60; using ll = long long; using vll = vector<ll>; using mll = map<ll, ll>; #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() template<class T>bool chma...
#include <bits/stdc++.h> #include <cassert> #define rep(i, N) for (int i = 0; i < (N); ++i) #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep3(i, a, b) for (ll i = a; i >= b; --i) #define pb push_back #define eb emplace_back #define fi first #define se second #define all(c) begin(c), end(c) #define ok() put...
#include<bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define mod 1e9+7 #define ff first #define ss second #define ins insert #define endl "\n" #define pie_op ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define tc int t;cin>>t;while(t--) #define pb push_back #define input(n) i...
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9+7; constexpr llong inf = mod * mod; int main() { llong N; cin >> N; llong ans = inf; for (llong b = 0; b <= 60; b++)...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pi; typedef vector<pi> vp; typedef set<ll> si; typedef map<string, ll> msi; #define REP(i,a,b) \ for(ll i=ll(a);i<=ll(b);i++) #define DEP(i,a,b) \ for(ll i=ll(a);i>=ll(b);i--) #define TR(c, it) \ for (auto it =...
#include<bits/stdc++.h> using namespace std; #define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define mod 1000000007 #define endl "\n" #define test ll txtc; cin>>txtc; while(txtc--) typedef long long int ll; typedef long double ld; int main() { FIO; //test { string s; cin>>s; ...
#include <iostream> #include <vector> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstring> #define fi first #define se second #define mp make_pair #define all(x) x.begin(), x.end() #define For(it, x, y) for(int it = x; it < y; it ++) #def...
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)(x.size()) #define all(x) (x).begin(), (x).end() const int N = 2e5 + 4; vector<int> adj[N]; bool vis[N]; int sz = 0; void dfs(int u) { if (vis[u]) return; ++sz; vis[u] = true; for (auto &v : adj[u]) { dfs(v); } } int32...
//設定言語check #include <bits/stdc++.h> #include <iostream> #include <string> #include <limits.h> #include <algorithm> #include <iomanip> #include <math.h> #include <queue> #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++) using namespace std; int main(){ long long int N, L, K, ans = 0, flag = 0 ; int i, j, k, cas, nu...
#include<iostream> #include<string> #include<vector> #include<set> #include<map> #include<unordered_set> #include<unordered_map> #include<stack> #include<queue> #include<deque> #include<algorithm> #include<cmath> #include<functional> #include<bitset> #include<iomanip> #define _GLIBCXX_DEBUG #define fi first #define se ...
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d; cin >> a >> b >> c >> d; int tot=a+b+c+d; int ok=0; if(tot-a==a)ok=1; if(tot-b==b)ok=1; if(tot-c==c)ok=1; if(tot-d==d)ok=1; if(tot-a-b==a+b)ok=1; if(tot-a-c==a+c)ok=1; if(tot-a-d==a+d)ok=1; if(tot-b-c==c+b)ok=1; if(tot-b-d...
#include<bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; const double pi=acos(-1.0); #define rep(i, n) for (int i = 0; i < (int)(n); i++) int max(int a,int b){if(a>b){return a;}return b;} int min(int a,int b){if(a<b){return a;}return b;} int main(void){ long long int a,n,v,t,s,d; ci...
#include <vector> #include <algorithm> #include <iostream> #include <string> #include <map> #include <unordered_map> #include <set> #include <queue> #include <unordered_set> using namespace std; #define pii pair<int,int> #define pll pair<long long, long long> int main(){ int ncases; cin >> ncases; for(int z ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; (i) < n ; i++) using namespace std; using ll = long long; ll result(ll a, ll b){ ll v = b - 2 * a + 1; ll u = v * (v + 1)/2; return u; } int main(){ int T; cin >> T; ll outc[T]; rep(i,T){ ll l, r ; cin >> l >> r; if (r >...
#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 ...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; typedef unsig...
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> #define MOD(x) ((x) >= mod ? (x) - mod : (x)) using namespace std; const int maxn = 500010, inf = 1e9 + 233, mod = 1e9 + 7; int n; int fib[maxn]; char s[233][233]; int main() { scanf("%d", &n); for (int i = 1; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1005; const int mod=1e9+7; int n; char c[2][2]; ll dp[maxn][2]; int main() { scanf("%d",&n); for(int i=0;i<2;i++) for(int j=0;j<2;j++) { char ch; do ch=getchar(); while(!isalpha(ch)); c[i][j]=ch; } if(n<=3) return print...
#include <bits/stdc++.h> using namespace std; #define int long long int const int mod = (int)1e9 + 7; template<class T> auto vec(int r, int c, T v){ return vector<vector<T>>(r, vector<T>(c, v)); } template<class T> auto vec(int o1, int o2, int o3, T v){ return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <vector> #include <numeric> #include <iostream> #include <random> #include <map...
#define taskname "test" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define fi first #define se second typedef long long lli; typedef pair<int, int> pii; string s; void read_input() { cin >> s; } void solve() { cout << s[1] << s[2] << s[0] << '\n'; } int main() { ios_ba...
// 299143BT #include<bits/stdc++.h> #define ll int64_t #define MOD 1000000007 #define pi 3.1415926535 #define fi first #define se second #define vll vector<ll> #define vpll vector<pair <ll,ll> > #define vvll vector< vll > #define str string #define umap unordered_map #define uset unordered_set #define rep(i,n) for(ll ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; long long c; cin >> n >> c; vector<array<int, 2>> events; for (int i = 0; i < n; ++i) { int l, r, w; cin >> l >> r >> w; events.push_back({l, w}); events.push_back({r + ...
#include <algorithm> #include <iostream> #include <cstdio> #define ll long long #define MOD 1000000007 using namespace std; int main() { int t; ll n, a, b; cin >> t; while(t--) { cin >> n >> a >> b; if(a+b > n) { cout << 0 << endl; continue; } ll ...
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) int N; signed main() { cin >> N; rep(i, N) cout << (2 * i + 1) % N + 1 << " " << (2 * i + 2) % N + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void chmin(int64_t& a, int64_t b){ a = min(a, b); } int main(){ int T; // cin >> T; T=1; typedef pair<int64_t, int64_t> P; while(T--){ int64_t X,Y; cin >>X>>Y; int64_t cost[6] = {0}; cost[2] = 1; cost[...
#include <bits/stdc++.h> #define pii pair<int, int> #define ld long double #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = s.length(); int cnt[300]; memset(cnt, 0, sizeof(cnt)); int lastIdx...
//jai baba loknath #include<bits/stdc++.h> // Program showing a policy-based data structure. #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> // for less using namespace std; using namespace __gnu_pbds; typedef long long int ll; // GNU link : ...
/* * author: vongkh * created: Sun Jan 17 2021 */ #include <stdio.h> #include <cstdlib> #include <map> int64_t x, y; std::map<int64_t, int64_t> memo; int64_t get_operation_num(int64_t z){ //get the number of operation need to transform z back to x //each stop we have three choices : increment, decrement, ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include<bits/stdc++.h> using namespace std; const int N = 1e5+10; int a[N]; int main() { int n; cin>>n; int maxn1=0,st1=0; int maxn2=0,st2=0; for(int i=1;i<=(1<<n);i++) { cin>>a[i]; if(i<=(1<<(n-1))) { if(a[i]>maxn1) { st1=i; maxn1=a[i]; } } else { if(a[i]>maxn2) { maxn...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #include <vector> int main() { int N; cin>>N; vector<int>vec(pow(2,N)); for(int i=0;i<pow(2,N);++i){ cin>>vec.at(i); } map<int,int>mp; for(int i=0;i<pow(2,N);++i){ mp[vec[i]]=i+1; } while(vec.size()>2){ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #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++) #define MOD 1000000007 int main() { double n; cin >> n; double x0, y0, xn, yn; cin >> x0 >> y0 >> xn >> yn; double vx = xn - x...
#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> using namespace std; int lucas(int a, int b){ int comb = 1; for(;;){ int a3 = a % 3; a /= 3; int b3 = b % 3; b /= 3; if(a3 < b3){ comb = 0; break; } else if(a3 == 2 && b3 == 1) comb *= 2; if(a == 0 && b == 0) break; } return comb ...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author tatsumack */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) using ll = long long; using P = pair<int, int>; template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b...
#include "bits/stdc++.h" using namespace std; #define ll long long #define pb push_back #define all(_obj) _obj.begin(),_obj.end() #define F first #define S second #define pll pair<ll, ll> #define vll vector<ll> ll n,m,a,b,c,k,temp,x,y,INF=1e18,s; const int N=1e5+11,mod=1e9+7; ll max(ll a,ll b) {return ((a>b)?a:b);} ll...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stack> #include <queue> #include <cmath> #include <tuple> #include <cstdio> #include <bitset> #include <sstream> #include <iterator> #include <numeric> #include <map> #include <cstring> #include <set> #include <functional> #include <...
#include<bits/stdc++.h> using namespace std; const int maxn=2e5+5; typedef long long ll; const int mod=1e9+7; ll dp[1<<18][18]; int x[105],y[105],z[105]; int sum[20]; int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(int i=0;i<n;i++) ...
#include <bits/stdc++.h> using namespace std; #define all(s) s.begin(), s.end() #define pb push_back #define ii pair<int, int> #define x first #define y second #define bit(x, y) ((x >> y) & 1) long long C(int n, int k) { long long res = 1; for (int i = 0; i < k; i++) { res *= (n - i); res /= (...
#include<iostream> #include<bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define mp make_pair #define fi first #define se second #define merge(a,b) a##b #define mkstr(a) #a #define flush fflush(stdout); #define debug(x,y) cout<<#x<<" "<<y<<...
#include<bits/stdc++.h> #define ll long long using namespace std; int main() { ll n,x; cin>>n>>x; x=x*100; ll a[n+1],b[n+1]; ll tol=0; ll ans=-1; for(ll i=0;i<n;i++) { cin>>a[i]>>b[i]; tol+=(a[i]*b[i]); if(tol>x&&ans==-1) { ans=i+1; } } cout<<ans; return 0; }
// 200b.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // #include <iostream> #include <vector> #include <iomanip> using namespace std; void solve(){ double d, h; int n; cin >> n >> d >> h; vector<double> sx(n); vector<double> sy(n); for (size_t i = 0; i < n; i++) { cin...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #define RST(i,n) memset(i,n,sizeof i) #define SZ(a) (int)a.size() #define ALL(a) a.begin(),a.end() #define X first #define Y second #define eb emplace_back #ifdef cold66 #define debug(...) do{\ fp...
#include <bits/stdc++.h> using namespace std; int main() { long long int A, B, C, D; cin >>A >> B >>C >> D; string ans ="No"; for (int a=0; a<2; a++){ for (int b =0; b<2; b++){ for (int c =0; c<2; c++){ for(int d =0; d<2; d++){ if(2*(A*a+B*b+C*c+D*d) == A + B + C+ D){ ...
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <queue> #include <set> #define endl '\n' using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INF=1e10+1; vector<int> graph[2001]; bool visit[2001]; void dfs(int root) { if(v...
#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<int, int>; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; const int mod = 1000000007; //const int mod = 998244353; int main() { int n, m; cin >> n >> m; v...
#include<bits/stdc++.h> #define rep(i,a,b) for(ll i=(a);i<=(b);i++) #define per(i,a,b) for(ll i=(a);i>=(b);i--) #define next Cry_For_theMoon typedef unsigned long long ll; using namespace std; const ll MAXN=103,INF=2e18; ll f[MAXN][MAXN][MAXN]; ll n,a[MAXN],sum; ll x,ans=INF; ll calc(ll k){ ll m=(k-(x-sum)%k)%k; //排除的...
/*Jai Shree Ram*/ // Never Give Up #include<bits/stdc++.h> #include<unordered_map> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi ...
#include <bits/stdc++.h> using namespace std; int main() { int x,y,z; int ans; cin >> x >> y >> z; // ans/z < y/x // ans < z*y/x ans = (y*z)/x; if( (ans*1000/z)==(y*1000/x) ) ans--; cout << ans << endl; };
#include <bits/stdc++.h> using namespace std; #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); // __VA_ARGS__可変引数マクロ template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template<typename First, typename...Rest>void MACRO_VA...
#include<iostream> #include<vector> #include<set> #include<queue> #include<map> #include<algorithm> #include<cstring> #include<string> #include<cassert> #include<cmath> #include<climits> #include<iomanip> #include<stack> #include<unordered_map> #include<bitset> #include<limits> #include<complex> #include<array> #includ...
#include<cstdio> #define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i) using namespace std; const int N=2e5+5; template<typename T>void read(T &x) { bool neg=false; unsigned char c=getchar(); for(;(c^48)>9;c=getchar())if(c=='-')neg=true; for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48); if(neg)x=-x; } int n,f[...
// Author:- Pratik Kinger // Birla Institute of Technology #include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define pii pair<ll, ll> #define vi vector<ll> #define vii vector<pii> #define mi map<ll, ll> #define mii map<pii, ll> #define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i++) ...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL) int main() { fastio; int n; cin>>n; cout<<n-1<<"\n"; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long long #define ll long long #define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr)) #define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr)) #define sz(a) sizeof(a) #define deb(a) cerr ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX_N = 1e4+2; int n; ll a[MAX_N]; void solve() { ll ans = 0; for(int i=0;i<n;++i){ ll mi = 1e6; for(int j=i;j<n;++j){ mi=min(mi, a[j]); ans=max(ans,1LL*(j-i+1)*mi); } } cout<<ans<<'\n'; } int main() { cin >...
#include <bits/stdc++.h> using namespace std; //begin of def #define fastio ios_base::sync_with_stdio(false);cin.tie(0) #define endl '\n' using lli = long long int; using ulli = unsigned long long int; using Ld = long double; using pii = pair<int, int>; using pll = pair<lli, lli>; using pld = pair<Ld, Ld>; #define X...
#include <bits/stdc++.h> using namespace std; unsigned long long p[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}, n, a[55]; unsigned long long ans = 614889782588491410LL; void dfs(unsigned long long x, unsigned long long y){ if(x > 15){ unsigned long long ret = 0; for(unsigned l...
#include <bits/stdc++.h> #define lg long long int #define loop(i, s, e) for (lg i = s; i <= e; i++) #define iloop(i, s, e) for (lg i = e; i >= s; i--) #define pb push_back #define mp make_pair #define mod 1000000007 using namespace std; lg min(lg a, lg b) { return a < b ? a : b; } lg max(lg a, lg b) { return a > b ?...
#include <bits/stdc++.h> using namespace std; string s; int f[10]; int main() { ios::sync_with_stdio(0); cin >> s; memset(f, 0, sizeof(f)); for(int i = 0; i < s.size(); i++) f[s[i] - '0']++; if(s.size() == 2) { int d1 = (s[0] - '0') * 10 + (s[1] - '0'); int d2 = (s[1] - '0') * 10 + (s[0] - '0'); if(d1...
// Problem : C - Collinearity // Contest : AtCoder - AtCoder Beginner Contest 181 // URL : https://atcoder.jp/contests/abc181/tasks/abc181_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-...
#include <algorithm> #include <iostream> #include <map> #include <memory> #include <string> #include <vector> #include "float.h" #define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc) #define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc) #define INT_MAX 1000000000 using ll = long long; using ...
#include<bits/stdc++.h> using namespace std; int main() { int n; double d,h; cin>>n>>d>>h; double x[n]; double y[n]; for(int i=0;i<n;i++) { cin>>x[i]>>y[i]; } double ymin=INT_MAX; for(int i=0;i<n;i++) { bool nope=false; double yc; for(int j=...
#include<bits/stdc++.h> #define pb push_back #define endl ("\n") #define mp make_pair #define lb lower_bound #define int long long #define up upper_bound #define M 1000000007LL #define yy cout<<"Yes"<<endl; #define nn cout<<"No"<<endl; #define rep(i, a, n) for (int i = a; i < n; i++) #define mod 1000000007 using names...
#include <bits/stdc++.h> using namespace std; #define for0(i, n) for (int i = 0; i < (int)(n); i++) #define for1(i, n) for (int i = 1; i <= (int)(n); i++) #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) #define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (int)(...
#include<iostream> #include<string> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<algorithm> #include<numeric> #include<cmath> #include<iomanip> #include<regex> using namespace std; #define int long long const int mod=1e9+7; bool pri[1000001],squf[1000001],even[1000001]; signed m...
#include "bits/stdc++.h" using namespace std; int main() { string s; cin >> s; int ans = 0; const std::string find_word("ZONe"); std::string::size_type pos = s.find(find_word); while (pos != std::string::npos) { ans++; // std::cout << pos << std::endl; pos = s.find(...
#include<bits/stdc++.h> using namespace std; #define endl '\n' typedef long long int ll; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c...
#include <bits/stdc++.h> #define int long long using namespace std; const int mod = 10; const int MAX=1e6+10; const int INF=0x3f3f3f3f; int fastPow(int a,int n){ int base=a; int res=1; while(n){ if(n&1){ res=(base*res)%4; } base=(base*base)%4; n=n>>1; } ...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long a,b,c,n,l,m,result; cin >> a >> b >> c ; n = ((a*(a + 1)/2%998244353))%998244353; l = ((b*(b + 1)/2%998244353))%998244353; m = ((c*(c + 1)/2%998244353))%998244353; result = ((n*l%998244353)*m)%998244353; cout << result << end...