code_file1
stringlengths
87
4k
code_file2
stringlengths
82
4k
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <set> using namespace std; typedef long long LL; #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define ALL(x) (x).begin(),(x).end() const int IINF = 1e9; const LL LINF...
#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>; double dp[105][105][105]; int main() { ll A, B, C; cin >> A >> B >> C; for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { for (i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define ...
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0, length = n; i < length; i++) #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ep emplace #define epb emplace_back #define scll static_cast<long long> #define sz(x) static_cast<int>((x).size()) #define pfll(x) printf("%lld...
#include <bits/stdc++.h> using namespace std; int main() { // freopen("input.in", "r", stdin); int n, k, m; scanf("%d %d %d", &n, &k, &m); m *= n; for (int i = 1; i < n; ++i) { int a; scanf("%d", &a); m -= a; } m = max(m, 0); if (m <= k) printf("%d\n", m); else puts("-1"); return 0; }
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,n) for(ll i=0;i<(n);i++) #define rrep(i,n) for(ll i = 1; i <= (n); ++i) #define drep(i,n) for(ll i = (n)-1; i >= 0; --i) #define all(v) v.begin(),v.end() #define len(x) (ll)(x).length() #define maxs(x,y) x = max(x,y) #define mins(x,y) x = min(x,y...
#include <bits/stdc++.h> using namespace std; #define FIO ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); #define int long long #define mod 1000000007 typedef vector<int> vi; typedef vector<bool> vb; #define ff first #define ss second #define pb push_back #define Pob pop_back #define mp make_pair void solve() { ...
#include <bits/stdc++.h> const int N = 2*100000; char S1[N + 5], S2[N + 5], S3[N + 5]; bool tag[4]; void solve() { int n; scanf("%d%s%s%s", &n, S1, S2, S3); for(int o=0;o<4;o++) tag[o] = 0; tag[(S1[0] - '0') << 1 | (S1[2*n - 1] - '0')] = true; tag[(S2[0] - '0') << 1 | (S2[2*n - 1] - '0')] = true; tag[(S3[0] - '...
#include<bits/stdc++.h> #define ll long long #define dbg(x) cout<<#x<<": "<<x<<endl; #define N 2005 #define M 1000000007 #define pii pair<ll,ll> #define fast ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; string s[2005]; int h,w; ll dp[N][N][5]; bool valid(int i,int j) { return i>=0&&i<h&&j>=0&&j<w&...
#include<iostream> #include<map> #include<vector> #include<algorithm> #include<set> #include<queue> #include<stack> #include<math.h> #include<time.h> #include<deque> #include<cstring> #define ll long long #define DB double #define FOR(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define F first #define S second #de...
/** * Author: Daniel * Created Time: 2021-01-24 23:19:13 **/ // time-limit: 2000 #include <bits/stdc++.h> using namespace std; #define F first #define S second #define ER erase #define IS insert #define PI acos(-1) #define PB pop_back #define EB emplace_back #define lowbit(x) (x & -x) #define SZ(x) ((int)x.size()...
//A #include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;++i) #define rep(i,n) REP(i,0,n) #define fst first #define snd second #define pb push_back #define ALL(x) x.begin(),x.end() #define EPS (1e-9) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; bool LT(double a,double b) { return !equals(a,b) &...
#include <bits/stdc++.h> #define clog(x) std::clog << (#x) << " is " << (x) << '\n'; using LL = long long; const int N = 2002; struct Edge { int to; LL c, d; Edge(int x, LL y, LL z) : to(x), c(y), d(z) {} }; const LL INF = 1e18; int main() { //freopen("in", "r", stdin); std::cin.tie(nullptr)->sync_with_stdio(fals...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; template <class T> using idx_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long #define ull unsigned long long #define arr array #define vt vector #def...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define re...
#include<bits/stdc++.h> #define pu push #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i,x) for(int i=0;i<x;i++) #define rrep(i,x) for(int i=1;i<=x;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....
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_ll.hpp> #define rep(i,a,b) for(ll i=a;i<b;i++) #define rrep(i,b,a) for(ll i=b;i>=a;i--) #define fori(a) for(auto i : a ) #define all(a) begin(a), end(a) #define set(a,b) memset(a,b,sizeof(a)) #define sz(a) a.size() double pi=acos(-1); #define ll long long ...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N=205; int n,a[N]; vector<int>v,res1,res2; vector<int>save[N]; bool flag; void dfs(int cur,int sum){ sum%=200; if(flag) return; if(cur==n+1){ if(save[sum].size()&&v.size()){ flag=true; res1=save[sum]; ...
// <Rahil Malhotra / ViciousCoder> #include "bits/stdc++.h" using namespace std; template <typename T> void print(T t) { cout<<t<<endl; } template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); } #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl ...
#include<bits/stdc++.h> using namespace std; long long n; long long m3[40],m5[30]; int main(){ scanf("%lld",&n); m3[0]=1ll;m5[0]=1ll; for(int i=1;i<=38;i++) m3[i]=m3[i-1]*3; for(int i=1;i<=26;i++) m5[i]=m5[i-1]*5; for(int i=1;i<=38;i++) for(int j=1;j<=26;j++) if(m3[i]+m5[j]==n){ printf("%d %d\n",i,j); return...
#include<bits/stdc++.h> using namespace std; #define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long #define pb push_back #define cases() ll t;cin>>t;while(t--) #define all(c) c.begin(),c.end() #define PI 3.14159265358979323846 const ll MAX = 2e5+5; const ll INF = 1e18; const l...
//#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<map> #include<cmath> #include<cctype> #include<vector> #include<set> #include<queue> #include<algorithm> #include<sstream> #include<ctime> #include<cstdlib> #define X first #define Y second #define L (u<<1) #define...
#include<bits/stdc++.h> #define fo(i,a,b) for(int i=(a);i<=(b);++i) #define fd(i,a,b) for(int i=(a);i>=(b);--i) #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const int maxn = 2e5 + 5; int n; int a[maxn], b[maxn], lg[maxn], st[maxn][22]; voi...
#include <bits/stdc++.h> #include <vector> #include <string> using namespace std; #define int long long #define ld long double #define vint vector<int> #define vpair vector<pair<int, int>> #define vvec vector<vector<int>> #define vvpair vector<vector<pair<int, int>>> #define qint queue<int> #define pint pair<int, int> ...
#include <bits/stdc++.h> #include <algorithm> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; int main(){ double n,ans=0; cin >> n; for(int i=1; i<n; i++){ ans += n/i; } cout << fixed << setprecision(15) << ans << endl; }
#pragma GCC target("avx2") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("O3") // include #include <bits/stdc++.h> using namespace std; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sou...
#pragma GCC optimize("Ofast") //#pragma GCC target ("sse4") #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> #i...
#include <vector> #include <stack> #include <queue> #include <list> #include <bitset> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <algorithm> #include <numeric> #include <iostream> #include <iomanip> #include <string> #include <chrono> #include <random> #include <cmath> #inc...
#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...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; using ll = long long; #define pp pair<int,int> #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define ld long double #define al(a) (a).begin(),(a).end() #define mk make_pair #define check cout<<"?"<...
#include<bits/stdc++.h> using namespace std; signed main(){ int n; int a; bool f=false; map<int,int> v; cin>>n; for(int i=0;i<n;i++){ cin>>a; v[a]++; if(v[a]!=1) f=true; } if(f) cout<<"No\n"; else cout<<"Yes\n"; }
#include <bits/stdc++.h> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#define ordered_set tree<int, null_type, less<int >,rb_tree_tag, tree_order_statistics_node_update> //using namespace __gnu_pbds; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimiza...
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #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 rep(i, a, b) for (int i = a; i ...
#include<bits/stdc++.h> using namespace std; using ll = long long; typedef complex<double> Point; const ll mod = 1e9 + 7; const double Pi = 3.14159265358979; int run_test(){ string s; cin >> s; reverse(s.begin(), s.end()); for(int i = 0; i < s.length(); i++){ if(s[i]=='6'){ s[i]='9'; } else ...
#include <bits/stdc++.h> #include <map> #include <vector> #include <algorithm> #include <iostream> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) using ll = long long; int main() { int N; cin>>N; N*=1.08; if(N<206)cout<<"Yay!"<<endl; else if(N==206)cout<<"so-so"<<endl; else cout<<":...
#include <iostream> #include <string> #include <vector> #include <cmath> #include <iomanip> #include <algorithm> #include <utility> #include <set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <complex> #include <regex> #define Debug cout << "line: " << __LINE__ << "Debug" << endl;...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) ...
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; #define x first #define y second const int N = 2e5 + 10; int a[N], res[N], pos[N]; void Swap(int p, int &idx) { swap(pos[a[p]], pos[a[p + 1]]); swap(a[p], a[p + 1]); res[idx++] = p; } void solve() { int n; scanf("%d"...
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cctype> #include <cmath> #include <vector> #include <set> #include <bitset> #include <map> #include <stack> #include <queue> #include <ctime> #define _for(i,a,b) for(int i=(a);...
#include <stdio.h> #include <bits/stdc++.h> #define ll long long int #define inf 1000000000000 #define mod 998244353 #define sz(x) (int)x.size() #define all(v) v.begin(), v.end() #define fi first #define se second #define ps(x, y) fixed << setprecision(y) << x using namespace std; void solve() { ll n, kl; cin >> n >...
#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; int cnt=1000000001; rep(i,n){ int a,p,x; cin>>a>>p>>x; if(x-a>0) cnt=min(cnt,p); } if(cnt!=1000000001) cout<<cnt<<endl; else cout<<-1<<endl; }
#include<bits/stdc++.h> using namespace std; #define MAXN 100005 #define lowbit(x) (x&-x) #define reg register #define mkpr make_pair #define fir first #define sec second typedef long long LL; typedef unsigned long long uLL; const int INF=0x3f3f3f3f; const int mo=998244353; const LL jzm=2333; const int iv2=499122177; c...
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_s...
#include<bits/stdc++.h> using namespace std; namespace Sakurajima_Mai{ #define ms(a) memset(a,0,sizeof(a)) #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ? #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i) #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].t...
/** * Dont raise your voice, improve your argument. * --Desmond Tutu */ #include <bits/stdc++.h> using namespace std; const bool ready = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); return true; }(); using ld=long double; const ld PI = acos((ld)-1); using ll= ...
#include <bits/stdc++.h> using namespace std; int main(){ int a,b,c,d; cin >> a >> b >> c >> d; cout << b - c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 #define pb push_back #define ss second #define ff first #define all(v) v.begin(), v.end() #define deb(x) cerr << "\n" \ << #x << "=" << x << "\n"; #define deb2(x, y) cerr << "\n" \ ...
#include <bits/stdc++.h> using namespace std; using ll = long long; struct P { bool operator<(const P &p) const { return x != p.x ? x < p.x : y < p.y; } int x, y; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int l = m + 1; vector<P> p...
#include <bits/stdc++.h> using namespace std; int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0)); using Int = long long; int main() { Int N; cin >> N; const int M = 44; vector<Int> X(M), Y(M); for (int i = 0; i < M; i++) { // X = X + 1 X[i] = 1; if (i...
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } template<int mod> struct ModInt{ int x; ModInt () : x(0) {} ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {} ModInt &operator += (const ModInt &p){ if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operato...
#include<bits/stdc++.h> using namespace std; const int N=111; int n,vis[N][N],now,sum[N]; char a[N][N]; void dfs(int x){sum[x]++;vis[now][x]=1; for(int i=1;i<=n;i++){if(a[x][i]=='1'&&!vis[now][i]) dfs(i); } } int main() { cin>>n; for(int i=1;i<=n;i++)scanf("%s",a[i]+1); for(int i=1;i<=n;i++)now=i,dfs(i);double a...
#include<bits/stdc++.h> using namespace std; const int N = 100; char mat[N][N]; int n; int tout[N]; bool used[N]; int timer = 0; int colored[N]; int c = 0; set <int> g[N]; int _sz[N], _sz1[N]; void dfs(int v) { used[v] = 1; for(int i = 0; i < n; i++) { if(mat[v][i] == '1' && !used[i]) { ...
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define all(a) a.begin(), a.end() #define ff(i,a,b) for(int i=a;i<=b;i++) #define fb(i,b,a) for(int i=b;i>=a;i--) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int maxn = 200005; const ll inf = 1e18 + 5; int ...
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #inclu...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") //#include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; #include<cstdio> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define fi first #define se second #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep0(i, n) for (ll i = 0; i <= (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep1(i, n) for (ll i = (n); i > 0; --i) #define rrep0(i, n)...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll ; int main(){ double n , d , h; cin >> n >> d >> h ; vector<double> D(n) , H(n) ; double a = h / d ; double ans = 0 ; rep(i,n){ cin >> D[i] >> H[i] ; if( a *(d - D[i]...
//a.9 #include<bits/stdc++.h> #define ll long long #define all(x) x.begin(),x.end() #define CASE(t) cout<<"Case #"<<(t)<<": "; #define endll endl #define endl '\n' #define mod 1000000007 #define INF 1e18 #define maxN 500005 #define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n' #define deb2(x,y) cout << "[" << (...
// clang-format off #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define mp make_pair #define fst first #define snd second #define forn(i,n) for (int i = 0; i < int(n); i++) #define forn1(i,n) for (int i = 1; i <= int(n); i++) #define popcnt __builtin_popcount ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; long long ret = 1; for (long long i = 2; i <= n; i++)ret = ret * i / __gcd(ret, i); cout << ret + 1 << endl; return 0; }
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstd...
#define LOCAL #define _USE_MATH_DEFINES #include <array> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include <stack> #include <list> #include <set> #include <map> #include <unordered_set> #include...
#include <bits/stdc++.h> using namespace std; // 小数点以下桁数 // fixed << setprecision(i) int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));} int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);} int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応 bool is_prime(int a){if(a<=1)return false;for...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++) #define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--) typedef pair<ll, ll> pi; typedef pair<pi, ll> pii; typedef pair<ll, pi> ipi; typedef pair<pi, pi> pipi; #define mp m...
#include<bits/stdc++.h> using namespace std; int N,M; int P[51][51]; int main(void) { register int i,j; cin>>N>>M; for(i=1;i<=50;i++)for(j=1;j<=50;j++)cin>>P[i][j]; N++,M++; if(M>1&&P[N][M-1]!=P[N][M])cout<<"L"<<endl,exit(0); if(M<50&&P[N][M+1]!=P[N][M])cout<<"R"<<endl,exit(0); if(N>1&&P[N-1][M]!=P[N][M])cout<<"...
#include <bits/stdc++.h> #define LIMTIME 1930 using namespace std; using P = pair<int, int>; using B = bitset<2500>; struct dat { B b; int x, y; dat(int _x = 0, int _y = 0, B _b = B()) : b(_b), x(_x), y(_y) {} bool operator<(const dat r) const { if (x != r.x) return x < r.x; if (y != r.y) return y < r...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 998244353 void solve(){ int H, W; cin>>H>>W; //set<int> s; int a[H][W]; int sum[10001] = {0}; int chk = 1; for(int i = 0; i<H; i++){ string S; cin>>S; for(int j = 0; j<W; j++){ if(S[j]=='R'){ if(sum[i+j]!=0&&sum[i+j]!=1)...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=2e5+5; const int mod=1e9+7; int h,w; char s[2003][2003]; int dp[2003][2003]; int s1[2003][2003],s2[2003][2003],s3[2003][2003]; int main(){ ios::sync_with_stdio(false); cin>>h>>w; for(int i=1;i<=h;i++) cin>>s[i]+1; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<ll>>; struct UnionFind{ vector<ll> par,siz; UnionFind(int n):par(n,-1),siz(n,1){} ll root(int x){ if(par[x]==-1) return x; else return par[x]= root(par[x]); } bool issame(int x,int y){ return root(x)=...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i <= (n); i++) #define zep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << end...
#include <bits/stdc++.h> #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define rng(a) a.begin(), a.end() #define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] #define sz(x) (int)(x).size() #define se second #define fi first #define prev coyhhhhhhyoc #define next sdNNNmNNNNNNNmd...
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<stack> #include<vector> #include<map> using namespace std; const long double eps = 1e-6; int read(){ int x=0,f=1; char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=...
#include <bits/stdc++.h> using namespace std; int N,c,z; vector<vector<int>> adj(105), tc(105, vector<int>(105)); void dfs(int u, int s) { tc[s][u] = true; //if (s == 1) cout << u << "\n"; for (int v: adj[u]) { // if (u == 1) cout << v << " "; if (!tc[s][v]) dfs(v,s); } } int main() {...
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" #define rep(i,n) repi(i,0,n) #define repi(i,a,n) for(ll i = a;i < (ll)n;++i) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SHOW(str,val) cout<<(str)<<" : "<<(v...
#include <iostream> #include <iomanip> #include <algorithm> #include <functional> #include <map> #include <vector> #include <queue> #include <cmath> typedef long long ll; typedef unsigned long long ull; using namespace std; int main() { ll s,p; cin>>s>>p; for(ll i=1; i<=sqrt(p); i++) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a; long long ans = 1; for(long long i = 1; i <= n; ++i){ string s; cin >> s; if(s == "OR"){ans += (long long)pow(2, i);} } cout << ans << endl; }
#include <cstring> #include <iostream> #include <string> #include <vector> typedef long long ll; using namespace std; int n; ll dp[100][2] = { 0 }; int main() { cin >> n; vector<string> s(n, ""); for (int i = 0; i < n; ++i) { cin >> s[i]; } dp[0][0] = dp[0][1] = 1; for (int i = 1; i <= n...
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff //#define ll long long #define int long long //#define double long double #define re register int #define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define...
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> using vc = vector<T>; template<class T> using vvc = vc<vc<T>>; template<class T> using vvvc = vc<vvc<T>>; template<class T> using vvvvc = vvc<vvc<T>>; template<class T> using PQ = priority_queue<T>; template<class T> using invPQ = pri...
using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define pai arccos(-1); #define keta(n) cout << fixed << setprecision((n)); using ll = long long; #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <set...
#include<bits/stdc++.h> using namespace std; int a[4],n,y,z,x[1001]; string s[1001],c; int main(){ cin>>n; for (int i=1;i<=n;i++){ cin>>s[i]>>x[i]; y=max(x[i],y); } for (int i=1;i<=n;i++) if (x[i]!=y&&x[i]>z) z=x[i],c=s[i]; cout<<c; }
#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 ...
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cos...
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #include<bits/stdc++.h> #define ll long long #define pb push_back #define bg begin() #define en end() #define endl "\n" #define vvl(n,m) vector<vector<ll> > a( n , vector<ll> (m)) #define fast ios_...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll,ll> int main(){ cout<<setprecision(15)<<fixed; int n; cin>>n; vector<ll> x(n); rep(i,n){ ll a; cin>>a; x[i]=abs(a); } ll M=0, C=0; double E=0; rep(i,n) M+...
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define rep(i,a,b) for (int i = (int)(a); i < (int)(b); i++) ll compute(ll a){ ll ans =0; while(a != 0){ ans += a-1; a--; } return ans; } int main(){ ll N; cin >> N; vector<ll> A(N); rep(i,0,N){ ...
#include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<string> #include <cassert> #include <numeric> #include <unordered_map> typedef long long ll; #define FOR(i, a, b) for(int i=(a); i<(b);i++) #define REP(i, n) for(int i=0; i<(n);i++) #define ROF(i, a, b) for(int i=(b-1); i>=(a);i--) #defi...
#include<bits/stdc++.h> typedef int LL; typedef double dl; #define opt operator #define pb push_back #define pii std::pair<LL,LL> const LL maxn=1e5+9,mod=998244353,inf=0x3f3f3f3f; LL Read(){ LL x(0),f(1); char c=getchar(); while(c<'0' || c>'9'){ if(c=='-') f=-1; c=getchar(); } while(c>='0' && c<='9'){ x=(x<<3ll...
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #define fo(i,x,y) for(int i = x;i <= y;++i) #define fd(i,x,y) for(int i = x;i >= y;--i) using namespace std; int n,e[200010][2],lst[100010],stk[100010],tot,c[100010],x,y; bool bz[100010]; char ch[20]; int rd() { int x=0,sig=1; char c; for (c=getc...
#include <iostream> #include <string> #include <vector> #include <map> #include <cmath> #include <algorithm> #define N 200000 unsigned long long dp[N][2]; using namespace std; int main(void) { unsigned long long n; cin >> n; map<long long, std::vector<long long> > balls; for (long long i = 0; i < n; i...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define fi first #define se second #define ll long long #define tp top() #define fr front() #define vi vect...
#include <bits/stdc++.h> using namespace std; #define int long long int const double pi = 3.14159265358979; const int inf = 1e13; const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; #define pii pair<int,int> #define endl "\n" #define dtor(deg) (((deg)/360)*2*pi) #define all(a) a....
#include <bits/stdc++.h> int nextInt() { int temp; scanf("%d", &temp); return temp; } long long nextLL() { long long temp; scanf("%lld", &temp); return temp; } void print(int x, char endc = '\n') { printf("%d%c", x, endc); return; } void print(long long x, char endc = '\n') { printf("%lld%...
#include <sys/time.h> #include <iostream> #include <iomanip> #include <algorithm> #include <utility> #include <cmath> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <utility> #include <cctype> #include <cstdlib> #include <typeinfo> /* #inc...
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <ctime> #include <ctype.h> #include <string> #include <map> #include <set> #include <vector> #include <queue> #include <stack> #include <algorithm> #define INF 0x3f3f3f3f #define eps 1e-8 // #define _ using namespace std; typedef long lo...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define mit map<int,int>::iterator #define sit set<int>::iterator #define itrm(g,x) for(mit g=x.begin();g!=x.end();g++) #define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) #define ltype int #define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++) #define r...
/* P_r_A_d_Y ☹ */ #include<bits/stdc++.h> using namespace std; #define int long long int #define endl "\n" #define mod 1000000007 #define inf 1e18 #define pb push_back #define all(x) x.begin(),x.end() #define arr_max(x) *max_element(x.begin(),x.end()) #define arr_min(x) *min_element(x.begi...
#include <iostream> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <array> #include <algorithm> #include <utility> #include <numeric> #include <functional> using namespace std; using ll = long long; using ull = unsigned long long; template <class ...Args> void Input...
#include<bits/stdc++.h> #define int long long //#define PI pair<int,int> using namespace std; const int maxm=2e6+5; const int mod=998244353; int cal(int x){ return x*(x+1)/2%mod; } void solve(){ int a,b,c;cin>>a>>b>>c; int C=cal(c); int B=cal(b)*C%mod; int A=cal(a)*B%mod; cout<<A<<endl; } signe...
#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> using namespace std; #define rng(x) x.begin(), x.end() #define pb push_back #define ff first #define ss second typedef double db; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef ve...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, b) for(ll i = a; i < b; i++) #define Rep(i, a, b) for(ll i = a; i <= b; i++) #define repr(i, a, b) for(ll i = b-1; i >= a; i--) // #define _GLIBCXX_DEBUG template <class T> using V = vector<T>; #define ALL(v) (v).begin(),(v).end() ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define loop(i,n) for(ll i=0;i<n;i++) #define loopn(i,j,n) for(ll i=j;i<n;i++) #define m_arr(arr, n) vector<ll>arr(n) #define m_arre(arr) vector<ll>arr #define m_set(sat) set<ll>sat #define ppn(name) pair<ll,ll>name #define pp pair<ll,ll> #define ff firs...
#include<bits/stdc++.h> using ll = int_fast64_t; using P = std::pair<ll,ll>; using PP = std::pair<ll,P>; #define REP(i,b,e) for(int i=b; i<e; i++) #define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");} #define fi first #define se second const int MOD = 1e9+7; int dx[] = {0, 1, 0, -1, 1, 1, -1, ...
#include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <string> #include <queue> #include <deque> using namespace std; int main() { int n; cin >> n; map<int, int> mp; for(int i = 1;i < n ; i++){ mp[i] = i - 1; } string s; ...
// #include <atcoder/all> #include <bits/stdc++.h> #define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) begin(x), end(x) using namespace std; using ll = long long; constexpr ll Mod = 998244353; constexpr ll mod = 1...
#include <cstdio> #include <cctype> namespace io{ #define cs const #define il inline #define tpl template #define tpn typename typedef cs int&ci; typedef unsigned size_t; typedef cs size_t&cst; #ifndef ONLINE_JUDGE using std::getchar; using std::putchar; using std::isdigit; #else const size_t _I_Buffer_Size ...
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #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 ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #def...
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <queue> #include <stdlib.h> #include <map> #include <cmath> #define MOD_P 1000000007 #define MOD_Q 998244353 #define PI 3.14159265358979 #define ll long long using namespace std; int main() { int h, w; cin >> h >> w; int ans = 0; ...
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define int long long #define cin(a,n) for(int i=0;i<n;i++) cin>>a[i] #define cin2(a,b,n) for(int i=0;i<n;i++) cin>>a[i]>>b[i] #define mod 998244353 #define pb push_back #define pie 3.141592653589793238462643383279 vector<bool> prime; vector<int> fact,inv,p...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int N = 0; cin >> N; vector<long long> A(N, 0); for(int i = 0; i < A.size(); i++){ cin >> A[i]; } sort(A.begin(), A.end()); long long MOD = 998244353; long long ans = 0; for(int i = 0;...
#include <bits/stdc++.h> using namespace std; using std::cout; using ll=long long; using ld=long double; ll I=1167167167167167167; ll Q=1e9+7; #define rep(i,a) for (ll i=0;i<a;i++) template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>; template<class T> ll LB(vector<T> v,T a){return lower_bound(v.begin...
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll n; ll ans = 0; cin >> n; if (n >= 1000) { ans += n - 999; } if (n >= 1000000) { ans += n - 999999; } if (n >= 1000000000) { ans += n - 999999999; } if (n >= 1000000000000) { ans += n - 999999999999; } if (n >= 100...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update> #define ordered_set tree<long long , null_type,less<long long >, rb...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int main() { int n, k; cin >> n >> k; k = abs(k); vector<ll> v(2 * n + 1); for (int i = 2; i <= 2 * n; i++) { v[i] = min(i - 1, 2 * n - i + 1); } ll ans = 0; for (int...
#include <bits/stdc++.h> using namespace std; bool flg[100][100]; int main() { int n; cin >> n; for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) { char c; cin >> c; flg[i][j] = (c == '1'); } flg[i][i] = true; } for(int k = 0; k < n; ++k) { for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ...
/* author : TAPAN SAVANI codeforces : savanitapan2001 codechef : savanitapan17 */ /* ------------------------------------------------------------------------ ░██╗░░░░░░░██╗░█████╗░██████╗░██╗░░██╗  ██╗░░██╗░█████╗░██████╗░██████╗░ ░██║░░██...
#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> using namespace std; int main() { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; int answer; int dr = r2 - r1; int dc = c2 - c1; if (dr == 0 && dc == 0) { answer = 0; } else if (dr == -dc || dr == dc || abs(dr) + abs(dc) <= 3 ) { answer = 1; ...
#include<bits/stdc++.h> using namespace std; typedef pair< int , int >PII; vector< PII >deltas(vector< int >X) { vector< PII >vd; for (int i = 0; i+1 < X.size(); i++) { if (X[i]+1 < X[i+1]) { vd.emplace_back(X[i+1]-X[i]-1, i); } } return vd; } void impossible() { cout <...
#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> #define rep(i,n) for(ll i=0;i<(n);++i) #define ll long long #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define pb push_back #define pob pop_back() #define Mod (ll)(1e9+7) #define mod (ll)(998244353) #define setp(x) setprecision((ll)(n)) #define INF (ll)(1000000000000000...
#include <bits/stdc++.h> using namespace std; int main() { int N,K; cin>>N>>K; cout<<50*K*N*(N+1)+N*(K*K+K)/2<<endl; }
#include<iostream> #include<algorithm> using namespace std; int main() { int a[4]; cin>>a[0]>>a[1]>>a[2]>>a[3]; sort(a,a+4); cout<<a[0]; }
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; constexpr int int_max = (1<<30)+((1<<30)-1); constexpr int int_min = -(1<<30)-(1<<30); constexpr ll ll_max = (1LL<<62)+((1LL<<62)-1LL); ...
#include<bits/stdc++.h> typedef long long ll; using namespace std; char maze[15][15]; struct node { int x, y; }; bool cmp1(node a, node b) { return a.x != b.x ? a.x < b.x : a.y < b.y; } bool cmp2(node a, node b) { return a.y != b.y ? a.y < b.y : a.x < b.x; } void solve() { int n, m, ans = 0; scanf("%d %d",...
#include<bits/stdc++.h> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; ///--->>> CONTAINERS <<<---/// using i64 = int64_t; using ll = long long; using ld = long double; using vi = vector<ll>; using vvi = vector<vector< ll > >; using vpi = ve...
#include <bits/stdc++.h> using namespace std; typedef __int128 ll; typedef pair<int,int> ii; void solve(){ int n; cin >> n; long long ci; cin >> ci; ll C = ci; vector<tuple<int,int,ll>> v; // point, ev, price for (int i=0; i<n; i++){ int a,b,c; cin >> a >> b >> c; v.push_back(make_tuple(a,0,c)); v.push_bac...
#include<bits/stdc++.h> #define int long long int //Compute XOR of all numbers from 1 to n in O(1) complexity #define xor1toN(n) (n&((n&1)-1)&~1 | ((n>>1)^n)&1) using namespace std; const int M = 998244353; const int mod = 1e9+7; const int inf = 1e18; #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); ...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define FOR(i, m, n) for(int i = m; i < n; i++) #define ALL(x) (x).begin(),(x).end() #define SIZE(x) ((ll)(x).size()) #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) #define INF 1e9 typedef long long ll; t...
#include<bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for (int i = 0; i < (n); ++i) const ll mod = 1000000007; const ll inf = (1ll << 60); vector<int> dy {0,1,0,-1}; vector<int> dx {-1,0,1,0};// ← ↓ → ↑ int main(){ ll x, y; cin >> x >> y; ll a, b; cin >> a >> b; ll ans = 0; ...
//clear adj and visited vector declared globally after each test case //check for long long overflow //while adding and subs check if mod becomes -ve //while using an integer directly in a builtin function add ll //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod; //Dont keep array name as size or any o...
#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 FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0) #define inf 2e18 #define mod 998244353 #define bg begin() #define en end() #define ll long long i...
#include<bits/stdc++.h> #define M 1000000007 using namespace std; int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output1.txt","w",stdout); #endif string s; cin >> s; if( (s[0]==s[1] && s[1]==s[2])){ cout << "Won"; } else{ cout << "Lost"; } return ...
#include<bits/stdc++.h> #define ll long long using namespace std; vector<int> primes; ll isPrime(ll n){ if(n==1){ return 1; } for(int j=2; j*j<=n; j++){ if(n%j==0){ return 0; } } return 1; } void solve(){ string in; cin >> in; set<char> s; for(int i=0; i<in.size(); i++){ s.insert(in[i]); } if(...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD=1000000000+7; //template<typename T> vector<ll> findall(string target,string find_word){ vector<ll> a; ll pos=target.find(find_word); while(pos!=std::string::npos){ a.push_back(pos); pos=target.find(find_word,po...
#include<cstdio> using namespace std; int main(void) { int n; scanf("%d",&n); if(n%2==0) printf("White\n"); else printf("Black\n"); return 0; }
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) const int INF =1001001001; using P = pair<int,int>; int main(void) { int h,w; ll n,m; cin >> h >> w >> n >> m; vector<vector<bool>>ab(h,vector<bool>(w,false)); vector<vector<bool>>cd(h,v...
#include<iostream> #include<stdio.h> #include<string> #include<vector> #include<map> #include<tuple> #include<algorithm> #include<cmath> #include<limits> #include<set> #include<deque> #include<queue> #include<stack> using namespace std; #define int long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #def...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vi>; using vvll = vector<vll>; using P = pair<int,int>; #define rep(i,n) for (int i = 0; i < (int)(n) ; i++) #define rep2(i,a,b) for (int i = (a); i < (int)(b); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; constexpr ll mod=1e9+7; char c[2010][2010]; int yoko[2010][2010]; int tate[2010][2010]; ll mod_pow(ll a,ll b){ a%=mod; if(b==0)return 1; if(b==1)return a; ll res=mod_pow(a,b/2)%mod; res*=res; res%=mod; if(b%2)res*=a; return res%mod; } in...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxl=4e5+10; const int mod=998244353; int n,m;ll ans; int p[maxl],dy[maxl]; ll fac[maxl],inv[maxl],dp[maxl]; bool no[maxl]; inline void shai() { for(int i=2;i<maxl;i++) { if(!no[i]) p[++p[0]]=i,dy[i]=i; int j=1,t=p[1]*i; while(j<=p[...
#include<bits/stdc++.h> using namespace std; int mod = 998244353; long long fac[200005], finv[200005], inv[200005]; void COMinit(int m) { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 200005; i++){ fac[i] = fac[i - 1] * i % m; inv[i] = m - inv[m % i] * (m...
#include <bits/stdc++.h> using namespace std; #define int long long #define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" void solve() { int a,b,c,d;cin>>a>>b>>c>>d; int ans=INT_MIN; for(int i=a;i<=b;i++) { for(int j=c;j<=d;j++) { an...
#include <bits/stdc++.h> using namespace std; int main(){ int a,b,c,d; cin >> a >> b >> c >> d; cout << b - c << endl; return 0; }
#include<bits/stdc++.h> using namespace std; bool flag; string x[10000010]; int main(void){ long long n; cin>>n; for(int i=1;i<=n;i++){ cin>>x[i]; reverse(x[i].begin(),x[i].end()); } sort(x+1,x+n+1); for(int i=1;i<n;i++){ if(x[i]+'!'==x[i+1]){ reverse(x[i].begin(),x[i].end()); cout<<x[i]<<endl; fla...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mod 998244353 #define big 1e18 + 1000000 #define small -big #define pb push_back #define endl "\n" template <typename T> void prarr(T a) { cerr << "[ "; for(auto i : a){ cerr << i << " "; ...
//#include <atcoder/all> #include <bits/stdc++.h> using namespace std; #define rep2(x,fr,to) for(int x=(fr);x<(to);x++) #define rep(x,to) for(int x=0;x<(to);x++) #define repr(x,fr,to) for(int x=(fr);x>=(to);x--) #define all(c) c.begin(),c.end() #define sz(v) (int)v.size() typedef long long ll; typedef vector<int> ...
#include <cstdio> #include <iostream> using namespace std; int n, m; int main() { cin >> n >> m; if (m % n == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i) static const ll INFTY = 1L << 62L; ll solver(ll n, ll k) { ll a1, a2, b1, b2, c1, c2, d1, d2, p, q, ans = 0; for (p = 2; p <= 2 * n - k; ++p) { q = p + k; b...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll N,K; cin>>N>>K; for(int i=0;i<K;i++){ if(N%200==0) N/=200; else{ N=N*1000+200; } } cout<<N; }
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #define re #define X first #define Y second #define mp std::make_pair #define pb push_back #define ohh(hhh...) fprintf(stderr,hhh) typedef long long ll; typedef unsigned long long ull; typedef std::pair<int,int> pii; template<class T1> inline bool c...
#include<iostream> #include<stdlib.h> #include<cassert> #include<time.h> #include<bitset> using namespace std; int t[210000]; int main(){ int a;scanf("%d",&a); int at=0; for(int i=0;i<a;i++){ int s;scanf("%d",&s); t[s]++; while(t[at]){ at++; } printf("%d\n...
#include<iostream> using namespace std; typedef long long LL; const int N=1e6+5; LL l,r; LL cnt[N],num[N]; void init(){ for(int i=2;i<=N;i++) for(int j=i;j<=r;j+=i){ if(j<l)continue; cnt[i]++; } } int main(){ cin>>l>>r; init(); LL ans=0; for(int i=r;i>=2;i--){ num[i]=cnt[i]*cnt[i]; for(int j=i+i;j<=r...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> 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...
#include <bits/stdc++.h> using namespace std; #define int long long void read (int &x) { char ch = getchar(); x = 0; int f = 0; while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x; } const int N = 3e5 + 5; int n, k, res, ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define f(i,a,b) for(ll i=a;i<b;i++) #define rf(i,a,b) for(ll i=a;i>=b;i--) #define pb push_back #define vi vector<pair<ll,ll>> #define ff first...
#include<iostream> #include<sstream> #include<iomanip> #include<cstdlib> #include<algorithm> #include<vector> #include<map> #include<cmath> #include<string> #include<numeric> #include<queue> #define rep(i,p) for(long long int i=0;i<p;i++) #define reep(i,p) for(long long int i=1;i<=p;i++) #define ll long long #define ...
// Problem: D - Staircase Sequences // Contest: AtCoder - AtCoder Beginner Contest 190 // URL: https://atcoder.jp/contests/abc190/tasks/abc190_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include<bits/stdc++.h> using namespace std; typedef long long...
#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 deb(x) cerr << #x << " = " << x << "\n"; #define deb2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << "\n"; #define deb3(x, y, z) cerr ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0;i < n; i++) using ll = long long; using P = pair<int,int>; const ll INF = 1e18; const int MX = 2005; ll factorial(ll l){ if(l == 1 || l == 0){ return 1; }else{ return l * factorial(l-1); } } int main() { ll L...
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int N = 4e5 + 5, mod = 1e9 + 7; vector<int> adj[N]; int in[N]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin >> n; for(int i = 0; i < n; i++){ int u, v; cin >...
#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 <iostream> using namespace std; int main() { string s; cin>>s; if ((s[0]==s[1])&&(s[1]==s[2])&&(s[2]==s[0] )) cout<<"Won"; else cout<<"Lost"; return 0; }
//KEEP IT SIMPLE STUPID #include<bits/stdc++.h> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> #pragma GCC optimize ("O3") #pragma GCC target ("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=n...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> Pii; typedef pair<int, ll> Pil; typedef pair<ll, ll> Pll; typedef pair<ll, int> Pli; typedef vector < vector<ll> > Mat; #define fi first #define se second const ll MOD = 1e9 + 7; const ll MOD2 = 99824435...
#include<bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed; #define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl; #define inf 1000000007 #define INF...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5, INF = 1e17 + 5; long long n, m, a, b, c, d, dist[N]; bool vis[N]; struct Edge{ long long b, c, d; }; vector<Edge> graph[N]; long double findtime(long long t, long long wait, Edge e){ return wait + e.c + ((e.d / (long double)(t + 1...
#include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long #define endl "\n" #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front ...
#include <iostream> #include <math.h> using namespace std; void aaa(int *a,int start,int end){ if(start<end){ for(int i=start;i<end; i++){ if(a[i]>a[i+1]){ int tmp=a[i]; a[i]=a[i+1]; a[i+1]=tmp; } } aaa(a,start,end-1); } } int main() { long long h, w; int ...
#include<bits/stdc++.h> using namespace std; int max(int a,int b){ return a>b?a:b; } int min(int a,int b){ return a<b?a:b; } int main() { int h,w,m=2000000000; scanf("%d %d",&h,&w); int a[102][102]; for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {scanf("%d",&a[i][j]);m=min(m,a[i][j]);} ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define mems(p) memset(p,-1,sizeof(p)) #define mp make_pair #define pb push_back #define eb emplace_back #define nl "\n" const int mxN = 8e5 + 100; const ll MOD = 1e9 + 7; void fast() {ios_base::sync_with_stdio(false);cin.ti...
#include <iostream> using namespace std; long long dp[16*16] = {0}; int H, W; bool used[16][16] = {false}; int dfs(int h, int w, int a, int b) { if ((a < 0) || (b < 0)) return 0; if (w == W) w = 0, h++; if (h == H) return 1; if (used[h][w]) return dfs(h, w+1, a, b); int res = 0; used[h][w] = true; res +...
// Problem : // bit.ly/pentagon03 #include<bits/stdc++.h> using namespace std; #define all(v) (v).begin(),(v).end() #define sz(v) (int)((v).size()) #define ini(st,en,X) fill(&st,&en,decltype(st)(X)) #define rep(i,n) for(int i=0;i<(n);i++) #define repr(i,a,b) for(int i=(a);i<=(b);i++) #define nl '\n' #define sp ' ' u...
#include <iostream> #include <vector> #include <algorithm> #include <utility> typedef long long ll; typedef std::pair<ll, ll> pll; const ll INF = (1LL << 60); struct segtree { int i, j; ll val; segtree *l, *r; segtree(std::vector<pll> &ar, int _i, int _j) : i(_i), j(_j) { if (i == j) { val = ar[i].s...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typed...
#include<bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back using namespace std; string s; ll ans,raod[200]; int main(){ ios::sync_with_stdio(false); cin >> s; for(int i=(int)s.size() - 1; i>=1; i--){ if(s[i] == s[i - 1]){ ans += (int)s.size() ...
//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(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,N) for(int i=0;i<int(N);++i) #define rep1(i,N) for(int i=1;i<int(N);++i) #define all(a) (a).begin(),(a).end() #define bit(k) (1LL<<(k)) #define SUM(v) accumulate(all(v), 0LL) typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; template...
#include <bits/stdc++.h> using namespace std; typedef long long int lld; typedef pair<int,int> pi; typedef pair<lld,lld> pl; typedef pair<int,lld> pil; typedef pair<lld,int> pli; typedef vector<int> vit; typedef vector<vit> vitt; typedef vector<lld> vlt; typedef vector<vlt> vltt; typedef vector<pi> vpit; typedef vector...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define DIV 1000000007 //10^9+7 #define INF LONG_MAX/3 #define bit(n) (1LL<<(n)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(...
#include<cstdio> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; int n; ll ans=1; ll gcd(ll ta,ll tb){ return tb?gcd(tb,ta%tb):ta; } int main(){ scanf("%d",&n); for(int i=2;i<=n;i++) ans=ans*i/gcd(ans,i); if(ans+1<=n) ans=(n/ans+1)*ans; printf("%lld\n",ans+1); retu...
#include <cctype> #include <cstdlib> #include <ctime> #include <deque> #include <iostream> #include <utility> #include <vector> #include <string> #include <algorithm> #include <queue> #include <climits> #include <cmath> #include <sstream> #include <iomanip> #include <map> #include <stack> #include <regex> #include <set...
#include <bits/stdc++.h> using namespace std; int N, T; long long A[44]; auto calc(int S, int T) { vector<long long> v; for (int b = 0, e = 1 << (T - S); b < e; ++b) { long long q = 0; for (int i = 0; i < T - S; ++i) { if (b & (1 << i)) q += A[S + i]; } v.push_back(q); } sort(v.begin(), ...
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin>> #define ll long long #define ln cout<<endl #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeo...
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' #define INF 1e9 using namespace std; using ll = long long; using pii = pair<int,int>; using vi = vector<int>; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int h, w; cin >> h >> w; vi arr(h*w); for(auto...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; //indexed set is using "int" here--------- // typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // #include <ext/rope> // using namespace __gnu_cxx;...
#pragma GCC optimize("Ofast") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; #define IOS ios::sync_with_stdio(0); cin.tie(0); mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count()); #define F first #define S second #def...
//IF YOU GIVE UP,THEN YOU DON'T DESERVE IT #include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define endl "\n" #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define PI 3.14159265358979...
/* after dusk passed, there is a starry sky. */ #include <bits/stdc++.h> #define inf 0x3f3f3f3f #define m_k make_pair using namespace std; const int N=2*1e5+100; int n,a[N],b[N],p[N],vi[N],wh[N]; vector <pair<int,int> > ans; priority_queue <pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q; inline int re...
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; using ll = long long; using ld = long double; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_nod...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define test() int t;cin>>t;for(int test=1;test<=t;test++) #define pb push_back #define nl cout<<"\n" #define all(x) x.begin(...
#include<bits/stdc++.h> #define _USE_MATH_DEFINES using namespace std; // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") #define ll long long int #define ld double #define pb push_back #define rep(i , j , n) for(ll i = j ; i < n ; i++) #define pre(i , j ...
#include <bits/stdc++.h> using namespace std; void __print(int x) {cout << x;} void __print(long x) {cout << x;} void __print(long long x) {cout << x;} void __print(unsigned x) {cout << x;} void __print(unsigned long x) {cout << x;} void __print(unsigned long long x) {cout << x;} void __print(float x) {cout << x;} void...
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <fstream> #include <iostream> #include <algorithm> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <cmath> #include <cstring> usin...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") #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 ll long long #define REP(i, a, b) for (ll i = a; i <...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x)...
#include <bits/stdc++.h> using namespace std; #pragma optimize("-O3") #define int long long int #define f first #define s second #define pb push_back #define endl '\n' main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; for(int i=1; i<=n; i++){ cout<<((2*i)%n)+1<<" "<<((2*i+1)%n...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(),(x).end() #define uniq(v) (v).erase(un...