code_file1
stringlengths
87
4k
code_file2
stringlengths
85
4k
#include<iostream> #include<cstdio> #include<cstring> typedef long long ll; typedef unsigned un; typedef std::pair<int,int> pii; typedef std::pair<ll,ll> pll; ll read() { ll f=1,x=0;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar(); return f*x; } ll m...
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i<n; i++) #define ll long long #define VV(t) vector<vector<t>> using namespace std; using Graph = VV(int); const int INF = 1<<29; int factorial(int n) { if (n<=1) return 1; else return n*factorial(n-1); } int main() { int N; cin >> N; Graph G(N, vect...
// // a.cpp // // // Created by Sagar Singh on 13/12/20. // #include <iostream> #include <fstream> #include <vector> #include <set> #include <map> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <ctime> #include <algorithm> #include <numeric> #include <sstream> #include <list> #in...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < (n); ++i) #define FOR(i, m, n) for(ll i = m; i < (n); i++) #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; using vi = vector<int>; using vii = vector<vi>; using pii = pair<int, int>; using vl = vector<ll...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define YES cout<<"YES" #define NO cout<<"NO" #define Yes cout<<"Yes" #define No cout<<"No" #define yes cout<<"yes" #define no cout<<"no" #define FOR(S , E) for(ll i=S;i<=E;i++) #define ROF(E , S) for(ll i=E;i>=S;i--) // V.push_back() // V.pop_front()//...
#include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int N=200010,mod=1e9+7; char s[100][10]; int main() { int n; cin >> n; long long ans = 1; for (int i = 1; i <= n;i++) { string s; cin >...
#define DEBUG 0 #include <bits/stdc++.h> using namespace std; #if DEBUG // basic debugging macros int __i__,__j__; #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl #define printVar(n) cout<<#n<<": "<<n<<endl #define printA...
#include<bits/stdc++.h> using namespace std; #define ll long long #define rep(i, a, b) for(int i = a; i <= b; ++i) const int N = 300007; const int mod = 1e9 + 7; int n; int a[N]; int main() { int T; cin >> T; while(T--){ cin >> n; int key = 0; rep(i, 1, n)cin >> a[i], key ^= a[i]; if(n & 1){ puts("Second"...
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> using namespace std; #define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i) #define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i) #define fi first #define se second #define mp(a, b) make_pair(a, b) #def...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5; const ll mod = 998244353; /* I should look for * if WA, check the code from very top until bottom. * always write observations if problem is hard. * keep thought process clear. * special cases (n=1?) * stay organized. * DON'T...
#include <bits/stdc++.h> #define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a) #define rep2(i, s, n) rep3(i, s, n, 1) #define rep(i, n) rep2(i, 0, n) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using Pll = pair<ll, ll>; int main() { ll n, w; ...
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <stack> #include <algorithm> using ll = long long int; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = (ll)(1e9+7); #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ ...
#include<bits/stdc++.h> using namespace std; const int N = 2000000 + 5, Mod = 1000000007; int n = 0, m = 0, k = 0; long long arr[N] = {}, x = 0, y = 0; long long f(int num, int cnt){ if(cnt == 0) return 1; long long temp = f(num, cnt / 2); if(cnt % 2 == 0) return (temp * temp) % Mod; else return ((temp * temp) %...
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> #define rep(i,a,b) for(ll i=a;i<b;i++) #define rrep(i,b,a) for(int 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 lon...
#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 fi first #define se second #define max Max #define min Min #define abs Abs #define lc (x<<1) #define rc (x<<1|1) #define m...
#include<bits/stdc++.h> using namespace std; inline int read() { register int x=0,f=1,ch=getchar(); while(!isdigit(ch)) { if(ch=='-') f=-1; ch=getchar(); } while(isdigit(ch)) x=x*10 +ch-'0',ch=getchar(); return x*f; } int n,k; int main() { n=read(),k=read(); printf("%d\n",(n+1)*n/2*k*100+(k+...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; vector<int> g(n); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; --u, --v; ...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ld = long double; using P = pair<ll, ll>; using Vec = vector<ll>; using VecP = vector<P>; template <class T> using Vec2 = vector<vector<T>>; #define REP(i, m, n) for(int i = (m); i < (n); ++i) #define REPN(i, m, n) for(int i = (m); i <= (n); ++i) #...
#include<bits/stdc++.h> using namespace std; #define en '\n' #define endl '\n' #define ll long long signed #define pb push_back #define append push_back #define all(v) (v).begin(),(v).end() #define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k) #define fori(a) for(int i=0; i<a; i++) #define forj(a) fo...
#include <iostream> #include <vector> using namespace std; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {ce...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define pii pair<ll,ll> #define inf 1000000000000000000 #define bpc(x) __...
#include <bits/stdc++.h> #define LL long long #define pb push_back using namespace std; char a[15],c[5]="ZONe"; int ans; int main() { scanf("%s",a+1); for(int i=1;i<=12;++i) { int flag=1; for(int j=0;j<4;++j) if(a[i+j]!=c[j]) flag=0; ans+=flag; } cout<<ans; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for (long long i = 0; i < (n); ++i) #define INF LONG_MAX/3 //#define DIV 1000000007 //#define DIV 998244353 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, con...
#include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #pragma GCC optimize("Ofast") using namespace std; #define int long long #define double long double #define fast ios_base::sync_with_stdio(false); cin.tie(NULL);...
#include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define MOD (int)(1e9+7) #define MOD1 998244353 #define ceil(x, y) ((x)%(y))==0? ((x)/(y)) : ((x)/(y)+1) #define FOR(i, N) for(int i = 0; i < N; ++i) #define FOR1(i, N) for(int i = 1; i <= N; ++i) #define vi vector <int> #define pii pair <int,...
//全力以赴 #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define PI 3.141592653L #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const ll INF = (ll)1e18; const int N = 2e5 + 5; const ll MOD = 1e9+7; int parent[N]; const int dx[4] = {+1, 0, -1, 0}; const int dy[4] ...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define V vector #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), ...
#include <bits/stdc++.h> #define speedup \ ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr), \ cout.precision(16) using namespace std; using ll = long long; #define pb push_back #define all(x) (x).begin(), (x).end() using ld = long double; void s...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63) //#define INF (1<<30) #define INF (2147483647) // 2^31 -1 //= 1,073,741,824 *2 -1 //= ...
//================code===================// //#define TLE #ifdef TLE #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #include <random> #include <ctime> #include <random> #include <chrono> ...
#include <bits/stdc++.h> using namespace std; using ll=long long; using vl=vector<int>; using vvl=vector<vl>; using P=pair<int,int>; const int INF=(1<<30); struct graph{ vvl edges; vvl cost; vl dist; graph(int n):edges(n), cost(n), dist(n, INF){} void add_edge(int from, int to, int c){ ed...
#include <bits/stdc++.h> using namespace std; #define int long long using vec_int = vector<int>; using P = pair<int,int>; using T = tuple<int,int,int>; using T2 = tuple<int,int,int, int>; using ll = long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int charToInt(char c){ char zero_num = '0'; retur...
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> // for less using namespace std; #define int long long #define pb push_back #define mp ma...
#include <bits/stdc++.h> #define FLASH ios_base::sync_with_stdio(0); #define ll long long #define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl; #define deb(x)cout<<"#x = "<<(x)<<endl; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define endl "\n" #define arr(a,n) for(ll i=...
#include<iostream> #include<map> #include<set> #include<cstdio> using namespace std; const int BUF = 1500005; int nVal, range; int val[BUF]; void read() { scanf("%d%d", &nVal, &range); for (int i = 0; i < nVal; ++i) { scanf("%d", &val[i]); } } void add(int v, int v2cnt[BUF], set<int> &candi) { ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define endl "\n" #define ll long long #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); const int N = 105; set<int> st; int main() { IOS; int n; cin >> n; for (int i = 0...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n; cin>>n; set<ll> memo; for(ll i=1; i*i<=n; i++){ if(n%i==0){ memo.insert(i); memo.insert(n/i); } } for(auto x : memo){ cout<<x<<endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0; i<n; ++i) #define rep1(i,n) for(ll i=1; i<=n; ++i) #define revrep(i,n) for(ll i=n-1; i>=0; --i) inline constexpr ll Inf = (1ULL << 62) -1; #define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false); #define endl '\n'...
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using pl = pair<ll,ll>; using pi = pair<int,int>; #define all(x) x.begin(),x.end() #define rep(i,j,n) for (long long i = j; i < (long long)(n)...
#include <bits/stdc++.h> using namespace std; using ll =unsigned long long; typedef pair<ll,ll> P; #define SORT(a) sort((a).begin(),(a).end()) #define REV(a) reverse((a).begin(),(a).end()) #define For(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define rep(i, n) For(i, 0, n) #define debug(x) cerr << #x << " = ...
#include <bits/stdc++.h> #define rep(i,N) for (int i = 0; i < (N); ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<int, int>; const int inf{int(1e9)}; int main(void){ int N, M; cin >> N >> M; if (M == 0){ cout << 1 << endl; return 0; } if (N == M){ ...
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("fast-math") #pragma GCC optimize("trapv") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree...
// #include "bits/stdc++.h" using namespace std; #define pr1(a) for(auto b : a) cout << b << " ";cout << endl; #define pr2(a) for(auto b : a){for(auto c:b) cout << c << " ";cout << endl;} #define prc(...) for(auto b:{ __VA_ARGS__ }) cout << b << " ";cout << endl; const int NN=200000; vector<vector<int>> g(NN+1,vector<...
#include<bits/stdc++.h> using namespace std; #define ll long long ll mod = 1e9+7; ll max(ll a,ll b){ if(a>b){ return a; } return b; } ll min(ll a,ll b){ if(a<b){ return a; } return b; } void solve(){ string s; cin >> s; ll n = s.size(); map<char,ll> mp; ll ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i ++ ) #define N 100010 struct Node { string s; int x; bool operator< (const Node &W) const{ return x > W.x; } }a[N]; int main(void) { int n; cin >> n; rep(i, n) cin >> a[i].s >> a[i].x; sort(a, a + n); cout <...
#include "bits/stdc++.h" using namespace std; typedef long long ll; // #define int long long template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T...
#include <bits/stdc++.h> #ifdef LOCAL #include "../../Library/DebugTool.cpp" #endif using namespace std; #define ll long long #define pii pair<int,int> //const ll MOD = 1000000007; const ll MOD = 998244353; ll INF_int = 1e9+11;ll INF_ll = 1e18 + 13; #define rep(i,n) for(int i = 0;i<n;i++) #define rep1(i,n) for(int ...
#include<bits/stdc++.h> using namespace std; #define lli long long int #define ulli unsigned long long int #define vi vector<int> #define ii pair<int,int> #define all(v) v.begin(),v.end() #define getunique(v) {v.erase(unique(v.begin(),v.end()),v.e...
#include <bits/stdc++.h> using namespace std; int main(){ int n,a,b; cin >> n >> a >> b; cout << n - a + b << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (int)n ;i++) #define rept(i,k,n) for(int i = (int)(k);i < (int)(n);i++) #define all(vec) vec.begin(),vec.end() #define ll int64_t int main(){ ll a,b,c; cin >> a >> b >> c; ll k,t; int p2,p4; if(b%2 == 0){ p2 =...
#include <bits/stdc++.h> #define ll long long int #define db double #define pb push_back #define mpr make_pair #define andl "\n" #define f first #define s second #define mset(x,y) memset(x,y,sizeof(x)) #define fr(i,n) for(long long int i=0;i<n;i++) #define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++) #...
#include<iostream> #include<algorithm> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<deque> #include<queue> #include<map> #include<set> #include<list> #define ll long long #define str string #define ld long double #define vec vector #define vll vec<ll> #define vvll vec<vll> #define vbo ve...
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false...
#include <bits/stdc++.h> using namespace std; #define rep( i, a, b ) for( int i = (a) ; i <= (b) ; i ++ ) #define per( i, a, b ) for( int i = (a) ; i >= (b) ; i -- ) typedef long long LL; const int mod = 998244353; const int MAXN = 105, MAXS = 1e4 + 5; template<typename _T> void read( _T &x ) { x = 0; char s = ...
#include<bits/stdc++.h> using namespace std; #define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define mp make_pair #define eb emplace_back #define pb push_back #define pob pop_back #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(),(x).rend() #define ll long long #defi...
#include <bits/stdc++.h> #pragma GCC optimize(2) #include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<cmath> #include<cstring> #include<bitset> #include<stack> #include<time.h> #define X first #define Y second #define PB push_b...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second #define T third typedef vector<int> vi; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<pair<int,int>> vp; typedef vector<long long> vll; typedef vector<vector<in...
#include <bits/stdc++.h> #define fo(i,a,b) for(int i=a;i<=b;++i) #define fod(i,a,b) for(int i=a;i>=b;--i) #define efo(i,q) for(int i=0;i<(int)B[q].size();++i) using namespace std; typedef long long LL; const int N=200500,mo=998244353; int read(int &n) { bool q=0;n=0;char ch=' '; for(;ch!='-'&&(ch<'0'||ch>'9');ch=getc...
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstdlib> #include<queue> #include<set> #include<cstdio> #include<map> #include<cassert> using namespace std; #define ll long long #define reps(i, a, b) for(int i = a; i < b; i++) #define rreps(i, a, b) for(int i = a-1; i >= b; i--) #def...
#include <bits/stdc++.h> using namespace std; int main() { int N, ans; string s; cin >> N >> s; ans = N; auto itr = s.begin(); while (distance(itr, s.end()) >= 3) { if (*itr=='f' && *(itr+1)=='o' && *(itr+2)=='x') { ans -= 3; s.erase(itr, itr+3); itr--; itr--; } else itr++;...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i = 0,c = 0; for(i = 0; i < s.size() ; i++){ if(s.substr(i, 4) == "ZONe") c++; } cout << c ; }
/*------------------------------------------ Author : Suyash Chavan Walchand College of Engineering, Sangli --------------------------------------------*/ #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma GCC target ("sse4") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_cont...
#include<bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long #define lld long double #define inf 1000000000 #define pii pair<int,int> #define fi first #define se second #define pb push_back #define mod 1000000007 #define mod2 998244353 #define all(x) ...
#include<bits/stdc++.h> #include<chrono> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace std::chrono; using namespace __gnu_pbds; #define ll long long int #define ull unsigned long long int #define FOR(I,a,b) for(int I=a;I<b;I++) #define FORit(it,a) for...
#include<bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define fi first #define se second const int MOD = 1000000007; const int MOD1 = 998244353; const int maxn = 100010; const int lim = (int)1e9; int main() { ios_base::sync_with_stdio(false); cin.ti...
#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 db double #define el "\n" #define ld long double #define rep(i,n) for(int i=0;i<n;i++) #define rev(i,n) for(int i=n;i>=0;i--) #define r...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <utility> #include <tuple> #define rep(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; using ll = long long int; using P = pair<ll, ll>; // clang-format off #ifdef _DEBUG_ #define dump(...) do{...
#include <bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; ll I=167167167167167167; ll Q=1e9+7; int main() { ll N; cin>>N; vector<ll> a(N),b(N); for(int i=0;i<N;i++) cin>>a[i]; for(int i=0;i<N;i++) cin>>b[i]; ll A=0,B=0; for(int i=0;i<N;i++){ A=max(A,a[i]); b[i]*=A; B=max(B,b[...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < int(n); i++) #define FOR(i, a, b) for (int i = a; i < int(b); i++) #define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++) #define SIZE(v) ((int)(v).size()) #define pb push_back #define mp make_pair #defin...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin(...
#include<bits/stdc++.h> using namespace std; #define ll long long const ll Mod=1e9+7; char a[2005][2005]; ll dp[2005][2005][4]; int n,m; int main(){ cin>>n>>m; for(int i=1;i<=n;i++){ cin>>(a[i]+1); } dp[1][1][0]=dp[1][1][1]=dp[1][1][2]=dp[1][1][3]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) ll ans = 0; const ll mo = 1000000007; auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; }; int main() { ll h , w ; cin >> h >> w ; vector<vector<ll>> v(h, vector<ll>(w,0) ); vector<vecto...
#include <iostream> #include <sstream> #include <algorithm> #include <cmath> #include <functional> #include <vector> #include <set> #include <map> #include <queue> #include <stack> using namespace std; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, ll>; #define rep(i,s,t) for(int i = (int)(s); i < (int)(t); i++) int main(){ ll a,b,c; cin >> a >> b >> c; if(a >= 0 && b >= 0){ if(a > b) puts(">"); else if(a == b) puts("="); else puts("<"); ...
#include <iostream> using namespace std; int main(void){ // Your code here! int t; long long int c; cin>>t; for(int i=0;i<t;i++){ cin>>c; if(c%4==0)cout<<"Even"; else if(c%2==0)cout<<"Same"; else cout<<"Odd"; cout<<endl; } }
//Bismillahir Rahmanir Raheem #include<bits/stdc++.h> using namespace std; typedef pair<int,int>pii; #define sf(x) scanf("%d",&x) #define sfl(x) scanf("%lld",&x) #define lli long long int #define ll64 int64_t #define pb push_back #define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define frr(i,...
#define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); i++) #include <bits/stdc++.h> using namespace std; using ll = long long; ll mod = 1000000007; ll INF = 1001001001; ll max(int a, ll b) { if (a < b) { return b; } else { return a; } } ll min(int a, int b) { re...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define rep1(i,n) for(ll i=1;i<=(ll)(n);i++) // #define LOCAL 1; #ifdef LOCAL #define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #else #define dbg(x) true #endif template<typename T> ostr...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main(){ int n, m; vector<int> t(1001, 0); cin >> n >> m; for(int i=0; i<n; i++){ int tmp; cin >> tmp; t[tmp]++; } for(int i=0; i<m; i++){ int tmp; cin >> tmp; t[tmp]++; } for(int i=1; i<1001; i++){ if(t[i] == 1){ cout << i;...
#include <iostream> #include <vector> #include <algorithm> template<typename Container> Container SetAnd(const Container &a, const Container &b){ Container res; std::set_intersection( std::begin(a), std::end(a), std::begin(b), std::end(b), std::inserter(res, std::end(res)) ); return res; } template...
#include <bits/stdc++.h> #define lc (o<<1) #define rc ((o<<1)|1) #define PB push_back #define MK make_pair using namespace std; #define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl const int maxn = 5000 + 5; const int modu = 998244353; // 1e9 + 7 const int inf = 0x3f3f3f3f; const double eps = ...
#include <bits/stdc++.h> #pragma GCC optimize(3) #define int long long #define ri register #define mk make_pair #define fi first #define se second #define pb push_back #define eb emplace_back #define is insert #define es erase using namespace std; const int N = 200010; inline int read() { int s = 0, w = 1; ri c...
#include<iostream> #include<cstdio> using namespace std; long long x,y; int n,m; int main() { scanf("%d %d",&n,&m); string temp; for(int a=1;a<=n;a++) { int t=0; cin>>temp; for(int b=0;b<temp.size();b++) t+=temp[b]-'0'; if(t%2==0) x++; else y++; //printf("%d\n",t); } printf("%lld",x*y); return 0; }
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ld long double #define ull unsigned long long int #define ll long long int #define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define rep(i,L,R) for(ll i=L;i<R;i++) #define...
#include<iostream> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; if (C % 2 == 1) { if (A <= 0 && B > 0) { cout << "<"; } else if (B <= 0 && A > 0) { cout << ">"; } else if (A > 0 && B > 0) { if (A > B) cout << ">"; else if (A < B) cout << "<"; else cout << "="; } el...
/* Author : Drigesh Anuragi */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<n;i++) #define repl(i,n) for(ll i=0;i<n;i++) #define repl1(i,n) for(ll i=1;i<n;i++) #def...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pll> vpll; #define FOR(n) for(int i=0;i<n;++i) #define IOS ios::sync_with_stdio(0); cin.tie(...
//Iamskk// #include <iostream> #include <iosfwd> #include <iomanip> #include <cstdio> #include <cstring> #include <cstdlib> #include <ctime> #include <cmath> #include <cassert> #include <cctype> #include <climits> #include <vector> #include <bitset> #include <set> #include <queue> #include <stack> #include <map> #inclu...
#include <bits/stdc++.h> #define LL long long #define ULL unsigned long long #define pb push_back #define st first #define nd second #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f template <class T> T read(T &a) { a=0;char x=getchar();bool f=0; for(;x<'0'||x>'9';x=getchar())f|=x=='-'; for(;x>='0'&&x<='...
// Problem : A - 106 // Contest : AtCoder - AtCoder Regular Contest 106 // URL : https://atcoder.jp/contests/arc106/tasks/arc106_a // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; long long N; long long myp...
#include <cstdio> #include <cstring> #define int long long const int N = 200005, M = 2*N, p = 1000000007; int num, head[N], next[M], vet[M], len[M], n, x, y, z, ans, dis[N], cnt[2]; void add(int u, int v, int c) { vet[++num] = v, len[num] = c; next[num] = head[u]; head[u] = num; } int Pow(int a, int b) { ...
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<string.h> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) do {} while (0) #endif #include<cassert> using ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() template<typename T> std::ostream & operator<<(std::ostream & Str, vector<T> const & vec) { Str << "["; for (int i = 0; i < vec.size(); ++i) { ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define vl vector<ll> #define ml map<ll,ll> #define sl set<ll> #define vp vector< pair <int,int> > #define pb push_back #define asort sort(a,a+n) #define all(v) v.begin(),v.end() #define vsort(v) sort(v.begin(),v.end()) #define F first #define S seco...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6; int cnt[MAX+4]; bool isSqr[MAX+4]; using pii = pair<int,int>; long long coprimes(int l, int r){ //[l,r]에서 x<y인 서로소 쌍의 수 //전체에서 k로 동시에 나눠떨어지는걸로 포함배제하면 된다 long long result = 1LL * (r-l+1) * (r-l) / 2; for(int i=2;i<=r;i++)if(!isSqr[i])...
#include <bits/stdc++.h> using namespace std; int main(){ int H,W; cin>>H>>W; vector<vector<int>> p(H+1,vector<int>(W+1)); for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ char a; cin>>a; if(a=='.'){ p[i][j]++; } } } int Z=0; for(int i=0;i<H;i++){ for(int j=0;j<W;j+...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //#define int long long #define len(x) (int)x.l...
#include <iostream> #include <algorithm> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <string.h> #include <vector> #include <queue> #include <cmath> #include <complex> #include <functional> #include <numeric> #include <iomanip> #include <cassert> #include <random> #include ...
#pragma GCC optimize "trapv" #include<bits/stdc++.h> #define int long long #define pb push_back #define ppb pop_back #define ff first #define ss second #define sz(s) (int)(s.size()) #define all(a) (a).begin(),(a).end() #define pii pair<int,int> #define deb(x) cout << #x << " = " << x << endl #define endl '\n' #define ...
#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 ld long double #define ll long long #define REP(i, a,...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++...
#include<bits/stdc++.h> #define re register #define N 2001001 #define MAX 2001 using namespace std; typedef long long ll; typedef double db; const ll mod=998244353; inline void read(re ll &ret) { ret=0;re char c=getchar();re bool pd=false; while(!isdigit(c)){pd|=c=='-';c=getchar();} while(isdigit(c)){ret=(ret<<1)+(r...
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; //using namespace atcoder; using ll = long long; typedef pair<ll,ll> P; typedef pair<ll,P> PP; typedef vector<vector<int> > Graph; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } temp...
// Problem: C - ORXOR // Contest: AtCoder - AtCoder Beginner Contest 197(Sponsored by Panasonic) // URL: https://atcoder.jp/contests/abc197/tasks/abc197_c // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> #include <iostream> #include <string> #in...
/*Jai Shree Ram*/ // Never Give Up #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi vector<int> #...
#include <bits/stdc++.h> using namespace std; // Templates here template<typename T1, typename T2, typename T3> class triple { public: T1 first; T2 second; T3 third; triple() { first = 0; second = 0; third = 0; } }; // Typedefs here typedef long long ll; typedef pair<int,...
#pragma region Macros #include <bits/stdc++.h> using namespace std; using ll = long long; #define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i) #define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i) #define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME #define REP(...) GET_MACRO_...
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int,int> P; int h,w; int fie[2005][2005]; vector<P> pos[29]; int dp[29][29]; int dist[2005][2005]; bool used[29]; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; int bfs(int v){ memset(dist,-1,sizeof(dist)); queue<...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(v) v.begin(), v.end() template<class T>bool chmax(T& a, const T& b) { if (a<b) { a=b; return 1;} return 0;} template<class T>bool chmin(T& a, const T& b) { if (b<a)...
#include <bits/stdc++.h> //#include <atcoder/all> #define endl "\n" using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bo...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=5e3+5; const int mod=998244353; int n,m; int dp[15][N]; int fac[N],invf[N]; inline int po(int x,int k){ int ret=1; while(k){ if(k&1) ret=1ll*ret*x%mod; x=1ll*x*x%mod; k>>=1; } return ret; } inline int C(int x,int k){ if(x<k) retur...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N=2e5+5; int n; char s[N],x[N]; int f[N][8]; int dp(int i,int k){ if(i==n) return (k==0); if(f[i][k]!=-1) return f[i][k]; int ans; if(x[i]=='T') ans=dp(i+1,(k*10+s[i]-'0')%7)|dp(i+1,(k*10)%7); else ans=dp(i+1,(...
#include<bits/stdc++.h> #include <stdio.h> #include <algorithm> #define all(x) x.begin(),x.end() #define sc(x) scanf("%d",&x) #define scl(x) scanf("%lld",&x) #define LL long long #define LD long double #define pb push_back #define F first #define S second const double PI=3.1415926535897932384626433; const int KL=1e6...
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") // #pragma GCC optimization ("unroll-loops") #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<cmath> #include<map> #include<vector> #include<unordered_map> #include<queue> #include<cstring> #include<string> #include<bi...
#include<bits/stdc++.h> #define int int64_t #define pb push_back #define endl '\n' #define pll pair<int,int> #define vll vector<int> #define all(a) (a).begin(),(a).end() #define ff first #define ss second #define sz(x) (int)x.size() #define hell ...
// #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; /************************************************...
#include<stdio.h> #include<string.h> #define it register int #define ct const int #define il inline using namespace std; #define P 998244353 #define inv2 499122177 typedef long long ll; const int N=1000005; int fac[N],ifac[N],inv[N],ans,a[N],b[N],n,m,pw[N],f[N],g[N]; il int C(ct n,ct m){return n<m||m<0?0:(0ll+fac[n])...
//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 <iostream> #include <map> #include <set> #include <cmath> #include <queue> #include <vector> #include <string> #include <algorithm> #include <functional> using namespace std; #pragma warning (disable: 4996) long long modpow(long long a, long long b, long long m) { long long p = 1, q = a; for (int i = 0; i <...
#include <iostream> #include <vector> #include <array> #include <set> using namespace std; int main() { int N; cin >> N; vector<array<int, 5>> A(N); for (auto& a : A) for (int& i : a) cin >> i; int ok = 0, ng = 1001001001; auto check = [&](int x) -> bool { set<int> s; for(au...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mxN = 501; const int INF = 1e9; int a[mxN][mxN]; void solve(){ long double x, y, r; cin >> x >> y >> r; r += 1e-14; ll ans = 0; for(int i = ceil(x - r); i <= x + r; i++){ ans += floor(y + sqrt(r * r - (x - i) ...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define PI 3.1415926535897932 #define INF 1e9 #define rep(i, n) for (int i = 0; i < n; i++) #define repe(i, j, n) for (int i = j; i < n; i++) #define repi(i, n) for (int i = 0; i <= n; i++) #define repie(i, j, n) for (int i = j; i <= n; i++) #define...
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(), x.end() int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<array<int, 2>> black(m); for(auto &[x, y] : black) cin >> x >> y; set<int> white; white.insert(n); sort(all(black)); for(int i =...
#include<bits/stdc++.h> using namespace std; vector< pair< int , int > > s[2003]; int q[2000006]; int main(){ int n,m;cin>>n>>m; for(int i=1;i<=m;++i){ int u,v,w;cin>>u>>v>>w; s[u].push_back(make_pair(v,w)); } for(int i=1;i<=n;++i){ int h=0,t=0; int d[2003];memset(d,0x3f3f3f3f,sizeof(d)); bool v[2003]={0}...
#include<bits/stdc++.h> #define rep(i,n) for(ll i=0;i<(ll)(n);i++) using namespace std; typedef long long ll; vector<ll> ans_vec(500,0); ll H,W,A,B; void dfs(ll a,ll k,ll board[]){ if(k == A){ ans_vec[a]++; } for(ll h=0;h<H;h++){ for(ll w=0;w<W;w++){ if(k < a){ i...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<vector<int>> vec(N, vector<int>(3)); for(int i = 0; i < N; i++){ cin >> vec[i][0] >> vec[i][1] >> vec[i][2]; } long long answer = 0; for(int i = 0; i < N; i++){ for(int j = i+1; j < N; j++){ if((vec[i][1] < ve...
#include<bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define LOCAL #endif typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; typedef vector<ll> vi; typedef vector<pll> vpll; const long infl=0x3f3f3f3f3f3f3f3fLL; const int infi=0x3f3f3f3f; #define endl '\n' #define pb p...
/* @authors MAGNETO @date 2021-05-24 11:33:20 */ #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> // Common file //#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; #define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr); #define endl ...
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; string s; cin >> n >> s >> q; vector<int> idxs(2*n + 1); for (int i = 1; i <= 2*n; i++) idxs[i] = i; int flag = 0; while (q--) { ...
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 5; set<int> s[N]; map<pair<int,int>, int> mp; int par[N]; int parent(int x) { if(par[x] != x) par[x] = parent(par[x]); return par[x]; } void join(int x, int y) { x = parent(x); y = parent(y); if(x == y) return; if(s[x].size() > s[y].size(...
#include<bits/stdc++.h> #define int long long #define PI pair<int,int> using namespace std; const int maxm=1e3+5; //const int mod=1e9+7; //const int mod=998244353; vector<PI>g2[maxm][maxm]; vector<PI>g[maxm]; int mark[maxm][maxm]; int d[maxm][maxm]; int n,m; void bfs(){ for(int i=1;i<=n;i++){ for(int j=1;j<...
#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 tuple<int,int> tpl; typedef pair<int,int> Pair; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c).en...
#include <bits/stdc++.h> using namespace std; int main(){ long long s,p; cin>>s>>p; for(long long i=1;i*i<=p;++i){ if(p%i==0){ if((i+p/i)==s){ cout<<"Yes"; return 0; } } } cout<<"No"; return 0; }
#include<bits/stdc++.h> using namespace std::chrono; using namespace std; #define int long long #define loop(i, start, end) for (int i = start; i <= end; i++) #define rloop(i, start, end) for (int i = start; i >= end; i--) #define read(a,n) loop(i,0,n-1) cin>>a[i]; #define vi vector<int> #define vec(x) vector<x> #defin...
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> pii; typedef vector<int> vii; typedef vector<pii> vpii; typedef unordered_map<int,int> umap; typedef long double ld; #de...
#include <bits/stdc++.h> template <class T> T read() { T num = 0; T f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { num = num * 10 + ch - '0'; ch = getchar(); } return num * f; } int main() { int x = read<int>(); int...
#include<bits/stdc++.h> using namespace std; int main() { string C; cin >> C; if(C.at(0)==C.at(1)) { if(C.at(1)==C.at(2)) { cout << "Won" << endl; } else { cout << "Lost" << endl; } } else { cout << "Lost" << endl; } }
#include <bits/stdc++.h> #define ll long long #define MODV 1000000007 // 998244353 #define INFLL (1LL<<62) #define EPS 1e-9 #define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++) #define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++) #define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--) #define all(v) v...
//Codeforcesで128bit整数を使いたいとき //→__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 FO...
#include <bits/stdc++.h> using namespace std; // #define int long long // #define double long double #define rep(i,a,b) for(int i=(int)(a); i<(int)(b); ++i) #define repeq(i,a,b) for(int i=(int)(a); i<=(int)(b); ++i) #define rrep(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); --i) #define rrepeq(i,a,b) for(int i=(int)(b); i>...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; const int inf = 1e9 + 10; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) using pint = pair<ll, ll>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { int n; ...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define INF 1 << 30 // bool solve1(string S) { // sort(S.begin(), S.end()); // for (int i = 8; i <= 999992; i += 8) { // auto T = to_string(i); // sort(T.begin(), T.end()); // ...
#include <bits/stdc++.h> using namespace std; using namespace chrono; #define flash ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define ndl '\n' void solve() { ll n;cin>>n; cout<<ceil((-1+sqrtl(1+8*n))/2)<<ndl; } int main() { auto starttime = high_resolution_clock::now(); flash s...
#include <bits/stdc++.h> using namespace std; int main() { int cur, n, i; cin >> n ; cur = 0; i = 1 ; while(i<=n){ cur += i ; if(cur>=n) break ; ++i ;} cout << i ; return 0; }
#include <bits/stdc++.h> #define pii pair<int,int> #define fi first #define pb push_back #define si second #define int long long // #define ll long long #define mod 1000000007 // #define mod 998244353 #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define double long double #define all(o...
#include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define vec vector using namespace std; const int MX = 1e6 + 1; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef LOCAL // freopen("in1.txt", "r", stdin); // freopen("in1.txt", "w", stdout); #endif int l, r; ci...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int tc; cin >> tc; while (tc--) { int n; cin >> n; set<int> s; for (int i = 0; i < n; ++i) { int a; cin >> a; if (s.find(a) != s.end()) s.erase(a); else s.insert...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; void solve(){ int n; scanf("%d",&n); vector<lint> a(n); rep(i,n) scanf("%lld",&a[i]); if(n%2==0){ map<int,int> f; rep(i,n) ++f[a[i]]; bool ok=true; for(auto p:f) if(p.second%2==1) ok=false; puts...
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define MOD 1000000007LL #define MXN 10005 #define INF 1e9 #define EPS 1e-8 #define endl '\n' #define lowbit(x) (x&-x) using namespace std; mt19937 gen(time(0)); ll n; bool isprime[MXN]; bool v[MXN]; ll ans[MXN]; ll factor[] = {6,10,15}; vector<l...
#include<bits/stdc++.h> using namespace std; #define int long long int #define ll long long #define quickie ios_base::sync_with_stdio(false); cin.tie(NULL); #define rep(i, a, b) for(int i=a; i<b; i++) #define rep1(i, a, b) for(int i=a; i<=b; i++) #define repp(i, a, b) for(int i=b-1; i>=a; i--) #define pb push_back #de...
#include<iostream> #include<algorithm> #include<cstdlib> #include<sstream> #include<cstring> #include<cstdio> #include<string> #include<deque> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; const long long MOD = 998244353; int n; long long a[200010]; long long base[200010]; void i...
#include<bits/stdc++.h> #define int long long using namespace std; /*#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; s.find_by_order(x) xth element in set x.order_of_key(x) number of element...
/** Bismilla- hir rahma-nir rahi-m @uthor Md Hasibur Rahman (Evan) JKKNIU */ #include<bits/stdc++.h> #define ll long long #define FI freopen("input.txt","r",stdin) #define FO freopen("output.txt","w",stdout) #define Pri...
#include <iostream> #include <string> using namespace std; int main(){ string n; cin >> n; int zero_counter = 0; for(int i = 0;i < n.size();i++){ if(n[n.size()-1-i] == '0'){ zero_counter += 1; }else{ break; } } for(int i = 0;i < zero_counter;i++){ ...
#include<bits/stdc++.h> using namespace std; const long long mod = 998244353; long long a [4] , ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in","r",stdin); //freopen(".out","w",stdout); long long n , m; cin >> n >> m; for ( int i = 0 ; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>; using graph = vector<VI>; template<class T = ll> using w_graph = vector<vector<pair...
#include <bits/stdc++.h> #define int long long #define ll long long #define endl "\n" using namespace std; const int maxn = 1e5; signed main() { int x, y; cin >> x >> y; if (x == y) cout << x << endl; else { cout << 3 - x - y << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print...
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin>>n; int k=10*10*10*10*10*10; vector<long long> yakusuu(2*k); for(int i=1;i<k+1;i++){ if(n%i==0){ yakusuu[i-1]=i; yakusuu[2*k-i]=n/i; } } sort(yakusuu.begin(),yakusuu.end()); yakusuu.erase(unique(yakusuu.begin()...
#include <bits/stdc++.h> using namespace std; int main() { long n; cin>>n; set<long> ans; for(long d=1;d*d<=n;d++) { if(n%d==0) { ans.insert(d); ans.insert(n/d); } } for(auto x:ans) cout<<x<<endl; }
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++) #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend...
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; //#define int long long const int N = 1e6; int n,m; bool pd[N]; inline int read() { int X=0;bool flag=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')flag=0;ch=getchar();} while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-'...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define deb(x) cout << #x << " " << x << endl; #define mod 1000000007 #define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); #define endl "\n" #define all(x) (x).begin(), (x).end() #define rall(v) v.rbegin(), v.rend() #define ...
//BISMILLAHIR RAHMANIR RAHIM #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define mem(a, b) (memset(a, b, sizeof(a))) #define pb push_back #define mk make_pair #define ff first #define ss second #define PI acos(-1) #define min3(a,b,c) min(a,min(b,c)) #define...
#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; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pdd; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pll> vpl; typedef vector<vll> vvll; #define ALL(a) a.begin(),a.end() #define SZ(a) ((i...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define FOR(i,n,j) for(int i=(j);i<(n);++i) #define ssort(n) sort((n).begin(),(n).end()) #define rsort(n) sort((n).begin(),(n).end(),greater<int>()) #define mp make_pair using ll=long long; using ld=long double; typedef pair<int,int> ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i,n) for(int i=0;i<n;i++) #define ALL(v) v.begin(),v.end() int main(){ VI a(4); REP(i,4) cin >> a[i]; ll sum=0; RE...
#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 fi first #define se second #define mem(a,b) memset(a,b,sizeof(a)) #define debug(x) cout << (#x) << " = " << x << endl; #defin...
#include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <bitset> #include <queue> using namespace std; using ll = long long int; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) const ll INF = 1LL << 60; ll...
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define Rep(i,n) for(int i = 1; i <= n; i++) #define sz(x) int(x.size()) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define YesorNo(a) printf(a ? "Yes\n" : "No\n") #define fin(a) cout << a << endl; retu...
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define all(v) v.begin(),v.end() using namespace std; const int INF = 1e9; const int TMX = 1 << 18; const long long llINF = 2e18; const long long mod = 1e9+7; const long long hashmod = 100003; typedef long long ll; typedef long double ld; ty...
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define vi vector <int> #define vl vector <ll> #define vii vector < pair <int,int> > #define vll vector < pair <ll,ll> > #define mii map<int,int> #define mll map<ll,ll> #define si set <int> #define sl set <ll> #define all(a) a.begin...
/* @uthor: Kashish Gilhotra user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001 */ #include <bits/stdc++.h> using namespace std; #define int long long int typedef vector<int> vi; typedef vector<pair<int, int>> vpi; typedef vector<vi> vvi; const int mod = 1e9 + 7; #define FAST io...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; typedef pair<int,int> P; const int MAX_K = 200005; ll cnt[MAX_K]; int main() { ll K; cin >> K; for (int i = 1; i <= K; ++i) { for (int j = 1; j*j <= i; ++j) { if (i % j == 0) { cnt[i]++; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 0x3f3f3f3f #define rep(i,b,e) for(int i=b;i<e;i++) #define per(i,e,b) for(int i=e;i>b;i--) const int maxn = 5e5+5; void solve() { int x; cin >> x; if (x >= 0) cout << x << '\n'; else cout << "0\n"; } int main() { ios_base::sync_with_...
#pragma GCC optimize("Ofast,unroll-loops") // #pragma comment(linker, "/stack:200000000") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespac...
#include <bits/stdc++.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define RI(X) scanf("%d", &(X)) #define RII(X, Y) scanf("%d%d", &(X), &(Y)) #define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y...
#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; ll dp[100][2]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; ll X; cin >> X;...
/** * 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> #define rep(i,n) for(int i=0; i<n; i++) #define reps(i,s,n) for(int i=s; i<n; i++) #define per(i,n) for(int i=n-1; i>=0; i--) #define pers(i,n,s) for(int i=n-1; i>=s; i--) #define all(v) v.begin(),v.end() #define fi first #define se second #define pb push_back #define si(v) int(v.size()) #defin...
#include <iostream> using namespace std; using LL = long long; const int kMaxN = 101; const LL kMod = 1e9 + 7; int n, m, k; LL d[kMaxN], a[kMaxN], r[kMaxN][kMaxN], p_n = 1, b[kMaxN][kMaxN], c[kMaxN][kMaxN]; bool l[kMaxN][kMaxN]; LL PM(LL x) { LL s = 1; for (LL i = kMod, b = x; i; i >>= 1, b = b * b % kMod) { ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N, Q; cin >> N >> Q; vector<long long> A(N); for (auto& x : A) { cin >> x; } vector<long long> low(N); for (int i = 0; i < N; ++i) { low[i] = A[i] - (i + 1); } while (Q-...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; using LL = long long; using ULL = unsigned long long; using IntPair = pair<int, int>; using ULLPair = pair<ULL, ULL>; #define scast static_cast #defi...
#include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/gcd(a,b) #define mem1(a) memset(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define forn(i,x,n) for(int i = x;i <= n;++i) #define forr(i,x,n) for(int i = n;i >= x;--i) #define Angel_Dust ios::sync_with_stdio(0);cin.tie(0) int main() { int a,b;scanf("%d%d",&a,&b); printf("%.18lf\n",a * b / 100.0); return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int> a(n), b(n); for(int& x: a) cin>>x; for(int&x : b) cin>>x; int res = 0; for(int i = 0; i < n; i++) res += a[i] * b[i]; cout<<(res == 0 ? "Yes\n" : "No\n"); }
#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <cmath> #include <cstring> #include <chrono> #include <complex> #define REP(i,a,b) for (auto i = a; i != b; i++) #define maxheap priority_queue < ll, std::vector<ll>, std::less<ll> > #define minheap priority_queue < ll, std::vector<ll>, std::greater...
#include <bits/stdc++.h> #define int long long #define pb push_back #define vi vector<int> #define vii vector<vi> #define viii vector<vii> #define all(a) a.begin(), a.end() #define sz(a) a.size() const int mod=998244353; using namespace std; void solve() { int n; cin >> n; vi w(n + 1); int summ = ...
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> using std::sort; using std::cout; using std::endl; using std::max; using std::min; inline int read(){ int h=0;char c=getchar(); while(c<'0'||c>'9')c=getchar(); while(c>='0'&&c<='9')h=(h<<1)+(h<<3)+c-'0',c=getchar(); return h; } const int p...
# include <bits/stdc++.h> #define rep(i,l,r)for(int i=(l);i<(r);i++) # define rrep(i,r,l) for(int i=(r); i>=l; --i) # define ALL(x) (x).begin(), (x).end() # define SZ(x) ((int)(x).size()) # define pb push_back # define optimize_cin() cin.tie(0); ios::sync_with_stdio(false) using namespac...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long bool comp(pair<ll, ll> a, pair<ll, ll> b) { return 2 * a.first + a.second > 2 * b.first + b.second; } int main() { int N; ll a, b, sumA = 0, sumB = 0; vector<pair<ll, ll>> C; cin >> N; for (int i = 0; i < N; ++i) { c...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<21-a-b-c; return 0; }
#include<bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mem(a,val) memset(a,(val),sizeof((a))) #define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define decimal(n) cout << fixed ; cout << setprecision((n)); #define mp make_pair #define eb emplace_ba...
//~ author : Sumit Prajapati #include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long #define int long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb ...
#include <cstdio> #include <algorithm> #define int long long const int N = 1000005; int l, r, f[N], ans; signed main() { scanf("%lld%lld", &l, &r); for(int i = r; i >= 1; i--) { int an = r/i - (l-1)/i; f[i] = an * an; for(int j = i+i; j <= r; j += i) f[i] -= f[j]; } for(int i = 2...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;++i) #define irep(i,a,b) for(int i=int(a);i<(int)b;++i) #define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i) #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vector<ll>> #define vvp vector<vector<pair<ll,ll>>> #...
#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> #define _GLIBCXX_DEBUG using namespace std; using Graph = vector<vector<int>>; const long long INF = 1LL << 60; typedef long long ll; const ll MOD = 998244353; int main() { //cout << std::fixed << std::setprecision(15) ; bool frg = false; vector<int> data(4); for(int i=0;i<4;i++...
#include <iostream> #include <vector> #include <utility> #include <queue> #include <vector> #include <list> #include <cmath> #include <deque> #include <utility> #include <climits> #include <unordered_map> #include <unordered_set> #include <cstdlib> #include <string> #include <stack> #include <set> #include <functional>...