code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include<bits/stdc++.h> #define I inline #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b)) #define abs(x) ((x)>0?(x):-(x)) #define re register #define ll long long #define db double #define N 100 #define mod 1000000007 #define eps (1e-4) #define U unsigned int #define IT set<ques>::iterator #define ...
#include <bits/stdc++.h> using namespace std; // clang-format off // #include <atcoder/all> // using namespace atcoder; // using mint = modint1000000007; // using mint = modint998244353 using ll = int64_t; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v) cin >> a; return is...
#line 1 "F.cpp" #include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);} template<typename T,typename... Ts> auto make_v(siz...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> //#include <atcoder/convolution> //#incl...
#include <iostream> #include <iomanip> #include <algorithm> #include <array> #include <cassert> #include <optional> #include <utility> #include <vector> #include <cmath> // #include <atcoder/all> template <class InputIterator> std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #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++) using Int = long long; int vmax(vector<int> w,vector<int> v, vector<int> x){ int n=w.size(); int m=x.size(); int ans=0; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n; cin>>n; ll a, sum=0, high=0, ans=0; for(int i=0; i<n; i++) { cin>>a; sum+=a; ans+=sum; high=max(high, a); cout<<ans+(i+1)*high<<endl; } return; } int main() { #ifde...
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll N,max = 0,sum = 0,ans = 0; cin >> N; vector<ll> A(N),B(N); for(ll i = 0; i < N; i++) { cin >> A.at(i); } for(ll i = 0; i < N; i++){ if(max < A.at(i)) max = A.at(i); sum += A.at(i); ans += sum; cout << ans + ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; ll ans = 0; rep(i, n) ans += abs(a[i]); cout << ans << endl; ans = 0; rep(i,...
#include <bits/stdc++.h> using namespace std; #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> range(c i, c j) { return rge<c>{i, j}; } s...
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n,m; cin >> m >> n; ll ar[m*n]; ll min = 101; for(ll i = 0; i < m*n; i++) { cin >> ar[i]; if(ar[i] < min) min = ar[i]; } ll kount = 0; for(ll i = 0; i < m*n; i++) { ...
#include <bits/stdc++.h> using namespace std; #define tcase int _; cin >> _; while(_--) //#define int long long const int MOD = 1e9+7; const int MAX = 1e6; const int INF = 2e9; int v[1000][1000]; void solve() { int h,w; cin >> h >> w; int mn = INF; for(int i=0; i<h; i++) for(int j=0; j<w; j++) { cin >> v[i][j];...
//https://atcoder.jp/contests/zone2021/tasks/zone2021_c #include <bits/stdc++.h> using namespace std; typedef long long ll; bool chk(vector<vector<int>> &arr, int mid) { int n=arr.size(); set<int> st; for (int i = 0; i < n; i++) { int c=0; for (int j = 0; j < 5; j++) { ...
#include <bits/stdc++.h> #define _overload3(_1,_2,_3,name,...)name #define _rep(i,n)repi(i,0,n) #define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i) #define MSVC_UNKO(x)x #define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__)) #define all(c)c.begin(),c.end() #define write(x)cout<<(x)<<'...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define F first #define S second ll MOD =...
#include<bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int long long int #define fi first #define se second #define pub push_back #define pi pair<int,int> #define all(v) (v).begin(), (v).end() #define rep(i, l, r) for(int i=(int)(l);i<(int)(r);...
#include<bits/stdc++.h> using namespace std; int n; int main() { cin >> n; vector<vector<int> > C( n,vector<int>( n ) ); vector<int> A( n ), B( n ); for( auto &i:C ) for( auto &j:i ) cin >> j; int minval=numeric_limits<int>::max(),mini=0,minj=0; for( int i=0;i<n;++i ) { for( int j=0;j<n;++j ) { if( C[i][j]...
#include <bits/stdc++.h> using namespace std; int n; vector<long long> a, b; vector<vector<long long>> c; bool solve(); int main() { cin >> n; c.resize(n); for (auto &v : c) { v.resize(n); for (auto &p : v) cin >> p; } if (solve()) { for (long long i = 0; i < n; ++i) for (long long j = 0;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> adj(n); for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; --u, --v; adj[u].push_back(v); adj[v].push_back(u); } vector<...
#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(){ int n, m; cin >> n >> m; vector<P> v(n); vector<vector<int>> g(n); vector<int> a(m), b(m); rep(i,m) { cin >> a[i] >> b[i]; a[i]--; b[i]--; g[...
#include<bits/stdc++.h> using namespace std; using lli = long long; #define rep(i,n) for(int i=0;i<n;i++) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } void printv(vector<lli> x){ cout <<...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //namespace mp=boost::multiprecision; //#define mulint mp::cpp_int //#define mulfloat mp::cpp_dec_float_100 struct __INIT{__INIT(){cin.tie(0);ios::sy...
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; ll dp[101][101][10001], MOD = 998244353, f[101]; int main() { f[0] = 1; rep(i, 0, 100) f[i + 1] = (f[i] * (i + 1)) % MOD; int N; cin >> N; vector<int> W(N); ll s = 0; r...
/* Lucky_Glass */ #include <cstdio> #include <cstring> #include <algorithm> const int N = 105, MOD = 998244353; inline int add(int a, const int &b) { return (a += b) >= MOD ? a - MOD : a; } inline int sub(int a, const int &b) { return (a -= b) < 0 ? a + MOD : a; } inline int mul(const int &a, const int &b) { return i...
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #define gp __gnu_pbds #define iset(T) gp::tree<T,gp::null_type,less<T>,gp::rb_tree_tag,gp::tree_order_statistics_node_update> using namespace std; #define SQ(x) ((x)*(x)) #define u unsigned #define ull unsigned long long #define ll long long #define ld...
#include<bits/stdc++.h> using namespace std; #define ll long long #define For(i,a,b,c) for(ll i=a;i<b;i+=c) #define For2(i,a,b,c) for(ll i=a;i>=b;i-=c) #define vec_ll vector<vector<ll>> #define vec_pr vector<pair<ll,ll>> #define p_ll pair<ll,ll> #define pbk push_back #define mkpr make_pair #define fst first #define snd...
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#def...
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; vector<bool> used(200001,0); int x=0; vector<int> p(n); for(int i=0;i<n;i++){ cin>>p[i]; used[p[i]]=true; while(used[x]){ x++; } cout<<x<<'\n'; } return 0; }
#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> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/detail/standard_policies.hpp> // using namespace __gnu_pbds; #pragma GCC optimize("O3") #ifdef LOCAL #include "/Users/lbjlc/Desktop/coding/debug_utils.h" #else #define print(...) ; #define printn(...) ; #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define rep1(i,n) for(ll i=1;i<=(ll)(n);i++) int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n,k; cin >> n >> k; k = abs(k); ll ans = 0; for(ll ab = k+2; ab<=2*n;ab++){ ll abc, cdc...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i = a; i < b; i++) #define rrep(i,a,b) for (int i = a - 1; i >= b; i--) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define ll long long #define out(x) std::cout ...
#pragma region Macros #include <bits/stdc++.h> using namespace std; using ll = long long; #define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i) #define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i) #define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME #define REP(...) GET_MACRO_...
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_st...
#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 <stdio.h> int main(){ int l,a,i,j; long long int ans = 1; scanf("%d", &l); a = (l-1) % 11; for(i = 1; i <= 11; i++){ ans *= (l-i) / (11 - i - 1 + a); } printf("%lld", ans); } */ #include <stdio.h> long long combi(int, int); int main() { int n, r = 11; scanf("%d...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i,s,n) for(ll i = s; i < (ll)(n); i++) #define Rep(i,s,n) for(int i = s-1;i >= (int)(n); i--) int main() { int sx, sy, gx, gy,dist; cin >> sx >> sy >> gx >> gy; dist = min(abs(sx + sy - gx - gy), abs(sx - sy - ...
//* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //*/ #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "<<x<<endl; #define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<"...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0) #define fp(i,a,b) for(int i=a ; i<b ; i++) #define fn(i,a,b) for(int i=a ; i>=b ; i--) #define ones(x) __builtin_popcount(x) #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() type...
#include <iostream> #include<bits/stdc++.h> using namespace std; #define long long long int main() { long int n; cin>>n; long int ans=1LL; for(long int i=2;i<=n;i++) { long int temp = __gcd(ans,i); ans*=(i/temp); } cout<<ans+1LL<<endl; // your code goes here return 0; }
#include<iostream> #include<stdio.h> #include<vector> #include<algorithm> #include<list> #include<string.h> #include<math.h> #include<set> #include<string> #include<queue> #include<map> #include<unordered_map> #include<stack> //#include<unordered_set> //#pragma GCC optimize (3) //#define segmenttree true #ifdef seg...
#include <bits/stdc++.h> using namespace std; typedef int_fast32_t int32; typedef int_fast64_t int64; const int32 inf = 1e9+7; const int32 MOD = 1000000007; const int64 llinf = 1e18; #define YES(n) cout << ((n) ? "YES\n" : "NO\n" ) #define Yes(n) cout << ((n) ? "Yes\n" : "No\n" ) #define POSSIBLE(n) cout << ((n) ?...
#include <bits/stdc++.h> using namespace std ; #define int int64_t //be careful about this #define endl "\n" #define f(i,a,b) for(int i=int(a);i<int(b);++i) #define pr pair #define ar array #define fr first #define sc second #define vt vector #define pb push_back #define eb emplace_back #define LB lower_bound #de...
#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>; using Graph = vector<vector<int>>; int main() { ll b, c; cin >> b >> c; ll mx1 = b + ((c - 2) / 2); ll mn1 = b - (c / 2); ll mx2 = -b + ((c - 1) / 2); ll mn2 = -b - ...
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 4000000000000000000 //オーバーフローに注意 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; #define SIZE 55 ll A[SIZE],maxi[SIZE]; ll dp[SIZE][2]; int main(){ ll N,input_X; ...
#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<ll, int>; map<P, int> mp; int N; vector<ll> A(55); ll solve(ll x, int i) { // i以降のコインを使う ...
#include<algorithm> #include<bitset> #include<cmath> #include<complex> #include<deque> #include<functional> #include<iomanip> #include<iostream> #include<iterator> #include<map> #include<numeric> #include<queue> #include<set> #include<stack> #include<string> #include<unordered_map> #include<unordered_set> #include<util...
#include <bits/stdc++.h> #if MYDEBUG #include "lib/cp_debug.hpp" #else #define DBG(...) ; #endif #if __cplusplus <= 201402L template <typename T> T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #endif using LL = long long; constexpr LL ...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long N,K; cin >> N >> K; for(int i=0;i<K;i++){ if((N%200)==0){ N = N/200; }else{ N = N*1000+200; } } cout << N << endl; }
#include<bits/stdc++.h> using namespace std; int S(int n){ int ret = 0; while(n>0){ ret += n%10; n /= 10; } return ret; } int main(){ int a,b; cin >> a >> b; int Sa = S(a); int Sb = S(b); if(Sa > Sb) cout << Sa << endl; else cout << Sb << endl; return 0; }
#include <bits/stdc++.h> #include <fstream> using namespace std; #define intMax 2147483647 #define rep(i, a, b) for (int i = a; i < b; i++) #define repp(i, a, b) for (int i = a; i >= b; i--) #define be(a) (a.begin(), a.end()) #define rbe(p) (p.rbegin(), p.rend()) #define pb push_back int main() { ios_base::sync_w...
#include <bits/stdc++.h> using namespace std; string revAB(string str) { for(int i=0;i<str.size();++i) str[i]=(str[i]=='A'?'B':'A'); return str; } int main() { int N,M; cin >> N; M = (1<<N); vector<vector<string>> S(N+1); S[1] = {"AB"}; for(int i=2;i<=N;++i) { int L = (1<<i); S...
#include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define MOD (int)(1e9+7) #define MOD1 998244353 #define ceil(x, y) ((((x)%(y))==0)? (x/y) : (x/y+1)) #define FOR(i, N) for(int i = 0; i < N; ++i) #define FOR1(i, N) for(int i = 1; i <= N; ++i) #define vi vector <int> #define pii pair <int, int...
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int64 i = 0;i < (n);i++) #define FOR(i, a, b) for(int64 i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_...
#define _USE_MATH_DEFINES #include <iostream> #include <sstream> #include <string> #include <list> #include <vector> #include <queue> #include <algorithm> #include <climits> #include <cstring> #include <cmath> #include <stack> #include <iomanip> #include <tuple> #include <functional> #include <cfloat> #include <map> #i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ub upper_bound #define lb lower_bound #define endl "\n" #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) void solve() { int n, m, q, x, y; cin ...
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; int main(){ ll a, b, c; cin >> a >> b >> c; if(c % 2 == 0){ if(abs(a) < abs(b)){ cout << "<" << endl; }else if(abs(a) > abs(b)){ cout << ">" << endl; }else{ cout...
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define fi first #define se second #define ll long long #define mp make_pair #define eb emplace_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define rnd(x) cout<<setprecision((int)(x)+1) #define f(i,n) for(int i = 0;i <(...
#include<iostream> #include<vector> #include<algorithm> #include<cassert> using namespace std; template< int mod > struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; ...
#include <cstdio> #include <iostream> #include <algorithm> #include <cctype> #include <vector> #include <cmath> #include <string> #include <cstring> #include <map> #include <set> #include <queue> using namespace std; using ll = long long; using ull = unsigned long long; template <typename T> void read(T & x){ x =...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mp make_pair #define fr first #define sc second template<class T> T T_INF(){ return 1000000000000000000; } template<> int T_INF<int>(){ return 1000000000; } struct Tree{ int n; vector<vector<pair<int,int>>>...
//================code===================// //#define TLE #ifdef TLE #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #include <random> #include <ctime> #define ci(t) cin>>t #define co(t) ...
#include <cstdio> #include <algorithm> using namespace std; char S[105]; int A[105]; int l[105],r[105],lcnt[105],rcnt[105]; int N,t; bool check(int x) { for(int i=0;i<=N;i++) { l[i]=A[i]/x; lcnt[i]=x-A[i]%x; r[i]=A[i]/x+1; rcnt[i]=A[i]%x; } for(int i=0;i<N;i++) if...
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "debug.hpp" #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; string S; cin >> S; vec...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define range(a) a.begin(), a.end() #define endl "\n" #define Yes() cout << "Yes" << endl #define No() cout << "No" << endl #define MP make_pair using P = pair<int, int>; const...
#include <iostream> #include <vector> #include <queue> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); vector<vector<pair<int, int>>> e(n); for (int i = 0; i < m; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); e[a - 1].push_back({b - 1, c}); } for (int i = 0; i < n; i++...
#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; } // 1-indexed template<typename T> struct BIT{ int n; vect...
#include "bits/stdc++.h" #include<sstream> using namespace std; typedef long long ll; #define _USE_MATH_DEFINES #include <math.h> #define NIL = -1; #define all(x) x.begin(),x.end() const ll INF = 1e9; const long long inf = 1e18; const ll INFL = 1e18; const ll MOD = 1e9 + 7; int digit(ll x) { int digits = 0; ...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll n;cin>>n; ll ans=0; if(n>=1000) ans+=n-999; if(n>=1000000) ans+=n-999999; if(n>=1000000000) ans+=n-999999999; if(n>=1000000000000) ans+=n-999999999999; if(n>=1000000000000000) ans+=n-9999999...
#include <bits/stdc++.h> #include <string> #include <cmath> using namespace std; #define ll long long #define ld long double #define pb push_back #define Messi \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define pii pair<ll, ll> #define mod 1000000007 #define vi vect...
#include<bits/stdc++.h> using namespace std; #define sz 200000 #define ll long long #define pb push_back #define pi 2*acos(0.0) #define f first #define s second #define mod 1000000007 #define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);} #define test ll t; cin...
#include <iostream> #include <string> #include <vector> #include <deque> #include <queue> #include <algorithm> #include <iomanip> #include <set> #include <map> #include <bitset> #include <cmath> #include <functional> using namespace std; #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define REV(i,n) for(ll (i) = (...
// https://atcoder.jp/contests/abc180/tasks/abc180_e #include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++) #define DEBUG 1 #if DEBUG #define _GLIBCXX_DEBUG #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.s...
#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); } template <typename T> class Dinic { public: static_assert(std::is_integral<T>::value, "Integral requir...
//#include <atcoder/all> //using namespace atcoder; #include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for(int i=0; i<n; i++) #define REPR(i, n) for(int i=n-1; i>=0; i--) #define FOR(i, m, n) for(int i=m; i<n; i++) #define ALL(v) v.begin(), v.end() #define SIZE(x) int(x.size()) #defi...
#include<bits/stdc++.h> using namespace std; using ll = long long; const int MT = 200010; int main() { int N; cin >> N; ll W; cin >> W; vector<ll> imos(MT + 1); for(int i = 0; i < N; i++) { ll s, t, p; cin >> s >> t >> p; imos[s] += p; imos[t] -= p; } for(int i = 0; i < MT; i++)imos[i + 1] += imos[i]; cou...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <climits> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define debug(x) cerr << #x << " = " << x << endl; #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define MSET(c, v) memset(c, v, sizeof(c)) const ll INF = 1e17; const int NEGINF = 0xC0C0C0C0; const int NU...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int main() { ll n; cin >> n; double t = (double)(n + 1); t = sqrt(2 * t + 0.25) - 0.5; int m = 10000; ll x = (ll)t + m; ...
#include <iostream> #include <cmath> using namespace std; int main() { long long n; cin >> n; long long k = (long long)floor(sqrt(2 * n + (long double)2.25) - (long double)0.5); long long result = n - k + 1; cout << result << endl; }
#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...
#pragma GCC optimize(2) //#include <bits/stdc++.h> #include <iostream> #include <set> #include <cmath> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <utility> #include <map> #define rush() int T; while(cin>>T) while(T--) #define ms(a,b) memset(a,b,sizeof ...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mod=1e9+7; const ll INF=4e18; const int inf=1e9; const double pi=acos(-1); ll n, ans; ll cek(ll pos, ll pjg){ return pjg*(2*pos+(pjg-1))/2; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int len=1;...
/****************************************** * AUTHOR : RTG * ******************************************/ #include <bits/stdc++.h> using namespace std; // long long dp[(long long)1e12+1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE // For getting input from input.txt fi...
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); int a,b; cin >> a >> b; vector <int> A(a),B(b); for(int i=0;i<a;i++)A[i]=i+1; for(int i=0;i<b;i++)B[i]=-(i+1); if(a>b){ B[b-1]=-((a*(a+1)/2)-((b*(b-1)/2...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> II; const int MAXN = 1000 + 10; int n, m, a[MAXN], b[MAXN]; int main() { scanf("%d%d", &n, &m); int rev = 0; if (n < m) { rev = 1; swap(n, m); } for (int i = 1; i <= n; ++i) { a[i]...
#include <bits/stdc++.h> #define int long long using namespace std; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')w=-1;ch=getchar(); } while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } inline bool read(int& a){ int s=0,w=1; cha...
/*input 2525 425 */ //#include "wall.h" #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; #pragma GCC optimize("unroll-loops,no-stack-protector") //order_of_key #of elements less than x // find_by_order kth element #...
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int l; cin >> l; vector<array<int, 12>> dp(l + 1); for(int i = 1; i <= l; i++) { dp[i][0] = 1; } for(int cut = 1; cut <= 1...
#include<iostream> #define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; const int MAXN=1e5+5; ll cal(ll n) { ll ans=1; int cnt=11; for(int i=1;i<12;++i) { ans*=n-i; ans/=i; } return ans; } int main() { FAST; ll n; cin>>n; ...
#include<iostream> #include<iomanip> #include<string> #include<vector> #include<algorithm> #include<utility> #include<tuple> #include<map> #include<queue> #include<deque> #include<set> #include<stack> #include<numeric> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; struct Ed...
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <cstring> #include <unordered_map> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> arr(n); vector<int> rem(201, 0); ll ans = 0; fo...
#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> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for(int i=(a); i<=(b); ++i) #define ROF(i, a, b) for(int i=(a); i>=(b); --i) #define make_unique(a) sort(all((a))), (a).resize(uni...
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define mp make_pair #define ...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define print(x) cout << (x) << endl typedef long long ll; using P = pair<int,int>; using Graph = vector<vector<int>>; //const ll MOD = 1000000007; const ll MOD = 998244353; template <typename T> inline bool chmax(T &a, T b) {return ...
#include <bits/stdc++.h> #define mp make_pair #define fi first #define se second #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #defin...
#include <bits/stdc++.h> #define MOD (long long)(1E9+7) #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; int table[2000][2000]; void bfs(queue<pair<int,int>> &que, vector<vector<pair<int,int>>> &warp, int &now, int &w, int &h) { int n = que.size(); rep(lll,n) { auto x = que.front(); int i = x...
#include<bits/stdc++.h> using namespace std; int main(){ int a, b, c; cin >> a >> b >> c; if(a + b == 2 * c || a + c == 2 * b || b + c == 2 * a) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#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 ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define mt ...
// Contest: AtCoder Regular Contest 104 (https://atcoder.jp/contests/arc104) // Problem: A: Plus Minus (https://atcoder.jp/contests/arc104/tasks/arc104_a) // region boilerplate #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <chrono> #include <cstdint> #include <de...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) using ll = long long; using P = tuple<ll, ll, int>; int main() { int n; cin >> n; vector<P> ps; rep(i, n) { ll x, y; cin >> x >> y; ps.emplace_back(x, y, i); } vector<bool> pushed(n...
/* ID: meadri01 LANG: C TASK: test */ #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define int long long #define w(t) int t;cin>>t;while(t--) #define pb push_back #define mk make_pair #define ascSort(v) ...
#include<bits/stdc++.h> using namespace std; /*#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> is;*/ #define fb find_by_order #define ok order_of_key #define me...
#include <bits/stdc++.h> using namespace std; void __print(int x) {cout << x;} void __print(long x) {cout << x;} void __print(long long x) {cout << x;} void __print(unsigned x) {cout << x;} void __print(unsigned long x) {cout << x;} void __print(unsigned long long x) {cout << x;} void __print(float x) {cout << x;} void...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { char n,s; cin>>n>>s; if(n=='N'){ s=(s>='A'&&s<='Z')?s+32:s; } else{ s=(s>='a'&&s<='z')?s-32:s; } cout<<s; }
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x...
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define ii pair<int, int> #define OK (cerr << "OK" << endl) #define debug(x) cerr << #x " = " << (x) << endl #define ff first #define ss second #define int long long #define tt tuple<int, int, int> #define all(x) x.begin(), x.end() #define vi vecto...
#include <iostream> #include <algorithm> using namespace std; int n, k, p[59][59], tp[59][59], ds[59], sz[59]; int uf(int n) { if (ds[n] == n) return n; return ds[n] = uf(ds[n]); } bool chk(int a, int b) { for (int i = 1; i <= n; i++) if (p[i][a] + p[i][b] > k) return false; return true; } int main() { io...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(0); cin.tie(0); map <int, set <int>> g ; int n, m ; cin >> n >> m ; for (int i=0;i<m;++i) { int a, b ; cin >> a >> b ; g[a].insert(b) ; } set <int> res...
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> ...
#include <iostream> using namespace std; int main(){ double a,b; cin>>a; cin>>b; double bKonprs = b / 100; cout<<a*bKonprs<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template<class T> void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++) #define all(vec) vec.begin(), vec.en...
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7; char s[N]; int a[N], k; int add (int a, int b) { return ((a += b) >= mod) ? (a - mod) : a; } int dp[N][20], K; int f (int l, int k) { if (~dp[l][k]) return dp[l][k]; if (l == 0) return k == K; dp[l][k] = (ll)...
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define pb(x) push_back(x) #define ff first #define ss second #define all(x) x.begin(), x.end() #define dbg(x) cout << #x << ": " << x << "\n" #define dbg2(x, y) cout <<"{ " << #x <<", "<< #y<< " }"<< ": " <<"{ " << x <<", ...
#include <bits/stdc++.h> #define INF 1e9 #define LINF (1LL << 63 - 1) #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 ALL(a) (a).begin(),(a).end() // #define chmax(a, b) a = max(a, b) // #define chmin(a, b) a = min(a, b) #define pb push_back #define fi fir...
#include <iostream> #include <string> #include <vector> #include <algorithm> int main() { std::string str; std::cin >> str; std::vector<int> v, mod; int sum = 0; for (int i = 0; i < str.length(); ++i) { v.push_back(str[i] - '0'); sum += v[i]; if (v[i] % 3) mod.push_back(v[i] % 3); } std::sort(...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #define RE...
/* How To Solve It 1st. Understanding The Problem 未知なもの、データ(与件), 条件 は何か? その条件は未知を決定するために十分か? 条件を分解せよ, 図を描け 2nd. Devising A Plan 類似、関連のある問題、典型問題を知らないか? 役立ちそうな定理やアルゴリズムを知らないか? 問題の一部を解決できるか、一部だけ残して他を切り捨ててみろ 既知のものやデータを変えることはできるか? 3rd. Carrying Out The Plan 各ステップで誤りがないか、正しいと説明できるか? 4th. L...
#include <bits/stdc++.h> #define fi first #define se second #define o2(x) (x) * (x) #define mk make_pair #define eb emplace_back #define SZ(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define clr(a, b) memset((a), (b), sizeof((a))) #define rep(i,s,t) for(register int i=s;i<t;++i) #define per(i,s,t) for(r...
#include <bits/stdc++.h> #include <string> #include <cmath> using namespace std; #define ll long long int #define pb push_back #define Messi ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pii pair<pair<ll,ll>, ll> #define mod 1000000007 #define vi vector<ll> #define vii vector<pii> #define all(v) v.begin(),v....
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<string> s(n); set<string> st; for(int i=0;i<n;i++){ cin >> s[i]; st.insert(s[i]); } for(int i=0;i<n;i++){ if(s[i][0]!='!'){ if(st.count('!'+s[i])>=1){ cout << s[i] << endl; return 0; }...
#include <bits/stdc++.h> using namespace std; #define FASTIO cin.tie(0);ios::sync_with_stdio(0) int main() { FASTIO; string n; cin >> n; map<char, int> ava; for (int i = 0; i < n.size(); i++) { ava[n[i]]++; } if (n.size() >= 3) { for (int i = 104; i < 1000; i+=8) { string mystring = to_string(i); int ...
#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>; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; vector<int> cnt(10); int n = s.size(); if(n == 1){ if(s == "8"...
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for(auto& nx : v) { cin >> nx; } bool b = 0; for(int i = 0; i < n; ++i) { for(int j = i + 1; j < n; ++j) { if(v[i] == v[j]) { cout << "No" << endl; b = 1; ...
// #include <atcoder/all> #include <bits/stdc++.h> #ifndef M_PI #define M_PI 3.14159265358979 #endif #define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI) #define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360) #define rep2(i, m, n) for(long long i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) f...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < int(n); i++) using namespace std; using ll = long long; const int INF = (1<<30)-1; const long long LINF = (1LL<<62)-1; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; retur...
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <map> #include <unordered_map> using namespace std; #define debug(x) cout << #x << '=' << x << '\n' #define rep(i, b, e) for (int i = b; i <= e; i++) const int N = 212345; int n, a[N], b[N], c[N]; unordered_map<in...
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0);ios_base::sync_with_stdio(0); string to_string(string s) { return '"' + s + '"';} string to_string(char s) { return string(1, s);} string to_string(const char* s) { return to_string((string) s);} string to_string(bool b) { return (b ? "true" : "fa...
#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 #...
//#pragma GCC optimize ("O3","unroll-loops") #include<iostream> #include<iomanip> #include<cstdio> #include<cstdlib> #include<cassert> #include<cmath> #include<functional> #include<algorithm> #include<numeric> #include<vector> #include<string> #include<queue> #include<stack> #include<deque> #include<set> #include<map...
#include<bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; ++i) #define rrep(i, n) for(int i = n-1; i >= 0; --i) #define fi first #define se second using namespace std; using ll = long long; using ui = unsigned int; using ul = unsigned long long; using ld = long double; using v1i = vector<int>; using v1ll = vector...
#include<iostream> using namespace std; #define ll long long ll pos(int a){ ll sum=1; for(int i=1;i<=a;i++){ sum*=10; } return sum; } ll pp(int n){ ll sum=0; for(int i=1;i<=n;i++){ sum=sum*10+9; } return sum; } int main() { ll n; cin>>n; ll temp=n; int digit=0; while(temp){ temp/=10; digit++; }...
#include <iostream> #include <vector> #include <cstdlib> #include <algorithm> #include <string> using namespace std; int main() { string s; cin >> s; int nn = s.length(); int i2 = 9; int i4 = 90; int i6 = 900; int i8 = 9000; int i10 = 90000; if(nn <= 1){ cout<<0; re...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define _GLIBCXX_DEBUG #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, c, n) for (ll i = c; i < (n); ++i) //以下debug用 #define d(x) cout << #x << "; " << x << endl; #define p(x) cout << x << endl; #define f(x) for (long unsigned int i = 0;...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using Vll =vector<ll>; using VVll =vector<vector<ll>>; template <class T> using Vec = vector<T>; template <class T> using VVec = vector<vector<T>>; #define INF 9223372036854775807LL/2 void Z(ll i=-1){ if(i==-1)cout<<"Test"<<endl; else cout<<"Test"<<i<<e...
/*........................... .........tank.jpg............ ...........................*/ //PointBlank's code (⌐■_■) #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; template<typename T> using pxx = pair<T, T>; ll power(ll x, ll y); #define...
#include<bits/stdc++.h> using namespace std; template<typename T>inline T read(){ T f=0,x=0;char c=getchar(); while(!isdigit(c)) f=c=='-',c=getchar(); while(isdigit(c)) x=x*10+c-48,c=getchar(); return f?-x:x; } #define int long long namespace run{ const int N=4e5+9; int head[N],nex[N],to[N],cnt; inline void add(...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long // const int md = 998244353; const int sz = 1e5+1; int A[sz+1]; int B[sz+1]; // int C[sz+1]; vector<int> primes; void sieve(){ primes.clear(); for (int i = ...
/**In the name of Allah, the Most Merciful, the Most Merciful.**/ #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wformat" #include <bits/stdc++.h> #include <ext/pb_ds/asso...
#include <bits/stdc++.h> #define inc(i, j, k) for (int i = j; i < k; i++) using namespace std; int f[17][1 << 17], n, g[17][17], x[17], y[17], z[17]; int dp(int i, int s) { if (f[i][s] != -1) return f[i][s]; f[i][s] = 0x3fffffff; inc(j, 0, n) if ((s & (1 << j)) == 0) f[i][s] = min(f[i][s], dp(j, s | (1 << j)) + g...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() using ll = long long; using P = pair<ll, ll>; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; string char_to_string(char val) { return string(1, val); } int ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define sz(a) a.size() #define re return #define all(a) a.begin(),a.end() #define int long long #define Type int #define rept(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,a) rept(i,0,a) using namespace std; int n,t; int a[44]; vector<int>v1,v2; signed ...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back int seive[200002]; ll mod = 998244353; ll inv[1000]; ll C(ll a, ll b){ ll temp = 1; for(ll i=0;i<b;i++){ temp = (temp * (a-i))%mod; } for(ll i=0;i<b;i++){ temp = (temp * inv[i+1])%mod; } return temp; } int main() { inv...
#include<bits/stdc++.h> #define ll long long int using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; ll s=0; for (int i = 1; ; ++i) { s+=i; if(s>=n){ cout<<i; break;} } return 0; }
#include <iostream> #include <string> #include <algorithm> #include <vector> #define rep(i,n) for(int i=0;i<n;i++) #define ll long long using namespace std; ll n,a; int main(){ cin >> n; a = 0; while(a*(a+1)/2 < n){ a++; } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define rep1(i,n) for (int i = 1; i <= (n); ++i) #define bit(n,k) ((n>>k)&1) //nのk bit目 #define vec(T) vector<T> #define vvec(T) vector<vector<T>> using ll = long long; using ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9; const int INF = 1001001001; int h, w; int a[2005][2005]; bool visited[2005][2005]; int memo[2005][2005]; int f(int i, int j) { if (i == h - 1 && j == w - 1) return 0; if (visited[i][j]) return memo[i][j]; visited...
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int N = 1e6 + 10, M = 2e6 + 10, inf = 0x3f3f3f3f; const long long Linf = 0x3f3f3f3f3f3f3f3f; inline int read() { bool sym = 0; int res = 0; char ch = getchar(); while (!isdigi...
#include<bits/stdc++.h> #include <iostream> #include <string> #define lli long long int #define deb1(x) cout<<#x<<" :: "<<x<<"\n"; #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"; #define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ string n;cin>>n; ll X = (ll)n.size(); string S; ll Q = stoll(n); if(Q<10){ cout<<0<<endl; return 0; } if(X%2==1){ n=""; for(ll i=0;i<X-1;i++){ n+='9'; } } ll Y = (ll)n.size(); str...
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder #include<bits/stdc++.h> //#include<atcoder/all> typedef long long ll; typedef long double ld; using namespace std; //using namespace atcoder; using Pii = pair<int, int>; using Pll = pair<ll, ll>; //ordered_set 重複不可 #include <ext/pb_ds/assoc_con...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define N 100005 #define MOD 1000000007 #define dd double #define vi vector<int> #define vll vector<ll> #define forr(i, n) for (ll i = 0; i < n; i++) #define revf(i, n) for (ll i = n - 1; i >= 0; i--) #define REP(i, a, b) for (ll i = a; i < b; i++) ...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn #define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa #define db(x) cout << #x << " = " << x << endl #define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用 #define all(x) (x).begin(), (...
#include <bits/stdc++.h> using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t; using i128 = __int128_t; using u128 = __uint128_t; using isize = std::ptrdiff_t; using usize = std::size_t; class rep { struct Iter { usize itr; constexpr Iter(const u...
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>...
#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>>; #define FOR(i,a,n) for(int i=(a);i<(n);++i) #define eFOR(i,a,n) for(int i=(a);i<=(n...
#include<stdio.h> #include<string.h> #include<algorithm> #include<map> #include<math.h> #define reg register #define ri reg int #define rep(i, x, y) for(ri i = x; i <= y; ++i) #define nrep(i, x, y) for(ri i = x; i >= y; --i) #define DEBUG 1 #define ll long long #define il inline #define swap(a, b) ((a) ^= (b) ^= (a) ^=...
#include <bits/stdc++.h> using namespace std; int main(){ int x,y; cin >> x >> y; if(abs(x-y) >= 3){ cout << "No" << endl; } else{ cout << "Yes" << endl; } }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #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() #define PI 3.14159265358979323846264338327950L #define mod 1000000007 using namespace std; typede...
/*input 2 3 ..# #.. */ #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<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; #pragma GCC opti...
//region #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; #define fastio ios_base::sync_with_stdio(0);cin.tie(NULL); #define en...
//AUTHOR: RAVAN_2070 //PUNE INSTITUTE OF COMPUTER TECHNOLOGY /* I ♥ CLARICE STARLING... EXPLAINATION BELOW-> */ #include<bits/stdc++.h> using namespace std; typedef unsigned long long int ull...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define print(x) cout << x << endl #define all(v) (v).begin(),(v).end() #define YN(ok) print((ok ? "YES" : "NO")) #define yn...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(ll i=0; i<(ll)n; i++) #define ALL(obj) begin(obj), end(obj) typedef long long ll; int n, m, a, b, cnt; vector<vector<int> > G(22); vector<int> color(22, -1), ts; vector<bool> vit(22, 0); void dfs(int now){ ts.push_back(now); vit[now]=1; for(int i...
#include <iostream> #include <math.h> #include <vector> using namespace std; const int MOD = 998244353; typedef pair <int,int> ii; long long fac(long long a){ if(a==0)return 1; return (a*fac(a-1))%MOD; } int n, k; int en[50][50]; vector < vector <int> > mc, mr; int vi[50][2]; bool cc(int i, int j){ for(int i...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=(n)-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue<x...
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, C, D; cin >> A >> B >> C >> D; if( D * C <= B ) { cout << -1 << endl; return 0; } long long a = A; long long b = 0; int ans = 0; while( a > b * D ) { a += B; b += C; ans++; } cout << ans << endl; }
#include<bits/stdc++.h> typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; using namespace std; //ループマクロ #define FOR(i , a , b) for(int i = (a) ; i < (b) ; i++) #define REP(i , n) for(int i = 0 ; i < n ; i++) #define REPR(i , n) for(int i = n ; 0 <= i ; i--) #define ROP(i, n) for(int i...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define all(a) (a).begin(),(a).end() #define endl "\n" #define yes "YES\n" #define no "NO\n" #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); vector<int>v,pos; vector<int>ans; int n; void perform_o...
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int n; cin >> n; ll s = 0; ll a[200005]; for(int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); ll ans = 0; for(int i = 0; i < n; i++){ ans = (ans + a[i] ...
#include<bits/stdc++.h> #define L(i, j, k) for(int i = (j); i <= (k); i++) #define R(i, j, k) for(int i = (j); i >= (k); i--) #define ll long long #define sz(a) ((int) a.size()) #define vi vector<int> using namespace std; const int N = 5e5 + 7, inf = 1e9 + 7; int n, a[N], b[N], cnt; int main() { ios::sync_with_stdio(...
//Bismillahir Rahmanir Rahim //Allahumma Rabbi Jhidni Elma /*--------Please carefully check-------- 1.Overflow and underflow 2. */ #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ld PI = 2*acosl(0.0); const int inf=2e5+7; const in...
#include <iostream> #include <cstdio> #include <vector> #include <iomanip> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <map> #include <set> #include <cmath> using namespace std; using VI = vector <int>; using SI = set<int>; int main() { int N; string S; cin >> N >> S; ...
//#pragma GCC optimize ("O2") //#pragma GCC optimize ("Ofast") // IN THE NAME OF GOD #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; template<typename Head> inline void dout(Head in) { cerr << in << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; ...
#include <bits/stdc++.h> #include <unordered_set> #include <algorithm> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vs = vector<string>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repll(i,n)...
#include <bits/stdc++.h> using namespace std; using ll = long long; const long long INF = 1001001001; const long long MOD = /**/1000000007;//*/998244353; const double EPS = 1e-10; int main(){ cin.tie(0); ios::sync_with_stdio(false); int a,b; cin>>a>>b; cout<<2*a+100-b<<endl; }
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define repr(i,n) for(int i=n-1;i>=0;i--) #define MAX(a,b) a=a>b?a:b #define MIN(a,b) a=a<b?a:b #define REP(i,x,n) for(int i=x;i<n;i++) #define REPR(i,x,n) for(int i=n-1;i>=x;i--) #define pb push_back #define ALL(obj) (obj).begin(), (obj).end() #define ALL...
#include<bits/stdc++.h> using namespace std; int n,a,b; void read(int &x) { char ch;bool ok; for(ok=0;!isdigit(ch);ch=getchar()) if(ch=='-') ok=1; for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar()); if(ok) x=-x; } int main() { read(n),read(a),read(b); cout<<n-a+b; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long inf = 1LL<<60; using ll = long long; template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig...
#include<bits/stdc++.h> #include<vector> #include <iostream> using namespace std; using ll = long long; int main() { int x, y; cin >> x >> y; if (x != y){ cout << 3 - x - y << endl; }else{ cout << x << endl; } return 0; }
/* 十 聖イシドールスよ、迷えるプログラマを導き給え! 十 */ #include <cstddef> #include <iostream> #include <math.h> #include <vector> #include <string> #include <map> #include <algorithm> #include <cmath> #include <deque> #include <queue> #include <cstring> #include <cstdint> #include <tuple> #include <fstream> #include <numeric> /*** MACRO a...
#include <bits/stdc++.h> using namespace std; #define db double const int N = 100020; int n, a[N]; int main() { // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); cin >> n; for (int i = 1; i <= n; i++) { int Max = 0; for (int j = 1; j <= (int)sqrt((db)i); j++) if (i % j == 0) { Max = max...
#include<bits/stdc++.h> #define ll long long #define mp make_pair #define f(i,n) for(int i=0;i<n;i++) #define F first #define S second #define pb push_back using namespace std; ll dp[205][15]; ll fun(ll len, ll parts){ if(len<parts) return 0; if(parts==1) return 1; if(dp[len][parts]!=-1) return ...
#include<bits/stdc++.h> using namespace std; #define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);} typedef long long int ll; typedef string S; #define M 1e18 #define AS 250005 #define sp cout<<' ' #define nw cout<<endl #define rt return #define __ template<typename T, typename... Types> void in() {rt;...
#include<iostream> using namespace std; int main(void) { int c = 0, ans = 0; for (int i = 0; i < 12; i++) { char a; cin >> a; if (a == 'Z') c = 1; else if (c == 1 && a == 'O')c = 2; else if (c == 2 && a == 'N')c = 3; else if (c == 3 && a == 'e') { ans++; c = 0; } } cout << ans << endl; }
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= ...
//#define local #include <bits/stdc++.h> using namespace std; #define endl '\n' #define rep(i,n); for(long long i = 0;i < (n);i++) using ll = long long; using P = pair<long long,long long>; template <class T> using vec = vector<T>; #ifdef local #include "library/debug.cpp" #else #define debug(...) #endif const ll inf =...
// Problem: B - 200th ABC-200 // Contest: AtCoder - KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) // URL: https://atcoder.jp/contests/abc200/tasks/abc200_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> using namespace std; #d...
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. ******************************************...
#include<bits/stdc++.h> using namespace std; int main(){ int m,h; cin>>m>>h; if(h%m==0) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <deque> #include <set> #include <limits> #include <string> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <numeric> using namespace std; using ll = long long; #define FOR(...
#include <iostream> using namespace std; int main(){ int v,t,s,d; cin >> v >> t >> s >> d; if(v * t <= d && d <= v * s){ cout << "No"; }else{ cout << "Yes"; } return 0; }
//#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <algorithm> #include <cstdlib> #include <string> #include <vector> #include <map> #include <queue> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int> > vvint; typedef vector<long long> vll, vLL; type...
#include <bits/stdc++.h> using namespace std; int main() { long long n,m,i,t,p,q,query,a,b; cin >> n; vector<long long> x(n),y(n); for(i=0; i<n; i++){ cin >> x[i] >> y[i]; } cin >> m; vector<long long> px(m+1),py(m+1),dx(m+1),dy(m+1); px[0]=1; py[0]=2; dx[0]=0; dy[0]=0; for(i=0; i<m; i++){ cin >> t; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for(int (i) = 0; (i) < (n); ++(i)) #define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i)) #define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i)) template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return ...
#include <bits/stdc++.h> using namespace std; const int N = 200200; int n, v[N*2], a[N], b[N]; priority_queue<int,vector<int>,greater<int> > Q; int main() { scanf("%d",&n); for (int i=1;i<=n*2;i++) scanf("%d",v+i); for (int i=1;i<=n;i++) { a[i] = max(v[n+1-i],v[n+i]); b[i] = min(v[n+1-i],...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; template<typename T>inline bool ch...
// E - Traveling Salesman among Aerial Cities // 典型: 巡回セールスマン問題 #include <bits/stdc++.h> using namespace std; using vi = vector<int>; #define rep(i,n) for(int i=0;i<(int)(n);++i) int main(){ int n; cin>>n; vi x(n), y(n), z(n); rep(i, n) cin>>x[i]>>y[i]>>z[i]; int m = 1<<n; vector<vi> dp(m, vi(n, 1'000'000'000)); ...
#include<bits/stdc++.h> #define SORT(v) sort(v.begin(),v.end()) #define si(n) scanf("%d",&n) #define sii(n,m) scanf("%d %d",&n,&m) #define sl(n) scanf("%lld",&n) #define sll(n,m) scanf("%lld %lld",&n,&m) #define ss(cad) scanf("%s",cad) #define all(v) (v).begin(), (v).end() #define PB push_back #define fst first #defin...