code1
stringlengths
54
12k
code2
stringlengths
66
12k
similar
int64
0
1
__index_level_0__
int64
24
101M
#include <bits/stdc++.h> using namespace std; using ll = long long; #pragma region Macros #define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i, n) FOR(i, 0, n) 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, co...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;n>i;++i) using namespace std; using ll=int64_t; using vi=vector<int>; using VI=vector<ll>; using vis=vector<string>; using vvi=vector<vi>; int gcd(int a,int b){ if(a%b==0) return b; return gcd(b,a%b); } int main(){ int k,s; cin>>k>>s; int ans=...
1
76,791,509
#include<bits/stdc++.h> typedef long long ll; using namespace std; int main(void) { ll R,G,B,N; cin >>R>>G>>B>>N; ll ans=0; for(ll r=0;r*R<=N;r++) { for(ll g=0;g*G<=N;g++) { ll bn=N-r*R-g*G; if(bn>=0&&bn<=N&&bn%B==0){ ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define ALL(v) (v.begin(),v.end()) #define COUT(x) cout<<(x)<<...
1
59,138,893
#include <bits/stdc++.h> #define pi 3.14159 using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f; #define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0); int main() { LL n,m,i; vector<pair<LL,LL>>v1,v2; scanf("%lld %lld",&n,&m); fo...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++) #define ALL(v) (s)....
1
26,445,286
#include<bits/stdc++.h> using namespace std; #define ll long long #define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const ll MOD = 1000000007; const ll N=1e5+9; int main() { FASTINOUT; ll x,k; cin>>x>>k; ll m=(x-1)*(x-2)/2; if (m<k) { cout<<-1<<endl; ...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> P; int INF = 1e18; int mod = 1e9+7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N,K; cin >> N >> K; if(K > (N-1)*(N-2)/2) { cout << -1 << endl; return 0; } int res ...
1
22,404,803
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false);cin.tie(0); int N; set<int> s; cin>>N; for(int i = 0;i < N;i++){ int a; cin>>a; s.insert(a); } if(s.size() != N){ cout<<"NO"<<'\n'; }else{ cout<<"YES"<<'\n'; } }
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unordered_set> #pragma GCC...
1
92,562,575
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using LL = long long; using P = pair<int,int>; int main(){ int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K; cout << H2*60 + M2 - (H1*60 + M1) - K << endl; return 0; }
#include<bits/stdc++.h> #define ll long long #define ld long double #define mk make_pair #define fi first #define se second #define vll vector<ll> #define pii pair<ll,ll> #define vvll vector< vector<ll> > #define pb push_back #define sz(v) (ll)(v).size() #define inf 1e18 #define md 1000000007 #define all(v) (v).begin()...
1
32,266,619
#include <bits/stdc++.h> #include <cmath> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define sz(x) ll(x.size()) typedef long long ll; typedef pair<ll, ll> P; const ll INF = 10e10; const ll MINF = -10e10; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) typedef priority_queue<P,...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define rev(x) greater<(x)>() #define MOD 1000000007 #define INF 1000000000 typedef long long LL; typedef long double LD; bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b...
1
89,150,945
#pragma region #include <bits/stdc++.h> using namespace std; inline void ci(void){ return; } template <typename First, typename... Rest> void ci(First& first, Rest&... rest){ cin >> first; ci(rest...); return; } inline void co(void){ cout << "\n"; return; } template <typename First, typename... Rest> void c...
#include <stdio.h> #include <string> #include <stdlib.h> #include<vector> #include<iostream> #include<set> #include<map> #include<algorithm> using namespace std; long long int divide(long long int h,long long w){ if(h %2 == 0){ return (h/2)*w; } if(w %2 == 0){ return (w/2)*h; } long long int mi = min(h,w); lo...
1
69,300,445
#include <bits/stdc++.h> using namespace std; int main() { int X, Y; cin >> X >> Y; for(int i = 0; i <= X; i++) { if(i*4 + (X-i)*2 == Y) { cout << "Yes" << endl; break; } else if(i == X) cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int x,y; string ans = "No"; cin >> x >> y; for(int i=0 ; i<=x ; i++){ if(i*2 + (x-i)*4 == y){ ans = "Yes"; break; } } cout << ans << endl; }
1
21,036,149
#include <iostream> #include <cstdio> using namespace std; long long n,m,sum; int main() { scanf("%lld%lld%lld",&n,&m,&sum); for(int i=0;i<n;i++) { if(i<m) {printf("%lld",sum); } else { if(sum!=1000000000)printf("1000000000"...
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define inf 1001001001 #define mod 1000000007 #define mod2 998244353 #define pi acos(-1) #define all(v) v.begin(),v.end() ll gcd(ll a,ll b){ if(b>a) swap(a,b); if(b==0) return a; return gcd(b,a%b);...
1
6,604,584
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int x, y; cin >> x >> y; if(y >= 2*x && y <= 4*x && y % 2 == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int X,Y; cin >> X >> Y; if(Y%2 == 1){ cout << "No" << endl; } else if(4*X >= Y && 2*X <= Y){ cout << "Yes" <<endl; } else{ cout << "No" << endl; } }
1
66,916,361
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const ll mod = 1000 * 1000 * 1000 + 7; ll dp[100000][2]; struct node { vector<int> edges; }; struct graph { vector<node> nodes; int n; graph(int _n) : n(_n) { nodes.resize(n); } void add_edge(int u, int v) { nodes...
#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 '\n' #define int long long #define doub...
1
72,595,927
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); double ans; int64_t sum = 0; vector<int> num(n, 1); for (int i = 0; i < n; i++) { cin >> a[i]; sum += 1e10 / a[i]; } ans = 1e10 / sum; printf("%.10f", ans); }
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define ll long long using namespace std; const ll P = 1000000007; int gcd(int a, int b) { return b != 0 ? gcd(...
1
76,959,009
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<cmath> #include<cstdio> #include<queue> #include<deque> #include<map> #include<stack> #include<set> #include<tuple> using namespace std; typedef pair<int,int> ii; typedef long long ll; typedef pair<ll,ll> pll; typedef unsigned long long i...
#include <bits/stdc++.h> #define rep(i, N) for (ll i = 0; i < N; i++) #define INF 1000000000 #define MOD 1000000007 using ll = long long; using namespace std; typedef pair<int,int> P; typedef vector<int> vi; int main() { int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int H, W; cin >> H >> W; int sx =...
1
21,675,205
#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>; using V = vector<int>; int main(int argc, char const *argv[]) { int n; cin >> n; int a, b = 0; long long int ans = 0; rep(i,n) { cin >> a; if (a>b) b...
#include <bits/stdc++.h> using namespace std; #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define rep(i, n) repl(i, 0, n) #define CST(x) cout << fixed << setprecision(x) using ll = long long; const ll MOD = 1000000007; const int inf = 1e9 + 10; const ll INF = 4e18 + 10; const int dx[9] = {1, 0, -1, 0, 1, -1, -...
1
19,061,172
# include <bits/stdc++.h> # define fi first # define se second using namespace std ; int vc[110][110], cnt=1, cnt2; int W, B,x ; int main() { cin >> W >> B ; if( W > B ) x = true ; else x = false ; for( int j = 1 ; j <= 100 ; j += 2 ) { for( int i = 1 ...
#include <iostream> #include <cstring> #include <stdlib.h> #include <vector> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <math.h> #include <string> #include <map> #include <iomanip> using namespace std; typedef long long ll; typedef pair<int, int> P; void print_vector(vector<ll> vt)...
1
4,629,872
#include<iostream> #include<cstdio> #include <stdio.h> #include<algorithm> #include<cstring> #include<cmath> #include<cstdlib> #include<queue> #include<map> #include<vector> #include <set> #define ll long long #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #define inf 0x3f3f3f3f #define pi 3.1415926535898...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 1e9 + 7; const ll longinf = 5LL << 60; const ll mod = 1e9 + 7; int main() { ll N, K; cin >> N >> K; ll ans = 0; for(int i = K; i <= N + 1; i++) { ans += (((i * (N + 1 - i)) % mod) + 1) % mod; ans %= mod; } cout << ans << "\n";...
1
48,393,965
#include<iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<n;i++) using P = pair<ll, ll>; char tolower(char c) {return (c + 0x20);} char toupr(char c) {return (c - 0x20);} int main() { ll n; cin >> n; ll res = n*(n-1)/2; cout << res << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() using ll = long long; string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } template<class T> inline bool chmin(T& a, T b...
1
46,424,349
#include<bits/stdc++.h> using namespace std; int solve(vector<int>&a){ map<int,int>kazu; for(int i=0;i<a.size();i++){ kazu[a.at(i)]++; kazu[a.at(i)-1]++; kazu[a.at(i)+1]++; } int ans=0; for(auto i:kazu){ ans=max(ans,i.second); } return ans; } int main(){ int n; cin >> n; vector<int>a...
#include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define f...
1
2,572,891
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define pii pair<int,int> const long long MOD=1000000007; int main(){ char a,b; cin>>a>>b; if(a==b) cout<<"H"<<endl; else cout<<"D"<<endl; return 0; }
#include<bits/stdc++.h> #define ll long long #define ld long double #define X first #define Y second #define pb push_back #define max_el(x) max_element(x.begin(),x.end())-x.begin() #define min_el(x) min_element(x.begin(),x.end())-x.begin() #define mp make_pair #define endl '\n' #define fastread ios_base::sync_with_std...
1
34,249,707
#include <bits/stdc++.h> using namespace std; using ll = long long; #define forn(i, n) for(int i = 0; i < (int)n; ++i) int main() { int p, q, r; cin >> p >> q >> r; int ans = min(p+q, min(q+r, r+p)); cout << ans << "\n"; return 0; }
#include<bits/stdc++.h> #include<vector> #include<string> #include<stack> #include<iostream> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long #define MOD 1000000007 #define vec(a) vector<int>a using namespace std; bool isPrime(ll n) { if(n==1||n==2||n==3||n==5||n==7) ...
1
37,944,692
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mx = 1e6 + 9; vector<ll>adj[mx]; bitset<mx>mark; ll dist[mx]; int main() { ll n, m; cin >> n >> m; for(ll i = 0; i < m; i++) { ll u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } bool nafi...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n, m; cin >> n >> m; set<int> reach; vector<pair<int, int> > p(m); rep(i, m) { cin >> p[i].first >> p[i].second; if (p[i].second == n) reach.insert(p[i].first); } rep(i, m) { if (p[i].f...
1
44,909,431
#include<bits/stdc++.h> using namespace std; int n,m,l,r,d,fl,fr,bo=1,fa[100010],dis[100010]; int find(int x) { if(fa[x]!=x) { int t=fa[x]; fa[x]=find(fa[x]); dis[x]+=dis[t]; } return fa[x]; } int main() { cin>>n>>m; for(int i=1;i<=n;i++) { fa[i]=i; } for...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> G; vector<vector<int>> W; vector<int> dist; vector<bool> visited; void dfs(int u) { visited[u] = true; for (int i = 0; i < G[u].size(); i++) { int v = G[u][i]; if (visited[v]) continue; dist[v] = dist[u] + W[u][i]; ...
1
59,085,135
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<ll,ll>; const ll mod = 1e9+7; #define ALL(x) (x).begin(),(x).end() #define pow(x,y) modpow(x,y) #define REP(i,n) for(ll (i)=0;(i)<(n);(i)++) template <class T = int>T in(){ T x; cin >> x; return (x); } signed main(){ cin....
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; template <typename Tp> inline void getint(Tp &num){ register int ch, neg = 0; while(!isdigit(ch = getchar())) if(ch == '-') neg = 1; num = ch & 15; while(isdig...
1
82,043,509
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> d(n); for (int i = 0; i < n; ++i) { cin >> d[i]; } sort(d.begin(), d.end()); int ans = d[n / 2] - d[n / 2 - 1]; cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { ll a; cin>>a; vector<ll>vec(a); ll b=0; for(ll i=0;i<a;i++){ cin>>vec.at(i); } sort(vec.begin(),vec.end()); cout<<vec.at(a/2)-vec.at(a/2-1)<<endl; return 0; }
1
59,014,951
#include<bits/stdc++.h> using namespace std; #define ll long long #define lvector vector<ll> #define cvector vector<char> #define svector vector<string> #define lque queue<ll> #define lpque priority_queue<ll> #define dlpque priority_queue<ll,lvector,greater<ll>> #define P pair<ll,ll> #define ALL(a) a.begin(),a.end() #d...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long LL; typedef long double ld; typedef vector<ll>VI; typedef pair<ll,ll>P; #define VV(T) vector<vector<T>> #define sz(x) int(x.size()) #define PI 3.1415926535897932384626433832795 #define rep(i, n) for (ll i = 0; i < (ll)n; i++) ...
1
19,844,467
#include<bits/stdc++.h> using namespace std; const int INF= 1e9+5; typedef long long ll; int main(){ int x,a,b; cin>>x>>a>>b; if(x+a<b)cout<<"dangerous"<<endl; else if(b<=a)cout<<"delicious"<<endl; else cout<<"safe"<<endl; }
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <map> #include <vector> #include <stack> #include <queue> #include <tuple> #include <cassert> #include <functional> #include <set> #include <deque> #include <list> using namespace std; typedef long long ll; int dx[4] = {0,0,1,-1}; int ...
1
96,386,305
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> using namespace std; typedef long long ll; #define rep(i, n) for (int i=0;i < (int)(n);i++) struct edge{int c,s,f;}; int main(){ int n; cin >> n; vector<edge> v(n-1); rep(i,n-1){ int a,b,c; ci...
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <cmath> #include <bitset> #include <iomanip> #include <stack> #include <list> #include <map> #include <unordered_map> #include <chrono> #include <numeric> using namespace std; using ll = long long; const ll INF = (ll)1e18+1; const ll D...
1
97,370,722
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll T[100]; ll get_lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main() { ll N; cin >> N; for (int i=0; i<N; i++) { cin >> T[i]; } ll lcm = 1; for (int i=0; i<N; i++) { lcm = get_lcm(lcm, T[i]); } cout << lcm << endl; return 0; }
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rrep(i,n) for(int i=n;i>=0;i--) #define reps(i,n) for(int i=1;i<(int)(n);i++) typedef long long ll; using namespace std; ll gcd(ll a, ll b) { if (b==0) return a; else return gcd(b, a%b); } ll lcm(ll a, ll b) { return a * (b/gcd(a, b));...
1
70,575,353
#include <bits/stdc++.h> using namespace std; #define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); typedef long long ll; const ll mod = 1000000007; const ll INF = 1e18; const ll MAX = 100001; bool check(string str){ int n = str.length(); for(int i = 0; i < n; i++) if(str[i] != str[n-1-i]) ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int flag=1; for(int i;i<(s.size()-1)/2;i++){ if(s.at(i)!=s.at(s.size()-1-i)){ flag=0; } } for(int i;i<(s.size()-1)/4;i++){ if(s.at(i)!=s.at((s.size()/2)-1-i)){ flag=0; } } if(flag==1){ cout<<"Yes...
1
85,827,460
#include <bits/stdc++.h> #define SS " " #define endl "\n" #define EPS 1e-9 #define gcd __gcd #define pb push_back #define pi acos(-1.0) #define Ars greater<int>() #define vi vector<int> #define vvi vector<vector<int> > #define flush ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,int> pdi; typedef pair<double,double> pdd; typedef pair<double,ll> pdl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<pll> vll; typedef vec...
1
28,661,159
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { int n, k; cin >> n >> k; int now = 1; for (int i = 0; i < n; i++) { if (now < k) { now = now * 2; } else { now += k; } } cout << now << endl; return 0; }
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ LL N,K; cin>>N>>K; LL X=1; while(N--){ if(X<K) X*=2; else X+=K; } cout<<X<<endl; return 0; }
1
7,444,664
#include<bits/stdc++.h> using namespace std; int main(){ int N, r, s, Ans; cin >> N; for (int i = 0; i < N; i++){ cin >> r >> s; Ans += s - r + 1; } cout << Ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int a[2]; int sum=0; for(int i=0;i<N;i++){ cin >> a[0] >> a[1]; sum += (a[1]-a[0]+1); } cout << sum << endl; }
1
46,817,467
#include <stdio.h> #include <string.h> int main() { char S[255], T[255]; scanf("%s%s", S, T); int A,B; scanf("%d%d", &A, &B); char U[20]; scanf("%s", U); int result1 = strcmp(S,U); int result2 = strcmp(T,U); if (result1 == 0) { A = A - 1; } if (result2 == 0) {...
#include<stdio.h> #include<string.h> int main(){ int a, b; char s[11]; char t[11]; char u[11]; scanf("%s %s\n", &s, &t); scanf("%d %d\n", &a, &b); scanf("%s", &u); if(strcmp(s,u) == 0){ printf("%d %d\n", a-1, b); } else if(strcmp(t, u) == 0){ printf("%d %d\n", a, b-1); } return 0; }
1
94,861,262
#include <bits/stdc++.h> using intl = long long; using ld = long double; using namespace std; #define rep(i, n) for(intl i = 0; i < (intl)(n); i++) #define repd(i, n) for(intl i = (intl)(n); i >= 0; i--) #define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++) #define repid(i, a, b) for(intl i = (intl)(a); i >...
#include<iostream> using namespace std; int main(){ int a,b,c,d; cin>>a>>b>>c; if(a==b)d=c; if(a==c)d=b; if(c==b)d=a; cout<<d<<endl; return 0; }
1
60,148,396
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define LCM(a, b) (a) / __gcd((a), (b)) * (b) #define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0) #define log_2(a) (log((a)) / log(2)) #define ln '\n' using n...
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int a,b,c,d; scanf("%d",&a); b=a*800; c=a/15; printf("%d\n",b-c*200); }
1
79,371,484
#include <cstdint> #include <iostream> using namespace std; int main() { int64_t H, N; cin >> H >> N; for (int64_t n = 0; n < N; ++n) { int64_t A; cin >> A; H -= A; if (H <= 0) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <stdio.h> int main() { int x,y,i,sum=0; scanf("%d%d",&x,&y); int ar[y]; for(int i=0;i<y;i++) { scanf("%d",&ar[i]); sum=sum+ar[i]; } if(x<=sum) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
1
37,631,034
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back typedef long long ll; typedef pair<int, int> pi; const int maxn = 1e5 + 5; ll a[maxn]; int n; ll L; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin...
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ int N,L; cin>>N>>L; vector<int> A(N); for(int &i:A)cin>>i; for(int i=1;i<N;i++) if(A[i]+A[i-1]>=L){ puts("Possible"); for(int j=1;j<i;j++)cout<<j<<endl; for(int j=N-1;j>i;j--)cout<<j<<endl; cout<<i<<e...
1
79,893,165
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9+7; const int MAX_N = 1e5+10; int n, m; int x[MAX_N], y[MAX_N]; ll xpsum[MAX_N], ypsum[MAX_N]; void solve() { for(int i=1;i<=n;++i) (ypsum[i] = ypsum[i-1]+y[i])%=MOD; ll ysum = 0; for(int i=2;i<=n;++i)(ysum += 1LL*(i-1)*y[i]...
#define _GLIBCXX_DEBUG #include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> typedef long long ll; const ll MOD = 1e9 + 7; int main(int argc, char* argv[]) { ll n, m; std::cin >> n >> m; std::vector< ll > vx; std::vector< ll > vy; vx.resize(n); vy.resize(m); std::ve...
1
97,164,004
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,s=0; string str; cin>>str; for(int i=0;i<str.size();i++){ int j=str[i]-48; s+=j; } if(s%9==0) cout<<"Yes"; else cout<<"No"; }
#include<bits/stdc++.h> using namespace std; char s[200005]; int main(){ cin>>s+1; int n=strlen(s+1); int res=0; for(int i=1;i<=n;++i){ res+=s[i]-'0'; } if(res%9==0){ cout<<"Yes"; }else{ cout<<"No"; } return 0; }
1
50,431,365
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int N = 10001; vector<int> par(N); vector<int> ran(N); int find(int a){ if(par[a] == a) return a; else{ par[a] = find(par[a]); return par[a]; } } void merge(int a, int b){ if(ran[find(a)] < ran[...
#include <iostream> #include <vector> using namespace std; class DisjointSet { public: vector<int> rank, p; DisjointSet() {} DisjointSet(int size){ rank.resize(size, 0); p.resize(size, 0); for(int i = 0; i < size; i++) makeSet(i); } void ma...
1
61,128,533
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { ll r,c; cin>>r>>c; if(r==1||c==1)cout<<1; else cout<<(r*c+1)/2; return 0; }
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll H, W, ans; cin >> H >> W; if(H == 1 || W == 1) ans = 1; else if(H%2 != 0 && W%2 != 0) ans = (H/2) * (W/2+1+W/2) + W/2+1; else if(H%2 == 0 && W%2 != 0) ans = (H/2) * (W/2+1+W/2); else if(H%2 != 0 && W%2 == 0) an...
1
73,967,273
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; double sumt = 0; vector<double> t(n), v(n); for (int i = 0; i < n; i++) { cin >> t.at(i); sumt += t.at(i); } for (int i = 0; i < n; i++) cin >> v.at(i); vector<double> x(sumt ...
#include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <map> #include <algorithm> #include <math.h> #include <cassert> #define rep(i,n) for(int i = 0; i < n; ++i ) using namespace std; using ld = long double; using P = pair<int,int>; int main() { int n; cin...
1
86,910,209
#include<bits/stdc++.h> using namespace std; int main(){ int a[5]; for(int i=0;i < 5;i++) { cin >> a[i]; } sort(a,a+5); for(int i=4;i > -1;i--) { cout << a[i]; if(i)cout << " "; } cout << endl; return 0; }
#include <iostream> #include <algorithm> using namespace std; int main(int argc, char **argv) { int a[5]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]; sort(a, a+5); cout << a[4]; for(int i = 3; i >= 0; i--){ cout << " " << a[i]; } cout << endl; return 0; }
1
78,489,454
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define OP(m) cout << m << endl typedef long long ll; typedef unsigned long long ull; t...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; using P = pair<int,int>; const int MOD = 1000000007; int main() { int a,b; cin>>a>>b; cout<<a*b+1-a-b<<endl; }
1
83,064,360
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> #include <string> #include <set> #include <queue> #include <stack> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long > vll; typedef vector< vi > vvi; int main() { string a; getline(cin, a); for (int...
#include <iostream> #include <string> #include <ctype.h> using namespace std; int main() { string str; getline(cin, str); for (unsigned int i = 0; i < str.size(); i++) { if (islower(str[i])) cout << (char)toupper(str[i]); else if (isupper(str[i])) cout << (char)tolower(str[i]); else cout << str[i]; }...
1
6,985,547
#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] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) ? "YES":"NO") << endl; }
#include <iostream> using namespace std; int main() { bool b[10] {0}; for(int i = 0; i < 4; i++){ int n; cin >> n; b[n] = true; } if(b[1] && b[9] && b[7] && b[4]) cout << "YES" << endl; else cout << "NO" << endl; }
1
76,726,070
#include<bits/stdc++.h> #define ro(a) (a).begin(),(a).end() using namespace std; using ll = long long int; typedef vector<ll> vi; ll n,m,x,y; int main(){ cin>>n>>m>>x>>y; vi no(n),mo(m); for(ll &i:no) cin>>i; for(ll &i:mo) cin>>i; sort(ro(no)); sort(ro(mo)); if(*min_element(ro(mo))> *max_elemen...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main(){ int n,m,X,Y; cin >> n >> m >> X >> Y; int mx = -101; int my = 101; rep(i,n){ int x; cin >> x; mx = max(mx,x); } rep(i,n){ int y; c...
1
15,259,173
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define forn(i,a,b) for(int i =a;i<b;i++) #define fi first #define se second #define fast ios_base::sync_with_stdio(false); using namespace std; typedef long long int ll; typedef vector<ll> vi; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const in...
#include <bits/stdc++.h> using namespace std; #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define rep(i, n) repl(i, 0, n) #define all(x) (x).begin(), (x).end() #define CST(x) cout << fixed << setprecision(x) using ll = long long; const ll MOD = 1000000007; const int inf = 1e9 + 10; const ll INF = 4e18 + 10; co...
1
74,127,528
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <random> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; ...
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <iomanip> using ll = long long; using uint = unsigned int; using graph = std::vector<std::vector<ll>>; using wGraph = std::vector<std::vector<std::pair<l...
1
26,573,042
#include <iostream> #include <string> #include <vector> #include <set> #include <cmath> #include <algorithm> #include <iomanip> #include <queue> using ll = long long; using namespace std; int dp[1010][1010]; int const MOD = 1e9 + 7; int main(void) { string s, t; cin >> s >> t; int n = s.size(); int m = ...
#include<bits/stdc++.h> #include<iostream> int INF=1001001001; int mini(int x,int y){ if(x<y){ return x; }else{ return y; } } int main(){ std::string str1,str2; int A[1001][1001]; std::cin>>str1; std::cin>>str2; for(int i=0;i<=str1.size();i++){ for(int j=0;j<=str2.size();j++){ A[i][j]=...
1
44,055,025
#include <iostream> using namespace std; int main() { int n, s, count, max, min, sum, adv; while(cin >> n){ if(n == 0){ break; } min = 1001; max = -1; sum = 0; count = 0; while(count < n){ count++; cin >> s; sum += s; if(s < min){ min = s; } ...
#include "bits/stdc++.h" using namespace std; int main() { int i, j; int n; while (cin >> n) { if (n == 0) break; int sum = 0; vector<int> a(n); for (i = 0; i < n; i ++) { cin >> a[i]; ...
1
8,039,305
#include <iostream> #include <algorithm> using namespace std; bool isRTri(int a, int b, int c) { return a * a + b * b == c * c; } int main() { int n; cin >> n; for (int k = 1; k <= n; k++) { int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); bool r = isRTri(a[0], ...
#include <stdio.h> void judge_right_triangle(int a, int b, int c); int main(void) { int number; scanf("%d", &number); for (int i = 0; i < number; ++i) { int a; int b; int c; scanf("%d %d %d", &a, &b, &c); judge_right_triangle(a, b, c); } return 0; } void judge...
1
21,952,379
#include <bits/stdc++.h> using namespace std; #define pb push_back #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define rep(i, n) for(int i = 0; i < (n); ++i) #define ina(x, n) rep(x_i,n) cin>>x[x_i] #define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1] typedef long long ll; typedef vector<ll> vl; int main...
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; vector<ll> sum(n + 1); for(int i = 0; i < n; i++) { int a; cin >> a; sum[i + 1] = sum[i] + a; } vector<ll> a; for(int i = 0; i < n; i++){ for(int j = i + 1; j <= n; j++)a.push...
1
7,278,725
#include<bits/stdc++.h> using namespace std; #define lp(i,n) for(int i=0;i<n;i++) #define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];} int a[101][101],ans=-1,check[101],n; void calc(int now,int g,int count){ if(count>ans && ans!=-1) return; if(now==g){ if(ans==-1){ ans=count; return; } else{...
#include<iostream> #include<queue> #include<vector> #include<algorithm> using namespace std; int main(){ int n,a,b,c,ans[101]; vector<int> vec[101]; queue<int> que; fill(ans,ans+101,105); ans[1] = 0; cin >> n; for(int i=0;i<n;i++){ cin >> a >> b; for(int j=0;j<b;j++){ cin >> c; vec[a]...
1
98,030,419
#include <bits/stdc++.h> using namespace std; #define ll long long #define lf double #define pb(x) push_back(x) #define ull unsigned long long #define sfl(a) scan...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,x,n) for(int i=x; i<(n); i++) #define ALL(n) begin(n),end(n) #define INF ((1<<30)-1) #define LINF (1LL<<60) #define EPS (1e-10) typedef long long Int; typedef pair<Int, Int> P; struct cww{cww(){ios::sync_with_stdio(fa...
1
5,782,673
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { array<int, 3> a; for (int& i : a) cin >> i; sort(a.begin(), a.end()); if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) cout << "YES" << endl; else cout << "NO" << endl; } }
#include<stdio.h> void right_triangle(int x, int y, int z); int main(void) { int n; scanf("%d", &n); int i = 0; int x, y, z; while (i < n) { scanf("%d %d %d", &x, &y, &z); right_triangle(x, y, z); i++; } return 0; } void right_triangle(int x, int y, int z) { int i, j, k; i = x * x; j...
1
16,297,558
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; if (n % 2 == 0) cout << n / 2 - 1 << endl; else cout << n / 2 << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); printf("%d\n",(n-1)/2); }
1
97,679,512
#include <bits/stdc++.h> #define PI 3.14159265359 #define NIL (-1) #define LL long long using namespace std; const int64_t MOD = 1e9 + 7; int main() { int N, K; cin >> N >> K; if (N % K) cout << 1 << endl; else cout << 0 << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { int a, b; cin >> a >> b; if(a % b) cout << 1 << endl; else cout << a % b << endl; return 0...
1
75,455,684
#include <bits/stdc++.h> using namespace std; int main() { int N,li,ri,sn; cin >> N; sn = 0; for(int i = 0; i < N; i++){ cin >> li >> ri; sn += ri - li + 1; } cout << sn; }
#include <bits/stdc++.h> #include <cmath> using namespace std; int main() { int n; cin >> n; bool arr[100000] = {0}; for(int i = 0; i < n; i++) { int start, end; cin >> start >> end; for(int j = start - 1; j < end; j++) { arr[j] = true; } } int n_people = accumulate(&arr[0], &arr[10000...
1
51,143,427
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mod 1000000007 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(...
#include <bits/stdc++.h> #define ss second #define ff first #define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ret(n) return cout << n, 0 #define se(n) cout << setprecision(n) << fixed #define pb push_back #define int long long #define ld long double #pragma GCC optimize("Ofast,no-stack-prote...
1
48,351,577
#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 vector<int> vint; typedef vector<double> vd; typedef vector<ll> vll; typedef vector<string> vstr; typedef vector<vector<int>> vvint; typedef vector<pair<int, int>> vp...
#include <bits/stdc++.h> using namespace std; #define int long long struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast; using intpair = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++) #define ALL(obj) (obj).begin(), (obj)....
1
30,950,303
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using iii = pair<ii, int>; #define vt vector #define pq priority_queue #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define __lcm(a, b) a * b / __gcd(a, b) const int MOD =...
#include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define pb push_back using namespace std; using ll = long long; const int maxn = 1<<18; signed main() { cin.tie(0)->sync_with_stdio(0); int n, a, b; cin >> n >> a >> b; while(a <= b) if(a%n == 0) return cout << "OK", 0; else a++; cout << "NG"; return 0; }
1
62,370,509
#include <iostream> #include<string> #include <cstdio> #include<utility> #include<algorithm> #include<vector> #include<cmath> #include<map> #include<bitset> #include<queue> #include<set> #include <limits> #include <numeric> #include<queue> using namespace std; typedef long long ll; typedef pair<int,int>P; typedef pair<...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin()...
1
93,027,736
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<pll> vll; typedef set<int> si; typedef map<st...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for(ll i = ll(0); i < ll(n); i++) #define Rep(i, n) for(ll i = ll(1); i < ll(n); i++) #define ALL(a) (a).begin(),(a).end() #define IOS ios::sync_with_st...
1
13,493,124
#include <bits/stdc++.h> using namespace std; int main() { int N; int A[100005]; int maxv = 0; cin >> N; for ( int i = 0; i < N; i++ ) { cin >> A[i]; maxv = max(A[i], maxv); } int ans = -1, close = maxv; for ( int i = 0; i < N; i++ ) { int val = min(abs(maxv / 2 - A[i]), abs((maxv - 1) / 2 - A[i])); if...
#include <iostream> #include <iomanip> #include <vector> #include <valarray> #include <map> #include <set> #include <list> #include <queue> #include <stack> #include <bitset> #include <utility> #include <numeric> #include <algorithm> #include <functional> #include <complex> #include <string> #include <sstream> #include...
1
29,768,373
#include<iostream> #include<vector> #include<utility> #include<algorithm> #include<stack> #include<set> using namespace std ; using ll = long long ; using vll = vector<ll> ; using vvll = vector<vll> ; using pll = pair<ll,ll> ; ll INF = 1e15 ; void chmin(ll &a,ll b){if(a>b) a = b ;} void chmax(ll &a,ll b){if(a<b) a = b ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ff first #define ss second typedef long long int ll; typedef vector< pair<int, int> > vii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<long long int> vll; typedef pair<int, int> pii; const ll INF = 1e18; c...
1
96,258,708
#include<iostream> using namespace std; int main(){ int A, B, X; cin >> A >> B >> X; cout << (A+B>=X && A <= X? "YES" : "NO") << endl; return 0; }
#include <iostream> int main() { int A, B, X; std::cin >> A >> B >> X; if (X - A < 0 || X - A > B) std::cout << "NO" << std::endl; else std::cout << "YES" << std::endl; }
1
98,250,092
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = unsigned long long; using p = pair<int, int>; int main() { int N; cin >> N; int count = 0; while (N != 0) { if (to_string(N).length() % 2 != 0) { ++count; } ...
#include<stdio.h> #include<iostream> using namespace std; int main() { int a,count=0,count2=0; cin>>a; int b=a; while(b!=0){ int rem=b%10; count++; b=b/10; } if(count==1){ for(int i=1;i<=a;i++){ count2++; } cout<<count2<<endl; } ...
1
8,287,478
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; auto f = [](long long x) { return x * x * x; }; cout << f(N / K) + f(K % 2 ? 0 : (N + K / 2) / K) << endl; }
#include<bits/stdc++.h> using namespace std; namespace FAST_IO { template<typename T> void read(T &a) { a=0; int f=1; char c=getchar(); while(!isdigit(c)) { if(c=='-') { f=-1; } c=getchar(); } while(isdigit(c)) { a=a*10+c-'0'; c=getchar(); } a=a*f; } template <typename T> v...
1
58,049,319
#include <bits/stdc++.h> using namespace std; typedef long long ll; using graph = vector<vector<ll>>; const ll nmax = 100001; ll n, m; ll notop[nmax]; ll h[nmax]; bool dfs(ll v, const graph &G){ for(auto nv : G[v]){ if(h[v]<=h[nv]){ notop[v]++; return false; } } return true; } int...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; #define repa(i, a, b) for (auto i = (a); i <= (b); i++) #define repd(i, a, b) for (auto i = (a); i >= (b); i--) #define rep(i, n) for (int i = 0; i < n; ...
1
1,872,375
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> using namespace std; typedef long long ll; #define rep(i,n) for (int i=0;i < (int)(n);i++) int main(){ int n; cin >> n; ll now = 0LL; map<ll,int> m; m[0]++; rep(i,n){ ll tmp; cin >> tmp; now ...
#include <bits/stdc++.h> #define int long long #define counter(m) for(int i=0;i<m;i++) #define gcd __gcd #define endl "\n" #define pb emplace_back #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define mod2 ...
1
67,060,751
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define FPEN freopen("in.txt", "r", stdin); #define debug(...) \ { cerr << "# " << __VA_ARGS__ << "\n"; } #else #define debug(...) #define FPEN #endif const int maxn = 200009; typedef long long i64; typedef pair<i64, i64> pi64; typedef pair<int, int> pi; co...
#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 f(int x) { int ret = 0; while (x % 2 == 0) { x /= 2; ret++; } return ret; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a...
1
31,564,453
#include<iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #define F first #define S second #define PB push_back #define MP make_pair #define what_is(x) cerr << #x << " is " << x << endl; #define MT make_tuple #define eb emplace_back #define ...
#include <bits/stdc++.h> using namespace std; using llong = long long int; #define rep(i, n) for (int i = 0; i < n; ++i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr) #define all(x) x.begin(), x.end() #define allr(x...
1
67,730,515
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int a, b; cin >> a >> b; cout << 6-a-b << endl; }
#include <bits/stdc++.h> #define repr(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) for(int i=0;i<n;i++) #define reprrev(i,a,b) for(int i=b-1;i>=a;i--) #define reprev(i,n) reprrev(i,0,n) using ll = long long; using ull = unsigned long long; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return tru...
1
13,270,177
#include <algorithm> #include <cassert> #include <climits> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; const int INF = 1e9; const long long LINF = 1e18; const do...
#include <bits/stdc++.h> #include <vector> # include <cstdint> #define FOR(i,l,r) for(int i=(l);i<(r);++i) #define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--) #define rep(i,n) FOR(i,0,n) #define rrep(i,n) RFOR(i,n-1,0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e13; const int mod ...
1
50,431,439
#include <bits/stdc++.h> using namespace std; int main() { int n; int l, r; cin >> n; int count = 0; for(int i=0; i<n; i++){ cin >> l >> r; count = count + (r - l)+ 1; } cout << count; }
#include<iostream> #include<algorithm> #include<functional> #include<cmath> #include<string> #include<vector> #include<stack> #include<queue> #include<map> #include<set> #include<deque> using namespace std; #define ll long long const int mod = 1000000007; const ll INF = 1000000000000000000; int main() { int N; ll ans...
1
79,543,651
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; int dy[4]={1,0,-1,0}; int dx[4]={0,1,0,-1}; vector<vector<int>> graph; bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){ if(a.second<b.second){ return true; } return false; } void swap(int *a,int *b){ int temp=*a; *a=*b...
#include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<numeric> using namespace std; int main() { int N, M, t, x, y; cin >> N >> M; long long ans; vector<int> a(N), c(31,0); for(int i=0; i<N; i++) cin >> a[i]; sort(a.begin(),a.end(),greater<int>()); for(int i=30; i>...
1
54,336,608
#include <iostream> int main() { int h, w; for (std::cin >> h >> w; h != 0 || w != 0; std::cin >> h >> w) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { char c; if (i == 0 || i == h - 1 || j == 0 || j == w - 1) { c = '#'; ...
#include <iostream> #include <algorithm> #include <vector> int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); while(true){ int h, w; std::cin >> h >> w; if(h==0 && w==0) break; for(int i=0; i<h; ++i){ for(int j=0; j<w; ++j){ std::cout <...
1
64,769,357
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <queue> #include <set> #include <stack> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begi...
#include "bits/stdc++.h" using namespace std; int main(void){ int i = 0; string str; while (getline(cin, str) && str != ".") { stack<char> st; bool balanced = true; for (char c : str) { if (c == '(' || c == '[') st.push(c); else if (c == ')' ||...
1
52,875,308
#include <iostream> #include <algorithm> using namespace std; const int MAX=1001; int lcs(string x,string y,int xlen,int ylen) { int i=0,j=0,c[MAX][MAX]; for (i=0;i<=xlen;i++)c[i][0]=0; for (i=0;i<=ylen;i++)c[0][i]=0; for (i=1;i<=xlen;i++) for (j=1;j<=ylen;j++) if (x[i -1]==y[j-1]) { c[i][j]=c[i-1][j-1]+1; ...
#include "bits/stdc++.h" #include <unordered_set> #define _CRT_SECURE_NO_WARNINGS #define REP(i, n) for(decltype(n) i = 0; i < (n); i++) #define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++) #define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++) #define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--...
1
8,840,897
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n"); 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 ...
#pragma region template #include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9; long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W; typedef long long ll; typedef pair<ll, ll> Pa;...
1
7,087,574
#include <iostream> #include <cstdio> using namespace std; int main() { int x, y; while (1) { scanf("%d%d", &x, &y); if (x == 0 && y == 0) break; if (x > y) swap(x, y); printf("%d %d\n", x, y); } return (0); }
#include <iostream> int main(){ int x,y; while(true){ std::cin >> x >> y; if(x == 0 && y == 0) break; if(x<=y) std::cout << x << " " << y << std::endl; else std::cout << y << " " << x << std::endl; } return 0; }
1
52,143,923
#include <iostream> #include <vector> #include <map> #include <set> #include <algorithm> #include <fstream> #include <string> #include <math.h> #include <cstdlib> #include <istream> #include <sstream> #include <cctype> #define fore(i,x,y) for(long long i=x;i<y;i++) typedef long long ll; using namespace std; int main() ...
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; const double PI = 3.14159265358979323846; int main() { char a, b; cin >> a >> b; if(a == 'D') { if(b == 'H') cout << 'D' << endl; else cout << 'H' << endl; } else { if(b == 'H') co...
1
84,576,148
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define rep(i, a, b) for (int i = a; i < (b); ++i) #define repd(i, a, b) for (int i = a; i >= (b); --i) #define all(x) (x).begin(), (x).end() #...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int c = a + b; int x = c / 2 + c % 2; cout << x; }
1
90,589,078
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; #define rep(i, n) for(ll i = 0;i < n;i++) #define all(i) i.begin(), i.end() template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }...
#include <iostream> using namespace std; int main() { long long int N, M; cin >> N >> M; long long int ans=0; if(N*2<=M) { ans += N; M -= N*2; ans += M/4; } else { ans += M/2; } cout << ans << endl; return 0; }
1
42,353,230
#include <iostream> #include <vector> using namespace std; int gcd(int x, int y){ if(x < y) swap(x, y); if(x % y == 0) return y; return gcd(y, x % y); } int main(){ int N; cin >> N; vector<int> A(N); for(int i = 0; i < N; i++) cin >> A[i]; int g = A[0]; for(int i = 1; i < N; i++){ ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) using ll = long long; using ull = unsigned long long; using P = pair<int,int>; using PP = pair<int,pair<int,int>>; using T = tuple<string,int,int>; const string EMP = " "; const ll INF = 1LL<<60; const ll MOD = 1000000007; int g...
1
15,429,429
#include <iostream> #include <stdio.h> using namespace std; typedef long long int lint; void answer() { int a, b; cin >> a >> b; printf("%d %d %lf\n", a / b, a % b, (double)a / b); } int main() { answer(); return 0; }
#include <iostream> #include <iomanip> #include <stdio.h> using namespace std; #define MAX 2 int main(void) { int a,b; int ttmp; double tmp; cin >> a; cin >> b; ttmp = a/b; tmp = (double)a/(double)b; printf("%d ", ttmp); printf("%d ", a%b); printf("%lf\n", tmp); return 0; }
1
7,139,975
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A; for(int i=0;i<N;i++){ int X; cin >> X; A.push_back(X); } sort(A.begin(), A.end()); bool chk = true; for(int i=0;i<N-1;i++){ if(A[i] == A[i+1]){ chk = false; break; } } if(chk) cout << "YES" << endl; else...
#include <bits/stdc++.h> #include <fstream> #include <cstdio> using namespace std; #define ff first #define ss second #define pb push_back #define mk make_pair #define vll vector<ll> #define mll map<ll,ll > #define mlli map<ll,ll>::iterator #define size size() #define endl "\n" #define ll long long int #define ld long ...
1
3,216,861
#include<bits/stdc++.h> using namespace std; #define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0); #define all(cont) cont.begin(), cont.end() #define rall(cont) cont.end(), cont.begin() #define FOR(i,k,n) for(int64 i=k;i<(int64)n;i++) #define FORr(i,k,n) for(int64 i=(int64)k;i>=n;i--) #define FORE...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int N; cin >> N; string ans = "Yes"; int t, x, y; int prev_t = 0, prev_x = 0, prev_y = 0; for (int i=0; i<N; i++) { cin >> t >> x >> y; if (t - prev_t < abs(x - prev_x) + abs(y - prev_y)) ans = "No"; if (((t - prev_t) - (abs(x ...
1
94,833,738
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { cin.tie(0); ios::sync_with_stdio(false); int h, n; cin >> h >> n; int a[n]; for (int i = 0; i < n; ++i) cin >> a[i]; ll sum = accumulate(a, a+n, 0); if (sum >= h) cout << "Yes\n"; else cout << "No\n"; return (0); }
#include<stdio.h> int main() { int i,n; long int h; scanf("%ld",&h); scanf("%d",&n); int a[n],s=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); s=s+a[i]; } if(h>s) printf("No"); else printf("Yes"); return 0; }
1
30,360,300
#include<bits/stdc++.h> using namespace std; #define LL long long char c[1001][1001]; int d[1000005], ans; queue<int> q; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) cin >> (c[i]+1); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++)...
#include <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; int main(){ int h,w; string map[1000]; cin >> h >> w; for (int i = 0; i < h; i++) cin >> map[i]; queue<pair<int,int>> todo; vector<vector<int>> seen(h,vector<int>(w,-1)); for (int i = 0; i < h; i++){ for (...
1
20,980,761
#include <iostream> #include <algorithm> #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <array> #include <unordered_set> #include <complex> #include <valarray> #include <cmath> #include <functional> #include <iomanip> #in...
#include <stdio.h> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <iterator> #include <assert.h> #include <time.h> #pragma warning(disable:4996) typedef long long ...
1
92,887,335
#include<bits/stdc++.h> using namespace std; #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define MOD 1000000007 #define int long long #define ALL(a) (a).begin(),(a).end() #define vi vector<int> #define vii vector<vi> #define pii pair<int,int> #define priq...
#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; int main(){ int h, w, a, b; cin >> h >> w >> a >> b; a--; b--; vector<vector<int>> s(h, vector<int>(w, 0)); rep(i, h){ rep(j, w){ if(i <= b && j <= a) s[i][j] = ...
1
17,154,637
#pragma GCC optimize("Ofast") #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 <cstdl...
#pragma region #include <bits/stdc++.h> using namespace std; inline void ci(void){ return; } template <typename First, typename... Rest> void ci(First& first, Rest&... rest){ cin >> first; ci(rest...); return; } inline void co(void){ cout << "\n"; return; } template <typename First, typename... Rest> void c...
1
28,596,240
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,LL> P; const LL mod=1000000007; const LL INF=1e18; string u="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main(){ int H,W; cin >> H >> W; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ string s; cin >> s; ...
#include <cstdio> #include <utility> #include <typeinfo> #include <cmath> #include <numeric> #include <algorithm> #include <iostream> #include <iomanip> #include <map> #include <stack> #include <queue> #include <string> #include <vector> #include <tuple> #define REP(i,n) for(int i=0;i<n;i++) typedef long long int ll; u...
1
41,139,186
#include<iostream> #include<bits/stdc++.h> using namespace std; int main(){ long long n,x; cin>>n>>x; long long a=x; long long b=n-x; if(a<b) swap(a,b); while(b !=0){ long long x=a; a=b; b=x%b; if(a<b) swap(a,b); } cout<<3*(n-a); return 0; ...
#include<bits/stdc++.h> typedef long long int ll; using namespace std; #define sz 200009 #define mod 1000000007 ll n,m,i,j,k,l,t,a,b; int main() { scanf("%lld %lld",&n,&m); j=2*m; if(j==n) { printf("%lld\n",n+m); return 0; } if(j<=n) { t=n+j; a=m; b=n-...
1
79,534,077
#include <bits/stdc++.h> using namespace std; int main(){ int a, b, c, k; cin >> a >> b >> c >> k; int z=0, y=0, x=0; if(k-a<0){ x=k; k=0; } else{ x=a; k-=a; } if(k-b<0){ y=k; k=0; } else{ y=b; k-=b; } if(k-c<0){ z=k; k=0; } else{ z=c; } cout << x*1+y*0+z*(-1); }
#include<bits/stdc++.h> #include<boost/dynamic_bitset.hpp> using namespace std; using u64 = uint64_t; using s64 = int64_t; int main(void) { s64 A, B, C, K; cin >> A >> B >> C >> K; if(A >= K) { cout << K << endl; } else if(A + B >= K) { cout << A << endl; } else { cout << A -...
1
81,842,727
#include <bits/stdc++.h> #define Int int64_t using namespace std; struct UnionFind { private: vector<int> uf; size_t sz; public: UnionFind(size_t Size) { uf.assign(Size, -1); sz = Size; } int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); } bool same(int x, int y) { return find(x) == find(y); } ...
#include<bits/stdc++.h> using namespace std; #define MAX 1003 int size[MAX]; int root (int Arr[ ] ,int i) { while(Arr[ i ] != i) { Arr[ i ] = Arr[ Arr[ i ] ] ; i = Arr[ i ]; } return i; } void initialize( int Arr[ ],int size[],int N) { for(int i = 0;i<N;i++) { Arr[ i ] = i ; size[ i...
1
71,958,921
#include<iostream> #include<queue> using namespace std; int AdjM[101][101]={0}; int D[101]; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } void bfs(int s){ queue<int> Q; Q.push(s); D[s]=0; while(!Q.empty()){ in...
#include<iostream> #include<queue> using namespace std; static const int N=100; static const int INFTY=2000000000; int n,M[N+1][N+1]; int d[N+1]; void bfs(int s){ queue<int> q; q.push(s); for(int i=1;i<=n;i++)d[i]=INFTY; d[s]=0; int u; while(!q.empty()){ u=q.front(); q.pop(); ...
1
10,520,832