code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
/* * Author: Utkal Sinha * Created on: 2020-10-31, Sat, 17:21 * Problem: * Platfrom: General * */ #if USE_BOOST2 #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> namespace bst = boost::multiprecision; typedef bst::int1024_t vll; //int512_t or //int128_t typedef bst::cpp...
#include <bits/stdc++.h> using namespace std; signed main() { long double x,y,r;long long t=0;cin>>x>>y>>r;r+=1e-14; for(int i=ceil(x-r);i<=floor(x+r);++i) t+=floor(y+sqrt(r*r-(i-x)*(i-x)))-ceil(y-sqrt(r*r-(i-x)*(i-x)))+1; cout<<t;return 0; }
//#pragma GCC optimize ("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define pb push_back #define F first #define S second #define ins insert #define mp ma...
#include<bits/stdc++.h> #define int int using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--){ long long x; cin >> x; if(x & 1LL){ cout << "Odd\n"; } else if((x / 2) % 2 == 0){ co...
#include<bits/stdc++.h> using namespace std; const int M=1000005; int n,a[M],cnt=3; int main() { scanf("%d",&n); printf("6 10 15 "); for(int i=2;;i++) { if(i*6>10000)break; a[++cnt]=i*6; } for(int i=2;;i++) { if(i*10>10000)break; a[++cnt]=i*10; } for(int i=2;;i++) { if(i*15>10000)break; a[++cnt...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A; for(int i = 2; i <= 10000; i+= 2){ if(i % 3 == 0 || i % 5 == 0 || i % 7 == 0){ A.push_back(i); } } cout << 105 << " "; for(int i = 0; i < N-1; i++){ cout << A[i] << " "; } cout << "\n"; }
/* This code belongs to Aadit Ambadkar Date: 2021-06-13 05:08:53 */ #include <bits/stdc++.h> using namespace::std; typedef long long ll; #define F0R(i, n) for (int i = 0; i < n; i++) #define R0F(i, n) for (int i = n-1; i >= 0; i--) #define FOR(i, a, n) for (int i = a; i < n; i++) #define pb push_back #define f...
#define _USE_MATH_DEFINES //#include <bits/stdc++.h> # include <iostream> # include <array> # include <string> # include <vector> # include <algorithm> # include <functional> # include <cmath> # include <iomanip> # include <stack> # include <queue> # include <numeric> # include <map> # include <set> # include <unord...
#include <iostream> #include<bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define endl "\n" #define vi vector<int> #define vii vector<pair<int,int>> #define pb push_back using namespace std; using ll = long long; const ll mod = 1e9+7; ll fac[1000001]; void pre(){ fac[0]=fac[1]=1; for(int i=2;i<=100000...
#pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << (#x) << " : " << x << '\n' void solve() { int n; cin >> n; vector<string> v; set<string> st; while (n--) { string s; cin >> s; if (s.front() == '!') st.emplace(s); else v.emplace_back(s); } for (const auto& ...
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; using ll=long long; using P=pair<ll,ll>; template<class T> using V=vector<T>; #define fi first #define se second #define all(v) (v).begin(),(v).end() const ll inf=(1e18); //const ll mod=998244353; const ll mod=1000000007; const vector<int> dy={-1...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #define ll long long #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; int ans[1001]; in...
/* CODER::==>ARYAN KANSAGARA CF HANDLE:=>Good_Devil -----------------------------------------------*/ #include<bits/stdc++.h> using namespace std; #define int long long int #define endl "\n" void solve() { string S; cin >> S; int ans = 0; for (int i = 0; i <= 9999; i++) { vector<bool> flag(10); int X = i;...
#include "bits/stdc++.h" using namespace std; #define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long #define mod 1000000007 const int N = 2e5 + 5; vector<int> tree[N], depth(N); vector<int> time_in(N), time_out(N); vector<int> orders[N]; int timer = 0, n; void dfs(int s) { time_in[s] ...
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { ll N; cin >> N; vector<ll> F(89, 0), a; F[1] = 1; rep(i, 2, 89) { F[i] = F[i - 1] + F[i - 2]; } //rep(i, 0, 89) cout << i << " " << F[i] << endl; ...
#pragma region Macros #include <bits/stdc++.h> #if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG) #include <atcoder/all> #endif using namespace std; #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i, n) for(int i=(n); i>=0; --i) #define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##...
#include <bits/stdc++.h> //Header Files #define ll long long int #define mod 1000000007 #define endl "\n" using namespace std; template <class T> void out(int t, T ans) { cout << "Case #" << t << ": " << ans << endl; } template <class T> void out(int t, T ans[]) { cout << "Case #" << t << ": "; for (T v...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define vll vector<ll> #define vvll vector<vll> #define mll map<ll,ll> #define f(i,m,n) for(i=m;i<n;i++) #define ee endl #define pb push_back #define mp make_pair #define ff first #define ss second #define take(v,n) for(i=0;i<n;i++) cin>>v[i]; #def...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; int solve(vector<pair<int, int>> ans) { return 0; } void Main() { int n, m; cin >> n >> m; int c = n-abs(m); if (m < 0 || m == n || (m >= n-1 && n >= 2)) { cout << -1 << endl; retu...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pii; typedef tuple<ll, ll, ll> ti; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //using Bint = mp::cpp_int; #define REP(a,b,c) for(l...
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector < ll > vl; typedef vector < vl > vvl; typedef pair < ll, ll > pll; typedef v...
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b,c,d; cin>>a>>b>>c>>d; c-=a; d-=b; d=abs(d); c=abs(c); if ( c> d) swap( c,d); if ( abs( d)==abs(c)){ if ( d==0) cout<<0<<"\n"; else cout<<1<<'\n'; } else if ( ...
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #include<ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; #define forn(i,x1,n) for(int i=x1;...
#include <vector> #include <iostream> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef vector<ll> vec; typedef vector<vec> mat; #define rep(i,n) for (int i=0; i<(n);++i) ll mod=998244353,fac[200001],finv[200001],inv[200001]; int INF = 1e9+7; mat matmul(mat &A,mat &B){ mat C(A.size(),vec(B[...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define f(i,j,n) for(long long i = j ; i < n ; ++i) #define ones(x) __builtin_popcount(x) #define endl '\n' using namespace std; //using names...
#include <bits/stdc++.h> using namespace std; using ll = long long; using matll = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define repi(i, a, b) for (ll i = ll(a); i < ll(b); i++) int main() { ll n; cin >> n; vector<bool> flag(10001, 0); flag[6] = 1, flag[10] = 1, flag[15]...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> ii; typedef vector<ii> vii; const ll mod = 3e5+2; int n; ll t[4*mod]; void build(ll h[],int v,int tl,int tr){ if(tl == tr) t[v] = h[tl]; else{ int tm = (tl+tr)/2; build(h,v<<1,tl,tm); ...
#include<bits/stdc++.h> #define rep(i,n) for(int i =0;i<n;++i) #define reps(i,s,n) for(int i =s;i<n;++i) using namespace std; using P = pair<int, int>; using ll = long long; //0-indexed template<class T, T (*op)(T,T), T(*e)()> class segtree { private: int n; vector<T> v; public: segtree(int n_) { ...
#include<bits/stdc++.h> using namespace std; const int N=2e5+5; const int mod=1e9+7; int l; string s,x; bool dp[N][7],visited[N][7]; bool DP(int pos,int val) { if(pos == l)return (val == 0); if(visited[pos][val])return dp[pos][val]; visited[pos][val]=1; bool &ans=dp[pos][val]; if(x[pos] == 'T') ...
#pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define ll long long int #define deb(x) cout << #x << " " << x << endl; #define mod 1000000007 #define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NU...
#include<bits/stdc++.h> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i...
//author: hitch_hiker42; #include<bits/stdc++.h> using namespace std; //solution: #define int int64_t auto gcd(int a, int b) { if(!b) return make_tuple(a, 1LL, 0LL); auto [g, x, y] = gcd(b, a % b); return make_tuple(g, y, x - (a / b) * y); } int linsolver(int a, int b, int m) { if(b % __gcd(a, m)) return -1;...
#include <iostream> #include <string> #include <vector> int main(){ int n; std::string s, t; std::cin >> n >> s >> t; int ans = 0; int sums = 0; int sumt = 0; for(int i = 0; i < n; i++){ sums += s[i] - '0'; sumt += t[i] - '0'; if(s[i] < t[i] && sums < sumt) ans++; if(s[i] > t[i] && sums ...
// // main.cpp // test // // Created by wyzwyz on 2021/5/13. // #include<cstdio> #include<cctype> #define maxn 505505 template<class T> inline T read(){ T r=0,f=0; char c; while(!isdigit(c=getchar()))f|=(c=='-'); while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar(); return f?-r:r; } template<...
#include <bits/stdc++.h> #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef unsigned long long llu; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef...
#include<bits/stdc++.h> #define ll long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define sz(x) (int)(x).size() #define PB push_back #define PI 3.1415926535897932384626433832795 #define what(x) cout<<#x<<" is "<<x<<endl; using namespace std; #ifdef LOCAL//ONLINE_JUDGE #include "D:\c_c++...
#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 p(x,y) pair<x,y> #define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update> #define all(x) (x).begin(),(x).end() #define ll ...
#include <bits/stdc++.h> using namespace std; typedef long long int lli; #pragma region DEBUG #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree< pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> o...
// 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 // Made by Licykoc // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> #def...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n, k; cin>>n>>k; while(k--){ if(n%200==0){ n/=200; } else{ n*=1000; n+=200; } } cout<<...
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> // Common file #include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #define ll long long #define pb pus...
#include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <utility> #include <algorithm> #include <cmath> #include <climits> #include <iomanip> #include <queue> #include <stack> #include <ctype.h> using namespace std; typedef long long ll; const int INF = (1<<30)-1; const ll LINF...
#include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <algorithm> #include <map> #include <set> #include <list> #include <queue> #include <deque> #include <stack> #include <vector> #include <string> #define il inline #define re register #define lc(p) p << 1 #define rc(p...
#include "bits/stdc++.h" using namespace std; int main() { int N, S, D; cin >> N >> S >> D; int flag =0; for(int i=0; i<N; i++){ int X, Y; cin>> X>> Y; if(X<S && Y>D){ flag=1; cout << "Yes"<< endl; return 0; } } cout << "No"...
#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...
#include <bits/stdc++.h> using namespace std; #define ll long long void print(vector<int> &a){for(auto l : a) cout<<l<<" "; cout<<'\n';} void solve(){ ll n; cin>>n; ll a[n]; 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+= (2 * i - n +1) * a[i];...
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define all(x) (x).begin(), (x).end() #define pii pair<int, int> #define FF first.first #define FS first.second #define pb push_back using namespace std; const ll N=1000006, INF=1e18, P=998244353; ll q=1, n, m, y, z, l, r, k, a[N], b[N], f[...
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <vector> #include <queue> #include <climits> #include <utility> typedef long long ll; using namespace std; int main(void){ int h, w, i, j; string buff; vector<vector<int> > field, score; c...
#include <bits/stdc++.h> #include <vector> #define foo ios_base::sync_with_stdio(0),cin.tie(nullptr),cout.tie(nullptr) #define ll long long using namespace std; ll makeInt(vector<int> v){ reverse(v.begin(), v.end()); int decimal = 1; int total = 0; for (auto& it : v) { total += it * dec...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = (a); i < (b); ++i) #define rrep(i,a,b) for(int i = (b); i --> (a);) #define all(v) (v).begin(),(v).end() #define trav(x,v) for(auto &x : v) #define sz(v) int(v.size()) typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; ty...
#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 rep(i, a , b) for (ll i =a ; i < b ; i++) #define IOS ios::sync_with_stdio(0...
// #pragma GCC optimize("Ofast,unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define dd double #define ld long double #define sl(n) scanf("%lld", &n) #define si(n) scanf("%d", &n) #define sd(n) scanf("%lf", &n) #d...
#include <iostream> #include <iomanip> using namespace std; int a, b, c; double p[101][101][101]; double m = 0; int main() { cin >> a >> b >> c; p[a][b][c] = 1; for(int i = a; i < 100; i++){ for(int j = b; j < 100; j++){ for(int k = c; k < 100; k++){ p[i + 1][...
#include<bits/stdc++.h> using namespace std; map<tuple<int,int,int>,double> M; double T(int A,int B,int C,double K){ if(K == 0) return 0; if(M[make_tuple(A,B,C)] > 0){ return M[make_tuple(A,B,C)] * K; } if(A >= 100 || B >= 100 || C >= 100){ return K; } double S = 0,Q = 1.0 / (A +...
/* * @Author: Krishnakant * @Date: 2021-03-19 23:18:20 * @Last Modified by: Krishnakant * @Last Modified time: 2021-03-20 01:23:11 */ #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") using namespace std; typedef long long ll; #de...
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <stack> #include <cassert> #include <map> #include <numeric> #include <cstring> #include <set> #include <ctime> #include <queue> #include <cmath> #include <iomanip> #include <iterator> #include <unordered_set> using namespace std; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 26; const int M = 10; void add_vars(vector<char> &vars, string &s) { for (char c : s) { if (find(vars.begin(), vars.end(), c) == vars.end()) { vars.emplace_back(c); } } } ll process(string &s, vector<int> &dict) { ll res = 0...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #define all(v) v.begin(), v.end() using in = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i,a,b) for(int i=(int)(a);i<(int)(...
// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T& x, T y){ if(x > y){ x = y; return true...
/** Created by: Humberto Yusta Codeforces User: humbertoyusta Country: Cuba */ #include<bits/stdc++.h> using namespace std; /// Pragmas #pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline","03") // Optimization flags //#pragma GCC option("arch=native","t...
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=...
#include<bits/stdc++.h> using namespace std; const int N=2e5+7; const int mod=998244353; typedef long long ll; int fa[N]; int find(int x) { return x==fa[x]?fa[x]:fa[x]=find(fa[x]); } ll qpow(ll a,ll b) { ll res=1; while(b) { if(b&1) { res=(res*a)%mod; ...
#include <bits/stdc++.h> using namespace std; #define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) typedef long long ll; typedef pair<int,int> pii; const int INF = 0x3f3f3f3f; const int MAXN = 1005; const int LIM = 30; map<pii,int> mp; int n,m; vector<int> G[MAXN][LIM]; struct Node{ int u,v; ...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define pll pair<ll,ll> #define ldb double template<typename T>void ckmn(T&a,T b){a=min(a,b);} template<typename T>void ckmx(T&a,T b)...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define ALL(x) (x).begin(), (x).end() static const int MOD = 1000000007; static const int INF = (1 << 30); int main() { ll x, y; cin >> x >> y; if(x > y) { ...
#include <bits/stdc++.h> using namespace std; int main(){ int X, Y; cin >> X >> Y; int d = X - Y; d = abs(d); string ans = "No"; if(d<=2){ ans = "Yes"; } cout << ans << endl; return 0; }
#pragma once #include <iostream> #include <string> #include <algorithm> #include <memory> #include <functional> #include <mutex> #include <cmath> #include <numeric> #include <unordered_map> #include <map> #include <set> #include <vector> #include <queue> #include <stack> #include <array> #include <chrono> #define...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define pii pair<int,int> #define pll pair<lli, lli> #define vi vector<int> #define vii vector<pair<int,int>> #define vll vector<lli> #define pb push_back #define mpr make_pair #define s second #define f first #define INF 1000000001 #define inf1...
//#define _GLIBCXX_DEBUG //#include "atcoder/all" //using namespace atcoder; #include <bits/stdc++.h> #define int long long #define ll long long using ull = unsigned long long; using namespace std; #define Dump(x) \ if (dbg) { \ cerr << #x << " = " <<...
#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; int n; mt19937 mt; const int TRIES = 750; const int SHUFFLES = 0; bool check(string s, vector<vector<char>>& a, int i, int j) { bool isOk = true; for (int k = 0; k < s.size() && isOk; ++k) { if (s[k] != a[i][(j + k) % n]) { isOk = false; ...
#include<bits/stdc++.h> #define N 105 using namespace std; int n,a[N],ans=1e9; char s[N]; int Abs(int x) { return x<0?-x:x; } int main() { scanf("%d%s",&n,s+1); for(int i=0; i<=n; ++i) { scanf("%d",&a[i]); if(i>0)ans=min(ans,Abs(a[i]-a[i-1])); } cout<<ans<<"\n"; for(int i=0; i<ans; ++i,puts("")) for(int j=0...
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include ...
#include <bits/stdc++.h> using namespace std; std::map<long long,long long> s; long long solve(long long x, long long y){ if(s[y]>0) return s[y]; if(y==1){ s[y]=abs(x-y); }else if(y%2==1){ s[y]=min(abs(x-y), min(solve(x,(y+1)/2)+2, solve(x, (y-1)/2)+2)); }else{ s[y]=min(abs(x-y),...
#include<bits/stdc++.h> #define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) #define all(v) v.begin(), v.end() using ll = long long; using namespace std; int ri() { int n; scanf("%d", &n); return n; } int main(){ int n=ri(); int x[n],y[n],sum=0; double s; rep(i,n) x[i]=ri(),y[i]=ri(); rep(i,n-1){...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { int N; vector<ll> A; cin >> N; rep(i, N) { int Ai; cin >> Ai; A.push_back(Ai); } int cnt_max = 0; int ans = 0; for (int i = 2...
#include<bits/stdc++.h> using namespace std; int n,val[200005][10],init[10]; bool life[35][6]; bool ok(int x) { for(int i=1;i<init[5];i++) for(int j=1;j<=3;j++) life[i][j]=0; int now; for(int i=1;i<=n;i++) { now=0; for(int j=0;j<5;j++) { if(val[i][j]>=x) now+=init[j]; } life[now][1]=1; for...
// Problem : D - Choose Me // Contest : AtCoder - AtCoder Beginner Contest 187 // URL : https://atcoder.jp/contests/abc187/tasks/abc187_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //HAR HAR MAHADEV //WHEN IT GETS HARDER REMEMBER WHY YOU STARTED๐Ÿ’ช ...
#include <bits/stdc++.h> using namespace std; #define SOLVER(x) solve_C x static void s_solve(void) { long long N; long long M; long long L; cin >> N >> M; L = 1; if ( M == 0 ) { for ( int i = 0; i < N; i++ ) { cout << L << " " << L+1 << endl; L +...
#include <bits/stdc++.h> using namespace std; #define int int64_t #define rep(i, a, b) for(int i = a; i < b; ++i) int debug = 0; const int N = 55; int n, x, lst, a[N], bit[N], dp[N][2]; main() { cin >> n >> x; rep(i, 1, n + 1) cin >> a[i]; for (int i = n; i > 0; --i) { bit[i] = x / a[i]; ...
#include "bits/stdc++.h" using namespace std; #define ffor(n) for(int i = 0; i < n; i++) #define fffor(n) for(int j = 0; j < n; j++) #define uwu ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize("Ofast") const int INF = 1e9 + 7; const long long INF2 = 1e17; int main(void) { uwu int n, m; cin >> n...
#include <iostream> #include <algorithm> #include <stack> #include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <map> #define ll long long using namespace std; ll n,inx,m,mod=10007,b[200005],a[20005][5],ma[200005]; char s[505][505]; int main() { ios::sync_with_stdio(false); cin>>n>>m; ...
#define _USE_MATH_DEFINES #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <string> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <iostream> #include <fstream> #include <chrono> using namespace std; void solve(int test, std::istream...
/* ใ“ใ‚Œใ‚’็ฟป่จณใ—ใฆใ„ใ‚‹้–“ใ€ใ‚ใชใŸใฏใ‚ใชใŸใฎไบบ็”Ÿใฎใ„ใใคใ‹ใฎ่ฒด้‡ใช็žฌ้–“ใ‚’็„ก้ง„ใซใ—ใพใ—ใŸ */ #include <bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define fi first #define se second #define all(x) (x).begin(),(x).end() #define S(x) (int)(x).size() #define L(x) ...
#include <bits/stdc++.h> #define ff first #define ss second #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; #define all(x) x.begin(), x.end() const ll mod = 1e9 + 7; ll mod_exp(ll a, ll n) { if (a < 0ll) return 0; if (n < 0ll) return 0; ll res = 1ll; while (n > 0)...
/****************************************** By Lord Sanskar Bhargava******************************/ #include<bits/stdc++.h> #include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #includ...
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ int N,K;cin>>N>>K; vector<pair<int,int>>V(N); for(int X=0;X<N;X++){ int A,B;cin>>A>>B; V[X]={A,B}; } sort(V.begin(),V.end()); int now=0;int p=K; for(int X=0;X<N;X++){ if(V[X].first-now<=p){ p-=V[X].first-no...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef long int li; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define test ll t; cin >> t; while(t--) #define print_tc(t, c) cout << "Case #" << t << ": " << c << "\n"; ...
#include <bits/stdc++.h> using namespace std; int main() { int N; long long int T; cin >> N >> T; vector<long long int> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); vector<long long int> B, C; for (int i = 0; i < N; i++) { if (i % 2 == 0) B.push_back(A.at(i)); else C.push_back(A.at(i)); ...
#include <bits/stdc++.h> using namespace std; int h, w; string ast; int a[2009][2009]; int max2 = 4009; int mem[2009][2009]; int opt(int i, int j) { if (mem[i][j] != max2) return mem[i][j]; if (i == h && j == w) return mem[i][j] = 0; if ( ( i + j ) % 2 == 0 ) { if (i+1>h) return mem[i][j] = opt(i, j+1) + a[i][j+...
#include<bits/stdc++.h> using namespace std; #define int long long // const int mod=1e9+7; // bool isPerfectSquare(long double x){ // if(x>=0){ // int sr=sqrt(x); // return (sr*sr==x); // } // return false; // } // bool isExponentOfTwo(int n){ // while(n%2==0){ // n/=2; // } // return n==1...
#include <bits/stdc++.h> #define int long long using pii=std::pair<int,int>; using namespace std; int n; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; vector<int> ans; ans.push_back(3 * 5 * 7); for(int i = 1; i <= 10'000; i++) if(ans.size() < n && (i % 6 == 0 ...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define isNum(a) (a >= '0' && a <= '9') #define SP ...
#include<bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; string s = "AB"; char c [4]; long long n = 10 , nn , a [20] , mask , dp [1003]; map < string , int > mp; void f ( ) { if ( s . size () == n ) { mp [s] ++; return; } for ( int i = 0 ; i < s . size () - 1 ; i ++ ) ...
//Hare Krishna //author: Dipjoy Basak //dip_10 #include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define int ll #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss second #define vi vector<int> #define pi pair<int, int> #define vpi vector<pai...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int a[3]; for (int i = 0; i < 3; ++i) { cin >> a[i]; } sort(a, a + 3); if (a[0] == a[1]) cout << a[2]; else if (a[1] == a[2]) cout << a[0]; else cout << 0; return 0;...
//้›ช่Šฑ้ฃ„้ฃ„ๅŒ—้ขจๅ˜ฏๅ˜ฏ //ๅคฉๅœฐไธ€็‰‡่’ผ่Œซ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se seco...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <cmath> #include <queue> #include <set> #include <stack> #include <numeric> #include <bitset> #include <math.h> #include <iomanip> #include <sstream> #include <cstdlib> #include <stdio.h> using namespace std; typedef l...
#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 vector<int> #define mii map<int, int> #define umii unordered_map<int, int> #define pqb priority_queue<int> #de...
#include <bits/stdc++.h> using namespace std; using ll = long long; // -------------------------------------------------------- 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) { ...
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> using namespace std; int main() { long double i,ans=0,x,y,r,k,a,b; scanf("%Lf %Lf %Lf",&x,&y,&r); r+=1e-14; for(i=ceil(x-r);i<=floor(x+r);i+=1.0) { k=sqrt(r*r-(x-i)*(x-i)); a=floor(y+k);b=ceil(y-k); ans+=a-b+1.0; } printf("%.0Lf\n",a...
#include <bits/stdc++.h> using namespace std; int main() { int X,Y,Z,A; double x,z; cin >> X >> Y >> Z; x = (double)Y / X; A = x * Z; while(true){ z = (double)A / Z; if(z >= x) break; A++; } A--; cout << A << endl; }
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <iomanip> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <bitset> #include <chrono> #include <random> #define rep(...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; typedef pair<int,int> P; int main() { int A,B; cin >> A >> B; int ans = 0; for (int i = 1; i <= 200005; ++i) { int aa = (A-1)/i; int bb = B/i; if (bb - aa >= 2) ans = i; } cout << ans << endl; ...
#include <bits/stdc++.h> #define Aint(vec) vec.begin(), vec.end() #define rep(i, n) for (int i = 0; i < n; ++i) #define repc(bit, k, n) for (int bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit)) #define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr) #define lb(bec, val) lower_bound(...
#include<bits/stdc++.h> using namespace std; typedef unsigned long long ll; #define endl '\n' #define sf(n) scanf("%d",&n); #define pf(n) printf("%d\n",n); #define fast_io ios_base::sync_with_stdio(0); cin.tie(0) int main() { fast_io; int a,b; cin >> a >> b; double ans = 0; ans = double(a)/100 * double(b); cout...
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #inclu...
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define sz(x) ((int)x.size()) #define ln(x) ((int)x.length()) #define mp make_pair #define pb push_back #define ff first #define ss second #define endl '\n' #define dbg(x) cou...
//khodaya khodet komak kon # include <bits/stdc++.h> /* // ordered_set # include <ext/pb_ds/assoc_container.hpp> # include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; # define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ using namespace std; typedef lo...
#pragma GCC optimize ("O2") #pragma GCC target ("avx") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (...
#include <bits/stdc++.h> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; using ll = long long; using P = pair<ll,ll>; using Graph= vector<vector<ll>>; struct edge{ll to ; ll cost ;} ; using graph =vector<vector<edge>> ; #define rep(i,n) for (ll i=0; i < (n); ++i) #define rep2(i,n,m) for(ll...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> typedef long long int ll; typedef long double ld; #define endl '\n' #define loop(i,m,n) for(int i=m;i<n;i++) #define loope(i,m,n) for(int i=m;i<=n;i++) #define epool(i,m,n) for(int i=m;i>=n;i--) #define mod 1000000007 #define mod2 998244353 #define d...
#include<bits/stdc++.h> using namespace std; #define li long long int #define rep(i,to) for(li i=0;i<((li)(to));i++) #define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((...
#include <bits/stdc++.h> using namespace std; #ifdef EVAL #define debug(...) cerr << '(' << #__VA_ARGS__ << "): " << (__VA_ARGS__) << '\n'; #else #define debug(...) 42 #endif constexpr long long tenpowten = 10000000000; bool tst(string T) { if (T.length() == 1) return true; if (T.length() == 2) { if (T == "00")...
#include<bits/stdc++.h> using namespace std; #define int int64_t int32_t main() { set<int> ans; for(int i=0;i<=200001;i++) { ans.insert(i); } int n;cin>>n; for(int i=0;i<n;i++) { int x;cin>>x; if(ans.find(x)!=ans.end()) { ans.erase(x); } ...
#include<bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define ull unsigned long long #define Toggle(n,i) (n^((ll)1<<i)) #define Check(n,i) (n&((ll)1<<i)) #define Set(n,i) (n|((ll)1<<i)) #define Reset(n,i) (n&(~((ll)1<<i))) #define fo(a,x,y) for(int i=(x);i<=(y);++i){...
#include<bits/stdc++.h> #define pii pair<int,int> #define fi first #define se second #define ll long long #define inf (1<<30) #define INF (1LL<<60) //#define int long long //const int mod=998244353; //const int mod=1e9+7; const int N=1e5+5,M=5e5+5; //int head[M],to[M],nxt[M],tot; using namespace std; int n,a[N]; bool ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #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 FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define i128 __int128 #define mp make_pair #define mt make_tuple #define tp(pos, name) get<pos>(name) #define ld long double #define VNAME(name) (#name) typedef pair<int, int> pii; typedef priority_queue<int, vector<int>, ...
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 2e5 + 50, INF = 0x3f3f3f3f, mod = 1e9 + 7; inline int read () { register int x = 0, w = 1; register char ch = getchar (); for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1; for...
#include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define mp make_pair #define fi first #define se second #define REP(i,j) for(int i=0;i<j;i++) #define REPA(i,j) for(int i=1;i<=j;i++) #define FORN(i,j,k) for(int i=j;i<k;i++) #define vi vector<int> #define vvi vector<vi > #define p...
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> using namespace std; int t,l,r; long long c,ans; int main() { int i,j; scanf("%d",&t); for (i=1;i<=t;i++) { scanf("%d%d",&l,&r); if (l+l>r) {printf("0\n"); continue;} c=r-l-l; ans=(c+1+1)*(c+1)/2; printf("%lld\n",an...
#include<bits/stdc++.h> #define LL long long #define mp make_pair #define fi first #define se second using namespace std; int read(){ char ch=getchar(); int x=0,fl=1; for(;!isdigit(ch);ch=getchar()) if(ch=='-') fl=-1; for(;isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch-'0'); return x*fl; } const int N=105; const int...
#include "bits/stdc++.h" using namespace std; #define mp make_pair #define pb push_back #define ll long long int #define sd(x) scanf("%lld",&x) #define inf 1e18+9 #define pll pair<ll,ll> #define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define bits(x) __builtin_popcountll(x) #define ld long doub...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;} #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long...
#include <bits/stdc++.h> using namespace std; const long long SZ = 1e5 + 7; const long long inf = 1e18; const long long mod = 1e9 + 7; const long long MOD = 998244353; typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; void __print(int x) {cerr << x;} void __print(long long x) {...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, x, res = 0, count = 0; cin >> n >> x; int v[n], p[n]; for (i = 0; i < n; i++) { cin >> v[i] >> p[i]; count += (v[i] * p[i]); // cout << count << " " << x << " " << res << "\n"; if (count / 100.0...
#include "bits/stdc++.h" using namespace std; #define int long long const int mod = 1e9 + 7; const int N = 2005; vector<int> adj[N]; vector<bool> visited; int n, m, c; void dfs(int s) { visited[s] = true; c++; for (int v : adj[s]) if (!visited[v]) dfs(v); } void test_case() { int res = 0; cin >> n >> m; i...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include <bits/stdc++.h> using namespace std; #define REP(i, j, k) for (int i = j; i < k; i++) #define RREP(i, j, k) for (int i = j; i >= k; i--) typedef long long ll; #define ALL(x) x.begin(), x.end() #define pb push_back typedef vector<int> vi; typedef vector<ll> vll; #define MAXN 200005 #define MOD 998244353 int...
#include <iostream> #include <algorithm> #include <tuple> #include <cmath> using namespace std; using trill = tuple<long long, long long, long long>; trill extEuclidean(long long a, long long b){ if(b == 0)return make_tuple(a, 1, 0); trill minor = extEuclidean(b, a%b); return make_tuple(get<0>(minor), get<...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < (n); i++) #define REPS(i, n) for(int i = 1; i <= (n); i++) #define RREP(i, n) for(int i = (n)-1; i >= 0; i--) #define RREPS(i, n) for(int i = (n); i > 0; i--) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #...
#include<iostream> using namespace std; int main() { long n,m,x,a[100005]; cin>>n>>x; for(long i=0;i<n;++i) { cin>>m; if(m!=x) { a[i]=m; } else a[i]=0; } for(long i=0;i<n;++i) { if(a[i]!=0) cout<<a[i]<<" "; } cout<<endl; return 0; }
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int N, check = 0; int num[1001] = { NULL }; cin >> N; for (int i = 0; i < N; i++) { cin >> num[i]; } sort(num, num + N); for (int i = 1; i < N; i++) { if (num[i - 1] == (n...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ull1d = vector<ull>; using ull2d = vector<ull1d>; using ull3d = vector<ull2d>; #define loop(i,n) for(ull i=0;i<n;i++) #define rloop(i,n) for(ll i=n-1;i>=0;i--) #define all(vec) vec.begin(),ve...
#include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define int long long using namespace std; namespace model{ const int N = 1e6+7,P=998244353; int read() { int a = 0,x = 1;char ch = getchar(); while(ch > '9' || ch < '0') {if(ch == '-') x = -1;ch = getchar();} while(ch >= '0' && ch <= ...
#define LOCAL #include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { return y != 0 ? gcd(y, x % y) : x; } /** * @brief ็ด„ๆ•ฐๅˆ—ๆŒ™ */ template <typename T> vector<T> divisor(T n) { vector<T> res; for (T i = 1; i * i <= n; i++) if (n % i == 0) { res.emplace_back(i)...
#include<iostream> #include<sstream> #include<iomanip> #include<cstdlib> #include<algorithm> #include<vector> #include<map> #include<cmath> #include<string> #include<numeric> #include<queue> #define rep(i,p) for(long long int i=0;i<p;i++) #define reep(i,p) for(long long int i=1;i<=p;i++) #define ll long long #define ...
#include <bits/stdc++.h> using namespace std; int64_t dp[305][13]; int64_t solve (int n,int i) { if (i == 11 and n > 0) return 1; if (n <= 0 or i >= 11) return 0; if (dp[n][i] != -1) return dp[n][i]; int64_t res = 0; for (int j = 1; j <= n; ++j) { res += solve(n - j,i + 1); } return dp[n][i] = res; } int ma...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define fi first #define se second #define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++) #define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++) #define DN(a,b,c) ...
//! ๅฐบๅ‚ไนƒๅ‚.ๅ‚๏พŒไน‡ไน‡ใ„’ #include<bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; //Using namespace __gnu_pbds; //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set; #define ll long long #define int long long #define ld...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <cstring> #include <utility> #include <numeric> using namespace std; vector<vector<int>> tree; pair<int, int> getPointAndChildCnt(int node){ int firstPoint = -1; int restPoint = 0; int childCnt = 0...
#include <iostream> #include <set> #include <algorithm> #include <vector> #include <map> #include <string> using namespace std; vector<long long> par; long long root(long long x) { //xใฎๅฑžใ™ใ‚‹ๆœจใฎๆ นใ‚’ๆฑ‚ใ‚ใ‚‹ if(par[x] == x) return x; else return par[x] = root(par[x]); } int same(long long x, long long y) { if(root(x) == root(y...
#include<cstdio> #include<algorithm> #include<cstring> #define ll long long #define fo(i,x,y) for(i=x;i<=y;i++) using namespace std; const ll mod=998244353; const int N=2e5+10; ll n,m,i,j,k,tot,ans,s,t,x,y,z; ll a[N]; ll d[N]; bool bz[N]; ll ksm(ll i,ll j) { ll re=1; while (j>0) { if (j&1) re=re*i%mod; j/=2; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, a) for(int i=0;i<a;i++) #define l list #define v vector #define u_p unordered_map typedef long long ll; const int mxN=1000; int s[4]; void solve(){ rep(i,4)cin>>s[i]; cout<<s[1]-s[2]; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0...
#include<bits/stdc++.h> #define int long long using namespace std; inline int read(){ int res=0; bool zf=0; char c; while(((c=getchar())<'0'||c>'9')&&c!='-'); if(c=='-')zf=1; else res=c-'0'; while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0'; if(zf)return -res; return res; } unordered_map<int,int>M; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using WGraph = vector<vector<pair<int, ll>>>; template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; } template<class T>inline bool chmin(T &a, const T &b) { if (b < ...
//include <atcoder> #include <iostream> #include <algorithm> #include <cmath> #include <tuple> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #define flush fflush(stdout) #define endl '\n' #define all...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define Graph vector<vector<int>> typedef long long ll; typedef pair<int, int> P; const int INF = 100000000...
#include <bits/stdc++.h> using namespace std; #define IO ios_base::sync_with_stdio(false); cin.tie(NULL); #define endl '\n' int main() { IO; int n; cin >> n; vector<pair<int, string>> v(n); for (auto& [h, name] : v) { cin >> name >> h; } sort(v.rbegin(), v.rend()); cout << v[1].second << endl; return ...
#include <bits/stdc++.h> using ll = long long; using namespace std; const char EOLN = '\n'; int n; vector<vector<int>> a; set<int> ids; int main() { cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; a.emplace_back(vector<int>{x, y, i}); } for (int k = 0; k < 2; k++) { sort(a.b...
/* author : aryan57 created : 29-May-2021 17:36:52 IST */ #include <bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_...
#include <algorithm> #include <array> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int X{}; cin >> X; int surplus = X % 100; cout << 100 - surplus << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (ll i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) (int)(x).size() #define pb push_back using ll = long long; using ld=lon...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<double,double> pdd; #define SQ(i) ((i)*(i)) #define MEM(a, b) memset(a, (b), sizeof(a)) #define SZ(i) int(i.size()) #define FOR(i, ...
#include<bits/stdc++.h> #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cctype> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstream> #include<algorithm> /******...
#include<bits/stdc++.h> #define db double #define ll long long #define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i) #define N 2005 const int mod=1e9+7; int h,w; char c[2005][2005]; int dp[N][N],sum[3][N][N]; inline void reduce(int&x){ x-=mod,x+=x>>31&mod; } int main(){ std::ios::sync_with_stdio(0),std::cin.tie(0...
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; const ll md = 1e9 + 7; int h, w; vector<str> v; vector<vector<ll>> way; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> h >> w; v.resize(h); ...
#pragma GCC optimize("O3") #define _GLIBCXX_DEBUG #include <iostream> #include <vector> #include <string> #include <string_view> #include <algorithm> #include <cmath> #include <iomanip> #include <cassert> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset>...
#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n, k, m; cin >> n >> k >> m; int ans = n * m; for (size_t i = 0; i < n-1; i++) { int a_i; cin >> a_i; ans -= a_i; } if (ans > k) { cout << -1 << endl; } els...
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace chrono; typedef long long int ll; typedef vector<int> vii; typedef vector<ll> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define pb push_back #define odd(x) ((x)&1) #define even(x) (!odd(x)) #define all(v) (v).begin(),(v).e...
#include<bits/stdc++.h> #define PI 3.141592653589793238462 #define eps 1e-20 #define fi first #define se second using namespace std; using cd = complex<double>; typedef long long ll; typedef long double db; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<db,db> pdd; vector<pll> edge[200005]; ll a[20000...
#include <bits/stdc++.h> #include <algorithm> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define wuyt main typedef unsigned long long ll; #define HEAP(...) priority_queue<__VA_ARGS__ > #define heap(...) priority_queue<__VA_ARGS__,vector<__VA_...
#include<bits/stdc++.h> using namespace std; template<class T> istream& operator >>(istream& is, vector<T>& v){ for(auto&& elem:v)cin >> elem; return is; } template<class T> ostream& operator <<(ostream& os, const vector<T>& v){ if(!v.empty()){ for(int i=0, size=v.size(); i<size-1; ++i)os << v[i] << " "; os<<...
#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; int main() { read(n...
#include <bits/stdc++.h> using namespace std; #define int long long 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++) int charToInt(char c){ char zero_num = '0'; return (int)c - (int)zero_num; } void co...
#include<bits/stdc++.h> using namespace std; int n,x,aa,y,bb=100000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; aa=max(aa,x); } for(int i=1;i<=n;i++){ cin>>y; bb=min(bb,y); } if(aa>bb) cout<<0; else cout<<bb-aa+1; return 0; }
/* made by amunduzbaev */ //~ #include <ext/pb_ds/assoc_container.hpp> //~ #include <ext/pb_ds/tree_policy.hpp> #include "bits/stdc++.h" using namespace std; //~ using namespace __gnu_pbds; #define ff first #define ss second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #def...
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string a; int i=0; bool isd=false; cin>>a; for(i=0; i<a.length(); i++) { if(a[i] == '.') { isd =true; break; } } if(isd) { cout<<a.substr(0,i-1)<<a[i-1]-'0'<<"\n"; } else{ cout<<a<<"\n"; } re...
// C++(GCC 9.2.1) #include <bits/stdc++.h> using namespace std; #define repex(i, a, b, c) for(int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for(int i = a; i >= b; i--) #define pb push_back int main(){ // 1. ๅ…ฅๅŠ›ๆƒ…ๅ ฑ. char c[222]; sc...
#include <bits/stdc++.h> using namespace std; const int MOD=1e9+7; //const int MOD=998244353; double PI = 3.14159265358979323846; struct POINT{ double x,y; }; POINT rotate_point(double cx,double cy, double angle,POINT p) { double s = sin(angle); double c = cos(angle); // translate point back to ...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const...
#include<bits/stdc++.h> using namespace std; #define setbits(x) __builtin_popcountll(x) #define leadzero(x) __builtin_clz(x) #define trailzero(x) __builtin_ctz(x) #define mod 1000000007 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; te...
#include <bits/stdc++.h> using namespace std; int a, b; int main() { std::ios::sync_with_stdio(0); cin >> a >> b; if (a + b >= 15 && b >= 8) { cout << 1; return 0; } if (a + b >= 10 && b >= 3) { cout << 2; return 0; } if (a + b >= 3) { cout << 3; return 0; } cout << 4; return 0; }
#include<bits/stdc++.h> #define int long long using namespace std; int n,m,c[505][505],a[505][505]; signed main() { cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cin>>c[i][j]; for(int i=2;i<=n;i++) for(int j=2;j<=n;j++) if(c[i-1][j]+c[i][j-1]!=c[i-1][j-1]+c[i][j]) { puts("No"); return 0; } in...
#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 <cstdio> #include <algorithm> using namespace std; long long int n, s; int l; long long int a = 1; int main(){ scanf("%lld", &n); if(n == 1){ puts("1"); return 0; } else { s = __INT64_MAX__; for(int i = 0; ; i++){ if(n / a == 0){ l = i; ...
#include<bits/stdc++.h> using namespace std; #define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long int #define endl "\n" const int maxr = 1e5 + 5; int32_t main() { GO; int n; cin >> n; n = 2*n; int count = 0; for(int i = 1; i*i <= n; i++) { if(n % i == 0)...
#include <bits/stdc++.h> #define cnk(n,k) ((fact[(n)] * invfact[(k)] % MOD) * invfact[(n)-(k)] % MOD) using namespace std; typedef long long ll; const ll MOD = 998244353; const int MAXN = 2*1e5 + 2; int n, m, s; ll ans[6000]; ll fact[MAXN], invfact[MAXN]; void precomp() { fact[0] = invfact[0] = 1; for(int i =...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ff first #de...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) <<...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using ll = int64_t; using ull = uint64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <ios> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <set> #include <stack> ...
/* เคนเคฐเฅ‡ เค•เฅƒเคทเฅเคฃ เคนเคฐเฅ‡ เค•เฅƒเคทเฅเคฃ เค•เฅƒเคทเฅเคฃ เค•เฅƒเคทเฅเคฃ เคนเคฐเฅ‡ เคนเคฐเฅ‡ เคนเคฐเฅ‡ เคฐเคพเคฎ เคนเคฐเฅ‡ เคฐเคพเคฎ เคฐเคพเคฎ เคฐเคพเคฎ เคนเคฐเฅ‡ เคนเคฐเฅ‡ */ #include<bits/stdc++.h> using namespace std; #define pb emplace_back #define pob pop_back typedef long long int lli; #define test lli t; cin>>t;...
#include <bits/stdc++.h> using namespace std; const long long N = 100 + 5, T = 1e5 + 5, INF = 1e18 + 5; long long n, arr[N], ans = INF, sum; bool knapsack[T]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n; for(int i = 0; i < n; i++) cin >> arr[i]; sum = accumulate(arr,...
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define pii pair<int,int> #define fastIO ios_bas...
#include <bits/stdc++.h> using namespace std; int main(){ int n, x; cin >> n >> x; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a.at(i); } for(int i = 0; i < n; i++){ if(x == a.at(i)){ a.erase(a.begin() + i); n--; i--; } } for(int i = 0; i < n; i++){ cout << a.a...
#include <algorithm> #include <bitset> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #inclu...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define x first #define y second #define FOR(i, m, n) for (ll i(m); i < n; i++) #define DWN(i, m, n) for (ll i(m); i >= n; i--) #define REP(i, n) FOR(i, 0, n) #define DW(i, n) DWN(i, n, 0) #define F(n) REP(i, n) #define FF(n) REP...
#include <bits/stdc++.h> #define clog(x) std::clog << (#x) << " is " << (x) << '\n'; using LL = long long; template<int N> class MInt { static inline constexpr int M = N; int n; static int inv(int x) { // assert(std::gcd(x, M) == 1); return x == 1 ? x : 1LL * (M - M / x) * inv(M % x) % M; } public: static voi...
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define pii pair<int,int> #define fastIO ios_bas...
#include <bits/stdc++.h> #define startt ios_base::sync_with_stdio(false);cin.tie(0); #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") typedef unsigned long long ull; typedef long long ll; using namespace std; #define FOR(n) for(int i=0;i<n;i++) #define vt vector #de...
#include "bits/stdc++.h" #define rep(i,n) for(int i=0; i<(n); ++i) #define fo(i,a,b) for(int i=a; i<(b); ++i) #define out(a) cout << a << endl #define so(v) sort(v.begin(),v.end()) #define revso(v) sort(v.begin(),v.end(), greater<int>()) using namespace std; using ll = long long; int main() { int n, k, m; cin >> n >...
#include<bits/stdc++.h> using namespace std; int n; int m; int k; int main(){ cin >> n >> k >> m; int top = 0; for(int i = 0;i<n-1;i++){ int s; cin >> s; top+=s; } int gereken = n*m; if(top > gereken){ cout << "0"; return 0; } int suanki = gereken...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include <bits/stdc++.h> using namespace std; const int maxn=1e5+10; typedef struct a{ int to,next; }per; per si[maxn*2]; int n,ctt,m,co[maxn],vis[maxn],head[maxn],ans[maxn],cur; void add(int u,int v){ si[++ctt].next=head[u]; si[ctt].to=v; head[u]=ctt; } void dfs(int now,int fa){ if(!vis[co[now]]) ans[++cur]=now; ...
/** * author: otera **/ #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60; #define rep(i, n) for(int i = 0; i < n; ++ i) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++)...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x)...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, s, n) for (int i = (s); i < (int)(n); i++) #define repn(i, n) for (int i = (int)(n)-1; i>= 0; --i) #define ll long long using Graph = vector<vector<int>>; int main(){ int n, Q, c...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int N=25; int a[N],n; int ans=(1<<30)+1; int idx[N],cnt; void dfs(int rank){ if(rank==n) { idx[cnt++]=n; int l,r,h,w; h=0; l=0; for(int i=0;i<cnt;i++){ r=idx[i]; w=0; for(int j=l;j<=r;j++) { w...