code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
//clear adj and visited vector declared globally after each test case //check for long long overflow //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod; //Incase of close mle change language to c++17 or c++14 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long l...
#include<bits/stdc++.h> #define int long long const int mod=1e9+7; using namespace std; int qpow(int a,int b){ int ans=1; while(b){ if(b&1)(ans*=a)%=mod; (a*=a)%=mod; b>>=1; } return ans; } int inv(int a){ return qpow(a,mod-2); } int fact(int a){ int ans=1; for(int i=1;i<=a;i++){ (ans*=i)%=mod; } retur...
#ifndef LOCAL #include <bits/stdc++.h> using namespace std; #define debug(...) 42 #else #include "Debug.hpp" #endif class Task { public: void Perform() { Read(); Solve(); } private: int a, b, c, d; void Read() { cin >> a >> b >> c >> d; } void Solve() { int max_diff = INT_MIN; ...
#include <bits/stdc++.h> #define int long long int using namespace std; void solve(); int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; } void solve() { int a,b,c,d; cin>>a>>b>>c>>d; cout<<b-c<<endl; }
#include<bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const int MAX = 1e5 + 5; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long int #define pb push_back #define print(x) cout<<x<<"\n" #define time_passed 1.0 * clock() / CLOCKS_PER_SEC //basic mathematics int gcd(int a,...
#include <bits/stdc++.h> typedef long double ld; #define int long long #define gcd __gcd #define endl "\n" #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define mod2 998244353 #define maxe *max_elemen...
// Jai Shree Ram #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; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ook order_of_key #define fb...
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<iomanip> #include<cmath> #include<numeric> #include<vector> #include<algorithm> #include<string> #include<deque> #include<stack> #include<map> #include<random> #include<queue> #include<iterator> #include<bitset> #include<unordered_set> #include<set> using nam...
#include <bits/stdc++.h> #pragma region ppd #define ll long long #define ld long double #define mp make_pair #define mt make_tuple #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define for0(i, n) for (int i = 0; i < (int)(n); ++i)...
#include<bits/stdc++.h> using namespace std; int n,k,nn,minn,maxx; string nts(int x) { string res=""; while(x) { res=(char)(x%10+'0')+res; x/=10; } return res; } int stn(string x) { int res=0; for(int i=0;i<x.size();i++) { res*=10; res+=x[i]-'0'; } return res; } int main() { cin>>n>>k; for(int i=0;i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define fill(a,b) memset(a,b,sizeof(a)) #define f first #define s second #define pb push_back #define inf 1e17 #define ninf -1*1e17 #define mod 1000000007 #define N 500005 #defin...
#include <bits/stdc++.h> using namespace std; // ModIntR::set_mod() struct ModIntR { int x; ModIntR() : x(0) {} ModIntR(int64_t y) : x(y >= 0 ? y % mod() : (mod() - (-y) % mod()) % mod()) {} static int &mod() { static int mod = 0; return mod; } static void set_mod(int md) { mod() = md; } ModIntR ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define all(a) (a).begin(),(a).end() template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;} template<typename T1, typename T2> inline void chkmax(T1 & x...
#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 = 1e6 + 5; int gcd(int a, int b, int& x, int& y) { if (b == 0) { x = 1; y = 0; return a; } int x1, y1; int d = g...
#include <iostream> #include <queue> #include <string> #include <random> using namespace std; int maze[50][50]; bool used[50][50]; //"RDUL" string moves = "RDUL"; int dx[4] = {0,1,-1,0}; int dy[4] = {1,0,0,-1}; int vals[50][50]; string fans = ""; long long fscore = 0; const int inf = 1e9; void dfs(int depth,int x,int...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define dbl(k, x) fixed << setprecision(k) << (x) template <typename _T> inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; } template <typename _T, typename... args> void _DBG(const char *s, _T x, args... a) { while (*s...
#include <bits/stdc++.h> #pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define ull unsigned long long #define rep(i,n,N) for(ll i=n;i<=N;++i) #define asd(i,n,N) for(int i=n;i< N;++i) #define rap(i,n,N) for(int i=n;i>=N;--i) #define mp make_pair #define pb ...
# include <iostream> # include <vector> using namespace std; const int kInf = 1 << 30; bool flg; int n, m; int main() { scanf("%d %d", &n, &m); vector<int> dp(1 << n, kInf), cnt(n + 1); for (int i = 1; i <= n; i++) { cnt[i] |= (1 << (i - 1)); } for (int i = 1, u, v; i <= m; i++) { scanf("%d %d", &...
//-------All power is within you,you can do Anything and Everything.---------// #include <bits/stdc++.h> // #pragma GCC optimize("Ofast") using namespace std; //library //*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*// #define F first #define S second ...
#include<bits/stdc++.h> using namespace std; int main(){ int h, w, n, m; cin >> h >> w >> n >> m; int che[h][w]; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ che[i][j] = 0; } } pair<int, int> light[n]; for(int i = 0; i < n; i++){ cin >> l...
#include<bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned ll #define uint unsigned int #define db double #define pint pair<int,int> #define mk make_pair #define pb push_back #define eb emplace_back #define ins insert #define fi first #define se second #define Rep(x,y,z) for(int x=(y);x<=(...
#include <bits/stdc++.h> #define pb push_back #define int long long #define ld long double using namespace std; const int M = 998244353; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; for (int x = 0; x < n; x++) { cout << 1 + (2 * x) ...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<cmath> #include<iomanip> #include<map> 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; } retu...
#include<bits/stdc++.h> using namespace std; int main(){int n;vector<int>a;cin>>n;for(int i=0,ai;i<n;i++)cin>>ai,a.push_back(ai); if(set<int>(a.begin(),a.end()).size()==a.size())cout<<"Yes";else cout<<"No";}
//----AUTHOR:developer.eeshan----/ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define it(a, x) for (auto &a : x) #define ll long long #define ld long double #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #defi...
// E - Transformable Teacher #include <bits/stdc++.h> using namespace std; int main(){ int n, m; cin>>n>>m; vector<int> H(n), W(m), evn(1), odd(1); // 偶・奇数番目の累積和 for(int& x:H) cin>>x; for(int& x:W) cin>>x; sort(H.begin(), H.end()); for(int i=0; i<n-1; ++i){ int d = H[i+1] - H[i]; if(i%2) odd.push_back(odd.b...
#include <bits/stdc++.h> using namespace std; int main() { int L; cin >> L; long long over=1; vector<int> ok(10); for(int i=1; i<=11; i++) { over *= (L-i); for(int k=2; k<=11; k++) { if( (over%k) == 0 && ok.at(k-2) == 0) { over /= k; ok.at(k-2) = 1; } } } cout <...
#ifdef DEBUG_BUILD # define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #ifdef DEBUG_BUILD # include "debugger.hpp" #else # define debug(...) # define debugdo(...) #endif using namespace std; using ll = long long; using ld = long double; using pll = std::pair<ll, ll>; template <class T> using vec = std::vector<T>; t...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for(int (i)=0; (i)<(n); (i)++) #define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++) #define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--) template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y)...
#include <bits/stdc++.h> using namespace std; using s64 = signed long long; using u64 = unsigned long long; using f128 = long double; s64 GetCeilS64(s64 fixed, s64 digit) { if(fixed % digit == 0) { return fixed; } if(fixed > 0) { return ((fixed / digit) + 1) * digit; } else...
#include <bits/stdc++.h> #define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++) #define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++) #define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--) #define deb(x) std::cout << #x << " " << x << endl; #define debl(x) std::cout << #x << " " << x << " "; #define all(x) x.beg...
#include <bits/stdc++.h> #define fo(i, k, n) for (ll i = k; i < n; i++) #define rfo(i, k, n) for (ll i = k; i >= n ; i--) #define ll long long #define ld long double #define que queue #define pb push_back #define mp make_pair #define vi vector<int> #define vl vector<ll> #define gcd(m,n) __gcd( m, n) #define sq(x) ...
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <cassert> #include <cmath> #include <string> #include <queue> #include <set> #include <map> #include <cstdlib> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #def...
#include <bits/stdc++.h> using namespace std; #define ar array #define ll long long const int MAX_N = 1e5 + 1; const int MOD = 1e9 + 7; const int INF = 1e9; const ll LINF = 1e18; ll helper(ll a){ vector<int> vec(10,0); while(a){ vec[a%10]++; a/=10; } ll v1=0,v2=0; for(int i=0;i<10;i++){ for(in...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) //g++ c.cpp //./a.out //oj d https://atcoder.jp/contests/abc205/tasks/abc205_c //oj t signed main(){ int a, b, c; cin >> a >> b >> c; if(c%2==0){ if(abs(a)>...
#include <bits/stdc++.h> using namespace std; int main(){ long long int A, B, C; cin >> A >> B >> C; long long int A1 = A % 10; if (A1 == 0){ cout << 0; } else if (A1 == 1){ cout << 1; } else if (A1 == 2){ if (B % 4 == 0){ cout << 6; } else if (B % 4 == 2){ if (C...
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr...
#include <bits/stdc++.h> using namespace std; using ll = long long; void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); } template<class T> void _cout(T &&x){ cout << x << "\n"; } template <class Head, class... Tail> void _cout(Head&& h...
#include <bits/stdc++.h> #define i64 long long #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b) - 1; i >= (a); --i) using namespace std; const int M = 3; struct mint { int x; mint(int x) : x(x) {} friend min...
#include <iostream> #include <vector> #define mod 998244353 using namespace std; int n, k; vector <vector <int> > a; vector <int> hgroups; vector <int> vgroups; vector <int> rep; vector <int> sizes; vector <long long> fact; bool compc(int x, int y) { for (int i = 0; i < n; i++) { if (a[i][x] + a[i][y] > k) retur...
// Author: old_school // Created: 02.01.2021 17:30:15 #include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") using namespace std; #define lld long long int #define ld long double #define pb push_bac...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; using ll = long long; const int INF = 1000000000; const int MOD = 1000000007; const ll llINF = 1000000000000000000; // #include <atcoder/all> // using namesp...
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define int long long int #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 3e5 + 7; int32_t main(){ IOS; int t; t=1; while(t--){ int x,y; cin >> x >> y; int p = abs(x-y); if(p>=3) ...
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ vector<int> a(4); for(int i=0;i<4;i++){ cin>>a[i]; } sort(a.begin(),a.end()); cout<<a[0]<<endl; return 0; }
#include <bits/stdc++.h> #include <array> #include <cstdlib> using namespace std; int main() { vector<int> a(3); for(int i =0; i < 3; i++){ cin >> a[i]; } sort(a.begin(), a.end()); if(a[2]-a[1] == a[1]-a[0]){ cout << "Yes" << endl; } else cout << "No" << endl; }
#include<stdio.h> #include<iostream> #include<string.h> using namespace std; int main() { int v,t,s,d; cin>>v>>t>>s>>d; if(v*t<=d&&s*v>=d) { cout<<"No"; } else cout<<"Yes"; }
#include<iostream> #include<vector> #include<algorithm> using namespace std; const int BUF = 100005; class ChildData { public: int subtreeNode; int fstTake, scdTake; ChildData(){} ChildData(int sb, int f, int scd): subtreeNode(sb), fstTake(f), scdTake(scd) {} bool operator< (const Ch...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#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 <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <queue> #include <vector> using namespace std; typedef pair<int,int> pii; int h,w,dis[4000500],sx,sy,tx,ty,vis[4000500]; char sp[2005][2005]; priority_queue<pii > q; vector<int> gg[30]; int dx[4]={0,-1,0,1}; int dy[4]={1,0,-1,0}; ...
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <stdint.h> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include <list> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #in...
#include <iostream> #include <iomanip> #include <vector> #include <set> #include <string> #include <queue> #include <algorithm> #include <map> #include <cmath> #include <numeric> #include <list> #include <stack> #include <cstdio> #include <cstdlib> #include <cstring> #include <tuple> #include <deque> #include <complex>...
#include<bits/stdc++.h> using namespace::std; const int N = 5000 + 10; const int MOD = 998244353; const int F = (2LL * 332748118) % MOD; int n; int m; int k; int fact; char v[N][N]; int memo[N][N]; int add(int a, int b){ return (a + b) % MOD; } int mul(int a, int b){ return (1LL * a * b) % MOD; } int pow_mod(int...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) void solve(long long X, long long Y, long long A, long long B) { ll exp_a = 0; while (true) { if (X > Y / A) break; if (X * A >= X + B) break; if (X * A >= Y)...
#include<cstdio> #include<cstring> using namespace std; bool a[11000]; int main() { memset(a,false,sizeof(a)); for(int i=6;i<=10000;i+=6)a[i]=true; for(int i=10;i<=10000;i+=10)a[i]=true; for(int i=15;i<=10000;i+=15)a[i]=true; int n;scanf("%d",&n); printf("6 10 15");a[6]=a[10]=a[15]=false; n-=3; for(int i=1;i<=1...
#include <bits/stdc++.h> using namespace std; int A[200005], B[200005]; long double E[200005], F[200005], G[200005], H[200005]; int main() { ios::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); int n, m, k; cin >> n >> m >> k; while (k--) { int x; cin >> x; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define REP(i,n) for (ll i = 0; i < n; ++i) #def...
#include<bits/stdc++.h> #define ll long long #define mp make_pair #define pb push_back #define F first #define S second #define mod 1000000007 #define Mod 998244353 #define pi 3.14159265358979323846 #define endl '\n' #define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; typedef ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::en...
#include<bits/stdc++.h> #define loop(i,n) for(int i = 0; i < n; ++ i) #define rloop(i, n) for(int i = n-1; i >=0; i--) #define inp(arr, n) for(int i=0; i<n; i++) cin >> arr[i]; #define deb(x) cout << " " << #x << " " << x << endl // used to debug any variable #define mod 1000000007 #define pb push...
#include <bits/stdc++.h> using namespace std; int main() { int n, nuts = 0; cin >> n; vector<int> a(n); for(int i = 0; i<n; i++) cin >> a[i]; for(int k:a) if(k>10) nuts+=(k-10); cout << nuts << endl; return 0; }
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <vector> #include <map> #include <set> #include <cmath> #include <stack> #include <algorithm> #include <ctime> using namespace std; #define ll long long #define ull unsigned long long #define pii pair<int,int> #define make make_pair #def...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using namespace std; const int INF = 1 << 30; int main() { ll N; cin >> N; // vector<ll> A(N), B(N); vector<ll> C(N); ll aoki = 0; rep(i, N) { ll a, b; cin >> a >> b; aoki +...
#include <bits/stdc++.h> #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) #define vall(x) (x).begin(), (x).end() using namespace std; namespace atcoder {} using namespace atcoder; using lli = long long int; void YESNO(bool), YesNo(bool); template <class T1, class T2> b...
////////////////////////// Author ////////////////////////// Nasim Hossain Rabbi ////////////////////////// JU-CSE28 ////////////////////////// CF - imnasim3.1415 ////////////////////////// UVA - imnasim3.1415 ////////////////////////// Mail - imnasim3.1415@gmail.com #include<bits/stdc++.h> using namespace std; #define...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> #define setIO(x) freopen(x".in", "r", stdin), fre...
// #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair<int, int> pint; typedef tuple<int, int, int> tint; const int N = 2e5 + 5; ...
#include<cstdio> #include<iostream> #include<cstring> using namespace std; const int maxn=1500100; const int inf=0x3f3f3f3f; int tree[maxn<<2];//维护个数,初始全部为0; int vis[maxn]; int num[maxn]; int n,m; void add(int tis,int l,int r,int tp,int k) { if(l==r){ vis[l]+=k; if(vis[l])tree[tis]=inf; else t...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<l...
#include "bits/stdc++.h" using namespace std; #define ll long long const int areTests = 0, N = 2e5 + 20; int n, p[N], q, u, d, dp[N], st[N], ed[N], tym, a[N]; vector <int> adj[N], idx[N]; void dfs(int node, int edges) { st[node] = ++tym; dp[node] = edges; idx[edges].push_back(tym); for(int child: adj[node]) { d...
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define PI acos(-1) #define pb push_back #define int long long #define ld long double #define sp fixed<<setprecision #define bp __builtin_popcountll #define all(x) x.begin(),x.end() #define pii pair<long long,long long> #define FAST ios_ba...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #define ll long long #define rep(i, n) for (int i = 0; i < (long long int)(n); i++) //namespace mp = boost::multiprecision; //mp::cpp_int /* nyuuryoku retu de ukeoru string s; getline(cin,s); int &n ha sansyou sort reverse swap unique */ using...
/*{{{*/ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<set> #include<map> #include<queue> #include<bitset> #include<vector> #include<limits.h> #include<assert.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).be...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int res = 0; for (int i=1; i<=k; i++) for (int j=1; j<=k/i; j++) for (int l=1; l<=k/i/j; l++) res++; cout << res << '\n'; return 0; }
#include<bits/stdc++.h> #define rep(i,k,n) for(int i = k; i < n; i++) using ll = long long; using namespace std; // arc113a // 列挙 // 重複あり並べ方パターン int main(){ ll K_0; cin >> K_0; int res = 0; rep(i,1,K_0 + 1){ ll K = i; for(ll A = 1; A*A*A <= K; A++){ if(K%A == 0){ ll K...
#include <iostream> using namespace std; int main() { int N; cin >> N; int num = 1; int i = 1; int count = 1; while(true){ if(num >= N){ cout << count << endl; break; } count++; num += count; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define loop(i, a, n) for (int i = a; i < n; i++) #define loope(i, b, n) for (int i = b; i <= n; i++) #define loopit(a) for (auto it = a.begin(); it != a.end(); it++) #define ms(a, b) memset(a, b, sizeof(a)) #define pb(a) push_back(a) #define MP make_p...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <sstream> #include <numeric> #include <map> #include <set> #include <queue> #include <vector> using namespace std; vector<vector<int>> solve(int N, const vector<vector<int>>& A) { int c = *min_element(A[0].begin()...
#include<bits/stdc++.h> using namespace std; //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vect...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int main(){ int N,X; cin>>N>>X; vector<int> A(0); int count=0; rep(i,N){ int tmp; cin>>tmp; if(tmp!=X){ A.push_back(tmp); count++; } } re...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; #define GETA 200 int main() { int N; cin >> N; vector<ll> A(N); rep(n, N) { cin >> A[n]; } ll ans = 1<<30; rep(pt, 1 << (N-1)) { ll XOr...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0; i<(n); ++i) #define rep1(i,n) for(ll i=1; i<=(n); ++i) #define revrep(i,n) for(ll i=(n)-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 62) -1; #define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false); #define new...
#include <iostream> using namespace std; int a[1010],b[1010],dp[1010][1010]; int main(){ int i,j,n,m; cin >> n >> m; for(i=0;i<n;i++) cin >> a[i]; for(j=0;j<m;j++) cin >> b[j]; for(i=0;i<=n;i++){ for(j=0;j<=m;j++) dp[i][j] = 100000000; } for(i=0;i<=n;i++) dp[i][0] = i; for(j=0;j<=m;...
#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; } signed ...
#include <bits/stdc++.h> // #include <atcoder/all> // #include "icld.cpp" using namespace std; using ll = long long int; using vi = vector<int>; using si = set<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using ss = string; using db = double; template<typename T> using minpq = priority_queue <T,vector...
typedef long long ll; #include <cstdio> #include <algorithm> #include <iostream> #include <string.h> #include <bits/stdc++.h> #include <cstdlib> using namespace std; int main() { int a,b,x,y; cin >> a >> b >> x >> y; int ans = 0; if (b ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define pii pair<int, int> const int M = 100; // int d[2 * M + 5]; vector<pii> adj[2 * M + 5]; void solve() { int a, b, x, y; cin >> a >> b >> x >> y; for (int i = 1; i <= 198; i++) { adj[i].emplace_back(i + 2, y); ...
#include <bits/stdc++.h> #define FOR(i,x,n) for(int i=x; i<n; i++) #define F0R(i,n) FOR(i,0,n) #define ROF(i,x,n) for(int i=n-1; i>=x; i--) #define R0F(i,n) ROF(i,0,n) #define WTF cerr << "WTF" << endl #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define F first #define S second #d...
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ios_base::sync_with_stdio(false);cin.tie(0); int n; cin>>n; string s; cin>>s; vector<int> min_rem(n+1, n); min_rem[n]=0; vector<int> ending_with_char(26, -1); for(int i=n-1;i>=0;i--){ if(i==n-1)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define vt vector #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) const int64_t MOD = 1000000007; // 🚩 // 20201115 2...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; int f(int N, int K) { if (K < 2 || K > 2 * N) return 0; return min(K - 1, 2 * N + 1 - K); } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; cin >> ...
/** * author: tomo0608 * created: 27.03.2021 21:12:02 **/ #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include<atcoder/all> using namespace atcoder; #endif typedef long long ll; typedef long double ld; template <class T> using V = vector<T>; temp...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int ansmin = (1 << 30); for (int tmp = 0; tmp < (1 << n-1); ++tmp) { bitset<19> s(tmp); //cout << tmp << endl; queue<int> q; int x = a[0]; //cout << x...
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <array> #include <climits> using namespace ...
#include <bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define x first #define y second using namespace std; int main(){ string a,b; cin>>a>>b; int a1=a[0]+a[1]+a[2]-'0'-'0'-'0'; int b1=b[0]+b[1]+b[2]-'0'-'0'-'0'; cout<<max(a1,b1); return 0; }
#include <bits/stdc++.h> /*#include <iostream> #include <algorithm> #include <math.h> #include <iomanip> #include <string> #include <vector> #include <set> #include <sstream>*/ #define ll long long #define fop(i,m,n) for(int i=m; i<n; i++) #define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define X first...
#include <bits/stdc++.h> #define ll long long #define t \ ll t; \ cin >> t; \ while (t--) #define ln "\n" #define fst \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define F(i, L, R) for (int i = L; i < R; i++) #define FE(i, L, R) for (int i = L; i <= R; i...
#include <bits/stdc++.h> using namespace std; template<typename T> using vec = vector<T>; template<typename K, typename V> using umap = unordered_map<K, V>; using ll = long long; using ld = long double; using str = string; using pll = pair<ll, ll>; using vll = vec<ll>; using vi = vec<int>; using vs = vec<str>; using ma...
#include <bits/stdc++.h> using namespace std; int main() { int N; long long C; cin >> N >> C; map<long long, long long> mp; for( int i = 0; i < N; i++ ) { long long a, b, c; cin >> a >> b >> c; b++; mp[a] += c; mp[b] -= c; } long long ans = 0; long long cost = 0; long long prev = 0; for( auto it ...
/** ▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂ In the name of Allah _ _ / / \ \ / / _ _ _ \ \ < < (_) (_) (_) > > \ \ / / \_\ /_/ Nerede Gitsen Çukur Orda **/ #include<bits/stdc++.h> #include<fstream> ///#include<conio.h> ///#include "windows.h" #define ll l...
#pragma GCC optimize("O3") #pragma GCC target("popcnt") #include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define ll long long void fillPrefixSum(int arr[], int n, int prefixSum[]) // a[i-1,j-1] = a[j-1] - a[i-2]; { prefixSum[0] = arr[...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) using ll = long long; using P = pair<ll,ll>; ll MAX = 0; const ll INF = 1001001001001001001; ll n; vector<ll> ma(200005,-INF); vector<ll> mi(200005,INF); int main(){ cin >> n; rep(i,n){ ll x,c; cin >> ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(x) ((x).begin()), ((x).end()) #define READ(x) (cin >> (x)) #define WRITE_N(x) (cout << (x) << endl) #define WRITE(x) (cout << (x)) #define WRITE_Y...
#include <bits/stdc++.h> using namespace std; #define int long long #define MS(x) memset((x), -1, sizeof((x))) 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; } #define MOD 1000000007 int k;...
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; typedef long long ll; string num; int rn[200005]; int k; int n; int dp[200005][20]; ll dfs(int x,ll now,bool zero,bool flag) { int cnt=0; for(int i=0;i<16;i++) { if(now&(1<<i))cnt++; } if(x>=n)return cnt==k; if(cnt>k)retur...
#include <bits/stdc++.h> #define debug(var) do{std::cout << #var << " :";std::cout << std::endl;view(var);}while(0) template<typename T> void view(T e){ std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if...
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <queue> #include <functional> #include <vector> #include <stack> #include <set> #include <string> #include <time.h> #include <assert.h> #include <deque> //#include <unordered_map> #d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define asd cout << "ok" << endl; #define trav(i, n...
#include<bits/stdc++.h> using namespace std; int main(){ int a,s,d; int g,h=0; cin >> a>>s>>d; vector<int>f(a); for(int i=0;i<a-1;i++){ cin>>g; h=h+g; } g=d*a-h; if(d*a-h<0)g=0; if(d*a-h<=s) cout <<g; else if(d*a-h>s) cout <<-1; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vi>; using ll = long long; int main() { int a, b, x, y; cin >> a >> b >> x >> y; ...
#include<bits/stdc++.h> using namespace std; #define int long long #define x first #define y second #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define forn(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define sz(a) ...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; template<int M> class ModInt { public: ll value; constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; } c...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; #define MOD 1000000007 //https://flex.phys.tohoku.ac.jp/~maru/implementations/exponentiation_squaring.php long long pow(long long a, long long n, long long m) { long long ret = 1; for (; n > 0; n >>= 1, a = a * a % ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vl = vector<ll>; using vvl = vector<vl>; using pl = pair<ll, ll>; const ll INF = ll(1e18); const ll mod = ll(1e9 + 7); const double pi = acos(-1); #define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i)) #define rrep0(i...
#include "bits/stdc++.h" using namespace std; #define int long long vector<vector<int>> adj; vector<int> vis; vector<int> sel; int cnt, nn, edges; void dfs(int root, int parent) { vis[root] = 1; cnt++; edges += sel[root]; for (auto i : adj[root]) { if (!vis[i]) { //cout << i << " "; dfs(i, parent); } } }...
#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; #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_...
#include<bits/stdc++.h> #define ll long long #define int long long #define pb push_back #define mp make_pair #define eb emplace_back #define fi first #define se second #define PI 3.1415926535897932384626433832795 #define MOD 1000000007 using namespace std; //----------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; #define ms(s, n) memset(s, n, sizeof(s)) #define f(i, a, b) for (int i = (a); i <=(b); i++) #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--) #define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) #define sz(a) int((a).size()) #d...
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for(size_t i = (l); i < (r); ++i) #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define rrep(i, n) for(int i = (n)-1; i >= 0; --i) #define rfor(v, vec) for(auto &v : (vec)) #define itrloop(itr, begin, end) for(auto itr = (begin); itr != end; ++itr...
#include <bits/stdc++.h> #define for0(i, n) for (int i = 0; i < (ll)(n); ++i) #define for1(i, n) for (int i = 1; i <= (ll)(n); ++i) #define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i) #define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (ll)(n); i >= 1; --i) #define pb ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; /* #define MULTI 1 */ void pre() { } void solve() { int n, m; cin >> n >> m; int a[1500005]; for (int i = 0; i < n; ++i) cin >> a[i]; int cnt[1500005] = {}; for (int i = 0; i < m; ...
#include<bits/stdc++.h> using namespace std; char s[11][11]; int ans; int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%s",s[i]+1); for(int i=1;i<n;i++){ int use=0; for(int j=1;j<=m;j++){ if(s[i][j]!=s[i+1][j]){ if(use==0) ans++; use=1; } else use=0; } } for(int j=1;...
#include<algorithm> #include<array> #include<bitset> #include<cassert> #include<climits> #include<cmath> #include<cstring> #include<deque> #include<functional> #include<iostream> #include<iomanip> #include<map> #include<numeric> #include<optional> #include<queue> #include<set> #include<stack> #include<string> #include<...
#include<iostream> #include<algorithm> #include<map> using namespace std; int main(){ int n; while(cin>>n){ int np,ans=0; for(int i=0;i<n;i++){ cin>>np; if(np>10)ans+=np-10; } cout<<ans<<endl; } }
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/rope> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/pb_ds/trie_policy.hpp> // using namespace __gnu_pbds; // using namespace __gnu_cxx; // typedef tree<long long, null_type, std::less<long l...
#include <bits/stdc++.h> using namespace std; #define FOR(i, begin, end) for(int i=begin;i<end;i++) void solve() { int N, M; vector<int> counter(1500001, -1); cin >> N >> M; int ans = INT_MAX; for (int i = 0; i < N; i++) { int elt; cin >> elt; if (i - counter[elt] ...
#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() { int n, m; cin >> n >> m; vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int x = 0; int g = n; for (int i = 0; i < m; i++) { if (a[i] > x + 1) { g = min(g, a[i] - x - 1); } x ...
// 解説を参考にコーディング #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define len(a) (int)a.size() #defi...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b;...
//https://atcoder.jp/contests/abc189/tasks/abc189_d //题意:给定一串OR和AND组成的n长字符串,代表V,^求有多少种n+1长的由0,1组成的字串使两两运算最终结果为1 //思路:找规律,默认有一种,有OR才增加,还与OR有关。 #include <stdio.h> int main(int argc, char **argv) { int N, i; unsigned long long T = 1; scanf("%d", &N); for(i = 1; i <= N; ++i){ char buff[10]; scanf("%s", buf...
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define ull unsigned long long #define pii pair<int,int> #define tiii tuple<int,int,int> #define pll pair<long long, long long> #define pdd pair<double, double> #define s second #define f first #define pb push_back #define ...
#include<iostream> #include<string> using namespace std; int main() { string s; cin>>s; for(int i=0;i<s.size();i++) { if(s.at(i)=='6') { s.at(i)='9'; } else if(s.at(i)=='9') { s.at(i)='6'; } } for(int i=s.size()-1;i>=0;i--) { cout<<s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; reverse(s.begin(),s.end()); for(char &c : s){ if(c == '6' || c == '9'){ c = 15 - (c-'0') + '0'; } } cout << s << '\n'; }
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<l...
#include <stdio.h> #include <algorithm> #include <vector> #include <string> #include <queue> #include <math.h> const long long mod = 1000000007; //const long long mod = 998244353; int main() { int N, K, M; scanf("%d %d %d", &N, &K, &M); int *A = new int[N]; int sum = 0; for (int i = 0; i < N - 1; i++) { scanf("...
# include <iostream> using namespace std; int N, K; int main() { cin >> N >> K; cout << int((1 + N)*N * 0.5 * 100 * K + (1 + K)* K * 0.5 * N) ; }
#include<bits/stdc++.h> //#define int long long using namespace std; void read() { #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif } int32_t main() { read(); ios::sync_with_stdio(0); cin.tie(...
#include<bits/stdc++.h> using namespace std; int n,k,a[110],b[110];char c[110]; int sol(int a,int b){if(a>b)swap(a,b);if(a==0&&b==2)return a;return b;} int main() { scanf("%d%d%s",&n,&k,c+1); for(int i=1;i<=n;i++) { if(c[i]=='R')a[i]=0; if(c[i]=='P')a[i]=1; if(c[i]=='S')a[i]=2; } while(k--) { if(n&1) { ...
#pragma GCC target ("avx2") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL; #define pb push_back #define mp make_pa...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f; const double pi=3.1415926535897932384626; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<...
#include<iostream> using namespace std; int main(){ int n; cin >> n; cout << n - 1; return 0; }
#include <iostream> using namespace std; int h, w, a, b; int room[18][18]; int cnt; void putA(int n, int pos) { if (n > a) { cnt++; return; } for (; pos < h * w; pos++) { int r = (pos / w) + 1; int c = (pos % w) + 1; if (room[r][c] == 0) { room[r][c] = n; if (room[r][c + 1] == 0) { room[r][c + ...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <cstdio> #include <algorithm> #include <vector> using namespace std; constexpr int MOD = 998244353; constexpr int prob = 665496236; long long dp[5001]; int pow(long long x, int n){ long long ret = 1; while (n > ...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <sstream> #include <numeric> #include <map> #include <set> #include <queue> #include <vector> using namespace std; int64_t solve(int64_t N, std::vector<int64_t> a, std::vector<std::string> c) { int t[128] = {}; t...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define mp make_pair #define pb push_back #define fi first #define se second #define sz(x) int(x.size()) const int mod = 1e9 + 7; const int inf = 2e9 + 5; const ll linf = 9e18 + 5; const ll ll0 = 0 * 1ll; ll n, s, k; ll gcd (...
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; const ll INF = 100000000000000; int main() { int n, m; cin >> n >> m; ll w[10]; for(int i = 0; i < n; i++) cin >> w[i]; ll l[100005], v[100005]; for(int i = 0; i < m; i++) cin >> l[i] >> v[i]; for(int i = 0...
#include <bits/stdc++.h> #include <unistd.h> #define rep(i,j,n) for(i=j;i<n;i++) #define repi(i,j,n) for(i=j;i>n;i--) #define pie 3.141592653589793238 #define ll long long #define ld long double #define vll vector<ll> #define pll pair<ll,ll> #define vpll vector<pll> #define pb push_back #define F first #define S secon...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ull unsigned long long #define ld long double #define F first #define S second #define eb emplace_back #define pb push_back #define mp make_pair #define all(x) begin(x), end(x) #define ra...
#include <bits/stdc++.h> using namespace std; #define ll long long #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define P pair<ll, ll> #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second ll n; vector<vector<ll>> G(400001); vector...
#include<bits/stdc++.h> using namespace std; vector<int> b[205]; int n,a[205],c[205],d[205]; bool mk[205]; void dfs(int x,int y,int u,int v){ if(u%200==v%200&&x!=0&&y!=0){ sort(c+1,c+x+1); sort(d+1,d+y+1); printf("Yes\n"); printf("%d ",x); for(int i=1;i<=x;i++)printf("%d ",c[i]); printf("\n"); printf("%d...
#include <bits/stdc++.h> using namespace std; #define fo(i, x, y) for (int i = (x); i <= (y); ++i) #define fd(i, x, y) for (int i = (x); i >= (y); --i) typedef long long ll; const int maxn = 1e5 + 5; const double inf = 1e18; int n; ll a[maxn]; int getint() { char ch; int res = 0, p; while (!isdigit(ch = getchar...
#include<iostream> #include<string> #include<cmath> #include<algorithm> #include<iomanip> using namespace std; int main() { int n; int a[1001]; int ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 10) { ans += a[i] - 10; } } cout << ans << endl; return 0; }
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; int main(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } int ans = 0; for(int i = 0; i < n; i++){ int x = a[i]; for(int j = i; j < n; j++){...
#include <bits/stdc++.h> #define F first #define S second #define FOR(i, a, b) for(int i = a; i <= b; i++) #define RFOR(i, a, b) for(int i = a; i >= b; i--) #define all(v) ((v).begin()), ((v).end()) #define endl '\n' using namespace std; using ll = long long; using ull = unsigned long long; using Graph = vecto...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll t,n; cin>>t; while(t--) { cin>>n; if(n%2==1) cout<<"Odd"<<endl; else { ll r=0 ; while(n%2==0) { ++r; n=n/2; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = int(2e5) + 10; ll a[N]; const ll mod = ll(998244353LL); // ll sum(int m, int n){ // ll mx = -1; // ll mn = -1; // for(int j = 0 ; j < n ; j++){ // int e = 1 << j; // if(m & e){ // if(mx == -1...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair <int, int> #define vi vector<int> #define FOR(i, a, b) for (int i=a; i<b; i++) #define FORd(i, a, b) for (int i=a-1; i>=b; i--) #define F0Rd(i, a) for (int i=a-1; i>=0; i--) #define F0R(i, a) for (int i=0; i<a; i...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll MOD=1e9+7; const ll MAX=1e5+2; void solve(){ ll n;cin>>n; ll a[n],b[n],c[n]; for(auto &x:a)cin>>x; for(auto &x:b)cin>>x; for(auto &x:c)cin>>x; unordered_map<ll,ll>mc; for(auto &x:c)mc[x]++; unordered_map<ll,ll>mb;...
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> #include<utility> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(n...
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define int long long #define pb push_back #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define all(v) v.begin(),v.end() #define F first #define S second #define pi pair<int,int> #define vi vector<int> #define mii map<int,...
//Duodecim Ferra #include<bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i,x,y) for(ll i=x;i<y;i++) #define rrep(i,x,y) for(ll i=x;i>=y;i--) #define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i] #define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i] #de...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } r...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (n); ++i) #define rep1(i, n) for(int i = 1; i < (n); ++i) using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, x; cin >> n >> x; int a = 0; rep(i, n){ int v, p; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<ll, ll>; #define fi first #define se second #define pb push_back #define pf push_front #define mp make_pair const ll N = 2e5 + 5; const ll MOD = 1e9 + 7; const ll INF = 2e9; const ll dr4[] = {1, -1, 0, 0}; const ll dc4[] = {0, 0, 1, ...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int,int>; using PIL = pair<int,ll>; using PLI = pair<ll,int>; using PLL = pair<ll,ll>; using Graph = vector<vector<int>>; using Cost_Graph = vector<vector<PIL>>; template<class T> bool chmin(...
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 1e5 + 5; inline int read() { int w = 0, f = 1; char ch = getchar(); while (ch < '0' or ch > '9') { if (ch == '-') f = -f; ch = getchar(); } while (ch >= '0' and ch <= '9') w =...
#include<bits/stdc++.h> using namespace std; using ll=long long; using P=pair<ll,ll>; ll N,M,Q; map<ll,ll>mp; map<ll,ll>mp1; P dat[2][800005]; ll n; void init(ll n_){ n=1; while(n<=n_)n*=2; for(ll i=0;i<2*n-1;i++){ dat[0][i]=P(0,0); dat[1][i]=P(0,0); } } void update(ll j,ll k,ll a){ ll m=mp1.at(k); k+=n-1;...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if(a == b) cout << c << endl; else if(b == c) cout << a << endl; else if(c == a) cout << b << endl; else cout << 0 << endl; }
// /* // power code taken from geeks for geeks // */ // cout << setprecision (2) << fixed << 1.2; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; // THINGS TO REMEMBER // ENDL is slow, '\n' is fast // Clear everything (including graphs) between test cases // use anti-anti-...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <cmath> #include <queue> #include <map> #include <iomanip> #include <time.h> using namespace std; int64_t mod = 998244353 ; int64_t min(int64_t a,int64_t b) { if (a > b) { return b ; }else ...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++) #define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--) #define all(v) v.begin(), v.end() typedef long long ll; template <class T> using V = vector<T>; template <class T> using VV = vector...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<iostream> #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 <= (n); i++) #define co...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using ll = int64_t; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vector<int>>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll =...
// #define LOCAL #ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++) #define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--) #define ll long long #define ld long double #define pb push_back #define eb empl...
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int A,B; long long k; long long dp[50][50]; int main(void){ // freopen("D.in","r",stdin); // freopen("D.out","w",stdout); scanf("%d %d",&A,&B); cin>>k; dp[0][0]=1; for(int i=0;i<=A;i++){ for(int j=0;j<=B;j+...
#include <bits/stdc++.h> #define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++) #define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++) #define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--) #define deb(x) std::cout << #x << " " << x << endl; #define debl(x) std::cout << #x << " " << x << " "; using namespace std;...
#include <bits/stdc++.h> using namespace std; #define int long long #define ull unsigned long long #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++) #define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--) #define all(a) a.begin(),a.end() ...
#include<algorithm> #include<cstdio> #define MaxN 200500 #define ll long long using namespace std; const int mod=998244353; ll powM(ll a,int t=mod-2){ ll ret=1; while(t){ if (t&1)ret=ret*a%mod; a=a*a%mod;t>>=1; }return ret; } ll fac[MaxN],ifac[MaxN]; ll C(int n,int m) {return fac[n]*ifac[m]%mod*ifac[n-m]%...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++) #define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--) #define all(v) v.begin(), v.end() void c...
#include <bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(false); cin.tie(0); int n; while (scanf("%d", &n) == 1) { vector<int> a(n, 1); for (auto &x : a) scanf("%d", &x); map<long long, int> m = { { 0, 1 } }; long long s[2] = { 0 } ; ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constex...
#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<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; typedef long long ll; char In[1 << 20], *ss = In, *tt = In; #define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++) ll read() { ll x = 0, f = 1; char ch = getchar(); for(; ch < ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> ostream& operator<<(ostream &os, vector<T> &v){ string sep = " "; if(v.size()) os << v[0]; for(int i=1; i<v.size(); i++) os << sep << v[i]; return os; } template<typename T> istream& operator>>(istream &is, vector<...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_back...
#include <iomanip> #include <iostream> #include <set> #include <string> #include <vector> #include <algorithm> #include <array> #include <map> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<ll> a(n); for(int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); ll a...
// EXPLOSION! #define _CRT_SECURE_NO_WARNINGS #include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> #include<chrono> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<...
#include "bits/stdc++.h" using namespace std; #define ll long long int #define pb(a) push_back(a) #define vll vector<ll> #define loop(i, n) for(ll i=1;i<=n;i++) #define loop0(i, n) for(ll i=0;i<n;i++) #define in(i) scanf("%lld", &i); #define out(i) printf("%lld", i) #define pll pair<ll, ll> #define vpll vector<pair<l...
#include <bits/stdc++.h> #define foreach(i,v) for(auto&& i: v) #define all(x) (x).begin(), (x).end() typedef std::vector< std::string > VS; typedef std::vector<int> VI; typedef long long ll; typedef std::pair<int, int> ii; template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; } template <class C> C& ma...
#include <algorithm> #include <cassert> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef lo...
#include <bits/stdc++.h> using namespace std; #define ms(s, n) memset(s, n, sizeof(s)) #define f(i, a, b) for (int i = (a); i <=(b); i++) #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--) #define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) #define sz(a) int((a).size()) #d...
#include "bits/stdc++.h" using namespace std; long long calc(int n){ long long ret=1ll*(n*(n+1ll))/2ll; return ret; } void solve(){ string s; cin>>s; int n=s.length(); if(n==1){ if(s[0]=='8'){ cout<<"Yes\n"; } else{ cout<<"No\n"; } ...
#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; using ll = long long; using ld = long double; using ordered_set = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>; void fastio() { cin.tie...
#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<iostream> using namespace std; int main() { int a, b; cin>>a>>b; cout<<2*a+100-b; }
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) #define repr(i, n) for(int i = n; i >= 0; i--) #define reps(i,a,b) for(int i= a; i < b; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { int a, b, c; cin >> a >> b >> c; if (c == 0) ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() using ll = long long; int mod = 1000000007; const int INF = 1001001001; template<class T> void chmin(T& a, T b) {if (a > b) a = b;} template<class T> void chmax(T& a, T b) {if (a < b) a = ...
#include<bits/stdc++.h> //Ithea Myse Valgulious namespace chtholly{ typedef long long ll; #define re0 register int #define rel register ll #define rec register char #define gc getchar //#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++) #define pc putchar #define p32 pc(' ') #define pl puts("...
#include <bits/stdc++.h> struct __fastio__ { __fastio__ () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } __fast_io__; template<class T, class U> bool chmin (T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template<class T, class U> bool chmax (T &a, const T &b) { if (a < b) { a = b; ret...