code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<bits/stdc++.h> #define int long long using namespace std; inline int read(){ int 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<<3)+(ch^48); ch=getchar(); } return x*f; } co...
#include <bits/stdc++.h> #define lc (o<<1) #define rc ((o<<1)|1) #define PB push_back #define MK make_pair using namespace std; #define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl const int maxn = 2e5 + 5; const int modu = 998244353; // 1e9 + 7 const int inf = 0x3f3f3f3f; const double eps = 1...
#include <bits/stdc++.h> // New Template using namespace std; #define fo(i, n) for (i = 0; i < n; i++) #define ll long long #define si(x) scanf("%d", &x) #define sl(x) scanf("%lld", &x) #define ss(s) scanf("%s", s) #define pi(x) printf("%d\n", x) #define pl(x) printf("%lld\n", x) #define ps(s) printf("%s...
#include <iostream> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <utility> #include <string> #include <sstream> #include <algorithm> #include <random> #include <cstdio> #include <cstdlib> #in...
#include "bits/stdc++.h" using namespace std; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); #define pb push_back #define eb emplace_back #define ins insert #define f first #define s second #define cbr cerr<<"hi\n" #define mmst(x, v) memset((x), v, sizeof ((x))) #define siz(x) ll(x.size()) #define all(x) (...
#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),i##z=(b);i<=i##z;i++) #define ROF(i,a,b) for(int i=(a),i##z=(b);i>=i##z;i--) #define temT template<typename T> using namespace std; typedef double ld; const int N=int(1e2)+10; int n; char f[N][N]; ld res; void bbfs(int i){//back bfs static queue<int> que; sta...
#include <algorithm> #include <iomanip> #include <cassert> #include <cmath> #include <functional> #include <iostream> #include <map> #include <stack> #include <queue> #include <vector> static const int IINF = 1 << 30; static const long long LINF = 1LL << 60; static const long long MOD = 1.0e+9 + 7; template <typename...
//ver 8.1 #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#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...
#include <bits/stdc++.h> #define rep(i, n) for(int i=0; i < (n); ++i) #define ll long long #define pll pair<ll, ll> using namespace std; long memo[1001001][2]; vector<pll> colors; // direction -> 1 = right; 0 = left; long dp(long unsigned color, int direction){ if (color >= colors.size()) return 0; ...
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("inline") #include<bits/stdc++.h> using namespace std; void*wmem; char memarr[96000000]; template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){ static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, ...
#include <bits/stdc++.h> using namespace std; int main(){ int n,k; cin >> n >>k; vector<long long> points; vector<int> money; long long temp1; int temp2; for (int i = 0; i < n; i++){ cin >> temp1; points.push_back(temp1); cin >> temp2; money.push_back(temp2); } vector<size_t> indices(po...
#pragma GCC optimize("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif void d_err() { ce...
// .-""""-. // / j \ // :.d; ; // $P : // .m._ $$ : // dSMMSSSss.__$b. __ : // :MMSMMSSSMMMSS$$b $P ; // SMMMSMMSMMMSSS$$$$ :b // dSMMMSMMMMMMSSMM$$b.dP ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define tej ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); #define ve vector<int> #define vl vector<long long int> #define vp vector<pair<long long int,long long int>> #define pb push_back #define fi first #define se second #define pb push_ba...
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <math.h> #include <cassert> #define rep(i,n) for(int i = 0; i < n; ++i ) using namespace std; using ll = long long; const int m = 1e9+7; ll n,p; ll f(ll n){ if(n==0) r...
#include<bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0) void err() { cout << "\033[39;0m" << endl; } template<template<typename...> class T, typename t, typename... A> void err(T<t> a, A... x) { for (auto v: a) cout << v << ' ';...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> pl; struct edge { ll to; // 辺の行き先 ll weight; // 辺の重み edge(ll t, ll w) : to(t), weight(w) { } }; typedef vector<vector<ll> > Graph; typedef vector<vector<edge> > WGraph; #define rep(i, n) for(...
// Template #include "bits/stdc++.h" #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (int)(n); ++i) #define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; ...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <unordered_map> #include <unordered_set> using namespace std; 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; r...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // -------------------------------------------------------- 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...
#include <iostream> #include <vector> #include <numeric> #include <algorithm> #include <climits> constexpr int SINT_MAX = std::numeric_limits<int>::max(); constexpr int SINT_MIN = std::numeric_limits<int>::min(); using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; using vll = ve...
#include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() #define ll long long #define rep(i,n) for(int i = 0; i < int(n); i++) #define vi vector<int> using namespace std; const int INF = 1001001001; const int MOD = 1e9+7; template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; } t...
#include <bits/stdc++.h> using namespace std; //useful #define rep(i,n) for(int i = 0; i < (n); i++) int long long gcd(int long long a, int long long b){ return b?gcd(b,a%b):a; } //最大公約数 int long long lcm(int long long a, int long long b){ return a/gcd(a,b)*b; } //最小公倍数 int long long GetDigit(int long long num...
#include "bits/stdc++.h" using namespace std; typedef long double ld; typedef long long ll; #define sz(x) (int)(x).size() #define eb emplace_back #define pb push_back #define mp make_pair #define f first #define s second template<typename T, typename U> bool ckmin(T &a, const U &b){ return b < a ? a = b, true : fal...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i < n;i++) typedef long long ll; int main(){ int n; cin >> n; vector<long long> a(n); rep(i,n){ cin >> a[i]; } sort(a.begin(),a.end()); vector<long lon...
#include<bits/stdc++.h> using namespace std; const int mod=998244353; int a,b,c; int main( ) { cin>>a>>b>>c; a%=mod, b%=mod, c%=mod; a=1ll*a*(a+1)/2%mod; b=1ll*b*(b+1)/2%mod; c=1ll*c*(c+1)/2%mod; cout<<1ll*a*b%mod*c%mod; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long int int32; typedef unsigned long int uint32; typedef long long int int64; typedef unsigned long long int uint64; typedef long double ldd; typedef double ld; #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define mp(x,y) make_pair(x,y) #d...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=n...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") //#pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define readFast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define fin cin #define ll long long #define sz(x) (int)(x).size() #define all(v) v.begin(), v.end() #define o...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<pll> vpll; void INX(){} template<typename Head, typename... Tail> void INX(Head&& head, Tail&&... tail) { cin >> head; IN...
#include<iostream> #include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define deb(x) cout << #x << " " << x << endl; typedef long long int ll; typedef pair<int, int> pi; typedef pair<int, double> pid; #define UP_Y 100 #define DOWN_Y -100 const double EPS ...
#include<bits/stdc++.h> #define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++) #define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--) #define ll long long #define ull unsigned long long #define db double #define pii pair<int, int> #define mkp make_pair using namespace std; const int N = 1e5 + 7; ll n, m; in...
#include <cstring> #include <cmath> #include <algorithm> #include <string> #include <map> #include <iostream> #include <vector> #include <queue> #include <unordered_map> #include <random> #include <stack> #include <set> #include <unordered_set> #define bug(x) cout<<"zdongdebug1: "<<x<<endl; #define bug2(x, y) cout<<"z...
#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--) const long long int cons = 200005; const long long int MOD = 1000...
#include<bits/stdc++.h> #define int long long #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pi; const int mod = 1e9 + 7; const int nax ...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; //indexed set is using "int" here--------- use ll ... // typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; typedef long long int ll; typedef long do...
#include <bits/stdc++.h> using namespace std; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} vo...
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using db = double; using ld = long double; template<typename T> using...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__); #else #define DEBUG(...) 6; #endif template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";} template<typename C, typ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define maxn 200005 int n; ll a[maxn],sum[maxn]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i]; ll summ=0,maxx=a[1]; for(int i=1;i<=n;i++){ summ+=sum[i-1];maxx=max(maxx,a[i]); ll ans=summ+i*maxx+sum...
#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 ll; const ll INF = 1e18; const int inf = 1e9; #define rep(i, a, b) for (ll i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define all(a) (a).begin(), (a).end() using pint = pair<ll, ll>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 400010, mod = 1e9 + 7; int e[N], ne[N], h[N], idx, w[N][61], n; ll tar, d[N][2], res; void add(int a, int b, long long c) { e[idx] = b, ne[idx] = h[a]; for (int i = 0; i < 60; ++i) { if (c & 1) w[idx][i] = 1; c /= 2; if (!c) b...
#include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <random> #include <iomanip> #include <functional...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin>>s; int n=s.length(),x=0; while(x<n && s[x]=='a') x++; cout<<(x==n?-1:s>"atcoder"?0:x-(s[x]>'t'))<<endl; } int main() { //freopen("t","r",stdin); int test; cin>>test; while(test--) solve(); return 0; }
#include <bits/stdc++.h> #define endl '\n' #define INF 0x3f3f3f3f #define Inf 1000000000000000000LL #define LL long long #define pb push_back #define mp make_pair #define F first #define S second using namespace std; typedef pair<int,int>pii; int readint(){ int x=0,y=1;char c=getchar(); while((c<'0'||c>'9')&&c!='-')c...
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<stack>...
#include <bits/stdc++.h> #define rep(begin, end) for (i=begin;i<end;i++) #define repj(begin, end) for (j=begin;j<end;j++) #define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val; #define printint(i0, i1) printf("%d %d\n", i0, i1) using namespace std; typedef long long int ll; const int inf = 1000000000; const int...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; constexpr ll MOD = 1000000007; #ifndef ONLINE_JUDGE template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : "...
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; namespace defines{ typedef long long ll; typedef pair<ll,ll> P; #define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b) #define REP(i,n) for(ll i = ...
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define y1 bfrsoihgdfnm #define INF (ll)1e18 #define mod 998244353 #define maxn 210 ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b; ll x1, y1, x, y, kn[maxn][maxn]; bool...
/******************************************************************** * @brief https://atcoder.jp/contests/abc145/tasks/abc145_c * @date 2020/10/16 *********************************************************************/ #include <bits/stdc++.h> //全てのヘッダファイルをインクルード using namespace std; //ループ #define rep(i, n) for(int i ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ld eps = 1e-8; #define len(x) ((int)x.size()) #define rep(i,n) for (int i = -1; ++ i < n; ) #define rep1(i,n) for (int i = 0; i ++ < n; ) #define be(a) (a).begin(), (a).end() // #define constexpr(...) (__VA_ARGS__) // D...
#include<iostream> #include<algorithm> #include<string> using namespace std; int ri(){ int n; scanf("%d", &n); return n; } int main(){ int h = ri(); int w = ri(); int x = ri() - 1; int y = ri() - 1; string s[h]; for(auto &i : s) cin >> i; int cnt = -3; for(int i = x; i < h && s[i][y] != '#';...
#include<bits/stdc++.h> using namespace std; int main(){ int h,w,x,y;cin>>h>>w>>x>>y; --x,--y; vector<string> s(h); int ans=1; for(int i=0;i<h;i++)cin>>s[i]; const int dx[]={-1,1,0,0}; const int dy[]={0,0,-1,1}; for(int i=0;i<4;i++){ for(int j=1;j<200;j++){ int nx=x+dx[i]*j,ny=y+dy[i]*j; ...
#include <bits/stdc++.h> // #include <atcoder/all> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for(int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; // using namespace atcoder; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}e...
#include<bits/stdc++.h> using namespace std; #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define ALL(a) a.begin(),a.end() #define SET(a,b) memset(a,b,sizeof(a)) #define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) typedef pair<int,int> II; typ...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long cyanmond; cin >> cyanmond; vector<unsigned long long> cyankawaii(cyanmond); for (unsigned long long mohumohu = 0; mohumohu < cyanmond; mohumohu++) { cin >> cyankawaii.at(mohumohu); } vector<unsigned long long> cyan(cyanmond+1, 0); ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using i64 = long long; #define forn(a, e) for (i64 a = 0; a < (i64)(e); a++) #define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++) #define fore(e, a) for (auto& e : a) #ifdef LOCAL #define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e <...
#include <bits/stdc++.h> #include <sys/time.h> #pragma GCC optimize "O3,omit-frame-pointer,inline" #define REP(i, n) for(int i = 0;i < n;i++) #define ll long long using namespace std; //typedef vector<unsigned int>vec; //typedef vector<ll>vec; //typedef vector<vec> mat; typedef pair<int, int> P; typedef pair<ll,ll> LP;...
#include<algorithm> #include<bitset> #include<cmath> #include<complex> #include<deque> #include<functional> #include<iomanip> #include<iostream> #include<iterator> #include<map> #include<numeric> #include<queue> #include<set> #include<stack> #include<string> #include<unordered_map> #include<unordered_set> #include<util...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long long, long long>; constexpr char ln = '\n'; constexpr long long MOD = 1000000007; constexpr long long INF = 1000000000 + 100; constexpr long long LINF = 1000000000000000000 + 100; #define all(v) v.begin( ), v.end() #define rep(i,...
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pb push_back #define pii pair<int, int> #define all(x) (x).begin(), (x).end() #define F first #define S second #define SF S.F #define SS S.S const int N=3000006, inf=1e6, P=1e9+7; int n,m,w,d,k,x,y,q,fac[N],inv[N],ans; vector<int...
/* ALLAH IS ALMIGHTY ******BISMILLAHIR RAHMANIR RAHIM.****** ALLAH IS ALMIGHTY ``````````````````````````````` AUTHOR: ANISUR RAHAMAN BSMRSTU(SHIICT) ...
#include<bits/stdc++.h> using namespace std; typedef int64_t ll; const int N=5e5+10; int c[N]; vector<ll>p[N]; ll min1(ll a,ll b) { if(a<b) return a; else return b; } ll lb(ll x) { return x&(-x); } void add(int x,int d) {for(;x<N;x+=lb(x))c[x]+=d;} int geti(ll x) { int r=0; for(;x;x-=lb(x)) r+=c[x]; return r; ...
#include<bits//stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i,n) for(int i = 1;i <= n; i++) #define rrep(i,n) for(ll i = n-1;i >= 0;i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a),rend(a) typedef long long int ll; typedef lon...
#include <bits/stdc++.h> using namespace std; main() { int H, W; cin >> H >> W; assert(2<=H && H<=100); assert(2<=W && W<=100); vector<string> S(H); for(string& s: S) cin >> s; int ans{}; for(string s: S) for(int j{}; j < W-1; j++) if(s.substr(j,2) == "..") ans++; assert(0 <= ans && ans <= H...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/trie_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define fef(i,a,b) for(ll i=a;i<=b;i++) #define rer(i,a,b) for(ll i=b;i>=a;i--) #d...
#include <bits/stdc++.h> using namespace std; int main() { string x; getline(cin,x); int v=0,i=0; while(v!=1&&i<x.size()) { if(x[i]=='.') v=1; i++; } if(v==1) for(int j=0;j<i-1;j++) cout<<x[j]; else for(int j=0;j<x.size();j++) cout<<x[j]; return 0; }
//缓缓飘落的枫叶像思念,我点燃烛火温暖岁末的秋天。 //堆排序找top k; #include<bits/stdc++.h> #define IO ios::sync_with_stdio(0);cin.tie(0); using namespace std; typedef long long ll; const ll N=2e6; int a[5]; int main() { cin>>a[1]>>a[2]>>a[3]; sort(a+1,a+4); if(a[3]-a[2]==a[2]-a[1])cout<<"Yes"; else cout<<"No"; } ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); vector<int> a(3); int sum = 0; for (int&x : a) cin >> x, sum += x; sort(a.begin(), a.end()); if (sum % 3 != 0 || sum/3 != a[1]) cout << "No"; else cout << "Yes"; return 0; }
//====================Template================== #include <bits/stdc++.h> // #include <boost/lexical_cast.hpp> // for lexical_cast() using namespace std; #define endl '\n' #define ll long long int #define ld long double #define mod 1000000007 #define pb p...
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n%100 == 0) { if(n>=100 || n==0) cout<<"100"; else cout<<"0"; } else { cout<<100-(n%100); } return 0; }
#include <iostream> #include <vector> #include <algorithm> #include <tuple> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i,n) for(int i = 0; i < (n); i++) tuple<ll, ll, ll> extgcd(ll a, ll b) { if(b == 0) return {a, 1, 0}; auto [g, x, y] = extgcd(b, a%b); return {g, y, x...
#include<bits/stdc++.h> #define ll long long #define re register #define INF 2147483647 using namespace std; inline ll read() { ll f=1,x=0;char s=getchar(); while(s<'0'||s>'9') { if(s=='-') f=-1; s=getchar(); } while(s>='0'&&s<='9') { x=x*10+s-48; s=getchar(); } return f*x; } ll exgcd(ll a,ll b,ll &x,...
#include <bits/stdc++.h> using namespace std; #define ll long long #define uint unsigned int #define inf (ll)1e18 #define end1 " " #define ld long double #define mp make_pair #define pb push_back #define all(x) begin(x),end(x) #define sf(x) sizeof(x) #define print_double(d, n) cout<<fixed<<setprecision(n)<<d<<end1; b...
#include <iostream> #include<algorithm> #include<iomanip> #include<cstdio> #include<cmath> #include<string> #include <cstring> #include<queue> #include<set> #include<stack> #define MAX_N 100050 #define INF 999999 using namespace std; typedef long long ll; ll cnt[300050]; ll a[300050]; ll n; ll sum; int main() { cin ...
#include <bits/stdc++.h> using namespace std; // BEGIN LIB template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } #define print_grid(x) for(auto &r:x){for(auto &c:r)cout<<c<<" ";cout<<endl;}cout<<endl; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define ...
#include<bits/stdc++.h> using namespace std; int main() { int a,c,b,i; cin>>a>>b>>c; if(c==1) { if(a>=b) { cout<<"Takahashi"<<endl; return 0; } else if(a<b) { cout<<"Aoki"<<endl; } } else { if(a<=b) ...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ff first #define ss second #define pb push_back #define mp make_pair #define deb(x) cout<< #x << " " << x << "\n"; #define MAX 9223372036854775807 #define MIN -9223372036854775807 #define setbits(n) __builtin_popcountll(n) #define mkunique(a...
#include <bits/stdc++.h> using namespace std; #ifndef aa #define trace(...) #define endl '\n' #endif #define pb push_back #define ub upper_bound #define lb lower_bound #define fi first #define se second #define int long long typedef long long ll; typedef long double ld; #define pii pair<int,int> #define pdd pair<doubl...
#line 1 "/home/siro53/kyo-pro/compro_library/template/template.cpp" #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; ...
#include <bits/stdc++.h> using namespace std; #define REP(a,b) for(long long a = 0;a < b;++a) using ld = long double; unsigned long xor128() { static unsigned long x=time(NULL), y=362436069, z=521288629, w=88675123; unsigned long t=(x^(x<<11)); x=y; y=z; z=w; return ( w=(w^(w>>19))^(t^(t>>8)) ); } typedef str...
#include <bits/stdc++.h> using namespace std; using ll=long long; using P = pair<int, int>; int main() { int n; cin >> n; int a[n]; for(int i = 0;i < n;i++){ cin >> a[i]; } int ans = 0; for(int l = 0;l < n;l++){ int x = a[l]; for(int r = l;r < n;r++){ x = min(x,a[r]); ans = max(an...
#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; template <typename T> using vt = vector<T>; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define pb p...
#include<bits/stdc++.h> using namespace std; int main(){ int N, X; char S; int cnt; cin>>N>>X; cnt = X; for (int i=0; i<N; i++){ cin>>S; if (S == 'o') cnt += 1; else{ if (cnt>0) cnt -= 1; } } cout << cnt << endl; }
#include<iostream> #include<algorithm> #include<vector> #include<iomanip> #include<cmath> #include<map> #include<string> #include<bitset> using namespace std; #define rep(i,N) for(ll i=0;i<N;i++) //0から typedef long long ll; ll binary_search(vector<ll> a, ll n, ll key){ ll right = n, left = -1; ll md = (...
#define _USE_MATH_DEFIMES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <ioman...
#include <bits/stdc++.h> using namespace std; #define int long long #define F first #define S second #define pii pair<int, int> #define pb push_back #define vi vector<int> #define all(x) (x).begin(), (x).end() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pc cerr<<"Time : "<<1000*(long do...
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define endl "\n" #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x.size()) int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;} int binpow(int a,int l){...
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> // #include <boost/rational.hpp> // using bigint = boost::multiprecision::cpp_int; // using fraction = boost::rational<bigint>; using namespace std; #define pb push_back #define eb emplace_back #define unused [[maybe_unused]] #define tempT templa...
// ABC180-E #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; template <typename T> T TSP(int s, vector<vector<pair<i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for(int i = 0; i < (n); ++i) #define io ios::sync_with_stdio(false); cin.tie(0) void print_vec(const vector<int>& vec) { int n = vec.size(); rep(i, n) { cout << vec[i]; if (i != n-1) ...
#include<algorithm> #include<cstdio> using namespace std; int n,m; int main() { scanf("%d",&n); printf("6 10 15 ");m=3; for (int i=16;i<=10000&&m<n;i++){ int cnt=0; if (i%2==0)cnt++; if (i%3==0)cnt++; if (i%5==0)cnt++; if (cnt>=2){m++;printf("%d ",i);} } return 0; }
#include <bits/stdc++.h> using namespace std; using ll=long long; #define P pair<int,int> #define fi first #define se second #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define pb push_back template<class T,class U> inline bool chmax(T &a,U b){ if(a<b){ a=b; return true; ...
#include <iostream> #include <iomanip> #include <vector> #include <array> #include <stack> #include <queue> #include <tuple> #include <algorithm> #include <unordered_set> #include <unordered_map> #include <cmath> #include <map> #include <numeric> #include <cassert> #include <string> #include <list> using ull = unsign...
#include <bits/stdc++.h> using namespace std; const int MAXN=2000; vector<vector<int>> g; bool temp[MAXN]; void dfs(int v){ if(temp[v]) return; temp[v]=1; for(auto vv:g[v]) dfs(vv); return; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); int n,m; cin>>n>>m; g.resize(n); for(int i=0;i<m;i++...
#include<bits/stdc++.h> // no of bits to store no 2e5 is 19 // 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai using namespace std; #define int long long #define mod 1000000007 #define MOD 1000000007 #define MAX 1000000000 #define inf ...
#include <bits/stdc++.h> #define endl "\n" using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> PP; #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rrep(i, n) for(ll i = n - 1; i > -1; i--) #define all(v) v.begin(), v.end() #define pb push_back #define fi first #define se secon...
/*input 3 4 3 1 9 5 3 7 8 1 8 6 9 4 4 1 4 1 3 */ // assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_containe...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PI; const int maxm=2e6+5; PI e[maxm]; PI ee[maxm]; int n,m,q; int main(){ cin>>n>>m>>q; for(int i=1;i<=n;i++){ int x,y; cin>>x>>y; e[i]={x,y}; } for(int i=1;i<=m;i++){ int x; cin>>x; ...
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; const int N = 5e6; int binpow[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int h, w; cin >> h >> w; vector<string> s(h); for (int i = 0; i < h; i++) ...
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #ifndef LOCAL #pragma GCC optimize("O3") #endif //~ #pragma GCC optimize("Ofast") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //~ #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #in...
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #define rg register template<typename T>void read(T &x){ x=0;rg int fh=1; rg char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') fh=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getcha...
#include<bits/stdc++.h> using namespace std; #define int long long const int M = 1e9 + 7; void solve() { int ar[] = {0, 6, 5, 4, 3, 2, 1}; int a, b, c; cin >> a >> b >> c; cout << ar[a] + ar[b] + ar[c]; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); co...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; ll sum = 0; for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= k; j++) { sum += i * 100 + j; } } cout << sum; }
#include <bits/stdc++.h> //#include <chrono> #pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pint pair<int, int> #define pll pair<ll, ll> const ll INF = 1LL << 60; // const int MOD = 1000000007; const ll MOD = 998244353; ll dp[5100][5100]; char field[5100][5100]; ll modpow(ll m, ll n) { if (n == 1) return m; if (n == ...
#include <bits/stdc++.h> #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#define int long long #define pb push_back #...
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ int N, K, M; cin >> N >> K >> M; int sumA = 0; for(int i = 0; i < N-1; ++i){ int tmp ; cin >> tmp; sumA += tmp; } for(int i = 0; i <= K; ++i){ if((sumA + i) / N >= M){ ...
#include <bits/stdc++.h> using namespace std; #define SELECTER(_1, _2, _3, SELECT, ...) SELECT #define REP1(i, n) for(int (i)=0; (i)<(n); (i)++) #define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++) #define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__) #define MOD 1000000007 template <class T> ostream& op...
//BISMILLAHIR RAHMANIR RAHIM #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define mem(a, b) (memset(a, b, sizeof(a))) #define pb push_back #define mk make_pair #define ff first #define ss second #define PI acos(-1) #define INF 2147483647 #define MOD 1000000007 #...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); i++) #define ll long long ll fact(int a, int b){ ll res = 1; rep(i, b) res *= a; return res; } int main(){ double k; cin >> k; string s, t; cin >> s; cin >> t; //二人のスコア ll tscore = 0; ...
//================code===================// //#define TLE #ifdef TLE #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #include <random> #include <ctime> #define ci(t) cin>>t #define co(t)...
//#include <bits/stdc++.h> //using namespace std; #include <cstdio> #include <vector> using namespace std; #define rep(i,_l,_r) for(signed i=(_l),_end=(_r);i<=_end;++i) #define fep(i,_l,_r) for(signed i=(_l),_end=(_r);i>=_end;--i) #define erep(i,u) for(signed i=head[u],v=to[i];i;i=nxt[i],v=to[i]) #define efep(i,u) for...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define MOD 1000000007 int main(void) { string s; cin >> s; int num[10]; rep(i,10) num[i]=0; int ans[111][10]; for(int i=0;i<111...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, j, k) for(int i = j; i < k; i++) #define print(x) cout << x #define newline cout << endl #define space cout << ' ' #define INF 1000000007 using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>...
#include <bits/stdc++.h> using namespace std; int main(){ long long n; cin >> n; double N = sqrt(n); int count = 0; /*vector<long long> vec(n, 2000000000000);*/ priority_queue<long long, vector<long long>, greater<long long>> Q1; for (int i = 1; i <= N; i++){ if (n % i == 0 && i != ...
#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; long long int power(long long int x,long long int y,long long int p) { long long int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) ...
#include<bits/stdc++.h> using namespace std; #define I inline int #define V inline void #define ll long long int #define isnum(ch) ('0'<=ch&&ch<='9') #define FOR(i,a,b) for(int i=a;i<=b;i++) #define ROF(i,a,b) for(int i=a;i>=b;i--) #define REP(u) for(int i=h[u],v;v=e[i].t,i;i=e[i].n) #define gc (_op==_ed&&(_ed=(_op=_bu...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define int long long #define ll long long #define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr)) #define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr)) #define sz(a) sizeof(a) #define deb(a) cerr ...
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define ll long long #define MOD 998244353LL using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける const ll llMAX=9223372036854775...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; constexpr ll MOD = 998244353; #ifndef ONLINE_JUDGE template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " ...
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5+3; #define fi first #define se second #define pb push_back #define wzh(x) cerr<<#x<<'='<<x<<endl; int n,a[N],b[N],f[N]; LL s[N]; int main() { ios::sync_with_stdio(false); cin.tie(0);...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #pragma GCC optimize("Ofast") #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) //#include <ext/pb_ds/assoc_container.hpp> ...
///Bismillahir Rahmanir Rahim #include<bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL) #define ll long long #define pb push_back #define pp pop_back #define mp make_pair #define pi 2*acos(0.0) #define ...
#include <bits/stdc++.h> #include <vector> #include <set> #include <map> #include <string> #include <algorithm> #include <cmath> #include <queue> #include <stack> using namespace std; #define pq_max priority_queue<ll> #define pq_min priority_queue<ll,vi,greater<ll>> #define iint int #define f(i,a,b) ...
#include<bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef std::vector<ll> vi; typedef std::vector<std::vector<ll> > vv; typedef std::vector<std::pair<ll,ll> > pii; typedef std::pair<ll,ll> pi; #define mod 1000000007 #define IO ios_base::sync_with_stdio(false);cin.tie(NULL); #define fo(i,a,...
#include <cstdio> #include <algorithm> using namespace std; int a[200005]; int main() { int n, m; scanf("%d%d", &n, &m); a[0] = 0; a[m + 1] = n + 1; for (int i = 1; i <= m; i++) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + m); int g = 1e9; for (int i = 1; i <= m + 1; i++) { if (a[i] - a[i - 1] - 1) { ...
/* How To Solve It 1st. Understanding The Problem 未知なもの、データ(与件), 条件 は何か? その条件は未知を決定するために十分か? 条件を分解せよ, 図を描け 2nd. Devising A Plan 類似、関連のある問題、典型問題を知らないか? 役立ちそうな定理やアルゴリズムを知らないか? 問題の一部を解決できるか、一部だけ残して他を切り捨ててみろ 既知のものやデータを変えることはできるか? 3rd. Carrying Out The Plan 各ステップで誤りがないか、正しいと説明できるか? 4th. L...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(register int (i) = (a); (i) <= (int)(b); (i)++) #define repd(i, b, a) for(register int (i) = (b); (i) >= (int)(a); (i)--) #define mset(a, x) memset((a), (x), sizeof(a)) #define x first #define y ...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define ndl '\n' #define mp make_pair #define mt make_tuple #define pb push_back #define up_b upper_bound #define low_b lower_bound #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mk make_pair #define fi first #define se second #define mset(a, b) memset(a, b, sizeof(a)) using ll = long long; using pii = pair<int, int>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<c...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define INF LONG_MAX/3 //#define DIV 1000000007 //#define DIV 998244353 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, con...
#include<iostream> #include<vector> using namespace std; int N,M; vector<int>G[20]; int col[20]; bool dfs(int u) { for(int v:G[u]) { if(col[v]==-1) { col[v]=3-col[u]; if(!dfs(v))return false; } else if(col[u]==col[v]) { return false; } } return true; } int main() { cin>>N>>M; vector<pair<int,int>...
#include <bits/stdc++.h> #define all(x) (x).begin(),(x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; using pii = pair<int, int>; template<typename... T> void rd(T&... args) {((cin>>args), ...);} template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;} int main...
#include <iostream> #include <math.h> #include <vector> #include <string> typedef long long ll; using namespace std; #define prt(var) cout << (var) << endl; #define rep(i,n) for(int i=0; i<int(n); i++) int main() { int n; string s; cin>>n>>s; ll ans=0; for(int i=0; i<n-1; i++){ int l=i, r=i+1; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, ans = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { int cnt[26] = {}; for (int j = i; j < n; j++) { cnt[s[j] - 'A']++; if (cnt[0] == ...
#include <bits/stdc++.h> #define ll long long using namespace std; vector<ll> subsets(vector<int> a){ int n = a.size(); vector<ll> ret; for(int mask = 0; mask < (1<<n); mask++){ ll sum = 0; for(int i=0; i<n; i++){ if( (mask&(1<<i)) != 0){ sum += a[i]; ...
#include<bits/stdc++.h> #define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define Freed freopen ("0in.txt","r",stdin); #define Fout freopen ("0out.txt","w",stdout); #define ll long long int #define pb push_back #define mp make_pair #define pi acos(-1.0) #define Mod 1000000007 #define limit 48 using namespace...
#include<bits/stdc++.h> #define mod 1000000007 #define pi pair<int, int> #define ll long long int #define pll pair<ll, ll> #define ppll pair<pll, ll> #define vi vector<int> #define vll vector<ll> #define vpi vector<pi> #define vpll vector<pll> #define vppll vector<pair<pll, ll>> #define vvll vector<vector<ll>> #define ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll a, b, c, d; cin >> a >> b >> c >> d; ll lo = ll(1LL), hi = ll(1e6); ll r = -1LL; while(lo <= hi){ ll x = (lo + hi) >> 1LL; if(a + x * b <= d * x * c){ r = x; hi = x - 1...
# include <bits/stdc++.h> using namespace std; const int maxn=4000000+5; map<pair<int,int>,int> P; int c[15][15]={{1,0,0,0,0},{1,1,0,0,0},{1,2,1,0,0},{1,3,3,1,0},{0,0,0,0,0},{0,0,0,0,0}}; int n; char s[maxn]; int lucas(int a,int b){ pair<int,int> d(a,b); if(P[d]!=0) return P[{a,b}]; return P[d]=(b>0?(luca...
#include<bits/stdc++.h> using namespace std; const int N=4e5+1e3+7; int C(int n,int m) { if(n<m||n<0||m<0) return 0; long long ret=1; for(int i=n;i>=n-m+1;i--) ret=ret*i; for(int i=1;i<=m;i++) ret=ret/i; return ret%3; } int Lucas(int n,int m) { if(n<3||m<3) return C(n,m); return C(n%3,m%3)*Lucas(n/3,m...
#include<bits/stdc++.h> using namespace std; #define X first #define Y second #define sz(a) (int)a.size() #define ll long long signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; while(n--) { string s; cin >> s; string s1 = "atcode...
#include <bits/stdc++.h> using namespace std; int main(){ int T; cin >> T; for(int i = 0; i < T; i++){ string S; cin >> S; int rest = 0; string atcoder = "atcoder"; int Slength = S.length(); for(int j = 0; j < min(7, Slength); j++){ rest += (S[j] ...
#include <bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%lld",&(x)); #define fi first #define se second #define pb push_back #define endl '\n' int n, k; int me; int A[808][808]; int B[808][808]; vector<int> w; vector<int> v; bool check(int x){ for(int i = 1; i <= n; i++){ ...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mkp make_pair #define vi vector<int> #define pii pair<int,int> #define FI(n) FastIO::read(n) #define FO(n) FastIO::write(n) #define ull unsigned long long #define mst(a,b) memset(a,b,sizeof(a)) #define foR(i,k,j) for(int i=(k);i>=(j);i--) #define...
#include <bits/stdc++.h> using namespace std; // #include <atcoder/all> // using namespace atcoder; using ll =long long; typedef pair<int,int> P; #define SORT(a) sort((a).begin(),(a).end()) #define REV(a) reverse((a).begin(),(a).end()) #define For(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define rep(i, n) Fo...
#include <iostream> #include <string> using namespace std; int main(){ int m,h;cin>>m>>h; string ans = "Yes"; if(h%m)ans = "No"; cout<<ans<<endl; return 0; }
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<string.h> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) do {} while (0) #endif #include<cassert> using ...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll INF = 1e18; int main() { ios::sync_with_stdio(0); cin.tie(0); int N; ll X; cin >> N >> X; vector<ll> A(N); for (int i=0;i<N;i++) cin >> A[i]; ll ans = INF; for (int i=1;i<=N;i++) { // dp[a][b][c]: a番目まで見て、b個とって、val = c(mod i) のとき...
#include <math.h> #include <algorithm> #include <array> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <vector> using namespace std; using ll = long long; struct Edge { int to; ll w; Edge(int to, ll w) : to(to), w(w) {} }; using Graph = vect...
/*ver 7*/ #include <bits/stdc++.h> using namespace std; void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);} using ll = long long; using ld = long double; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vb = vector<bool>; using vvl = vector<vector<ll>>; ...
#include<bits/stdc++.h> using namespace std; #define test(t) int t;cin>>t;while(t--) #define lli long long int #define pb push_back #define MAX 10000007 #define mod 1000000007 #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) //a.push_back(i+'0');convert i to char; //cout << fixed << setprecision(...
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define DEBUG #ifdef DEBUG template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << '(' << ...
#include <bits/stdc++.h> #include <math.h> using namespace std; typedef long long ll; typedef unsigned long long ull; # define M_PI 3.14159265358979323846 const int M=1e9+7; long long mod(long long x){ return ((x%M + M)%M); } ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define all(x) (x).begin(),(x).end() using namespace std; constexpr int INF = 1e9, MOD = 1e9 + 7; constexpr int64_t LINF = 5e18, LMOD = 998244353; // #include <atcoder/all> // using namespace atcoder; // const int dy[]={0,-1,0,1,1,-1,-1,1}; // const int dx[...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ int n; string s,t; cin >> n >> s >> t; vector<int> a,b; for(int i = 0;i < n;i++){ if(s.at(i) == '0') a.push_back(i); if(t.at(i) == '0') b.push_back(i); } if((int...
#include <bits/stdc++.h> constexpr int DEBUG = 0; using namespace std; using int64 = long long; int64 Solve() { int n; cin >> n; string s0; cin >> s0; string s1; cin >> s1; vector<int> x0s; vector<int> x1s; for (int i = 0; i < n; i++) { if (s0[i] == '0') { x0s.push_back(i); } if (s1[i] ==...
#include <bits/stdc++.h> template <typename InputIterator> typename InputIterator::value_type summation(InputIterator first, InputIterator last) { return std::accumulate(first, last, typename InputIterator::value_type()); } template <typename T> std::istream &operator>>(s...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1e9; const long long inf = 1LL<<60; //cout << fixed << setprecision(10) << << endl; char judge(char a, char b) { if (a == b) return a; if (a == 'P') { if (b == 'R') { return a; } else { return b; ...
#include <math.h> #include <assert.h> #include <algorithm> #include <set> #include <iostream> #include <vector> #include <iomanip> #include <queue> #include <map> #include <string> #include <cstring> #include <functional> #include <stack> #include <array> #include <random> #include <chrono> #include <climits> #include ...
#include <bits/stdc++.h> using namespace std; const long long MOD=1000000007; // const long long MOD=998244353; #define LOCAL #pragma region Macros typedef long long ll; typedef __int128_t i128; typedef unsigned int uint; typedef unsigned long long ull; #define ALL(x) (x).begin(),(x).end() const int INF=1e9; const long...
#include <bits/stdc++.h> #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define show(x) cout << (#x) << " : " << x << endl; #define ll long long #define ull unsigned long long #define ld long double #define pow power #def...
#include<iostream> #include<algorithm> #include<cstdlib> #include<climits> using namespace std; int main(){ int n,m; long long children[200005]; long long teacher[200005]; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>children[i]; } for(int i=1;i<=m;i++){ cin>>teacher[i]; } sort(children+1,children...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#include "atcoder/all" using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef pair<ll, ll> P; ...
#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++) using ll = long long; using P = pair<int, int>; #define INF 1e18 #define MAX 200005 int main() { int n; cin >> n; set<int> a; rep(i,n+1) a.insert(i); vect...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll> pql; typedef set<ll> sl; typedef pair<ll, ll> pl; ty...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int T; cin >> T; while(T--){ int N; cin >> N; set<int> se; rep(i,N){ int a; cin >> a; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll MOD,dp[101][150000]; int main(){ for(int i=0;i<101;i++)for(int j=0;j<150000;j++)dp[i][j]=0; ll N,K,MOD; cin>>N>>K>>MOD; if(N==1){ cout<<K<<endl; return 0; } dp[1][0]=1,dp[1][K+1]=-1; for(int i=1;i<50;i+...
#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> using namespace std; // #include <atcoder/all> // using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; bool ok(long long N, std::string &S, std::vector<long long> &A, int m) { rep (i, m) { vector<ll> tmp(N+1); rep(j, N+1) { ...
#include <bits/stdc++.h> #define ALL(A) (A).begin(), (A).end() #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) 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; retu...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pint; typedef pair<ll,ll> pll; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<string> vstr; typedef vector<pint> vpint; typedef vector<pll> vpll; #define vint2(v,n,m,init) vector<vector<int>> v(...
/// kazuki08 /* #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/...
// D - Game in Momotetsu World #include "bits/stdc++.h" using namespace std; #ifndef DEBUG #define fundri 108 #define debug(...) 1729 #define endl '\n' #endif #define int int64_t typedef pair<int, int> pii; typedef vector<int> vi; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline int rnd...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree < pairs , null_type , greater<pairs>, rb_tree_tag , tree_order_statistics_node_update > #define ll long long #define lld long double #de...
#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; /*---------------------DEBUGGING--------------------------------------------*/ void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long...
#include<bits/stdc++.h> using namespace std; int n; int chk[100001]; int main(){ scanf("%d" , &n); for(int i = 0; i<n;i++){ int tmp; scanf("%d" , &tmp); if(chk[tmp]){ printf("No"); return 0; } chk[tmp]=1; } printf("Yes"); }
#include <iostream> #include <iomanip> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> #include <numeric> #include <array> #include <complex> using namespace std; #pragma...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false) #define rep(i, n) for(ll i=0; i<(ll)n; i++) #define ALL(obj) begin(obj), end(obj) typedef long long ll; vector<vector<int> > G(22); vector<int> color(22, -1), ts; vector<bool> vis(22, 0); int n, m, a, b; void dfs(int now){ ts.push_...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++) constexpr ll mod = 1000000007; void solve() { ll n; cin >> n; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; if(n % 2) { cout << "Second\n"; ...
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <string> #include <iomanip> #define _USE_MATH_DEFINES #include <math.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) using namespace std; i...
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <map> #include <unordered_map> using namespace std; #define debug(x) cout << #x << '=' << x << '\n' #define rep(i, b, e) for (int i = b; i <= e; i++) const int N = 212345; int n, a[N], b[N], c[N]; map<int, queue<i...
#include<bits/stdc++.h> using namespace std; int a[200010],b[200010]; queue<int>pos[200010]; map<int,int>id; int tot,n; int T[200010<<2]; int q(int rt,int l,int r,int pos){ if(l==r)return T[rt]; int mid=l+r>>1; if(pos<=mid)return T[rt]+q(rt<<1,l,mid,pos); else return T[rt]+q(rt<<1|1,mid+1,r,pos); } void ad(int rt,i...
// Template #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <iomanip> #include <tuple> #include <utility> #include <queue> #include <set> #include <map> #include <array> #include <cassert> #include <cmath> #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i...
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; void*wmem; char memarr[96000000]; template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){ static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, d[N], ans[N], last, fa[N], rt, st, mxd[N]; vector <int> e[N]; void dfs1_(int u) { mxd[u] = d[u] = d[fa[u]] + 1; for (int v, i = 0; i < (int) e[u].size(); i++) { v = e[u][i]; if (v == fa[u]) continue; fa[v] = u, dfs1_(v), mx...
/** ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀ ⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀ ⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀ ⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀ ⠀⡇⠀⠀⠀⠀...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #defin...
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <queue> using namespace std; const int mod = 998244353; int A[200010]; int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &A[i]); } sort(A + 1, A + 1 + n); int res = 0, ans = 0; A[n + 1] = 0; for...
#include <bits/stdc++.h> #define loop(s, e, i) for (int i = s; i < e; ++i) #define print(s) cout << s << endl; #define DIV 1000000007 using namespace std; typedef long long ll; typedef unsigned long long ull; const ll INF = 1e18+7; ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ ll floordiv(ll a, ll b) { retu...
#include<bits/stdc++.h> #include <iostream> using namespace std; int main() { long int n; cin>>n; if(n%100==0){ cout<<n/100; }else{ cout<<((n/100)+1); } return 0; }
#include<bits/stdc++.h> using namespace std; const int maxn=2e5+10; const int mod=1e9+7; char s[maxn];int n,vis[300],ans=0,cnt=0; int dp[maxn][17],f[maxn][17][17]; int mp[300]; void dfs(int pos) { if(pos>n) return; for(int i=1;i<=16;i++){ dp[pos][i]=(dp[pos][i]+1LL*i*dp[pos-1][i]%mod)%mod; dp[pos][i]=(dp[pos][i...
#include<iostream> #include<cstdlib> #include<utility> #include<tuple> #include<string> #include<vector> #include<numeric> #include<algorithm> #include<queue> #include<deque> #include<bitset> #include<cmath> #include<map> #include<string> #include<iomanip> #include<set> using namespace std; using ll = long long; const ...
#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() { int N; cin >> N; long long A[N], B[N]; long long sum = 0; for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; sum = sum + 0.5 * (B[i] - A[i] + 1)*(A[i] + B[i]); } cout << sum << endl; return 0; }