code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define ifs freopen("aa.in","r",stdin); #define ofs freopen("aa.out","w",stdout); #define iof ifs ofs #define ll long long #define ld ...
#include<iostream> #include<cstdio> #include<ctime> #include<cmath> #include<cstdlib> #include<cstring> #include<string> #include<vector> #include<iomanip> #include<fstream> #include<stack> #include<queue> #include<set> #include<map> #include<algorithm> #include<sstream> using namespace std; #define sync std::ios::sync...
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0);ios_base::sync_with_stdio(0); string to_string(string s) { return '"' + s + '"';} string to_string(char s) { return string(1, s);} string to_string(const char* s) { return to_string((string) s);} string to_string(bool b) { return (b ? "true" : "fa...
#include<bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for(int i=0;i<(int)n;i++) #define PI acos(-1) #define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0); ll mod=1e9+7; int main(){ fast_io ll n; cin >> n; vector<ll> A(n); ...
// Problem: E - Akari // Contest: AtCoder - AtCoder Beginner Contest 182 // URL: https://atcoder.jp/contests/abc182/tasks/abc182_e // Memory Limit: 1024 MB // Time Limit: 2500 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std...
#include <bits/stdc++.h> using namespace std; int main() { int h, w, n, m; cin >> h >> w >> n >> m; int map[h][w] = {}; int a, b, c, d, ans = 0; for (int i = 0; i < n; i++) { cin >> a >> b; map[a - 1][b - 1] = -1; ans++; } for (int i = 0; i < m; i++) { cin >> c >> d; map[c - 1][d - 1]...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> x(n), y(n); int ans = 0; for (int i=0; i<n; i++) cin >> x[i] >> y[i]; for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { if (i==j) continue; int dx = x[i] - x[j]; ...
#include <vector> #include <iostream> using namespace std; int main(){ int N; cin >> N; int a=0; vector<double> X(N,0); vector<double> Y(N,0); for (int i=0; i<N; i++){ cin >> X[i] >> Y[i]; } for (int i=0; i<N; i++){ for (int j=i+1; j<N; j++){ for (int k=j+1; k<N; k++){ if (X[i]==X[...
#include<bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';} template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_...
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define POPCOUNT(x) __builtin_popcount(x) template <typename T> void chmin(T &a, const T &b) { a = min(...
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <numeric> #include <functional> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vec...
#include<stdio.h> static inline int MPow(int a,int b,const int MOD){return b?1l*MPow(1l*a*a%MOD,b>>1,MOD)*(b&1?a:1)%MOD:1;} int main(void){int A,B,C;if(!scanf("%d %d %d",&A,&B,&C)){return 1;}return !putchar(MPow(A,MPow(B,C,4)+4,10)+48);}
// Problem: B - Alcoholic // Contest: AtCoder - AtCoder Beginner Contest 189 // URL: https://atcoder.jp/contests/abc189/tasks/abc189_b // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") ...
#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 <iostream> #include <string> #include <vector> #include <stack> #include <utility> #include <unordered_set> #include <map> using namespace std; typedef long long ll; typedef unsigned long long ull; int main() { int n; ll cost; cin >> n >> cost; map<int, ll> delta; for (int i = 0; i ...
#include "bits/stdc++.h" #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000...
#include <iostream> #include <sstream> #include <algorithm> #include <cstring> #include <cstdio> #include <string> #include <ctime> #include <cmath> #include <vector> #include <deque> #include <queue> #include <string> #include <cctype> #include <functional> using namespace std; #define REP(i,n) for(int i=0;i<(n);++i)...
//#pragma GCC optimize(2) //#include <bits/stdc++.h> #include <iostream> #include <set> #include <cmath> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <utility> #include <map> #define rush() int T;cin>>T;while(T--) #define ms(a,b) memset(a,b,sizeof a) #de...
#include<bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; using Graph = vector<vector<int>>; using P = pair<int, int>; #define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i)) #define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i)) #define all(x) (x).begin(),(x).end() ...
#include<bits/stdc++.h> using namespace std; bool f1; #define LL long long #define db double #define Max(a,b) ((a)<(b))&&((a)=(b)) #define Min(a,b) ((a)>(b))&&((a)=(b)) inline int rd() { int res=0; char ch; while(ch=getchar(),ch<48||ch>57); do res=(res<<1)+(res<<3)+(ch^48); while(ch=getchar(),ch>47&&ch<58); retur...
// // Created by Anton Gorokhov // #ifdef lolipop #define _GLIBCXX_DEBUG #endif #include <iostream> #include <cstddef> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <set> #include <map> #include <ctime> #include <unordered_map> #include <random> #include <iomanip> #include <cmat...
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define pb push_back #define COUT(x) cout << (x) << "\n" #define COUTF(x) cout << setpre...
#include<bits/stdc++.h> using namespace std; using LL=long long; using P=pair<int,int>; using T=tuple<int,int,int>; constexpr int mod=1000000007; constexpr int inf=1e9; constexpr double eps=1e-13; int in(){ int x; scanf("%d",&x); return x; } int main(){ int n=in(); string s,x; cin>>s>>x; for...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,cc,n) for(int i=cc...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using _lint = int; #define REP(i, n) for (_lint i = 0; i < (_lint)(n); i++) #define FOR(i, a, b) for (_lint i = (_lint)(a); i < (_lint)(b); i++) #def...
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<cmath> #include<set> #include<map> #include<queue> #include<iomanip> using namespace std; int main(){ int n; cin >> n; pair<int, int> a[n]; for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second; for(int i=0;i<(n-1);i++)...
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' // n acho que eu seja bom, mas eu ja fui pior using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const int oo = 1e9; const ll OO = 0x3f3f3f3f3f3f3f3fll; const int MOD = 1000000007; int main() { ...
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define rrep(i,n) for(int i = (n)-1; i >= 0; i--) #define rep1(i,n) for(int i = 1; i <= (n); i++) #define rrep1(i,n) for(int i = (n); i > 0; i--) #define ll long long #define pi pair<int, int> #define pll pair<ll, ll> #define F first #define S sec...
#include <bits/stdc++.h> using namespace std; #define int long long const int maxs = 2e5 + 5; int PARENT[maxs]; int SIZE[maxs]; vector<int>a; map<int,int>mp[maxs]; void SET(int V) { SIZE[V] = 1; PARENT[V] = V; } int FIND_SET(int V) { if(V == PARENT[V]) return PARENT[V]; else return PAR...
#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 int long long #define S second #define F first #define pb push_back #define all(c) (c).begin(),(c).e...
#include <bits/stdc++.h> using namespace std; int main() { int n,m; cin >> n >> m; vector<int> vec (n); for(int i=0; i<n; i++){ int x; cin >> x; vec.at(i) = x; } for(int i=0; i<m; i++){ int x; cin >> x; vec.push_back(x); } sort(vec.begin()...
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define fs first #define ss second #define fr(i,n) for(ll i=0;i<n;i++) #define fr1(i,a,n) for(ll i=a;i<n;i++) #define mp make_pair #define pb push_back using namespace std; const ll mod=1e9+7; const ll INF=LLONG_MAX; const ll NINF=LLONG_MIN; int ma...
#include <iostream> #include <array> #include <algorithm> #include <vector> #include <bitset> #include <set> #include <unordered_set> #include <cmath> #include <complex> #include <deque> #include <iterator> #include <numeric> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <string> #i...
#include <bits/stdc++.h> // header file includes every Standard library using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif // ONLINE_JUDGE ios_base::sync_with_stdio(false); double n,d; cin>>n>>d; cout<< ((n-d)/n)*100; re...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i,x,n) for(int i = x; i < n; ++i) #define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it) typedef long long ll; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll n,...
#include <bits/stdc++.h> #define ll long long using namespace std; ll k, n; const ll mod = 1e9 + 7; ll dp[200100][17], cdp[17][17]; ll nCr(ll n, ll r) { if (r == 0 || r == n) return 1; if(cdp[n][r] != -1) return cdp[n][r]; cdp[n][r] = (nCr(n-1, r-1) + nCr(n-1, r)) % mod; return cdp[...
#include <bits/stdc++.h> using namespace std; //↓AC-library使うなら //型関係 using Graph = vector<vector<int>>; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> pll; typedef priority_queue<int, vector<int>, greater<int>> PQ;//昇順priority_queue typedef unsigned long long int ull; typedef vector<int> vi; typ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> pll; typedef vector<ll> vll; #define repi(i,a,b) for(ll i=a;i<b;i++) #define rep(i,a) repi(i,0,a) #define rrep(i,a) for(ll i=a-1;i>=0;i--) #define MOD 1000000007 //debug #define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";f...
//In the name of ALLAH #include<bits/stdc++.h> using namespace std; #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl '\n' // User defined sizeof macro # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) #define ll long long int int main() { optimize(); int n,a,b;...
#include <bits/stdc++.h> #include <iostream> #include <queue> #include <stack> #include <vector> #include <string> #include <set> #include <map> #include <random> #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) #define repl(i,n) for (long long i = 0; i < (n); ++i) #defin...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define all(aa) aa.begin(), aa.end() int main(){ int n, ans=0; cin>>n; for(int a = 1; a <= n; a++) for(int b = 1; b <= n/a; b++) ans+=n/(a*b); cout<<ans<<endl; }
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<bitset> #include<cmath> #include<ctime> #include<queue> #include<map> #include<set> #define int long long #define lowbit(x) (x&(-x)) #define mid ((l+r)>>1) #define lc (x<<1) #define rc (x<<1|1) #define max Max #define min Min #define ab...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(200010); int ans = 0; for(int i = 0; i < n; i++){ int p; cin >> p; a[p] = 1; while(a[ans] == 1) ans++; cout << ans << endl; } }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) using namespace std; using ll = long long; int main() { int N; cin >> N; vector<int> n; rep(i, 0, N + 1) { n.push_back(i); } vector<int> ans; rep(i, 0, N) { int p; cin...
#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include<bits/stdc++.h> using namespace std; #define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++) #define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<ll,ll> Pll; typede...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; //cin>>t; while(t--){ ll n,k; cin>>n>>k; vector<ll>a(n); map<ll,ll>mp; for(int i=0;i<n;i++){ cin>>a[i]; mp[a[i]...
#include "bits/stdc++.h" using namespace std; typedef long long ll; void sum(vector<ll>&x, vector<ll>&y, int pos, ll total){ if(pos >= (ll)x.size()) return; y.push_back(total); sum(x, y, pos+1, total); y.push_back(total + x[pos]); sum(x, y, pos+1, total + x[pos]); } int main(){ ll n, t, ans ...
/* { ###################### # Author # # Gary # # 2020 # ###################### */ //#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") #pragma GCC optimize(2) #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #...
#include<bits/stdc++.h> // #include<atcoder/all> // #include<boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace atcoder; // using bint = boost::multiprecision::cpp_int; using ll = long long; using ull = unsigned long long; using P = pair<int,int>; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #de...
#include <iostream> #include <vector> #include <string> #include <list> #include <queue> #include <algorithm> #define rep(i, n) for(i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define MOD 998244353 #define PI 3.14159265358979323846 #define INF 1 << 30 using namespace std; t...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; cout << N - 1; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #defin...
#include<bits/stdc++.h> #define LL long long #define pb push_back #define SZ(x) ((int)x.size()-1) #define ms(a,b) memset(a,b,sizeof a) #define F(i,a,b) for (int i=(a);i<=(b);++i) #define DF(i,a,b) for (int i=(a);i>=(b);--i) using namespace std; inline int read(){ char ch=getchar(); int w=1,c=0; for(;!isdigit(ch);ch=g...
#include <bits/stdc++.h> using namespace std; int fanc(string S){ int ret=0; ret += S[0]-'0'; ret += S[1]-'0'; ret += S[2]-'0'; return ret; } int main() { string A,B; cin>>A>>B; int ans = max(fanc(A),fanc(B)); cout<<ans<<endl; return 0; //解説を見た }
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define fastIO ios_base::sync_with_stdio(false); cin.tie(0); #define mod 1000000007 int main() { double R,X,Y; cin>>R>>X>>Y; double K = sqrt(X*X + Y*Y); if(K == R) cout<<1<<endl; else if(K <= 2*R) cout<<2<<endl; else co...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; bool ll_sqrt(ll x, ll& lower_bound, ll& upper_bound) { constexpr ll ll_max = numeric_limits<ll>::max(); bool first_boost = true; lower_bound = 0; upper_bound = x; while (upper_bound - lower_bound > 1) { if (first_b...
#include <bits/stdc++.h> #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple<int,int>; double Sx, Sy, Gx, Gy; int main(){ std::cin.tie(nullptr); std::ios::sync_with_std...
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= *$* WRITER:kakitamasziru/OxOmisosiru *$* ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/ #ifdef LOCAL_JUDGE #define _GLIBCXX_DEBUG #endif #include <stdio.h> #include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorit...
#include <bits/stdc++.h> #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); #define lowbit(x) (x & -x) #define FOR(i,a,b) for(int i=(a); i< (b); ++i) #define RFOR(i,b,a) for(int i=(b);i>=(a);i--) #define REP(i,a,b) for(int i=(a); i<=(b); ++i) #define PI 3.14159265358979323846264338327950L using nam...
#include <bits/stdc++.h> using namespace std; #define int int64_t void __print(int x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x...
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define ii pair<int, int> #define OK (cerr << "OK" << endl) #define debug(x) cerr << #x " = " << (x) << endl #define ff first #define ss second #define int long long #define tt tuple<int, int, int> #define all(x) x.begin(), x.end() #define vi vecto...
#include<bits/stdc++.h> using namespace std; const int N = 810; typedef long long ll; int g[N][N]; int s[N][N]; int n, k; bool check(int x) { for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + (g[i][j] >= x); for(int i=k;i<=n;i++) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; //bool vis[1000]; //int x[]={1,-1,0,0}; //int y[]={0,0,1,-1}; //int f=0; //"''; void dfs(int i,ll d,vector<vector<vector<ll> > > &adj,vector<ll> &v){ v[i]=d; //cout<<i<<" "<<d<<endl; for(int j=0;j<adj[i].size();j++){ int ...
// // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/`---'\___ // .' \\| |// '. // / \\||| : |||// \ // / _||||| -:- ||||...
#include <bits/stdc++.h> using namespace std; #define deb(k) cerr << #k << ": " << k << "\n"; #define size(a) (int)a.size() #define fastcin cin.tie(0)->sync_with_stdio(0); #define st first #define nd second #define pb push_back #define mk make_pair #define int long long typedef long double ldbl; typedef double dbl; typ...
//! 尺卂乃卂.卂フ乇乇ㄒ #include<bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; //Using namespace __gnu_pbds; //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set; #define ll long long #define int long long #define ld...
/*************************************************************** File name: D.cpp Author: ljfcnyali Create time: 2021年02月21日 星期日 21时00分33秒 ***************************************************************/ #include<bits/stdc++.h> using namespace std; #define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; +...
#include<bits/stdc++.h> using namespace std; struct{template<class T>constexpr operator T(){return numeric_limits<T>::max();}constexpr auto operator-();}inf; struct{template<class T>constexpr operator T(){return numeric_limits<T>::lowest();}constexpr auto operator-();}negative_inf; constexpr auto decltype(inf)::operat...
//* Jai shree Ram #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define lli long long int #define ll long long #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define vi ...
#include<bits/stdc++.h> using namespace std; int main(){ int a, b, c; cin >> a; cin >> b; cin >> c; int d = 21 - (a+b+c); cout << d; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int arr[4],sum=0; for(int i=0;i<3;i++){ cin>>arr[i]; int x=arr[i]; if(x==1) sum+=6; else if(x==2) sum+=5; else if(x==3) sum+=4; else if(x==4) sum+=3; else if(x==5) sum+=2; else if(x==6) sum+=1; } cout<<sum; return 0; }
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define ii pair<int, int> #define OK (cerr << "OK" << endl) #define debug(x) cerr << #x " = " << (x) << endl #define ff first #define ss second #define int long long #define tt tuple<int, int, int> #define all(x) x.begin(), x.end() #define vi vecto...
#pragma GCC optimize("Ofast") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <vector> #include <set> #include <map> #include <unordered_map> #define lli long long int #define loop(i,x,n) for(int i=x;i<n;i++) #define loopr(i,x,n) for(int i=n-1;i>=x;i--) #define st set<l...
/* これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました */ #include <bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define fi first #define se second #define all(x) (x).begin(),(x).end() #define S(x) (int)(x).size() #define L(x) ...
#include <bits/stdc++.h> using namespace std; static const bool LOCAL_TEST = false; vector<vector<int>> h(30, vector<int>(30, 5000)); vector<vector<int>> v(30, vector<int>(30, 5000)); int si, sj, ti, tj; int b, result; double a, e; int prev_result; double score; string path; void read_h_v() { for (int i = 0; i <...
#include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i < b; i++) #define rrep(i, a, b) for(int i=a; i >=b; i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(), (x).end() using namespace std; void _main(); int main() {cin.tie(0); ios::sync_with_stdio(false); _main();} typedef long long ll; const in...
#include<bits/stdc++.h> #define ll long long int #define ld long double #define ff first #define ss second #define mod 1000000007 #define ull unsigned long long #define vll vector<ll> #define uom unordered_map #define uo...
#include "bits/stdc++.h" using namespace std; typedef pair<int,int>pii; typedef long long ll; typedef pair<ll,ll> pll; typedef __int128 lll; typedef vector<int> vi; typedef vector<ll> vl; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); const ll inf=0x3f3f3f3f3f3f3f3f; const int mn=101; const ll mod...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; #define fi first #define se second #define mp make_pair #define pb push_back #define all(a) a.begin(),a.end() typedef pair<ll,ll> pi; //__builtin_popcountll(2) (the number of ones in the binary represe...
#include<bits/stdc++.h> using namespace std; const int N=20; int n,m,s[N],g[N][N]; long long dp[N][1<<N]; int main() { cin>>n>>m; memset(g,0x3f,sizeof g); //前x个 最多有z个小于等于y //y-1 映射到二进制的0 ~ n-1 for(int i=1,x,y,z; i<=m; ++i) cin>>x>>y>>z,--y,g[x][y]=min(g[x][y],z); dp[0][0]=1; for(int i=0; i<n; ++i) for...
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i < b; ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << #define sz(x) ((int) x.size()) #define pb(x) push_back(x) #define TRACE(x) cerr << #x << " = " << x << endl typedef long long ll; typedef pair<int, int> point; const int mod...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mod 1000000000 #define endl "\n" #define PI 3.14159265358979323846264338327950288 using namespace std ; using bigint = long long int ; using ...
//* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //*/ #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "<<x<<endl; #define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<"...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int p[n+1]; for(int i=1;i<=n;i++){ cin >> p[i]; } int dis[n]; int dissum=0; int absdissum=0; for(int i=1;i<=n;i++){ dis[i]=p[i]-i; if(dis[i]==0){ printf("-1"); return 0; } dissum+=...
#include <bits/stdc++.h> #include <fstream> using namespace std; #define all(a)a.begin(),a.end() using ll=long long; const int INF = 1<<30; const ll INFll =1LL<<62; //const int mod= int(1e9)+7; const int mod=998244353; using P = pair<int,int>; using Pl= pair<ll,ll>; using ld=long double; using V=vector<int>; using Vl=...
#include<bits/stdc++.h> using namespace std; int main() { int N; int ans=0, tmp, maxa=0, maxb=0, maxc=0, maxd=0, maxe=0, ai, bi, ci, di, ei; cin >> N; vector<int> a(N), b(N), c(N), d(N), e(N), m(5); for(int i=0; i<N; i++){ cin >> a[i] >> b[i] >> c[i] >> d[i] >> e[i]; if(maxa < a[i]){ maxa =...
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<cmath> #include<iomanip> #include<cstring> #include<complex> #include<cstdio> #define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1; #define fi first #define se second #define pb push_back #d...
#include<bits/stdc++.h> using namespace std; using ll = long long; using pint = pair<ll,ll>; // #include"debug.hpp" void calc(vector<ll> A) { const ll M = 60; const ll mod = 1e9 + 7; ll n = A.size(); vector<ll> dig(M); for(ll i = 0; i < n; i++) { ll a = A[i]; for(ll j = 0; j < M; j++) if((1LL<<j) & (a))dig[j...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, k, m; cin >> n >> k >> m; int sm = 0; rep(i, n - 1) { int a; cin >> a; sm += a; } int ans = m * n - sm; if (ans < 0) ans = 0; if ...
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) int T; int extGCD(int a, int b, int &x, int &y) { if(b == 0) { x = 1; y = 0; return a; } int ret = extGCD(b, a % b, y, x); y -= a / b * x; return ret; } int unit(...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(int argc, char const *argv[]) { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (c % 2 == 0) { if (a < 0) a = -a; if (b < 0) b = -b; } if (a == b) printf("=\n"); if (a > b) printf(">\n"); if (a < b) printf("<\n"); retu...
#include <iostream> using namespace std; int hantei(long long n); int main(){ long long t, n; cin >> t; for (int i = 0; i < t; i++){ cin >> n; if (hantei(n) == -1) cout << "Odd" << endl; else if (hantei(n) == 0) cout << "Same" << endl; else if (hantei(n) == 1) cout << "Even" << endl; } retur...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define rng(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i) #define per(i, b) gnr(i, 0, b) #define all(obj) begin(obj), end(obj) #define allr(ob...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef pair<int, int> pii; #define endl "\n" #define sd(val) scanf("%d", &val) #define ss(val) scanf("%s", &val) #define sl(val) scanf("%lld", &val) #define debug(val) printf("check%d\n", val) #define all(v) v.begin(), v.end() #define pb push_back ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define ff first #define ss second #define rep(i, n) for(int i = 0; i < n; ++i) #define repR(i, n) for (int i = n-1; i >= 0; --i) #define repA(i, a, n) for (int i = a; i <= n; ++i) #de...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <unordered_map> #include <stack> #include <math.h> #include <queue> #include <functional> #include <iomanip> using namespace std; #define ll long long bool comp(pair<int,int> a, pair<int,int> b){ return a.first<b....
#include<bits/stdc++.h> using namespace std; int read(); #define LL long long #define fr(i,l,r) for(int i = (l);i <= (r);++i) #define rf(i,l,r) for(int i = (l);i >= (r);--i) #define fo(i,l,r) for(int i = (l);i < (r);++i) #define foredge(i,u,v) for(int i = fir[u],v;v = to[i],i;i = nxt[i]) #define ci const int & #define...
#include <algorithm> #include <iostream> using namespace std; typedef long long ll; const ll INF = 10000000000009; int main() { int n, m; cin >> n >> m; ll h[200005], w[200005]; for(int i = 0; i < n; i++) cin >> h[i]; for(int i = 0; i < m; i++) cin >> w[i]; sort(h, h + n); sort(w, w + m); ...
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define ll long long #define int ll #define pb push_back #define mp make_pair #define pii pair<ll,ll> #define ff first #define ss second #define vi vector<ll...
#include<stdio.h> #include<queue> #define INF 1000000000000007 #define int long long using namespace std; struct pr{ int now; int data; }; int a[25]; queue<pr> q; signed main(){ int n,ans=INF; scanf("%lld",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); pr x;x.data=0;x.now=1; q.push(x); while(!q.empty()){ x=q...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int A[3]; rep(i, 3) cin >> A[i]; sort(A, A+3); ...
//----------BHAVIK DIWANI(PICT_COMP)--------------- #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define test ll t; cin>>t; while(t--) #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define mod 1000000007 #define ll long long #define int long...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<int>>; ll inf=300000000000000000; const d...
#include <bits/stdc++.h> #ifndef M_PI #define M_PI 3.14159265358979 #endif #define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI) #define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360) using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef pair<int, int> ...
#include <bits/stdc++.h> using namespace std; #define ll long long const int mod = 1e9 + 7; //1.takes nothing returns nothing //2.takes nothing returns something //3.takes something returns something //4.takes something returns nothing int digi(ll n){ ll f=0; while(n>0){ n/=10;f++; } return f; ...
#include<bits/stdc++.h> #define ll long long int #define ld long double using namespace std; #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define mp make_pair #define fi first #define se second #define pb push_back #define endl "\n" #define maxpq priority_queue<ll> #define minpq priority...
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define vl vector<ll> #define all(v) v.begin(), v.end() #define endl "\n" #define MOD 1e9 + 7 int main() { int n, i, j; cin >> n; int A[n], B[n]; for (i = 0; i < n; i++) cin >> A[i]; for (i = 0; i ...
#include <bits/stdc++.h> #define setIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define PI 3.14159265358979 #define f first #define s second #define ar array using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<string, int> psi; typedef pair<long long, long long> pll; typedef pai...
#include <bits/stdc++.h> using namespace std; char s[4]; int main() { cin >> s; cout << s[1] << s[2] << s[0] << endl; return 0; }
#include <iostream> #include <vector> #include <deque> #include <algorithm> #include <numeric> #include <string> #include <cstring> #include <list> #include <unordered_set> #include <tuple> #include <cmath> #include <limits> #include <type_traits> #include <iomanip> #include <map> #include <unordered_map> #include <que...
#include<bits/stdc++.h> using namespace std; int main () { long long int n, t, save; cin >> n; t= 0; for(long long int i=1; ; i++) { t+= i; if(t>=n) { save= i; break; } } cout << save << endl; return 0; }
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#def...
#include<bits/stdc++.h> #include<chrono> using namespace std; using namespace chrono; typedef long long int lli; typedef long long ll; lli M=1000000007; lli mod(lli a) { return ((a%M+M)%M);} lli add(lli a,lli b) { return mod(mod(a)+mod(b));} lli multiply(lli a,lli b) { return mod(mod(a)*mod(b));} lli min(lli a,lli ...
#include <iostream> #include <iomanip> #include <cmath> #include <cstring> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <map> using namespace std; #define fr(i, s, t) for(int (i) = s; (i) <= t; (i)++) typedef long long ll; const int MAX_V = 100005; const int IINF = 0x3f3f3f3f; ...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define setIO(x) freopen(x".in", "r", stdin), freopen(x".out", "w", ...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define ...
#include<bits/stdc++.h> #define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);} #define all(x) (x).begin(), (x).end() #define Unique(a) a.erase(unique(all(a)), a.end()) #define ld long double #define pb push_back #define fi first #define se second #define inf 1e9 using namespace std; typedef long long ...
#include <bits/stdc++.h> using namespace std; #define vll vector<long long> #define mll map<long long,long long> #define pll pair<long long,long long> #define pb push_back #define F first #define S second #define all(v) v.begin(),v.end() #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define mod 9...
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast") #define ll long long #define ull unsigned long long #define pll pair<long long,long long> #define pii pair<int,int> #define pb push_back #define mp make_pair #define F first #define S second #define forn(i, n) for(int i=0; i<int(n); i++) #define Forn(i, n) for(int...
#include<iostream> using namespace std; int main() { float a,b; cin >> a; cin >> b; cout << a*(b/100); return 0; }
#include <iostream> #include <cmath> int main(void) { int64_t A; int64_t B; int64_t C; std::cin >> A >> B >> C; if (C % 2 == 0) { if (std::abs(A) == std::abs(B)) { std::cout << "=" << std::endl; } else if (std::abs(A) < std::abs(B)) { std::cout << "<" << std::endl; } else { ...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); #define cerr if(0) cerr #define ll long long int #define fp cout<<fixed<<setprecision(15); #define loop(var,s,n) for(ll var=s ;var<n;var++) #define rloop(var,s,n) for(ll var=s ;var>=n;var--) #define pb push_back #define endl '\n' #d...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define REPR(i, n) for(int i = n - 1; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i < n; i++) #define FORR(i,m,n) for(int i = m - 1; i >= n; i--) #define ALL(v) v.begin(), v.end() #define itn int #define Yes() cout << "Yes" ...
#include <stdio.h> #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <...
#include <iostream> using namespace std; int main() { int N; string s,t; cin >> N >> s; for (char c: s) { t.append(1,c); if (t.length()>2 && t.substr(t.length()-3,3) == "fox") { t.resize(t.length()-3); } } cout << t.length() << endl; }
//IQ134高知能系Vtuberの高井茅乃です。 //Twitter: https://twitter.com/takaichino //YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw #include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF INT_MAX #define LLINF LLONG_MAX #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(int i=1;i<...
#include<bits/stdc++.h> using namespace std; #define rep(i, a, n) for(int i=(a); i<(n); ++i) #define per(i, a, n) for(int i=(a); i>(n); --i) #define pb emplace_back #define mp make_pair #define clr(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(),(x).end() #define lowbit(x) (x & -x) #define fi first #define se...
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<stdio.h> #include<algorithm> constexpr long long MOD = 998244353; constexpr long long MOD32 = 665496236; int main(){ long H=0, W=0, K=0; char c=getchar_unlocked(); while(c<='9'&&c>='0') {H=(H<<1)+(H<<3)+c-'0...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for(int i=0; i<n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vect...
#include <bits/stdc++.h> #include <numeric> using namespace std; #define int long long #define FOR(i, size) for (int i = 0; i < size; i++) #define all(x) x.begin(), x.end() #define endl "\n" #define MOD 1000000007 #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template <typename... Args> void logger(string vars, ...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<stack> #include<queue> #include<map> #include <utility> #include<functional> #include<math.h> using namespace std; #define rep(i,n) for(ll i=0;i<(n);i++) #define REP(i,l,n) for(ll i=(l);i<(n);i++) #define per(i,n) for(ll i=(n);i>0;i--) #d...
#include<bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int long long int #define fi first #define se second #define pub push_back #define pi pair<int,int> #define all(v) (v).begin(), (v).end() #define rep(i, l, r) for(int i=(int)(l);i<(int)(r);...
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; double ans = 0; for (int i = 1; i <= n-1; i++){ ans += 1.0*n/i; } cout << fixed << setprecision(8) << ans << endl; return 0; }
#include<bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define...
#include<iostream> using namespace std; int main() { int n,x[201],y[201],a[201],b[201],c[201],d[201]; int i,j,rr; long long int r[201]; cin >> n; for(i=0;i<n;i++){ cin >> x[i] >> y[i] >> r[i]; if(x[i]==0 || y[i]==0){ if(x[i]==0 && y[i]==0){ a[i]=b[i]=0; c[i]=x[i]+1; d[i]=...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n; cin >> n; vector<ll> x(n); vector<ll> y(n); vector<ll> r(n); for(int i = 0;i < n;i++)cin >> x[i] >> y[i] >> r[i]; for(int i = 0;i < n;i++){ ll xsi = 0; ll ysi = 0; ll xmin = 10000; ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define repn(i,n) for(int i=1;i<=n;++i) #define LL long long #define pii pair <int,int> #define fi first #define se second #define pb push_back #define mpr make_pair using namespace std; const LL MOD=1e9+7; int n,a[200010],b[200010],p[200010],pos[200010...
//Jo Hack kiya Wo Madharchod #include"bits/stdc++.h" #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define ll long long int #define inf 1e18+5 #define sr string #define M 1000000007 //998244353// #define start int t;cin>>t;while(t--) #define db(x) cout<<#x<<"="<<x<<"\n" #define db2(a,b)c...
#include <bits/stdc++.h> #define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++) #define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++) using namespace std; using ll = long long; using pint = pair<int, int>; template <class T> void chmin(T& a, T b) { if (a > b) a = b; } template <class T> void chmax(T& a, T b) {...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; #define rep(i,a) for(i=0;i<=a;i++) #define repr(i,a) for(i=a;i>=0;i--) #define repp(i,a,b) for(i=a;i<=b;i++) #define reppr(i,b,a) for(i=b;i>=a;i--) #define maxarr(a,n) *max_element(a,a+n); #defin...
#include <bits/stdc++.h> #define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++) #define forn(i,n) forsn(i,0,n) #define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--) #define debug(x) cout << #x << " = " << x << endl using namespace std; typedef long long tint; random_device rd; mt19937 gen(rd()); uniform_int_dist...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--) #define rrep(i,n) RREP(i,(n)-1,0) #define all(v) v.begin(), v.end() #define endk '\n' co...
#include<bits/stdc++.h> using namespace std; const int N=1e5; vector<int>v[N]; int main() { int n; cin>>n; string s; cin>>s; if(s[0]==s[s.size()-1]) { char x=s[0]; int o=0; for(int i=1; i<s.size()-1; i++) { if(x!=s[i] && x!=s[i+1]) { o=1; break...
/*######################################################################## # File Name: d.cpp # Author: SoMnus_L # Mail: lr599909928@gmail.com # Created Time:六 5/15 22:12:23 2021 ########################################################################*/ #include <bits/stdc++.h> #define ll long long #define fi first #d...
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long int N; int A[100101]; double f(double X) { double ret = 0; for(int i=1; i<=N; i++) { ret += X + A[i] - min(1.0*A[i], X+X); } ret /= N; return ret; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin.exceptions(io...
#include <iostream> #include <fstream> #include <set> #include <map> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <functional> #include <algorithm> #include <climits> #include <cmath> #include <iomanip> using namespace std; #define ll long long int #define rep(i,n) for...
#include <iostream> #include <iomanip> #include <assert.h> #include <vector> #include <string> #include <cstring> #include <sstream> #include <map> #include <set> #include <queue> #include <algorithm> #include <numeric> #include <cmath> using namespace std; typedef long long ll; typedef unsigned long long ull; typede...
#include<bits/stdc++.h> using namespace std; int main() { int x,y; cin>>x>>y; if(abs(x-y)<3) { cout<<"Yes"; } else { cout<<"No"; } cout<<endl; return 0; }
#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...
//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 /**#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unro...
#include <iostream> #include <math.h> #include <iomanip> #include <bits/stdc++.h> #include <string.h> #include <string> #include <algorithm> #define ll long long int #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; ll binomialCoeff(ll n,ll k) { ll res = 1; if(k >n - k) ...
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1e9 + 7; vector<long long int> inverse; void factorial_Initialize(int max){ inverse.assign(max+1,1); for (int i=2; i<=max; i++){ inverse[i] = MOD - inverse[MOD % i] * (MOD / i) % MOD; } } long long int nCr(int n, int r){ ...
#include <bits/stdc++.h> using namespace std; //TEMPLATE #define len(a) (ll) a.size() #define ms(a, x) memset(a, x, sizeof a) #define bitcount(n) __builtin_popcountll(n) #define FR ios_base::sync_with_stdio(false);cin.tie(NULL) #define cin1(a) cin >> a #define cin2(...
//ll min_len[1<<8]; //void __(){ // _(ll,n); // _(ll,m); // _(vl,a,n); // _(vpll,b,m); // rep(bm,1<<n){ // ll w = 0; // rep(i,n) // if(bm&(1<<i)) // w += a[i]; // rep(i,m){ // if(b[i].Y < w) // min_len[bm] = max(min_len[bm],b[i].X);...
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define X first #define Y second #define nl '\n' #define AC return 0 #define pb(a) push_back(a) #define mst(a,b) memset(a, b, sizeof a) #define rep(i,n) for(int i = 0; (i)<(n); i++) #define rep1(i,n) for(int i = 1; (i)<=(n); i++) #de...
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using pll = pair<ll, ll>; using vpll = vector<pll>; using ld = long double; using vld = vector<ld>; using vb = vector<bool>; #define rep(i, n) for ...
#include <bits/stdc++.h> using namespace std; int main(){ string S; cin >> S; int N = S.size(); bool ok = true; for (int i = 0; i < N; i++){ if (i % 2 == 0){ if (isupper(S[i])){ ok = false; } } else { if (islower(S[i])){ ok = false; } } } if (ok){ co...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // THINGS TO REMEMBER // ENDL is slow, '\n' is fast // Clear everything (including graphs) between test cases // use anti-anti-hash: https://codeforces.com/blog/entry/62393 // pb-ds: https://codeforces.com/blog/entry/11080 // check when to use LLONG_M...
#include<iostream> #define MAX_N 300000 using namespace std; typedef long long ll; ll N, a[MAX_N], ans[MAX_N]; ll bit[MAX_N + 1]; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= N) { bit[i] += x; i += i & -i; } } int main() {...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<vector<int>>C(N, vector<int>(N)); for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ cin >> C[i][j]; } } vector<int>A(N); vector<int>B(N); int mini=1000000001; for(int i=0; i<N; i++){ B[i]=C[0][i]-C[0...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long modpow(long long a, long long b){ long long ans = 1; while (b > 0){ if (b % 2 == 1){ ans *= a; ans %= MOD; } a *= a; a %= MOD; b /= 2; } return ans; } long long modinv(long long a){ return modpow(a, MOD - 2); ...
// Author : Shivraj Ahirwar // #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < n; ++i) #define rep1(i,n) for (int i = 1; i < n; ++i) #define REP(i,k,n) for (int i = k; i <= n; ++i) #define REPR(i,k,n) for (int i = k; i >= n; --i) #define ll long lon...
#include<bits/stdc++.h> using namespace std ; #define Next( i, x ) for( register int i = head[x]; i; i = e[i].next ) #define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i ) #define drep( i, s, t ) for( register int i = (t); i >= (s); -- i ) #define re register #define int long long int gi() { char cc = getc...
#include <bits/stdc++.h> using namespace std; using ll = long long; 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; return true; } return false; } map<ll, ll> memo; ll x, y; ll solve(ll y) { i...
//→__int128_tを使う&GNU C++17 (64)で提出する //インクルードなど #include<bits/stdc++.h> using namespace std; typedef long long ll; //イテレーション #define REP(i,n) for(ll i=0;i<ll(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll(b);i--) #define FORA(i,I) for...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,x,n) for(int i=x; i<(n); i++) #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define rng(v) v.begin(),v.end() #define rngr(v) v.rbegin(),v.rend() const long long INF = 1LL << 60; using name...
#include <cstdio> #include <cstring> #define N 110 #define mo 998244353 using namespace std; int f[N][5010]; int n, w[N]; int sum; int jc[N]; int ans; int main(){ // freopen("funny.in", "r", stdin); scanf("%d", &n); for (int i=1; i<=n; i++) scanf("%d", &w[i]), sum+=w[i]; jc[0]=1; for (int i=1; i<=n; i++) jc[i]=1...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef pair<int,int> Pair; typedef tuple<int,int,int> tpl; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) const ll MAX = 1001001; const ll MOD = 1000000007; const long double pi = 2.0 * asin(1.0); ll dx[4] = {1, 0, -1, 0}; ll ...
#include <bits/stdc++.h> using namespace std; const int P = 1e9+7; /*struct mat{ int a[3][3]; void start() { for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { a[i][j] = 0; } } for (int i = 0; i < 2; ++i) { a[i][i] = 1; ...
#include <bits/stdc++.h> #include <math.h> using namespace std; template<typename T> long long modpow(const T n,const T p,const T mod); template<typename T> long long modinv(const T n,const T mod); template<typename T> bool chmax(T &a,const T &b); template<typename T> bool chmin(T &a,const T &b); long long inf=10000...
#include <bits/stdc++.h> #define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i) #define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i) #define Set(a, v) memset(a, v, sizeof(a)) #define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout) using namespace std; bool chkmin(int &a, ...
#pragma region Region_1 #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() using ll = long long; using ...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; class FenwickTree { private: int bit_size; vector<LL> bit; public: FenwickTree(int siz): bit_size(siz), bit(siz + 1) {} void add(int num, LL val) { ...
#include <bits/stdc++.h> using namespace std; int main(){ int N,M; cin >> N >> M; if(M==0){ cout << 1 << endl; }else{ vector<int> A(M), S(M+1); int k=N; for(int i=0; i<M; i++) cin >> A[i]; sort(A.begin(),A.end()); for(int i=0; i<M; i++){ if(i==0){ S[0]=A[0]-1; if(S[0...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using pl = pair<ll, ll>; using vl = vector<ll>; using vp = vector< pair<ll, ll> >; using vvl = vector<vl>; using vs = vector<string>; #define pi 3.14159265359; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (ll)(s); ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n)for(int i=0;i<(int)(n);++i) #define fixed(n)fixed<<setprecision(n) #define ll long long #define ALL(a)a.begin(),a.end() #define LLA(a)a.rbegin(),a.rend() template<class T>void chmin(T& a,T b){ if(a>b){ a=b; } } template<class T>void chmax(...
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = std::vector<int>; using Vl = std::vector<ll>; using Pii = std::pair<int, int>; using Pll = std::pair<ll, ll>; constexpr int I_INF = std::numeric_limits<int>::max(); constexpr ll L_INF = std::numeric_limits<ll>::max(); templ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int inf=0x3f,INF=0x3f3f3...
#include<iostream> #include<cstdio> #include<cstring> #define MAXM 25 typedef long long ll; using namespace std; ll n,m; ll cnt[3],ans; char a[MAXM]; int main(){ cin>>n>>m; ll zz = 0; for(int i = 1 ; i <= n ; i++){ zz = 0; scanf("%s" , a + 1); for(int j = 1 ; j <= m ; j++)zz += (a[j] == '1'); zz %= 2; if...
#include<bits/stdc++.h> using namespace std; #define ll long long int main() {ll n; cin>>n; ll ans=0; ll a[n],b[n]; for(ll i=0;i<n;i++)cin>>a[i]; for(ll j=0;j<n;j++)cin>>b[j]; for(ll i=0;i<n;i++)ans+=a[i]*b[i]; if(ans==0)cout<<"Yes"<<endl; else cout<<"No"<<endl; }
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; typedef long long ll;typedef long double ld;typedef vector <int> vi;typedef vector <ll> vll;typedef vector <string> vS;typedef vector <vector <int>> vv;typedef map<int, int> mi;typedef map<string, int> ms;typedef map<char, int> mc;typedef str...
// B - Plus Matrix #include <bits/stdc++.h> using namespace std; #define vec vector using vi = vec<int>; #define rep(i,e) for(int i=0;i<(e);++i) int main(){ int n; cin>>n; vec<vi> C(n, vi(n)); rep(i, n) rep(j, n) cin>>C[i][j]; vi B(n, 1e9), A(n, 0); rep(i, n) rep(j, n) B[i] = min(B[i], C[j][i]); rep(i, n){ rep(...
#include<bits/stdc++.h> using namespace std; #define ll long long #define f(i,a,b) for(int i=a;i<=b;i++) inline ll r() { ll x=0,f=1; char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c))x=x*10+c-'0',c=getchar(); return x*f; } #define d r() ll n,tmp,k; int main(){ n=d; if(n==0){ co...
#include<bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000030; constexpr ll INF= 2000000000000000000; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int,int> P; typedef pair<int,P> PP; template<class T> inline bool chmax(T &a, T b) { if (a < b) { ...
#include <bits/stdc++.h> using namespace std; void DBG() { cerr << endl; } template<class Head, class... Tail> void DBG(Head H, Tail... T) { cerr << ' ' << H; DBG(T...); } #define dbg(...) cerr << "(" << (#__VA_ARGS__) << "):", DBG(__VA_ARGS__) using ll = long long; using ld = long double; #define sqr(a) ll(a) * (a)...
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define db double #define pii pair<int,int> #define pli pair<ll,int> #define pil pair<int,ll> #define pll pair<ll,ll> #define ti3 tuple<int,int,int> #define mat vector<vector<int>> const int inf = 1 << 30; const ll mod = 1e...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #ifdef ENABLE_DEBUG #define dump(a) cerr<<#a<<"="<<a<<endl #define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl #else #define dump(a) #define dumparr(a,n) #endif #...
#include<bits/stdc++.h> #include<cmath> #define pb push_back #define ld long double #define mp make_pair #define vl vector<ll> #define vd vector<double> #define vld vector<long double> #define ll long long int #define pl pair<ll, ll> #define all(a) a.begin(), a.end() #define forr(i, n) for(ll i=0; i<n; i++) #define f...
#include <cmath> #include <cstdio> #include <bits/stdc++.h> using namespace std; long long S = 1; void dfs(int i ,vector<int> arr[] , vector<bool>& v){ v[i] = true; long long a = 3; if(arr[i].size()> 2) S = 0; for(int k = 0; k < arr[i].size() ; k++){ if(!v[arr[i][k]]) a--; ...
#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; // typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define scn(n)...
#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 <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i=1; i < (int)(n); i++) #define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--) #define rreps(i, n) for (int i=((int)(n)-1); i>0; i--) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) using name...
#include <bits/stdc++.h> using namespace std; // #define LOCAL // 提出時はコメントアウト #define DEBUG_ typedef long long ll; const double EPS = 1e-9; const ll INF = ((1LL<<62)-(1LL<<31)); typedef vector<ll> vecl; typedef pair<ll, ll> pairl; template<typename T> using uset = unordered_set<T>; template<typename T, typename U> usi...
#include <stdio.h> using namespace std; long long pr[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}; long long a, b, n, ans = 1; long long dp[1 << 21]; long long te[73]; void dfs(long long now, long long t) { if (t == n) { return; } for (int i = t; i < n; i++) { if (...
#include<bits/stdc++.h> using namespace std; const int64_t MAX = 10000000000; int64_t is_valid(string &S, string &T){ int64_t ret = -1; for(int i=0; i<S.size() - T.size()+1; i++){ bool flag = true; for(int j=0; j<T.size(); j++){ if(S[i+j] != T[j]){ flag = false; } } if(flag){ ...
#include "bits/stdc++.h" #pragma GCC optimize "trapv" #define int long long #define For(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define endl "\n" #define F first #define S second #define drink_boost ios_base::sync_with_stdio(false);cin.tie(NULL) #define all(v) v.begin(),v.end() #define TEST_CASE int t;c...
#include <bits/stdc++.h> #define endl "\n" #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 e_b emplace_back #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ipair; typedef pair...
#include<cstdio> #include<iostream> #include<cmath> #define ll long long using namespace std; int main() { ll n; scanf("%lld",&n); for(ll i = 1; i<=sqrt(n); i++) { if(n%i==0) cout<<i<<endl; } for(ll i = sqrt(n); i>=1; i--) { if(i*i!=n) if(n%i==0) cout<<n/i<<endl; } }