Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p02996
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int, int> II; typedef tuple<int, int, int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int, int> MAPII; typedef unordered_set<int> SETI; template <class T> using VV = vector<vector<T>>; // minmax template <class T> inline T SMIN(T &a, const T b) { return a = (a > b) ? b : a; } template <class T> inline T SMAX(T &a, const T b) { return a = (a < b) ? b : a; } // repetition #define FORE(i, a, b) for (int i = (a); i <= (b); ++i) #define REPE(i, n) for (int i = 0; i <= (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define FORR(x, arr) for (auto &x : arr) #define SZ(a) int((a).size()) // collection #define ALL(c) (c).begin(), (c).end() // DP #define MINUS(dp) memset(dp, -1, sizeof(dp)) #define ZERO(dp) memset(dp, 0, sizeof(dp)) // stdout #define println(args...) fprintf(stdout, ##args), putchar('\n'); // debug cerr template <class Iter> void __kumaerrc(Iter begin, Iter end) { for (; begin != end; ++begin) { cerr << *begin << ','; } cerr << endl; } void __kumaerr(istream_iterator<string> it) { (void)it; cerr << endl; } template <typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr << *it << "=" << a << ", ", __kumaerr(++it, args...); } template <typename S, typename T> std::ostream &operator<<(std::ostream &_os, const std::pair<S, T> &_p) { return _os << "{" << _p.first << ',' << _p.second << "}"; } #define __KUMATRACE__ true #ifdef __KUMATRACE__ #define dump(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ __kumaerr(_it, args); \ } #define dumpc(ar) \ { \ cerr << #ar << ": "; \ FORR(x, (ar)) { cerr << x << ','; } \ cerr << endl; \ } #define dumpC(beg, end) \ { \ cerr << "~" << #end << ": "; \ __kumaerrc(beg, end); \ } #else #define dump(args...) #define dumpc(ar) #define dumpC(beg, end) #endif // $ cp-batch Megalomania | diff Megalomania.out - // $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address // Megalomania.cpp && ./a.out /* 6/22/2019 5:18-5:41 WA */ const int MAX_N = 1e6 + 1; LL A[MAX_N], B[MAX_N]; int N; void nope() { println("No"); exit(0); } void solve() { vector<tuple<LL, LL, int>> X; REP(i, N) X.emplace_back(B[i], -A[i], i); sort(ALL(X)); // dumpc(X); LL t = 0; REP(i, N) { int j = get<2>(X[i]); t = t + A[j]; // dump(j,t,A[j],B[j]); if (t - 1 > B[j]) { // dump(i,j,t,B[j]); nope(); } } println("Yes"); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << setprecision(12) << fixed; cin >> N; REP(i, N) cin >> A[i] >> B[i]; solve(); return 0; }
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int, int> II; typedef tuple<int, int, int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int, int> MAPII; typedef unordered_set<int> SETI; template <class T> using VV = vector<vector<T>>; // minmax template <class T> inline T SMIN(T &a, const T b) { return a = (a > b) ? b : a; } template <class T> inline T SMAX(T &a, const T b) { return a = (a < b) ? b : a; } // repetition #define FORE(i, a, b) for (int i = (a); i <= (b); ++i) #define REPE(i, n) for (int i = 0; i <= (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define FORR(x, arr) for (auto &x : arr) #define SZ(a) int((a).size()) // collection #define ALL(c) (c).begin(), (c).end() // DP #define MINUS(dp) memset(dp, -1, sizeof(dp)) #define ZERO(dp) memset(dp, 0, sizeof(dp)) // stdout #define println(args...) fprintf(stdout, ##args), putchar('\n'); // debug cerr template <class Iter> void __kumaerrc(Iter begin, Iter end) { for (; begin != end; ++begin) { cerr << *begin << ','; } cerr << endl; } void __kumaerr(istream_iterator<string> it) { (void)it; cerr << endl; } template <typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr << *it << "=" << a << ", ", __kumaerr(++it, args...); } template <typename S, typename T> std::ostream &operator<<(std::ostream &_os, const std::pair<S, T> &_p) { return _os << "{" << _p.first << ',' << _p.second << "}"; } #define __KUMATRACE__ true #ifdef __KUMATRACE__ #define dump(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ __kumaerr(_it, args); \ } #define dumpc(ar) \ { \ cerr << #ar << ": "; \ FORR(x, (ar)) { cerr << x << ','; } \ cerr << endl; \ } #define dumpC(beg, end) \ { \ cerr << "~" << #end << ": "; \ __kumaerrc(beg, end); \ } #else #define dump(args...) #define dumpc(ar) #define dumpC(beg, end) #endif // $ cp-batch Megalomania | diff Megalomania.out - // $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address // Megalomania.cpp && ./a.out /* 6/22/2019 5:18-5:41 WA */ const int MAX_N = 1e6 + 1; LL A[MAX_N], B[MAX_N]; int N; void nope() { println("No"); exit(0); } void solve() { vector<tuple<LL, LL, int>> X; REP(i, N) X.emplace_back(B[i], -A[i], i); sort(ALL(X)); // dumpc(X); LL t = 0; REP(i, N) { int j = get<2>(X[i]); t = t + A[j]; // dump(j,t,A[j],B[j]); if (t > B[j]) { // dump(i,j,t,B[j]); nope(); } } println("Yes"); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << setprecision(12) << fixed; cin >> N; REP(i, N) cin >> A[i] >> B[i]; solve(); return 0; }
[ "expression.operation.binary.remove" ]
807,584
807,585
u465317453
cpp
p02996
#include <algorithm> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { int n; std::cin >> n; vector<pair<int, int>> work(n); rep(i, n) { cin >> work[i].second >> work[i].first; } sort(work.begin(), work.end()); long long t; rep(i, n) { t += work[i].second; if (t < work[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <algorithm> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { int n; std::cin >> n; vector<pair<int, int>> work(n); rep(i, n) { cin >> work[i].second >> work[i].first; } sort(work.begin(), work.end()); long long t = 0; rep(i, n) { t += work[i].second; if (t > work[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "variable_declaration.value.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
807,588
807,589
u851205244
cpp
p02996
#include <algorithm> #include <iostream> #include <limits> #include <string> #include <vector> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } int main() { vector<pair<int, int>> vec; int N; cin >> N; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; vec.push_back(make_pair(a, b)); } sort(vec.begin(), vec.end(), sortbysec); int sum = 0; bool yes = true; for (int i = 0; i < N; i++) { sum += vec[i].first; if (sum > vec[i].second) { yes = false; break; } } if (yes) { cout << "yes" << endl; } else cout << "no" << endl; }
#include <algorithm> #include <iostream> #include <limits> #include <string> #include <vector> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } int main() { vector<pair<int, int>> vec; int N; cin >> N; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; vec.push_back(make_pair(a, b)); } sort(vec.begin(), vec.end(), sortbysec); int sum = 0; bool yes = true; for (int i = 0; i < N; i++) { sum += vec[i].first; if (sum > vec[i].second) { yes = false; break; } } if (yes) { cout << "Yes" << endl; } else cout << "No" << endl; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,594
807,595
u986889396
cpp
p02996
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define fst first #define snd second int N; vector<pair<int, int>> dat; // until, duration int main() { scanf("%d", &N); for (int i = 0; i < N; i++) { int A, B; scanf("%d%d", &A, &B); dat.push_back(make_pair(B, A)); } sort(dat.begin(), dat.end()); int cur = 0; for (auto d : dat) { int until = d.fst, dur = d.snd; if (cur + dur > until) { printf("NO"); return 0; } else { cur += dur; } } printf("YES"); return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define fst first #define snd second int N; vector<pair<int, int>> dat; // until, duration int main() { scanf("%d", &N); for (int i = 0; i < N; i++) { int A, B; scanf("%d%d", &A, &B); dat.push_back(make_pair(B, A)); } sort(dat.begin(), dat.end()); int cur = 0; for (auto d : dat) { int until = d.fst, dur = d.snd; if (cur + dur > until) { printf("No"); return 0; } else { cur += dur; } } printf("Yes"); return 0; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
807,609
807,610
u720394712
cpp
p02996
#include "bits/stdc++.h" using namespace std; pair<int, int> Array[200005]; int main() { int N, i; scanf("%d", &N); for (i = 1; i <= N; ++i) scanf("%d%d", &Array[i].second, &Array[i].first); sort(Array + 1, Array + N + 1); long long Total = 0; for (i = 1; i <= N; ++i) { if (Total + Array[i].second <= Array[i].first) Total += Array[i].second; else { puts("NO"); return 0; } } puts("YES"); return 0; }
#include "bits/stdc++.h" using namespace std; pair<int, int> Array[200005]; int main() { int N, i; scanf("%d", &N); for (i = 1; i <= N; ++i) scanf("%d%d", &Array[i].second, &Array[i].first); sort(Array + 1, Array + N + 1); long long Total = 0; for (i = 1; i <= N; ++i) { if (Total + Array[i].second <= Array[i].first) Total += Array[i].second; else { puts("No"); return 0; } } puts("Yes"); return 0; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
807,617
807,618
u843106258
cpp
p02996
#include <bits/stdc++.h> #define ll long long #define dl double #define pb push_back #define eb emplace_back #define mp make_pair #define F first #define S second #define endl "\n" #define rep(i, a, b) for (i = a; i < b; i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define mod 1e9 + 7 #define CIN(V, s, n) \ for (int i = s; i < n; i++) { \ cin >> V[i]; \ } #define COUT(V, s, n) \ for (int i = s; i < n; i++) { \ cout << V[i] << " "; \ } #define SbS sortbysec #define fast \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define CLEAR(V) \ ; \ for (ll i = 0; i < V.size(); i++) \ V[i] = 0; // map<ll,vector<ll> > M; // map<ll,vector<ll> >:: iterator it; // it = M.begin(); // it.F will be ll // it.S will be vector<ll> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } ll BS(vector<ll> &PS, ll s, ll e, ll ser) { if (s > e) return s; ll mid = (s + e) / 2; if (PS[mid] == ser) { return mid; } else if (PS[mid] > ser) { return BS(PS, s, mid - 1, ser); } else return BS(PS, mid + 1, e, ser); } int main() { ll t = 1; // cin >> t; while (t--) { ll a, b, c, d, n, m, i, j, k, h, l, l2, w, q = 1, u, v, temp = 0, cn = 0, cp = 0, c0 = 0, max1 = 0; cin >> n; vector<pair<ll, ll>> DP(n); for (i = 0; i < n; i++) { cin >> a >> b; DP.pb(mp(b, a)); } sort(all(DP)); if (n == 1) { if (DP[0].S <= DP[0].F) { cout << "Yes"; } else cout << "No"; } else { ll j1 = 0; for (i = 0; i < n; i++) { j1 += DP[i].S; if (j1 > DP[i].F) { cout << "No"; return 0; } } cout << "Yes"; } } return 0; }
#include <bits/stdc++.h> #define ll long long #define dl double #define pb push_back #define eb emplace_back #define mp make_pair #define F first #define S second #define endl "\n" #define rep(i, a, b) for (i = a; i < b; i++) #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define mod 1e9 + 7 #define CIN(V, s, n) \ for (int i = s; i < n; i++) { \ cin >> V[i]; \ } #define COUT(V, s, n) \ for (int i = s; i < n; i++) { \ cout << V[i] << " "; \ } #define SbS sortbysec #define fast \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define CLEAR(V) \ ; \ for (ll i = 0; i < V.size(); i++) \ V[i] = 0; // map<ll,vector<ll> > M; // map<ll,vector<ll> >:: iterator it; // it = M.begin(); // it.F will be ll // it.S will be vector<ll> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } ll BS(vector<ll> &PS, ll s, ll e, ll ser) { if (s > e) return s; ll mid = (s + e) / 2; if (PS[mid] == ser) { return mid; } else if (PS[mid] > ser) { return BS(PS, s, mid - 1, ser); } else return BS(PS, mid + 1, e, ser); } int main() { ll t = 1; // cin >> t; while (t--) { ll a, b, c, d, n, m, i, j, k, h, l, l2, w, q = 1, u, v, temp = 0, cn = 0, cp = 0, c0 = 0, max1 = 0; cin >> n; vector<pair<ll, ll>> DP; for (i = 0; i < n; i++) { cin >> a >> b; DP.pb(mp(b, a)); } sort(all(DP)); if (n == 1) { if (DP[0].S <= DP[0].F) { cout << "Yes"; } else cout << "No"; } else { ll j1 = 0; for (i = 0; i < n; i++) { j1 += DP[i].S; if (j1 > DP[i].F) { cout << "No"; return 0; } } cout << "Yes"; } } return 0; }
[]
807,621
807,622
u121266738
cpp
p02996
#include <algorithm> #include <iostream> #include <map> // pair #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; ll func(ll a, ll b) { ll r = a % b; if (r == 0) return b; return func(b, r); } int main() { ll n, x, y; cin >> n; pair<ll, ll> p[n]; for (ll i = 0; i < n; i++) { cin >> x >> y; p[i] = make_pair(x, y); } sort(p, p + n); ll sum = 0; bool can = true; for (ll i = 0; i < n; i++) { sum += p[i].second; if (sum > p[i].first) { can = false; break; } } if (can) { cout << "Yes"; } else { cout << "No"; } }
#include <algorithm> #include <iostream> #include <map> // pair #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; ll func(ll a, ll b) { ll r = a % b; if (r == 0) return b; return func(b, r); } int main() { ll n, x, y; cin >> n; pair<ll, ll> p[n]; for (ll i = 0; i < n; i++) { cin >> x >> y; p[i] = make_pair(y, x); } sort(p, p + n); ll sum = 0; bool can = true; for (ll i = 0; i < n; i++) { sum += p[i].second; if (sum > p[i].first) { can = false; break; } } if (can) { cout << "Yes"; } else { cout << "No"; } }
[ "call.arguments.change", "call.arguments.add" ]
807,623
807,624
u019870062
cpp
p02996
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long // priority_queue<int, vector<int>, greater<int> > pq; #define _CRT_SECURE_NO_DEPRECATE const int N = 1000001; #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<pair<ll, ll>> v; rep(i, 0, n) { ll a, b; cin >> a >> b; v.push_back({b, a}); } sort(v.begin(), v.end()); ll x = -1; rep(i, 0, n) { if (x + v[i].se <= v[i].fi) { x += v[i].se; } else { cout << "No"; return 0; } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long // priority_queue<int, vector<int>, greater<int> > pq; #define _CRT_SECURE_NO_DEPRECATE const int N = 1000001; #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<pair<ll, ll>> v; rep(i, 0, n) { ll a, b; cin >> a >> b; v.push_back({b, a}); } sort(v.begin(), v.end()); ll x = 0; rep(i, 0, n) { if (x + v[i].se <= v[i].fi) { x += v[i].se; } else { cout << "No"; return 0; } } cout << "Yes"; }
[ "literal.number.change", "variable_declaration.value.change" ]
807,625
807,626
u278557567
cpp
p02996
//#define NDEBUG #include <cstddef> #include <cstdint> #include <vector> namespace n91 { using i8 = std::int_fast8_t; using i32 = std::int_fast32_t; using i64 = std::int_fast64_t; using u8 = std::uint_fast8_t; using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t; using isize = std::ptrdiff_t; using usize = std::size_t; constexpr usize operator"" _z(unsigned long long x) noexcept { return static_cast<usize>(x); } class rep { const usize f, l; public: class itr { friend rep; usize i; constexpr itr(const usize x) noexcept : i(x) {} public: void operator++() noexcept { ++i; } constexpr usize operator*() const noexcept { return i; } constexpr bool operator!=(const itr x) const noexcept { return i != x.i; } }; constexpr rep(const usize first, const usize last) noexcept : f(first), l(last) {} constexpr itr begin() const noexcept { return itr(f); } constexpr itr end() const noexcept { return itr(l); } }; class revrep { const usize f, l; public: class itr { friend revrep; usize i; constexpr itr(usize x) noexcept : i(x) {} public: void operator++() noexcept { --i; } constexpr usize operator*() const noexcept { return i; } constexpr bool operator!=(const itr x) const noexcept { return i != x.i; } }; constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {} constexpr itr begin() const noexcept { return itr(l); } constexpr itr end() const noexcept { return itr(f); } }; template <class T> using vec_alias = std::vector<T>; template <class T> auto md_vec(const usize n, const T &value) { return std::vector<T>(n, value); } template <class... Args> auto md_vec(const usize n, Args... args) { return std::vector<decltype(md_vec(args...))>(n, md_vec(args...)); } template <class T> constexpr T difference(const T &a, const T &b) { return a < b ? b - a : a - b; } } // namespace n91 #include <utility> namespace n91 { template <class T> constexpr T gcd(T m, T n) noexcept { while (n != static_cast<T>(0)) { m %= n; std::swap(m, n); } return m; } template <class T> constexpr T lcm(const T &m, const T &n) noexcept { return m / gcd(m, n) * n; } } // namespace n91 #include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> namespace n91 { bool solve() { usize n; std::cin >> n; struct task { u32 a, b; }; std::vector<task> tasks; for (auto &t : tasks) { std::cin >> t.a >> t.b; } std::sort(tasks.begin(), tasks.end(), [](const auto &l, const auto &r) { return l.b < r.b; }); u32 now = static_cast<u32>(0); for (const auto &t : tasks) { now += t.a; if (now > t.b) { return false; } } return true; } void main_() { std::cout << (solve() ? "Yes" : "No") << std::endl; } } // namespace n91 int main() { n91::main_(); return 0; }
//#define NDEBUG #include <cstddef> #include <cstdint> #include <vector> namespace n91 { using i8 = std::int_fast8_t; using i32 = std::int_fast32_t; using i64 = std::int_fast64_t; using u8 = std::uint_fast8_t; using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t; using isize = std::ptrdiff_t; using usize = std::size_t; constexpr usize operator"" _z(unsigned long long x) noexcept { return static_cast<usize>(x); } class rep { const usize f, l; public: class itr { friend rep; usize i; constexpr itr(const usize x) noexcept : i(x) {} public: void operator++() noexcept { ++i; } constexpr usize operator*() const noexcept { return i; } constexpr bool operator!=(const itr x) const noexcept { return i != x.i; } }; constexpr rep(const usize first, const usize last) noexcept : f(first), l(last) {} constexpr itr begin() const noexcept { return itr(f); } constexpr itr end() const noexcept { return itr(l); } }; class revrep { const usize f, l; public: class itr { friend revrep; usize i; constexpr itr(usize x) noexcept : i(x) {} public: void operator++() noexcept { --i; } constexpr usize operator*() const noexcept { return i; } constexpr bool operator!=(const itr x) const noexcept { return i != x.i; } }; constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {} constexpr itr begin() const noexcept { return itr(l); } constexpr itr end() const noexcept { return itr(f); } }; template <class T> using vec_alias = std::vector<T>; template <class T> auto md_vec(const usize n, const T &value) { return std::vector<T>(n, value); } template <class... Args> auto md_vec(const usize n, Args... args) { return std::vector<decltype(md_vec(args...))>(n, md_vec(args...)); } template <class T> constexpr T difference(const T &a, const T &b) { return a < b ? b - a : a - b; } } // namespace n91 #include <utility> namespace n91 { template <class T> constexpr T gcd(T m, T n) noexcept { while (n != static_cast<T>(0)) { m %= n; std::swap(m, n); } return m; } template <class T> constexpr T lcm(const T &m, const T &n) noexcept { return m / gcd(m, n) * n; } } // namespace n91 #include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> namespace n91 { bool solve() { usize n; std::cin >> n; struct task { u32 a, b; }; std::vector<task> tasks(n); for (auto &t : tasks) { std::cin >> t.a >> t.b; } std::sort(tasks.begin(), tasks.end(), [](const auto &l, const auto &r) { return l.b < r.b; }); u32 now = static_cast<u32>(0); for (const auto &t : tasks) { now += t.a; if (now > t.b) { return false; } } return true; } void main_() { std::cout << (solve() ? "Yes" : "No") << std::endl; } } // namespace n91 int main() { n91::main_(); return 0; }
[]
807,633
807,634
u708618797
cpp
p02996
#include <bits/stdc++.h> using namespace std; struct job { int a; int b; } s[200010]; int cmp(job a, job b) { if (a.b != b.b) { return a.b < b.b; } else { return a.a < b.a; } } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i].a >> s[i].b; } sort(s, s + n + 1, cmp); int t = 0; for (int i = 0; i < n; i++) { t += s[i].a; if (t > s[i].b) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct job { int a; int b; } s[200010]; int cmp(job a, job b) { if (a.b != b.b) { return a.b < b.b; } else { return a.a < b.a; } } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i].a >> s[i].b; } sort(s, s + n + 1, cmp); int t = 0; for (int i = 0; i <= n; i++) { t += s[i].a; // cout<<t<<' '<<s[i].b<<endl; if (t > s[i].b) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
807,635
807,636
u612745975
cpp
p02996
#include <bits/stdc++.h> #define ll long long #define rep(i, a, b) for (i = a; i < b; i++) #define pb push_back #define all(v) v.begin(), v.end() #define F first #define S second #define CLR(a) memset((a), 0, sizeof(a)) #define mp make_pair #define hell 1000000007 using namespace std; // int g[105][105]; // vector < int > wt(100004); // vector < int > a; // vector < int > v(30500); // int cst[102][100005]; // int ansr[100005]; // ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0; // vector < vector < int > > adj(5000, vector < int > (5000)); // int dp[1000006]; // int level[500]; void solve() { ll int i, j = 0, r = 200, p, q, y = 0, ans = 0, d, h, flag = 0, n, m, a, b, c; cin >> n; vector<pair<ll int, ll int>> v(n); rep(i, 0, n) { cin >> v[i].S >> v[i].F; } sort(all(v)); rep(i, 0, n) { y += v[i].S; if (y <= v[i].F) continue; else { cout << "NO"; return; } } cout << "YES"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; while (t--) solve(); } /* void bfs( int i , int j) { vis[i][j]= true; queue < int > que; que.push(k); while(!que.empty()) { int x= que.front(); que.pop(); for ( int i=1;i<=n;i++) { if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i])) { if(!vis[i]) { que.push(i); level[i]=level[x]+1; vis[i]= true; } } } } } ll int por(ll int a,ll int b) { ll int k=1; while(b>0) { if(b%2) k=k*a,k%=hell; b/=2; a*=a; a%=hell; } return k; } */
#include <bits/stdc++.h> #define ll long long #define rep(i, a, b) for (i = a; i < b; i++) #define pb push_back #define all(v) v.begin(), v.end() #define F first #define S second #define CLR(a) memset((a), 0, sizeof(a)) #define mp make_pair #define hell 1000000007 using namespace std; // int g[105][105]; // vector < int > wt(100004); // vector < int > a; // vector < int > v(30500); // int cst[102][100005]; // int ansr[100005]; // ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0; // vector < vector < int > > adj(5000, vector < int > (5000)); // int dp[1000006]; // int level[500]; void solve() { ll int i, j = 0, r = 200, p, q, y = 0, ans = 0, d, h, flag = 0, n, m, a, b, c; cin >> n; vector<pair<ll int, ll int>> v(n); rep(i, 0, n) { cin >> v[i].S >> v[i].F; } sort(all(v)); rep(i, 0, n) { y += v[i].S; if (y <= v[i].F) continue; else { cout << "No"; return; } } cout << "Yes"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; while (t--) solve(); } /* void bfs( int i , int j) { vis[i][j]= true; queue < int > que; que.push(k); while(!que.empty()) { int x= que.front(); que.pop(); for ( int i=1;i<=n;i++) { if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i])) { if(!vis[i]) { que.push(i); level[i]=level[x]+1; vis[i]= true; } } } } } ll int por(ll int a,ll int b) { ll int k=1; while(b>0) { if(b%2) k=k*a,k%=hell; b/=2; a*=a; a%=hell; } return k; } */
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,645
807,646
u216069198
cpp
p02996
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (a); i >= (b); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n, 0) #define dump(x) cout << #x << " = " << (x) << endl; typedef long long ll; typedef pair<int, int> ii; const int mod = 1e9 + 7; const ll INF = 1e18; const int inf = 1e9; bool compare_by_second(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } void solve() { int n; cin >> n; vector<ii> job(n); for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; job.push_back(make_pair(a, b)); } sort(job.begin(), job.end(), compare_by_second); int sum = 0; bool flg = true; for (int i = 0; i < n; i++) { sum += job[i].first; if (sum < job[i].second) { flg = false; break; } } if (flg) cout << "Yes" << endl; else cout << "No" << endl; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (a); i >= (b); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n, 0) #define dump(x) cout << #x << " = " << (x) << endl; typedef long long ll; typedef pair<int, int> ii; const int mod = 1e9 + 7; const ll INF = 1e18; const int inf = 1e9; bool compare_by_second(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } void solve() { int n; cin >> n; vector<ii> job; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; job.push_back(make_pair(a, b)); } sort(job.begin(), job.end(), compare_by_second); int sum = 0; bool flg = true; for (int i = 0; i < n; i++) { sum += job[i].first; if (sum > job[i].second) { flg = false; break; } } if (flg) cout << "Yes" << endl; else cout << "No" << endl; } int main() { solve(); return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
807,647
807,648
u305824645
cpp
p02996
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <list> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <utility> using namespace std; #define FOR(i, a, b) for (ll i = (a); i <= (b); i++) #define REP(i, n) FOR(i, 0, n - 1) #define NREP(i, n) FOR(i, 1, n) using ll = long long; using pii = pair<int, int>; using piii = pair<pii, pii>; const ll dx[4] = {0, -1, 1, 0}; const ll dy[4] = {-1, 0, 0, 1}; const int INF = 1e9 + 7; int gcd(int x, int y) { if (x < y) swap(x, y); if (y == 0) return x; return gcd(y, x % y); } void mul(ll a, ll b) { a = a * b % INF; } double mysqrt(double x) { double l = 0, r = x; for (int i = 0; i < 64; ++i) { double m = (l + r) / 2.0; if (m * m < x) l = m; else r = m; } return l; } /////////////////////////////////////// int main() { ll n; cin >> n; ll a[201000], b[201000]; vector<pair<double, ll>> v; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; v.push_back({b[i] / a[i], i}); } sort(v.begin(), v.end()); ll now = 0; for (int i = 0; i < n; ++i) { now += a[v[i].second]; if (now > b[v[i].second]) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <list> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <utility> using namespace std; #define FOR(i, a, b) for (ll i = (a); i <= (b); i++) #define REP(i, n) FOR(i, 0, n - 1) #define NREP(i, n) FOR(i, 1, n) using ll = long long; using pii = pair<int, int>; using piii = pair<pii, pii>; const ll dx[4] = {0, -1, 1, 0}; const ll dy[4] = {-1, 0, 0, 1}; const int INF = 1e9 + 7; int gcd(int x, int y) { if (x < y) swap(x, y); if (y == 0) return x; return gcd(y, x % y); } void mul(ll a, ll b) { a = a * b % INF; } double mysqrt(double x) { double l = 0, r = x; for (int i = 0; i < 64; ++i) { double m = (l + r) / 2.0; if (m * m < x) l = m; else r = m; } return l; } /////////////////////////////////////// int main() { ll n; cin >> n; ll a[201000], b[201000]; vector<pair<ll, ll>> v; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; v.push_back({b[i], i}); } sort(v.begin(), v.end()); ll now = 0; for (int i = 0; i < n; ++i) { now += a[v[i].second]; if (now > b[v[i].second]) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "expression.operation.binary.remove" ]
807,653
807,654
u414877092
cpp
p02996
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME) #define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME) #define ALL(NAME) (NAME).begin(), (NAME).end() #define cMOD 1000000007ULL #define cINF ((1ll << 62) - 1) #define cINFINT ((1 << 30) - 1) int main() { ll n; cin >> n; vector<ll> a(n, 0); vector<ll> b(n, 0); vector<pair<ll, ll>> ab(n, {0, 0}); REP(i, n) { cin >> a[i] >> b[i]; ab[i].first = a[i] + b[i]; ab[i].second = i; } sort(ALL(ab)); ll t = 0; bool isOK = true; REP(i, n) { ll idx = ab[i].second; if (t + a[idx] <= b[idx]) { t + a[idx]; } else { isOK = false; break; } } cout << (isOK ? "Yes" : "No") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME) #define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME) #define ALL(NAME) (NAME).begin(), (NAME).end() #define cMOD 1000000007ULL #define cINF ((1ll << 62) - 1) #define cINFINT ((1 << 30) - 1) int main() { ll n; cin >> n; vector<ll> a(n, 0); vector<ll> b(n, 0); vector<pair<ll, ll>> ab(n, {0, 0}); REP(i, n) { cin >> a[i] >> b[i]; ab[i].first = b[i]; ab[i].second = i; } sort(ALL(ab)); ll t = 0; bool isOK = true; REP(i, n) { ll idx = ab[i].second; if (t + a[idx] <= b[idx]) { t += a[idx]; } else { isOK = false; break; } } cout << (isOK ? "Yes" : "No") << endl; return 0; }
[ "expression.operation.binary.remove", "assignment.compound.arithmetic.replace.add", "expression.operator.arithmetic.replace.remove", "expression.operation.binary.change" ]
807,657
807,658
u627427672
cpp
p02996
#include <bits/stdc++.h> using namespace std; long long n, i, s; pair<long long, long long> mas[100001]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> mas[i].second >> mas[i].first; sort(mas + 1, mas + n + 1); for (i = 1; i <= n; i++) { s += mas[i].second; if (s > mas[i].first) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; long long n, i, s; pair<long long, long long> mas[1000001]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> mas[i].second >> mas[i].first; sort(mas + 1, mas + n + 1); for (i = 1; i <= n; i++) { s += mas[i].second; if (s > mas[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,668
807,669
u771796442
cpp
p02996
#include <bits/stdc++.h> typedef long long int ll; using namespace std; struct Job { ll a, b; bool operator<(const Job &j) { return b < j.b; } }; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; ll sum = 0LL; vector<Job> jobs(n); for (int i = 0; i < n; ++i) cin >> jobs[i].a >> jobs[i].b; sort(jobs.begin(), jobs.end()); ll currTime = 0; ll timeAvailable = 0; for (int i = 0; i < n; ++i) { if (jobs[i].b > currTime) { timeAvailable += jobs[i].b; currTime = jobs[i].b; } timeAvailable -= jobs[i].a; if (timeAvailable < 0) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }
#include <bits/stdc++.h> typedef long long int ll; using namespace std; struct Job { ll a, b; bool operator<(const Job &j) { return b < j.b; } }; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; ll sum = 0LL; vector<Job> jobs(n); for (int i = 0; i < n; ++i) cin >> jobs[i].a >> jobs[i].b; sort(jobs.begin(), jobs.end()); ll currTime = 0; ll timeAvailable = 0; for (int i = 0; i < n; ++i) { if (jobs[i].b > currTime) { timeAvailable += jobs[i].b - currTime; currTime = jobs[i].b; } timeAvailable -= jobs[i].a; if (timeAvailable < 0) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }
[ "assignment.change" ]
807,670
807,671
u408808361
cpp
p02996
#include <algorithm> #include <iomanip> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> ab(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ab[i] = make_pair(b, a); } sort(ab.begin(), ab.end()); bool flag = true; long long count = 0; for (int i = 0; i < n; i++) { count += ab[i].second; if (count > ab[i].first) flag = false; } cout << (flag ? "yes" : "no") << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> ab(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ab[i] = make_pair(b, a); } sort(ab.begin(), ab.end()); bool flag = true; long long count = 0; for (int i = 0; i < n; i++) { count += ab[i].second; if (count > ab[i].first) flag = false; } cout << (flag ? "Yes" : "No") << endl; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,678
807,679
u990764614
cpp
p02996
#include <bits/stdc++.h> using namespace std; int main() { int n, i; pair<long long, long long> task[100005]; cin >> n; long long a[100005], b[100005], suma = 0, sumb = 0; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; task[i] = make_pair(-b[i], -a[i]); } sort(task, task + n); int flag = 0; for (i = n - 1; i >= 0; i--) { suma -= task[i].second; if (suma > -task[i].first) { flag = 1; break; } } if (flag == 0) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; pair<long long, long long> task[200005]; cin >> n; long long a[200005], b[200005], suma = 0, sumb = 0; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; task[i] = make_pair(-b[i], -a[i]); } sort(task, task + n); int flag = 0; for (i = n - 1; i >= 0; i--) { suma -= task[i].second; if (suma > -task[i].first) { flag = 1; break; } } if (flag == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,684
807,685
u073082475
cpp
p02996
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back #define ins insert #define er erase #define f(i, a, b) for (i = a; i < b; ++i) #define rf(i, a, b) for (i = a; i >= b; --i) #define tc \ int t; \ cin >> t; \ while (t--) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define vi vector<int> #define vll vector<ll> #define vull vector<ull> #define vc vector<char> #define vst vector<string> #define bs bitset #define mp make_pair #define ff first #define ss second #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (a * b) / gcd(a, b) #define lb lower_bound #define ub upper_bound #define nl "\n" #define sp " " using namespace std; // LET'S PLAY THE GAME!! int main() { fast; int n, i, a, b; cin >> n; vector<pll> v; f(i, 0, n) { cin >> a >> b; v.pb(mp(b, a)); } sort(all(v)); ll t = 0; f(i, 0, n) { ll f = v[i].ff, s = v[i].ss; t += s; if (t > f) { cout << "NO"; return 0; } } cout << "YES"; return 0; } // AND THE GAME IS OVER!!
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back #define ins insert #define er erase #define f(i, a, b) for (i = a; i < b; ++i) #define rf(i, a, b) for (i = a; i >= b; --i) #define tc \ int t; \ cin >> t; \ while (t--) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define vi vector<int> #define vll vector<ll> #define vull vector<ull> #define vc vector<char> #define vst vector<string> #define bs bitset #define mp make_pair #define ff first #define ss second #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (a * b) / gcd(a, b) #define lb lower_bound #define ub upper_bound #define nl "\n" #define sp " " using namespace std; // LET'S PLAY THE GAME!! int main() { fast; int n, i; ll a, b; cin >> n; vector<pll> v; f(i, 0, n) { cin >> a >> b; v.pb(mp(b, a)); } sort(all(v)); ll t = 0; f(i, 0, n) { ll f = v[i].ff, s = v[i].ss; t += s; if (t > f) { cout << "No"; return 0; } } cout << "Yes"; return 0; } // AND THE GAME IS OVER!!
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,690
807,691
u172942446
cpp
p02996
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ cin >> aa; \ (p).push_back(aa); #define vecpl2(p) \ long long a b; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define set0(k, n) \ for (int nn = 0; nn < (n); nn++) { \ (k).push_back(0); \ } #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define vecsize(b, size) vector<int>(b)((size)); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsl(s) vector<pair<ll, ll>>(s); #define pairss(s) vector<pair<string, string>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairspl(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsps(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsREV(s) (s).push_back(make_pair(bb, aa)); #define pairslREV(s) (s).push_back(make_pair(bb, aa)); #define pairssREV(s) (s).push_back(make_pair(bb, aa)); #define MOD 1000000007 int main() { int N; cin >> N; pairs(C) fx(N) { int a, b; cin >> a >> b; pb(C, make_pair(b, a)) } sorts(C) reverses(C) ll Time = C.at(0).first; bool flag = true; fx(N - 1) { Time -= C.at(x).second; if (Time > C.at(x + 1).first) { Time = C.at(x + 1).first; break; } // ce(Time) } Time -= C.at(N - 1).second; if (Time < 0) { flag = false; } if (flag) { ce("Yes") } else { ce("No") } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ cin >> aa; \ (p).push_back(aa); #define vecpl2(p) \ long long a b; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define set0(k, n) \ for (int nn = 0; nn < (n); nn++) { \ (k).push_back(0); \ } #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define vecsize(b, size) vector<int>(b)((size)); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsl(s) vector<pair<ll, ll>>(s); #define pairss(s) vector<pair<string, string>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairspl(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsps(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsREV(s) (s).push_back(make_pair(bb, aa)); #define pairslREV(s) (s).push_back(make_pair(bb, aa)); #define pairssREV(s) (s).push_back(make_pair(bb, aa)); #define MOD 1000000007 int main() { int N; cin >> N; pairs(C) fx(N) { int a, b; cin >> a >> b; pb(C, make_pair(b, a)) } sorts(C) reverses(C) ll Time = C.at(0).first; bool flag = true; fx(N - 1) { Time -= C.at(x).second; if (Time > C.at(x + 1).first) { Time = C.at(x + 1).first; } // ce(Time) } Time -= C.at(N - 1).second; if (Time < 0) { flag = false; } if (flag) { ce("Yes") } else { ce("No") } return 0; }
[]
807,694
807,695
u824327013
cpp
p02995
#include <bits/stdc++.h> // #include <iostream> // #include <vector> // #include <map> // #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) template <typename T> T mod(T a, T b) { return (a + b) % b; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // n を素因数分解 map<ll, ll> factor(ll n) { map<ll, ll> mp; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { mp[i]++; n /= i; } } if (n > 1) { mp[n]++; } return mp; } // 文字列に "hoge" が含まれているか // string str = "hogepiyo"; // if (str.find("hoge") != string::npos) { // cout << "文字列が含まれています" << endl; // } // char to string // char c = 'a'; // string str = {c}; ll A, B, C, D; ll f(ll x) { return x / gcd(C, D); } ll g(ll x) { return x / C; } ll h(ll x) { return x / D; } ll i(ll x) { return g(x) + h(x) - f(x); } void solve() { // ll A, B, C, D; cin >> A >> B >> C >> D; cout << B - A + 1 - (i(B) - i(A - 1)) << endl; return; } int main(int argc, char const *argv[]) { solve(); return 0; }
#include <bits/stdc++.h> // #include <iostream> // #include <vector> // #include <map> // #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) template <typename T> T mod(T a, T b) { return (a + b) % b; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // n を素因数分解 map<ll, ll> factor(ll n) { map<ll, ll> mp; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { mp[i]++; n /= i; } } if (n > 1) { mp[n]++; } return mp; } // 文字列に "hoge" が含まれているか // string str = "hogepiyo"; // if (str.find("hoge") != string::npos) { // cout << "文字列が含まれています" << endl; // } // char to string // char c = 'a'; // string str = {c}; ll A, B, C, D; ll f(ll x) { return x / lcm(C, D); } ll g(ll x) { return x / C; } ll h(ll x) { return x / D; } ll i(ll x) { return g(x) + h(x) - f(x); } void solve() { // ll A, B, C, D; cin >> A >> B >> C >> D; cout << B - A + 1 - (i(B) - i(A - 1)) << endl; return; } int main(int argc, char const *argv[]) { solve(); return 0; }
[ "identifier.change", "call.function.change", "function.return_value.change", "expression.operation.binary.change" ]
807,712
807,713
u796269639
cpp
p02995
#include <bits/stdc++.h> // #include <iostream> // #include <vector> // #include <map> // #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) template <typename T> T mod(T a, T b) { return (a + b) % b; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // n を素因数分解 map<ll, ll> factor(ll n) { map<ll, ll> mp; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { mp[i]++; n /= i; } } if (n > 1) { mp[n]++; } return mp; } // 文字列に "hoge" が含まれているか // string str = "hogepiyo"; // if (str.find("hoge") != string::npos) { // cout << "文字列が含まれています" << endl; // } // char to string // char c = 'a'; // string str = {c}; ll A, B, C, D; ll f(ll x) { return x / (C * D); } ll g(ll x) { return x / C; } ll h(ll x) { return x / D; } ll i(ll x) { return g(x) + h(x) - f(x); } void solve() { // ll A, B, C, D; cin >> A >> B >> C >> D; cout << B - A + 1 - (i(B) - i(A - 1)) << endl; return; } int main(int argc, char const *argv[]) { solve(); return 0; }
#include <bits/stdc++.h> // #include <iostream> // #include <vector> // #include <map> // #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) template <typename T> T mod(T a, T b) { return (a + b) % b; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // n を素因数分解 map<ll, ll> factor(ll n) { map<ll, ll> mp; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { mp[i]++; n /= i; } } if (n > 1) { mp[n]++; } return mp; } // 文字列に "hoge" が含まれているか // string str = "hogepiyo"; // if (str.find("hoge") != string::npos) { // cout << "文字列が含まれています" << endl; // } // char to string // char c = 'a'; // string str = {c}; ll A, B, C, D; ll f(ll x) { return x / lcm(C, D); } ll g(ll x) { return x / C; } ll h(ll x) { return x / D; } ll i(ll x) { return g(x) + h(x) - f(x); } void solve() { // ll A, B, C, D; cin >> A >> B >> C >> D; cout << B - A + 1 - (i(B) - i(A - 1)) << endl; return; } int main(int argc, char const *argv[]) { solve(); return 0; }
[ "call.add", "function.return_value.change", "expression.operation.binary.change" ]
807,714
807,713
u796269639
cpp
p02995
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; --a; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / a + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; --a; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / d + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
807,720
807,721
u519950235
cpp
p02995
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; a--; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / a + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; --a; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / d + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
807,722
807,721
u519950235
cpp
p02995
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(int x, int y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; a--; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / a + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; ll a, b, c, d, r1, r2; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { cin >> a >> b >> c >> d; --a; r1 = b - b / c - b / d + b / lcm(c, d); r2 = a - a / c - a / d + a / lcm(c, d); cout << r1 - r2 << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
807,724
807,721
u519950235
cpp
p02995
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <vector> //#include<bits/stdc++.h> using namespace std; #define ok1 printf("ok1\n"); #define ok2 printf("ok2\n"); #define M 1000000000000000000LL #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, s, n) for (int i = (s); i < (n); ++i) #define repr(i, n) for (int i = n - 1; i >= 0; --i) #define REPR(i, s, n) for (int i = (s); i >= (n); --(i)) #define all(a) (a).begin(), (a).end() #define reall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front #define MIN(a, b) a = min((a), (b)) #define MAX(a, b) a = max((a), (b)) #define SIZE(v) (int)v.size() #define fi first #define se second const double pi = acos(-1.0); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<double> vd; typedef vector<bool> vb; typedef deque<ll> dll; typedef pair<ll, ll> P; typedef vector<P> vP; using Edge = pair<int, ll>; using Graph = vector<vector<Edge>>; const ll mod = 1e9 + 7; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }; void Pvll(vll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) cout << v[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void Pvvll(vvll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) { rep(j, v[i].size()) { cout << v[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Ps(string s) { cout << "------------------------------------------------\n"; rep(i, s.size()) cout << s[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void Pvs(vs s) { cout << "------------------------------------------------\n"; rep(i, s.size()) { rep(j, s[i].size()) { cout << s[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Yes(bool x) { if (x) cout << "Yes\n"; else cout << "No\n"; } void YES(bool x) { if (x) cout << "YES\n"; else cout << "NO\n"; } void yes(bool x) { if (x) cout << "yes\n"; else cout << "no\n"; } void Yay(bool x) { if (x) cout << "Yay!\n"; else cout << ":(\n"; } ll gcd(ll x, ll y) { ll r; while ((r = x % y) != 0) { x = y; y = r; } return y; } ll lcm(ll x, ll y) { return (x * y / gcd(x, y)); } ll d, n, m, r, l, k, h, w, ans = 0, ret = M; bool flag = false, flag2 = false, flag3 = false; string s, t; ll count(vvll gg) { vvll g = gg; // Pvvll(g); rep(k, n) rep(i, n) rep(j, n) { g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } ll count = 0; // Pvvll(g); rep(i, n) rep(j, n) { if (g[i][j] == 2) count++; } // cout << count/2 << endl; return count / 2; } int main() { cin.tie(0); ios::sync_with_stdio(false); long long a, b, c, d; cin >> a >> b >> c >> d; long long aa = (a - 1) / c; long long bb = b / c; long long cc = (a - 1) / d; long long dd = b / d; long long e = lcm(c, d); long long ee = (a - 1) / e; long long eee = b / e; cout << (b - a) - (bb - aa) - (dd - cc) + (ee - eee) + 1 << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <vector> //#include<bits/stdc++.h> using namespace std; #define ok1 printf("ok1\n"); #define ok2 printf("ok2\n"); #define M 1000000000000000000LL #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, s, n) for (int i = (s); i < (n); ++i) #define repr(i, n) for (int i = n - 1; i >= 0; --i) #define REPR(i, s, n) for (int i = (s); i >= (n); --(i)) #define all(a) (a).begin(), (a).end() #define reall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front #define MIN(a, b) a = min((a), (b)) #define MAX(a, b) a = max((a), (b)) #define SIZE(v) (int)v.size() #define fi first #define se second const double pi = acos(-1.0); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<double> vd; typedef vector<bool> vb; typedef deque<ll> dll; typedef pair<ll, ll> P; typedef vector<P> vP; using Edge = pair<int, ll>; using Graph = vector<vector<Edge>>; const ll mod = 1e9 + 7; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }; void Pvll(vll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) cout << v[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void Pvvll(vvll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) { rep(j, v[i].size()) { cout << v[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Ps(string s) { cout << "------------------------------------------------\n"; rep(i, s.size()) cout << s[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void Pvs(vs s) { cout << "------------------------------------------------\n"; rep(i, s.size()) { rep(j, s[i].size()) { cout << s[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Yes(bool x) { if (x) cout << "Yes\n"; else cout << "No\n"; } void YES(bool x) { if (x) cout << "YES\n"; else cout << "NO\n"; } void yes(bool x) { if (x) cout << "yes\n"; else cout << "no\n"; } void Yay(bool x) { if (x) cout << "Yay!\n"; else cout << ":(\n"; } ll gcd(ll x, ll y) { ll r; while ((r = x % y) != 0) { x = y; y = r; } return y; } ll lcm(ll x, ll y) { return (x * y / gcd(x, y)); } ll d, n, m, r, l, k, h, w, ans = 0, ret = M; bool flag = false, flag2 = false, flag3 = false; string s, t; ll count(vvll gg) { vvll g = gg; // Pvvll(g); rep(k, n) rep(i, n) rep(j, n) { g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } ll count = 0; // Pvvll(g); rep(i, n) rep(j, n) { if (g[i][j] == 2) count++; } // cout << count/2 << endl; return count / 2; } int main() { cin.tie(0); ios::sync_with_stdio(false); long long a, b, c, d; cin >> a >> b >> c >> d; long long aa = (a - 1) / c; long long bb = b / c; long long cc = (a - 1) / d; long long dd = b / d; long long e = lcm(c, d); long long ee = (a - 1) / e; long long eee = b / e; cout << (b - a) - (bb - aa) - (dd - cc) + (eee - ee) + 1 << endl; return 0; }
[ "expression.operation.binary.remove" ]
807,750
807,751
u373958718
cpp
p02995
#include <algorithm> #include <cassert> #include <cmath> #include <cstdint> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; #define EPS (1e-7) template <class T> T gcd(T a, T b) { return (b == 0) ? a : gcd(b, a % b); } template <class T> T lcm(T a, T b) { T h = gcd(a, b); return (h != 0) ? (a * (b / h)) : 0; } int main() { ll A, B, C, D; cin >> A >> B >> C >> D; const ll m = lcm(C, D); const ll before_A = max(1LL, A - 1); const ll ansB = B - (B / C) - (B / D) + (B / m); const ll ans_before_A = before_A - (before_A / C) - (before_A / D) + (before_A / m); const ll ans = ansB - ans_before_A; cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdint> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; #define EPS (1e-7) template <class T> T gcd(T a, T b) { return (b == 0) ? a : gcd(b, a % b); } template <class T> T lcm(T a, T b) { T h = gcd(a, b); return (h != 0) ? (a * (b / h)) : 0; } int main() { ll A, B, C, D; cin >> A >> B >> C >> D; const ll m = lcm(C, D); const ll before_A = A - 1; const ll ansB = B - (B / C) - (B / D) + (B / m); const ll ans_before_A = before_A - (before_A / C) - (before_A / D) + (before_A / m); const ll ans = ansB - ans_before_A; cout << ans << endl; return 0; }
[ "call.remove", "call.arguments.change" ]
807,752
807,753
u101264341
cpp
p02995
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } ll g(ll C, ll D) { ll X, tmp, r; X = C * D; /* 自然数 a > b を確認・入替 */ if (C < D) { tmp = C; C = D; D = tmp; } ll c = C; ll d = D; /* ユークリッドの互除法 */ r = C % D; while (r != 0) { C = D; D = r; r = C % D; } ll lcm = X / D; return lcm; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C, D; cin >> A >> B >> C >> D; ll ans = 0; ll lcm = g(C, D); ll numb = B / C + B / D - B / lcm; ll numa = (A - 1) / C + (A - 1) / D - (A - 1) / lcm; cout << B - numb - A + numa - 1 << endl; }
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } ll g(ll C, ll D) { ll X, tmp, r; X = C * D; /* 自然数 a > b を確認・入替 */ if (C < D) { tmp = C; C = D; D = tmp; } ll c = C; ll d = D; /* ユークリッドの互除法 */ r = C % D; while (r != 0) { C = D; D = r; r = C % D; } ll lcm = X / D; return lcm; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C, D; cin >> A >> B >> C >> D; ll ans = 0; ll lcm = g(C, D); ll numb = B / C + B / D - B / lcm; ll numa = (A - 1) / C + (A - 1) / D - (A - 1) / lcm; cout << B - numb - A + numa + 1 << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change" ]
807,754
807,755
u535810324
cpp
p02995
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } ll g(ll C, ll D) { ll X, tmp, r; X = C * D; /* 自然数 a > b を確認・入替 */ if (C < D) { tmp = C; C = D; D = tmp; } ll c = C; ll d = D; /* ユークリッドの互除法 */ r = C % D; while (r != 0) { C = D; D = r; r = C % D; } ll lcm = X / D; return lcm; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C, D; cin >> A >> B >> C >> D; ll ans = 0; ll lcm = g(C, D); ll numb = B / C + B / D - B / lcm; ll numa = (A - 1) / C + (A - 1) / D - (A - 1) / lcm; cout << B - numb - A + numa << endl; }
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } ll g(ll C, ll D) { ll X, tmp, r; X = C * D; /* 自然数 a > b を確認・入替 */ if (C < D) { tmp = C; C = D; D = tmp; } ll c = C; ll d = D; /* ユークリッドの互除法 */ r = C % D; while (r != 0) { C = D; D = r; r = C % D; } ll lcm = X / D; return lcm; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C, D; cin >> A >> B >> C >> D; ll ans = 0; ll lcm = g(C, D); ll numb = B / C + B / D - B / lcm; ll numa = (A - 1) / C + (A - 1) / D - (A - 1) / lcm; cout << B - numb - A + numa + 1 << endl; }
[ "expression.operation.binary.add" ]
807,756
807,755
u535810324
cpp
p02995
#include <algorithm> #include <float.h> #include <iostream> #include <limits> #include <math.h> #include <numeric> using namespace ::std; int main() { long long int A; long long int B; long long int C; long long int D; cin >> A >> B >> C >> D; long long int tmp; long long int tc = C; long long int td = D; if (tc < td) { tmp = td; td = tc; tc = tmp; } tmp = tc % td; while (tmp != 0) { tc = td; td = tmp; tmp = tc % td; } cout << td; if (A == B) { cout << ((A % C) && (A % D)); } else { long long int L = C * D / td; long long int BC = B / C; long long int BD = B / D; long long int BL = B / L; long long int AC = (A - 1) / C; long long int AD = (A - 1) / D; long long int AL = (A - 1) / L; cout << B - A + 1 - (BC - AC) - (BD - AD) + (BL - AL); } }
#include <algorithm> #include <float.h> #include <iostream> #include <limits> #include <math.h> #include <numeric> using namespace ::std; int main() { long long int A; long long int B; long long int C; long long int D; cin >> A >> B >> C >> D; long long int tmp; long long int tc = C; long long int td = D; if (tc < td) { tmp = td; td = tc; tc = tmp; } tmp = tc % td; while (tmp != 0) { tc = td; td = tmp; tmp = tc % td; } if (A == B) { cout << ((A % C) && (A % D)); } else { long long int L = C * D / td; long long int BC = B / C; long long int BD = B / D; long long int BL = B / L; long long int AC = (A - 1) / C; long long int AD = (A - 1) / D; long long int AL = (A - 1) / L; cout << B - A + 1 - (BC - AC) - (BD - AD) + (BL - AL); } }
[]
807,757
807,758
u319945100
cpp
p02995
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long A, B; cin >> A >> B; int C, D; cin >> C >> D; int CD = gcd(C, D); long long CD_lcm = C * D / CD; if (C == D) { long long Ccnt = (B / C) - ((A - 1) / C); cout << (B - A + 1) - Ccnt; } else { long long Ccnt = (B / C) - ((A - 1) / C); long long Dcnt = (B / D) - ((A - 1) / D); long long CDcnt = (B / (CD_lcm)) - ((A - 1) / (CD_lcm)); cout << (B - A + 1) - Ccnt - Dcnt + CDcnt; } }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long A, B; cin >> A >> B; long long C, D; cin >> C >> D; int CD = gcd(C, D); long long CD_lcm = C * D / CD; if (C == D) { long long Ccnt = (B / C) - ((A - 1) / C); cout << (B - A + 1) - Ccnt; } else { long long Ccnt = (B / C) - ((A - 1) / C); long long Dcnt = (B / D) - ((A - 1) / D); long long CDcnt = (B / (CD_lcm)) - ((A - 1) / (CD_lcm)); cout << (B - A + 1) - Ccnt - Dcnt + CDcnt; } }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
807,777
807,778
u109497000
cpp
p02995
#include <bits/stdc++.h> typedef long long ll; using namespace std; int sa(ll a, ll b) { if (a < b) swap(a, b); ll r = a % b; ll x = a * b; while (r != 0) { a = b; b = r; r = a % b; } return x / b; } int main() { ll a, b, c, d; cin >> a >> b >> c >> d; ll ans = 0; ans += b / c - (a - 1) / c; ans += b / d - (a - 1) / d; ans -= b / sa(c, d) - (a - 1) / sa(c, d); cout << b - a - ans + 1; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll sa(ll a, ll b) { if (a < b) swap(a, b); ll r = a % b; ll x = a * b; while (r != 0) { a = b; b = r; r = a % b; } return x / b; } int main() { ll a, b, c, d; cin >> a >> b >> c >> d; ll ans = 0; ans += b / c - (a - 1) / c; ans += b / d - (a - 1) / d; ans -= b / sa(c, d) - (a - 1) / sa(c, d); cout << b - a - ans + 1; }
[]
807,779
807,780
u408650734
cpp
p02995
#include <bits/stdc++.h> #include <cmath> typedef long long ll; #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) ll mod = 1e9 + 7; using namespace std; ll inputValue() { ll a; cin >> a; return a; }; void inputArray(int *p, ll a){rep(i, a){cin >> p[i]; } } ; template <typename T> void inputVector(vector<T> &p, ll a) { rep(i, a) { T input; cin >> input; p.emplace_back(input); } } template <typename T> void output(T a) { cout << a << "\n"; } ll gcd(ll a, ll b) { if (a % b == 0) return b; else return gcd(b, a % b); } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll a, b, c, d; cin >> a >> b >> c >> d; ll e, f, g, h, i, j; ll lcm = c * d / gcd(c, d); e = a / c; f = a / d; g = a / lcm; h = b / c; i = b / d; j = b / lcm; cout << b - (h + i - j) - (a - (e + f - g)) << endl; // cout << gcd(c,d) << endl; }
#include <bits/stdc++.h> #include <cmath> typedef long long ll; #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) ll mod = 1e9 + 7; using namespace std; ll inputValue() { ll a; cin >> a; return a; }; void inputArray(int *p, ll a){rep(i, a){cin >> p[i]; } } ; template <typename T> void inputVector(vector<T> &p, ll a) { rep(i, a) { T input; cin >> input; p.emplace_back(input); } } template <typename T> void output(T a) { cout << a << "\n"; } ll gcd(ll a, ll b) { if (a % b == 0) return b; else return gcd(b, a % b); } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll a, b, c, d; cin >> a >> b >> c >> d; ll e, f, g, h, i, j; ll lcm = c * d / gcd(c, d); a--; e = a / c; f = a / d; g = a / lcm; h = b / c; i = b / d; j = b / lcm; cout << b - (h + i - j) - (a - (e + f - g)) << endl; // cout << gcd(c,d) << endl; }
[ "expression.unary.arithmetic.add" ]
807,791
807,792
u712259491
cpp
p02995
#include <algorithm> #include <iomanip> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a1, b1, a, b, c = 0, d = 0, e, m, n, k, o = 0, p, l, q, x1, y1, z, max1 = 0, s = 0, ans, r, i1 = -1, x, w, h, y, j1; string t, u; cin >> a >> b >> c >> d; a1 = c; b1 = d; while (1) { if (a1 < b1) swap(a1, b1); if (!b1) break; a1 %= b1; } a1 = d * c / a1; ans = b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - b / a1 - (a - 1) / a1); cout << ans << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a1, b1, a, b, c = 0, d = 0, e, m, n, k, o = 0, p, l, q, x1, y1, z, max1 = 0, s = 0, ans, r, i1 = -1, x, w, h, y, j1; string t, u; cin >> a >> b >> c >> d; a1 = c; b1 = d; while (1) { if (a1 < b1) swap(a1, b1); if (!b1) break; a1 %= b1; } a1 = d * c / a1; ans = b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - b / a1 + (a - 1) / a1); cout << ans << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
807,801
807,802
u953532675
cpp
p02995
#include <bits/stdc++.h> #define MAX 100005 using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll a, b, c, d; cin >> a >> b >> c >> d; ll g = __gcd(c, d); ll l = (c * d) / g; ll ans1 = b / c - a / c; if (a % c == 0) ans1++; ll ans2 = b / d - a / d; if (a % d == 0) ans2; ; ll ans3 = b / l - a / l; if (a % l == 0) ans3++; ll ans = (b - a + 1) - ans1 - ans2 + ans3; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define MAX 100005 using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll a, b, c, d; cin >> a >> b >> c >> d; ll g = __gcd(c, d); ll l = (c * d) / g; ll ans1 = b / c - a / c; if (a % c == 0) ans1++; ll ans2 = b / d - a / d; if (a % d == 0) ans2++; ll ans3 = b / l - a / l; if (a % l == 0) ans3++; ll ans = (b - a + 1) - ans1 - ans2 + ans3; cout << ans << endl; return 0; }
[]
807,814
807,815
u066910956
cpp
p02995
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0ll) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdsita - cdue + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0ll) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdue - cdsita + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
[ "expression.operation.binary.remove" ]
807,823
807,824
u424602097
cpp
p02995
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0ll) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdsita - cdue + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0ll) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdue - cdsita + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
[ "expression.operation.binary.remove" ]
807,825
807,824
u424602097
cpp
p02995
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdsita - cdue + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
#include <bits/stdc++.h> using namespace std; int64_t gcd(int64_t a, int64_t b) { if (b == 0ll) return a; return gcd(b, a % b); } int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); } int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t cd = lcm(c, d); int64_t cue = b / c; int64_t csita; if (a % c == 0ll) csita = a / c; else csita = a / c + 1ll; int64_t due = b / d; int64_t dsita; if (a % d == 0ll) dsita = a / d; else dsita = a / d + 1ll; int64_t cdue = b / cd; int64_t cdsita; if (a % cd == 0ll) cdsita = a / cd; else cdsita = a / cd + 1ll; int64_t wareru = (cue - csita + 1ll) + (due - dsita + 1ll) - (cdue - cdsita + 1ll); int64_t ans = b - a + 1ll - wareru; cout << ans; }
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
807,826
807,824
u424602097
cpp
p02995
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C, D; cin >> A >> B >> C >> D; int sumAC = 0, sumAD = 0, sumACD = 0, sumBC = 0, sumBD = 0, sumBCD = 0, sumACDuso = 0, sumBCDuso = 0; int out; int saidai; int tempC = C, tempD = D; saidai = C * D; int r; if (tempC > tempD) { int tmp = tempC; tempC = tempD; tempD = tmp; } r = tempD % tempC; while (r != 0) { tempD = tempC; tempC = r; r = tempD % tempC; } saidai = saidai / tempC; sumAC = A / C; sumAD = A / D; sumBC = B / C; sumBD = B / D; sumACD = A / (saidai); sumBCD = B / (saidai); sumBCDuso = sumBC + sumBD - sumBCD; sumACDuso = sumAC + sumAD - sumACD; if (A % C == 0 | A % D == 0) { sumACDuso--; } out = sumBCDuso - sumACDuso; out = B - A + 1 - out; cout << out << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long int A, B, C, D; cin >> A >> B >> C >> D; long int sumAC = 0, sumAD = 0, sumACD = 0, sumBC = 0, sumBD = 0, sumBCD = 0, sumACDuso = 0, sumBCDuso = 0; long int out; long int saidai; long int tempC = C, tempD = D; saidai = C * D; int r; if (tempC > tempD) { long int tmp = tempC; tempC = tempD; tempD = tmp; } r = tempD % tempC; while (r != 0) { tempD = tempC; tempC = r; r = tempD % tempC; } saidai = saidai / tempC; sumAC = A / C; sumAD = A / D; sumBC = B / C; sumBD = B / D; sumACD = A / (saidai); sumBCD = B / (saidai); sumBCDuso = sumBC + sumBD - sumBCD; sumACDuso = sumAC + sumAD - sumACD; if (A % C == 0 | A % D == 0) { sumACDuso--; } out = sumBCDuso - sumACDuso; out = B - A + 1 - out; cout << out << endl; }
[ "variable_declaration.type.widen.change" ]
807,827
807,828
u431602218
cpp
p02996
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { // ll a, b, c, d; // cin >> a >> b >> c >> d; // ll ans = 0; int n; cin >> n; vector<pair<int, int>> ab(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ab[i] = make_pair(b, a); } bool flg = false; sort(ab.begin(), ab.end()); int now = 0; for (int i = 0; i < n; i++) { now += ab[i].second; if (now <= ab[i].first) { flg = true; } else { flg = false; } } if (flg) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<pair<int, int>> ab(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ab[i] = make_pair(b, a); } bool flg = false; sort(ab.begin(), ab.end()); int now = 0; for (int i = 0; i < n; i++) { now += ab[i].second; if (now <= ab[i].first) { flg = true; } else { flg = false; break; } } if (flg) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
[ "control_flow.break.add" ]
807,831
807,832
u291178324
cpp
p02996
#include <algorithm> #include <iostream> using namespace std; struct ab { long long j, t; }; bool tmp(ab a, ab b) { if (a.j < b.j) return true; else if (a.t < a.t) return true; return false; } int main() { long long n, i; cin >> n; ab a[n]; for (i = 0; i < n; i++) { cin >> a[i].t >> a[i].j; } sort(a, a + n, tmp); for (i = 0; i < n; i++) { if (i != 0) a[i].j += a[i - 1].j; if (a[i].t > a[i].j) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <algorithm> #include <iostream> using namespace std; struct ab { long long j, t; }; bool tmp(ab a, ab b) { if (a.j < b.j) return true; else if (a.t < a.t) return true; return false; } int main() { long long n, i; cin >> n; ab a[n]; for (i = 0; i < n; i++) { cin >> a[i].t >> a[i].j; } sort(a, a + n, tmp); for (i = 0; i < n; i++) { if (i != 0) a[i].t += a[i - 1].t; if (a[i].t > a[i].j) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
[ "assignment.variable.change", "assignment.value.change" ]
807,833
807,834
u180614022
cpp
p02996
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using itn = int; const ll MOD = 1000000007; const ll INF = MOD * MOD; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll dp[100010]; int main() { int n; cin >> n; vector<pair<ll, ll>> ba; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; ba.push_back(make_pair(b, -a)); } sort(ba.begin(), ba.end()); ll time = 0; for (int i = 0; i < n; i++) { time += -ba[i].second; if (time > ba[i].first) { cout << "NO" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using itn = int; const ll MOD = 1000000007; const ll INF = MOD * MOD; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll dp[100010]; int main() { int n; cin >> n; vector<pair<ll, ll>> ba; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; ba.push_back(make_pair(b, -a)); } sort(ba.begin(), ba.end()); ll time = 0; for (int i = 0; i < n; i++) { time += -ba[i].second; if (time > ba[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,835
807,836
u538125576
cpp
p02996
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using itn = int; const ll MOD = 1000000007; const ll INF = MOD * MOD; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll dp[100010]; int main() { int n; cin >> n; vector<pair<ll, ll>> ba; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; ba.push_back(make_pair(b, a)); } sort(ba.begin(), ba.end()); ll time = 0; for (int i = 0; i < n; i++) { time += ba[i].second; if (time > ba[i].first) { cout << "NO" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; using itn = int; const ll MOD = 1000000007; const ll INF = MOD * MOD; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll dp[100010]; int main() { int n; cin >> n; vector<pair<ll, ll>> ba; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; ba.push_back(make_pair(b, -a)); } sort(ba.begin(), ba.end()); ll time = 0; for (int i = 0; i < n; i++) { time += -ba[i].second; if (time > ba[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "expression.operation.unary.add", "call.arguments.change", "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,837
807,836
u538125576
cpp
p02996
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef pair<long long, long long> P; typedef long long ll; typedef long long lint; #define REP(i, n) for (long long(i) = 0; (i) < (n); ++i) #define FOR(i, a, b) for (long long(i) = (a); (i) < (b); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() const long long MOD = static_cast<long long>(1e9) + 7LL; const long long INF = 1234567891234567890LL; ll N; signed main() { cin >> N; vector<P> T(N); REP(i, N) { ll a, b; cin >> a >> b; T[i] = P(b, a); } sort(ALL(T)); bool res = true; ll t = -1; REP(i, N) { t += T[i].second; if (t > T[i].first) { res = false; break; } } if (res) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef pair<long long, long long> P; typedef long long ll; typedef long long lint; #define REP(i, n) for (long long(i) = 0; (i) < (n); ++i) #define FOR(i, a, b) for (long long(i) = (a); (i) < (b); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() const long long MOD = static_cast<long long>(1e9) + 7LL; const long long INF = 1234567891234567890LL; ll N; signed main() { cin >> N; vector<P> T(N); REP(i, N) { ll a, b; cin >> a >> b; T[i] = P(b, a); } sort(ALL(T)); bool res = true; ll t = 0; REP(i, N) { t += T[i].second; if (t > T[i].first) { res = false; break; } } if (res) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
807,843
807,844
u166696759
cpp
p02996
#include <bits/stdc++.h> #define ll long long int using namespace std; typedef pair<ll, ll> Pair; int main() { ll n; scanf("%lld", &n); vector<Pair> v(n); for (auto &x : v) scanf("%lld%lld", &x.first, &x.second); sort(v.begin(), v.end(), [](Pair x, Pair y) { if (x.second <= y.second) { if (x.first > y.first && x.second == y.second) return false; return true; } return false; }); bool flag = true; ll now = 0; for (int i = 0; i < n; i++) { now += v[i].first; if (now > v[i].second) { flag = false; break; } } puts(flag ? "Yes" : "NO"); return 0; }
#include <bits/stdc++.h> #define ll long long int using namespace std; typedef pair<ll, ll> Pair; int main() { ll n; scanf("%lld", &n); vector<Pair> v(n); for (auto &x : v) scanf("%lld%lld", &x.first, &x.second); sort(v.begin(), v.end(), [](Pair x, Pair y) { if (x.second <= y.second) { if (x.first > y.first && x.second == y.second) return false; return true; } return false; }); bool flag = true; ll now = 0; for (int i = 0; i < n; i++) { now += v[i].first; if (now > v[i].second) { flag = false; break; } } puts(flag ? "Yes" : "No"); return 0; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
807,845
807,846
u145429281
cpp
p02996
// Keep working hard :) #include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long multimap<int, int> mp; void fileIO() { #ifndef ONLINE_JUDGE freopen("int.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } int main() { IOS; fileIO(); int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; mp.insert({y, x}); } int temp = 0; for (auto it : mp) { temp += it.second; if (temp > it.first) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
// Keep working hard :) #include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long multimap<int, int> mp; void fileIO() { #ifndef ONLINE_JUDGE freopen("int.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } int main() { IOS; // fileIO(); int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; mp.insert({y, x}); } int temp = 0; for (auto it : mp) { temp += it.second; if (temp > it.first) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
[ "call.remove" ]
807,853
807,854
u490234157
cpp
p02996
#include <bits/stdc++.h> using namespace std; #define pb emplace_back #define int long long #define endl "\n" #define pii pair<int, int> #define ff first #define ss second #define mii map<int, int> #define si set<int> #define sti stack<int> #define qi queue<int> #define vi vector<int> #define pq priority_queue<int> #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const int M = 998244353; int32_t main() { int n; cin >> n; pii p[n]; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; p[i] = {y, x}; } sort(p, p + n); int sum = 0; for (int i = 0; i < n; i++) { if (sum + p[i].ss > p[i].ff) { cout << "NO"; return 0; } sum += p[i].ss; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; #define pb emplace_back #define int long long #define endl "\n" #define pii pair<int, int> #define ff first #define ss second #define mii map<int, int> #define si set<int> #define sti stack<int> #define qi queue<int> #define vi vector<int> #define pq priority_queue<int> #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const int M = 998244353; int32_t main() { int n; cin >> n; pii p[n]; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; p[i] = {y, x}; } sort(p, p + n); int sum = 0; for (int i = 0; i < n; i++) { if (sum + p[i].ss > p[i].ff) { cout << "No"; return 0; } sum += p[i].ss; } cout << "Yes"; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,869
807,870
u231918578
cpp
p02996
#include <bits/stdc++.h> #include <utility> using namespace std; int main() { int N; cin >> N; vector<pair<long long, long long>> work(N); for (int i = 0; i < N; i++) { long long A, B; cin >> A >> B; work[i] = make_pair(B, A); } sort(work.begin(), work.end()); long long A = 0; long long B = 0; for (int i = 0; i < N; i++) { A += work[i].second; B += work[i].first; if (A > B) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> #include <utility> using namespace std; int main() { int N; cin >> N; vector<pair<long long, long long>> work(N); for (int i = 0; i < N; i++) { long long A, B; cin >> A >> B; work[i] = make_pair(B, A); } sort(work.begin(), work.end()); long long A = 0; long long B = 0; for (int i = 0; i < N; i++) { A += work[i].second; B = work[i].first; if (A > B) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "assignment.value.change" ]
807,877
807,878
u058186113
cpp
p02996
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<l_l> pair(N); rep(i, N) { ll a; ll b; cin >> a >> b; pair[i] = make_pair(b, a); } sort(pair.begin(), pair.end()); ll time = 0; rep(i, N) { if (time + pair[i].second >= pair[i].first) { time += pair[i].second; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<l_l> pair(N); rep(i, N) { ll a; ll b; cin >> a >> b; pair[i] = make_pair(b, a); } sort(pair.begin(), pair.end()); ll time = 0; rep(i, N) { if (time + pair[i].second <= pair[i].first) { time += pair[i].second; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
807,883
807,884
u535810324
cpp
p02996
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<l_l> pair(N); rep(i, N) { ll a; ll b; cin >> a >> b; pair[i] = make_pair(b, a); } sort(pair.begin(), pair.end()); ll time = 0; rep(i, N) { if (time + pair[i].first >= pair[i].second) { time += pair[i].first; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
using namespace std; #include <bits/stdc++.h> #define rep(i, s) for (int i = 0; i < s; ++i) #define repr(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define all(v) (v.begin(), v.end()) #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define VEC(a, n) vector<int> a(n) #define PQ(a) priority_queue<int> a #define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a #define PAIR pair<int, int> typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e10) #define PI (acos(-1)) const ll mod = 1000000007; bool f(string s) { bool ans = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() / 2 + i]) { ans = false; break; } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<l_l> pair(N); rep(i, N) { ll a; ll b; cin >> a >> b; pair[i] = make_pair(b, a); } sort(pair.begin(), pair.end()); ll time = 0; rep(i, N) { if (time + pair[i].second <= pair[i].first) { time += pair[i].second; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "control_flow.branch.if.condition.change", "assignment.value.change" ]
807,885
807,884
u535810324
cpp
p02996
#include <bits/stdc++.h> using namespace std; #define maxn 200007 #define ll long long int #define db(x) cout << #x << " ->" << x << " " << endl #define db2(x, y) cout << #x << "->" << x << ", " << #y << " -> " << y << endl #define db3(x, y, z) \ cout << #x << " -> " << x << " , " << #y << " -> " << y << " , " << #z \ << " -> " << z << endl #define prt(x) \ for (auto it = x.begin(); it != x.end(); it++) { \ cout << *it << " "; \ } \ cout << endl #define IN freopen("input.txt", "r", stdin) ll duration[maxn], deadline[maxn]; vector<pair<ll, ll>> V; int main() { ios_base::sync_with_stdio(false); cin.tie(0); // IN; int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> duration[i] >> deadline[i]; V.push_back({deadline[i], duration[i]}); } sort(V.begin(), V.end()); ll sum = 0LL; for (int i = 0; i < V.size(); i++) { ll x = V[i].first; ll y = V[i].second; sum += y; // db3(y,x,sum); if (sum > x) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define maxn 200007 #define ll long long int #define db(x) cout << #x << " ->" << x << " " << endl #define db2(x, y) cout << #x << "->" << x << ", " << #y << " -> " << y << endl #define db3(x, y, z) \ cout << #x << " -> " << x << " , " << #y << " -> " << y << " , " << #z \ << " -> " << z << endl #define prt(x) \ for (auto it = x.begin(); it != x.end(); it++) { \ cout << *it << " "; \ } \ cout << endl #define IN freopen("input.txt", "r", stdin) ll duration[maxn], deadline[maxn]; vector<pair<ll, ll>> V; int main() { ios_base::sync_with_stdio(false); cin.tie(0); // IN; int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> duration[i] >> deadline[i]; V.push_back({deadline[i], duration[i]}); } sort(V.begin(), V.end()); ll sum = 0LL; for (int i = 0; i < V.size(); i++) { ll x = V[i].first; ll y = V[i].second; sum += y; // db3(y,x,sum); if (sum > x) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
807,888
807,889
u616128518
cpp
p02996
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) cin >> a.at(i).second >> a.at(i).first; int ans = 0; int time = 0; sort(a.begin(), a.end()); for (pair<int, int> x : a) { int s, t; tie(s, t) = x; time += t; if (time > s) { ans++; break; } } if (ans > 0) cout << "No"; else cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) cin >> a.at(i).second >> a.at(i).first; int ans = 0; int time = 0; sort(a.begin(), a.end()); for (pair<int, int> x : a) { int s, t; tie(s, t) = x; time += t; if (time > s) { ans++; break; } } if (ans > 0) cout << "No"; else cout << "Yes"; }
[]
807,915
807,916
u424602097
cpp
p02996
#include <bits/stdc++.h> #define mxn 1000010 #define LL long long #define pb push_back #define pf push_front #define pii pair<int, int> #define mp make_pair #define fr first #define sc second using namespace std; int n, nw, sl, fh; LL S; struct node { int a, b; bool operator<(const node &x) const { return b < x.b; } } s[mxn]; int rd() { sl = 0; fh = 1; char ch = getchar(); while (ch < '0' || '9' < ch) { if (ch == '-') fh = -1; ch = getchar(); } while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar(); return sl * fh; } int main() { n = rd(); for (int i = 1; i <= n; ++i) s[i].a = rd(), s[i].b = rd(); sort(s + 1, s + n + 1); for (int i = 1; i <= n; ++i) { if (S + s[i].a > s[i].b) { puts("No"); return 0; } S += s[i].a; } puts("YES"); return 0; }
#include <bits/stdc++.h> #define mxn 1000010 #define LL long long #define pb push_back #define pf push_front #define pii pair<int, int> #define mp make_pair #define fr first #define sc second using namespace std; int n, nw, sl, fh; LL S; struct node { int a, b; bool operator<(const node &x) const { return b < x.b; } } s[mxn]; int rd() { sl = 0; fh = 1; char ch = getchar(); while (ch < '0' || '9' < ch) { if (ch == '-') fh = -1; ch = getchar(); } while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar(); return sl * fh; } int main() { n = rd(); for (int i = 1; i <= n; ++i) s[i].a = rd(), s[i].b = rd(); sort(s + 1, s + n + 1); for (int i = 1; i <= n; ++i) { if (S + s[i].a > s[i].b) { puts("No"); return 0; } S += s[i].a; } puts("Yes"); return 0; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
807,938
807,939
u938301018
cpp
p02996
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define rep(i, a, b) for (int i = a; i < b; i++) #define F first #define S second using namespace std; typedef long long ll; typedef vector<int> vi; bool pairCompare(const pair<ll, ll> &firstElof, const pair<ll, ll> &secondElof) { return firstElof.second < secondElof.second; } int main() { int n; scanf("%d", &n); vector<pair<ll, ll>> a(n); int b, c; for (int i = 0; i < n; i++) { cin >> b >> c; a[i].first = b; a[i].second = c; } sort(a.begin(), a.end(), pairCompare); ll sum = 0; bool ans = true; for (int i = 0; i < n; i++) { sum += a[i].first; // printf("sum is %d at %d\n", sum, i); if (sum > a[i].second) { ans = false; // printf("falsed at %d\n", i); } else { ans = true; } } if (ans == true) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define rep(i, a, b) for (int i = a; i < b; i++) #define F first #define S second using namespace std; typedef long long ll; typedef vector<int> vi; bool pairCompare(const pair<ll, ll> &firstElof, const pair<ll, ll> &secondElof) { return firstElof.second < secondElof.second; } int main() { int n; scanf("%d", &n); vector<pair<ll, ll>> a(n); int b, c; for (int i = 0; i < n; i++) { cin >> b >> c; a[i].first = b; a[i].second = c; } sort(a.begin(), a.end(), pairCompare); ll sum = 0; bool ans = true; for (int i = 0; i < n; i++) { sum += a[i].first; // printf("sum is %d at %d\n", sum, i); if (sum > a[i].second) { ans = false; break; // printf("falsed at %d\n", i); } else { ans = true; } } if (ans == true) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
[ "control_flow.break.add" ]
807,940
807,941
u916207924
cpp
p02996
#include <bits/stdc++.h> #include <map> #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #define REP(i, n) FOR(i, 0, n) using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> p(n); REP(i, n) { int temp1, temp2; cin >> temp1 >> temp2; p[i] = make_pair(temp2, temp1); } sort(p.begin(), p.end()); int count = 0; REP(i, n) { count += p[i].first; if (count > p[i].second) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> #include <map> #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #define REP(i, n) FOR(i, 0, n) using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> p(n); REP(i, n) { int temp1, temp2; cin >> temp1 >> temp2; p[i] = make_pair(temp2, temp1); } sort(p.begin(), p.end()); int count = 0; REP(i, n) { count += p[i].second; if (count > p[i].first) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
807,942
807,943
u538853954
cpp
p02996
#include <iostream> #include <stdlib.h> #include <vector> #include <algorithm> #include <stdio.h> #include <string> #include <map> #include <math.h> #include <iomanip> #include <set> #include <limits.h> #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define swap(a, b) \ a ^= b; \ b ^= a; \ a ^= b; #define chmax(a, b) \ { \ if (a < b) \ a = b; \ } #define chmin(a, b) \ { \ if (a > b) \ a = b; \ } using namespace std; typedef long long ll; ll gcd(ll, ll); vector<bool> to_binary(int); int sum(vector<int>); int min(vector<int>); int max(vector<int>); ll nCr(ll n, ll r); const ll INF = 1LL << 60; typedef tuple<ll, ll> mtupl; bool mycomp(mtupl x, mtupl y) { return get<1>(x) < get<1>(y); } int main(void) { cin.tie(0); ios::sync_with_stdio(false); // Program Start int N; cin >> N; vector<mtupl> AB(N); ll A, B; rep(i, N) { cin >> A >> B; AB[i] = make_pair(A, B); } sort(AB.begin(), AB.end(), mycomp); int time = 0; rep(i, N) { time += get<0>(AB[i]); if (time >= get<1>(AB[i])) { cout << "No" << endl; exit(0); } } cout << "Yes" << endl; /* ll N, W; cin >> N >> W; vector<ll> w(N), v(N); rep(i, N) { cin >> w[i] >> v[i]; } vector<vector<ll>> dp(N + 1); rep(i, N + 1) dp[i].resize(W + 1); for (int i = 0; i < N; i++) { for (int weight = 0; weight <= W; weight++) { if (weight - w[i] < 0) { chmax(dp[i + 1][weight], dp[i][weight]); } else chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]); } } /* rep(i, N + 1) { rep(j, W + 1) { cout << to_string(dp[i][j]) + " "; } cout << endl; }* cout << dp[N][W] << endl; */ ProgramEndPointLabel:; // Program End system("pause"); return 0; } ll nCr(ll n, ll r) { ll res = 1; for (int i = 0; i < r; i++) { res *= (n - i); } for (int i = 1; i <= r; i++) { res /= i; } return res; } int vsum(vector<int> v) { int res = 0; for (auto it = v.begin(); it != v.end(); it++) res += *it; return res; } int vmin(vector<int> v) { int min = INT32_MAX; for (auto it = v.begin(); it != v.end(); it++) min = std::min(min, *it); return min; } int vmax(vector<int> v) { int max = 0; for (auto it = v.begin(); it != v.end(); it++) max = std::max(max, *it); return max; } ll gcd(ll A, ll B) { int r = A % B; while (r != 0) { A = B; B = r; r = A % B; } return B; } vector<bool> to_binary(int x) { vector<bool> res; while (x != 0) { res.push_back(x % 2); x /= 2; } return res; }
#include <iostream> #include <stdlib.h> #include <vector> #include <algorithm> #include <stdio.h> #include <string> #include <map> #include <math.h> #include <iomanip> #include <set> #include <limits.h> #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define swap(a, b) \ a ^= b; \ b ^= a; \ a ^= b; #define chmax(a, b) \ { \ if (a < b) \ a = b; \ } #define chmin(a, b) \ { \ if (a > b) \ a = b; \ } using namespace std; typedef long long ll; ll gcd(ll, ll); vector<bool> to_binary(int); int sum(vector<int>); int min(vector<int>); int max(vector<int>); ll nCr(ll n, ll r); const ll INF = 1LL << 60; typedef tuple<ll, ll> mtupl; bool mycomp(mtupl x, mtupl y) { return get<1>(x) < get<1>(y); } int main(void) { cin.tie(0); ios::sync_with_stdio(false); // Program Start int N; cin >> N; vector<mtupl> AB(N); ll A, B; rep(i, N) { cin >> A >> B; AB[i] = make_pair(A, B); } sort(AB.begin(), AB.end(), mycomp); int time = 0; rep(i, N) { time += get<0>(AB[i]); if (time > get<1>(AB[i])) { cout << "No" << endl; goto ProgramEndPointLabel; } } cout << "Yes" << endl; /* ll N, W; cin >> N >> W; vector<ll> w(N), v(N); rep(i, N) { cin >> w[i] >> v[i]; } vector<vector<ll>> dp(N + 1); rep(i, N + 1) dp[i].resize(W + 1); for (int i = 0; i < N; i++) { for (int weight = 0; weight <= W; weight++) { if (weight - w[i] < 0) { chmax(dp[i + 1][weight], dp[i][weight]); } else chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]); } } /* rep(i, N + 1) { rep(j, W + 1) { cout << to_string(dp[i][j]) + " "; } cout << endl; }* cout << dp[N][W] << endl; */ ProgramEndPointLabel:; // Program End system("pause"); return 0; } ll nCr(ll n, ll r) { ll res = 1; for (int i = 0; i < r; i++) { res *= (n - i); } for (int i = 1; i <= r; i++) { res /= i; } return res; } int vsum(vector<int> v) { int res = 0; for (auto it = v.begin(); it != v.end(); it++) res += *it; return res; } int vmin(vector<int> v) { int min = INT32_MAX; for (auto it = v.begin(); it != v.end(); it++) min = std::min(min, *it); return min; } int vmax(vector<int> v) { int max = 0; for (auto it = v.begin(); it != v.end(); it++) max = std::max(max, *it); return max; } ll gcd(ll A, ll B) { int r = A % B; while (r != 0) { A = B; B = r; r = A % B; } return B; } vector<bool> to_binary(int x) { vector<bool> res; while (x != 0) { res.push_back(x % 2); x /= 2; } return res; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
807,944
807,945
u040251933
cpp
p02996
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<P> ab(n); for (int i = 0; i < n; i++) { cin >> ab[i].second >> ab[i].first; } sort(all(ab)); int now = 0; for (int i = 0; i < ab[i].first; i++) { if (ab[i].first - now >= ab[i].second) { now += ab[i].second; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<P> ab(n); for (int i = 0; i < n; i++) { cin >> ab[i].second >> ab[i].first; } sort(all(ab)); int now = 0; for (int i = 0; i < n; i++) { if (ab[i].first - now >= ab[i].second) { now += ab[i].second; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
807,946
807,947
u654240084
cpp
p02998
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define dump(...) #endif #define endl '\n' #define ll long long #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define REPS(i, x) for (int i = 1; i <= (int)(x); i++) #define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--) #define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--) #define INF 2147483647 #define LLINF 9223372036854775807LL #define vi vector<int> #define vvi vector<vector<int>> #define pi pair<int, int> #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define BIT(n) (1LL << (n)) #define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper) #define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define FILLZERO(s, n) \ do { \ ostringstream os; \ os << setw(n) << setfill('0') << s; \ s = os.str(); \ } while (0); #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてからつかうこと #define INIT \ std::cin.tie(nullptr); \ std::ios_base::sync_with_stdio(false); \ cout << std::fixed << std::setprecision(10); template <typename T> vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); } template <typename T, typename... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } constexpr ll MOD = 1e9 + 7; int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1}; ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S, T; ll ans = 0; struct UnionFind { vector<int> rank, parent, num; UnionFind(){}; UnionFind(int size) : rank(size, 0), parent(size, 0), num(size, 0) { for (int i = 0; i < size; i++) makeset(i); } void makeset(int x) { parent[x] = x; rank[x] = x; num[x] = 1; } int size(int x) { return num[findset(x)]; } bool same(int x, int y) { return findset(x) == findset(y); } int findset(int x) { if (x != parent[x]) { parent[x] = findset(parent[x]); } return parent[x]; } void unite(int x, int y) { if (!same(x, y)) link(findset(x), findset(y)); } void link(int x, int y) { if (rank[x] > rank[y]) { parent[y] = x; num[x] += num[y]; } else { parent[x] = y; num[y] += num[x]; if (rank[x] == rank[y]) rank[y]++; } } }; signed main() { INIT; cin >> N; map<pi, int> mp; int cnt = 0; vi x(N), y(N); REP(i, N) { cin >> x[i] >> y[i]; if (mp.find({x[i], 0}) == mp.end()) { mp[{x[i], 0}] = cnt++; } if (mp.find({y[i], 1}) == mp.end()) { mp[{y[i], 1}] = cnt++; } } UnionFind uf(cnt); REP(i, N) { uf.unite(mp[{x[i], 0}], mp[{y[i], 1}]); } vector<set<int>> xs(cnt); vector<set<int>> ys(cnt); REP(i, N) { xs[uf.findset(mp[{x[i], 0}])].insert(x[i]); ys[uf.findset(mp[{y[i], 0}])].insert(y[i]); } REP(i, cnt) { ans += (ll)xs[i].size() * ys[i].size(); } cout << ans - N << endl; }
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define dump(...) #endif #define endl '\n' #define ll long long #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define REPS(i, x) for (int i = 1; i <= (int)(x); i++) #define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--) #define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--) #define INF 2147483647 #define LLINF 9223372036854775807LL #define vi vector<int> #define vvi vector<vector<int>> #define pi pair<int, int> #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define BIT(n) (1LL << (n)) #define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper) #define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define FILLZERO(s, n) \ do { \ ostringstream os; \ os << setw(n) << setfill('0') << s; \ s = os.str(); \ } while (0); #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてからつかうこと #define INIT \ std::cin.tie(nullptr); \ std::ios_base::sync_with_stdio(false); \ cout << std::fixed << std::setprecision(10); template <typename T> vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); } template <typename T, typename... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } constexpr ll MOD = 1e9 + 7; int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1}; ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S, T; ll ans = 0; struct UnionFind { vector<int> rank, parent, num; UnionFind(){}; UnionFind(int size) : rank(size, 0), parent(size, 0), num(size, 0) { for (int i = 0; i < size; i++) makeset(i); } void makeset(int x) { parent[x] = x; rank[x] = x; num[x] = 1; } int size(int x) { return num[findset(x)]; } bool same(int x, int y) { return findset(x) == findset(y); } int findset(int x) { if (x != parent[x]) { parent[x] = findset(parent[x]); } return parent[x]; } void unite(int x, int y) { if (!same(x, y)) link(findset(x), findset(y)); } void link(int x, int y) { if (rank[x] > rank[y]) { parent[y] = x; num[x] += num[y]; } else { parent[x] = y; num[y] += num[x]; if (rank[x] == rank[y]) rank[y]++; } } }; signed main() { INIT; cin >> N; map<pi, int> mp; int cnt = 0; vi x(N), y(N); REP(i, N) { cin >> x[i] >> y[i]; if (mp.find({x[i], 0}) == mp.end()) { mp[{x[i], 0}] = cnt++; } if (mp.find({y[i], 1}) == mp.end()) { mp[{y[i], 1}] = cnt++; } } UnionFind uf(cnt); REP(i, N) { uf.unite(mp[{x[i], 0}], mp[{y[i], 1}]); } vector<set<int>> xs(cnt); vector<set<int>> ys(cnt); REP(i, N) { xs[uf.findset(mp[{x[i], 0}])].insert(x[i]); ys[uf.findset(mp[{y[i], 1}])].insert(y[i]); } REP(i, cnt) { ans += (ll)xs[i].size() * (ll)ys[i].size(); } cout << ans - N << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change" ]
808,653
808,654
u030090262
cpp
p02998
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep1(i, n) for (int i = 1; i <= (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define rrep1(i, n) for (int i = (int)(n); i >= 1; --i) #define range(i, l, r) for (int i = l; i < (int)(r); ++i) #define rrange(i, l, r) for (int i = (int)(r)-1; i >= l; --i) #define unless(a) if (!(a)) #define all(a) begin(a), end(a) #define fst first #define scd second #define PB emplace_back #define PPB pop_back #define UNIQ(a) a.erase(unique(all(a)), end(a)) using vi = vector<int>; using pii = pair<int, int>; using vpii = vector<pii>; using ll = long long; constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); } template <typename T> bool chmin(T &a, T b) { return a > b ? (a = b, 1) : 0; } template <typename T> bool chmax(T &a, T b) { return a < b ? (a = b, 1) : 0; } int read() { int a; scanf("%lld", &a); return a; } const double pi = acos(-1); constexpr int inf = 3 * TEN(18) + 10; constexpr int mod = TEN(9) + 7; int N; vpii x[100010]; // x[i] := y = i にあるx座標の列(sorted) vpii y[100010]; // y[i] := x = i にあるy座標の列(sorted) pii P[100010]; bool visited[100010]; int bfs(int idx) { queue<pair<pii, int>> q; q.emplace(P[idx], idx); set<int> SX, SY; SX.insert(P[idx].first); SY.insert(P[idx].second); visited[idx] = true; int sz = 1; while (q.size()) { auto cur = q.front(); q.pop(); int curx = cur.first.first, cury = cur.first.second; int id = cur.second; int xidx = lower_bound(all(x[cury]), pii(curx, id)) - begin(x[cury]); int yidx = lower_bound(all(y[curx]), pii(cury, id)) - begin(y[curx]); for (int i = -1; i <= 1; ++i) { if (0 <= xidx + i and xidx + i < x[cury].size()) { pii neix = x[cury][xidx + i]; int nx = neix.first; int nid = neix.second; if (visited[id]) continue; sz++; SX.insert(nx); q.emplace(pii(nx, cury), nid); visited[id] = true; } } for (int i = -1; i <= 1; ++i) { if (0 <= yidx + i and yidx + i < y[curx].size()) { pii neiy = y[curx][yidx + i]; int ny = neiy.first; int nid = neiy.second; if (visited[id]) continue; sz++; SY.insert(ny); q.emplace(pii(curx, ny), nid); visited[id] = true; } } } return SX.size() * SY.size() - sz; } signed main() { cin >> N; rep(i, N) { int a, b; cin >> a >> b; P[i] = pii(a, b); x[b].PB(a, i); y[a].PB(b, i); } rep(i, 100010) { sort(all(x[i])); sort(all(y[i])); } int ans = 0; rep(i, N) { if (visited[i]) continue; int v = bfs(i); ans += v; } cout << ans << endl; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep1(i, n) for (int i = 1; i <= (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define rrep1(i, n) for (int i = (int)(n); i >= 1; --i) #define range(i, l, r) for (int i = l; i < (int)(r); ++i) #define rrange(i, l, r) for (int i = (int)(r)-1; i >= l; --i) #define unless(a) if (!(a)) #define all(a) begin(a), end(a) #define fst first #define scd second #define PB emplace_back #define PPB pop_back #define UNIQ(a) a.erase(unique(all(a)), end(a)) using vi = vector<int>; using pii = pair<int, int>; using vpii = vector<pii>; using ll = long long; constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); } template <typename T> bool chmin(T &a, T b) { return a > b ? (a = b, 1) : 0; } template <typename T> bool chmax(T &a, T b) { return a < b ? (a = b, 1) : 0; } int read() { int a; scanf("%lld", &a); return a; } const double pi = acos(-1); constexpr int inf = 3 * TEN(18) + 10; constexpr int mod = TEN(9) + 7; int N; vpii x[100010]; // x[i] := y = i にあるx座標の列(sorted) vpii y[100010]; // y[i] := x = i にあるy座標の列(sorted) pii P[100010]; bool visited[100010]; int bfs(int idx) { queue<pair<pii, int>> q; q.emplace(P[idx], idx); set<int> SX, SY; SX.insert(P[idx].first); SY.insert(P[idx].second); visited[idx] = true; int sz = 1; while (q.size()) { auto cur = q.front(); q.pop(); int curx = cur.first.first, cury = cur.first.second; int id = cur.second; int xidx = lower_bound(all(x[cury]), pii(curx, id)) - begin(x[cury]); int yidx = lower_bound(all(y[curx]), pii(cury, id)) - begin(y[curx]); for (int i = -1; i <= 1; ++i) { if (0 <= xidx + i and xidx + i < x[cury].size()) { pii neix = x[cury][xidx + i]; int nx = neix.first; int nid = neix.second; if (visited[nid]) continue; sz++; SX.insert(nx); q.emplace(pii(nx, cury), nid); visited[nid] = true; } } for (int i = -1; i <= 1; ++i) { if (0 <= yidx + i and yidx + i < y[curx].size()) { pii neiy = y[curx][yidx + i]; int ny = neiy.first; int nid = neiy.second; if (visited[nid]) continue; sz++; SY.insert(ny); q.emplace(pii(curx, ny), nid); visited[nid] = true; } } } return SX.size() * SY.size() - sz; } signed main() { cin >> N; rep(i, N) { int a, b; cin >> a >> b; P[i] = pii(a, b); x[b].PB(a, i); y[a].PB(b, i); } rep(i, 100010) { sort(all(x[i])); sort(all(y[i])); } int ans = 0; rep(i, N) { if (visited[i]) continue; int v = bfs(i); ans += v; } cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "assignment.variable.change" ]
808,676
808,677
u491256431
cpp
p02998
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #ifdef _DEBUG #define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n" #else #define DUMP(x) #endif #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define EREP(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rep(i, n) REP(i, 0, n) #define erep(i, n) EREP(i, 0, n) #define rrep(i, n) RREP(i, n, 0) #define ALL(r) (r).begin(), (r).end() #define pb push_back #define eb emplace_back #define fi first #define se second template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", "); os << "}"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return (os << "(" << p.first << ", " << p.second << ")"); } template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &m) { bool first = true; os << "{"; for (const auto &e : m) { if (!first) os << ", "; os << "{" << e.first << ": " << e.second << "}"; first = false; } os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &s) { os << "{"; bool first = true; for (const auto &e : s) { if (!first) os << ", "; os << e; first = false; } os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &s) { os << "{"; bool first = true; for (const auto &e : s) { if (!first) os << ", "; os << e; first = false; } os << "}"; return os; } template <typename T> T dup(T x, T y) { return (x + y - 1) / y; }; template <typename A, size_t N, typename T> inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } struct in { const size_t n = 0; in() = default; in(size_t n) : n(n){}; template <typename T> operator T() { T ret; cin >> ret; return ret; } template <typename T> operator vector<T>() { assert(n != 0); vector<T> ret(n); for (T &x : ret) { T tmp = in(); x = tmp; } return ret; } template <typename T, typename U> operator pair<T, U>() { pair<T, U> ret; ret.first = in(); ret.second = in(); return ret; } }; namespace fiore::impl { template <typename T> inline void out_impl(const T &x, char end_char) { std::cout << x << end_char; } template <typename T> inline void out_impl(const vector<T> &x, char end_char) { bool first = true; for (const auto &e : x) { if (!first) std::cout << ' '; std::cout << e; first = false; } std::cout << end_char; } } // namespace fiore::impl template <typename T> inline void out(const T &x) { fiore::impl::out_impl(x, '\n'); }; template <typename T, typename U, typename... Args> inline void out(const T &x, const U &y, const Args &...args) { fiore::impl::out_impl(x, ' '); out(y, args...); } using ll = int64_t; using vint = vector<int32_t>; using vvint = vector<vint>; using vll = vector<ll>; using vvll = vector<vll>; using vstr = vector<string>; using pint = pair<int32_t, int32_t>; using vpint = vector<pint>; using pll = pair<ll, ll>; using vpll = vector<pll>; using setint = set<int32_t>; using qint = queue<int32_t>; using qpint = queue<pint>; constexpr std::int32_t INF = 1001001001; constexpr std::int64_t LINF = 1001001001001001001; class UnionFind { public: UnionFind(const int n) : par(n), rank(n, 0), sz(n, 1) { rep(i, n) par[i] = i; // 全てが根であるとして初期化 } // x が属する木の根を求める int find(const int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } // x と y を併合する void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; } else { par[y] = x; sz[x] += sz[y]; if (rank[x] == rank[y]) { ++rank[x]; } } } // x と y が同じ木に属するか bool same(const int x, const int y) { return find(x) == find(y); } int size(const int x) { return sz[find(x)]; } private: vint par; // 親 vint rank; // ランク(根からの距離) vint sz; // 木の要素数 }; void Main() { int n = in(); UnionFind uf(100005 * 2); vpint edges; rep(i, n) { int x = in(), y = in(); uf.unite(x, 100005 + y); edges.eb(x, y); } map<int, setint> mp1, mp2; map<int, int> edge_cnt; for (auto [x, y] : edges) { mp1[uf.find(x)].insert(x); mp2[uf.find(y)].insert(y); ++edge_cnt[uf.find(x)]; } ll ans = 0; auto itr1 = mp1.begin(), itr2 = mp2.begin(); auto itr3 = edge_cnt.begin(); rep(i, edge_cnt.size()) { ans += itr1->se.size() * itr2->se.size() - itr3->se; ++itr1; ++itr2; ++itr3; } out(ans); } signed main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #ifdef _DEBUG #define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n" #else #define DUMP(x) #endif #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define EREP(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rep(i, n) REP(i, 0, n) #define erep(i, n) EREP(i, 0, n) #define rrep(i, n) RREP(i, n, 0) #define ALL(r) (r).begin(), (r).end() #define pb push_back #define eb emplace_back #define fi first #define se second template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", "); os << "}"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return (os << "(" << p.first << ", " << p.second << ")"); } template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &m) { bool first = true; os << "{"; for (const auto &e : m) { if (!first) os << ", "; os << "{" << e.first << ": " << e.second << "}"; first = false; } os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &s) { os << "{"; bool first = true; for (const auto &e : s) { if (!first) os << ", "; os << e; first = false; } os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &s) { os << "{"; bool first = true; for (const auto &e : s) { if (!first) os << ", "; os << e; first = false; } os << "}"; return os; } template <typename T> T dup(T x, T y) { return (x + y - 1) / y; }; template <typename A, size_t N, typename T> inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } struct in { const size_t n = 0; in() = default; in(size_t n) : n(n){}; template <typename T> operator T() { T ret; cin >> ret; return ret; } template <typename T> operator vector<T>() { assert(n != 0); vector<T> ret(n); for (T &x : ret) { T tmp = in(); x = tmp; } return ret; } template <typename T, typename U> operator pair<T, U>() { pair<T, U> ret; ret.first = in(); ret.second = in(); return ret; } }; namespace fiore::impl { template <typename T> inline void out_impl(const T &x, char end_char) { std::cout << x << end_char; } template <typename T> inline void out_impl(const vector<T> &x, char end_char) { bool first = true; for (const auto &e : x) { if (!first) std::cout << ' '; std::cout << e; first = false; } std::cout << end_char; } } // namespace fiore::impl template <typename T> inline void out(const T &x) { fiore::impl::out_impl(x, '\n'); }; template <typename T, typename U, typename... Args> inline void out(const T &x, const U &y, const Args &...args) { fiore::impl::out_impl(x, ' '); out(y, args...); } using ll = int64_t; using vint = vector<int32_t>; using vvint = vector<vint>; using vll = vector<ll>; using vvll = vector<vll>; using vstr = vector<string>; using pint = pair<int32_t, int32_t>; using vpint = vector<pint>; using pll = pair<ll, ll>; using vpll = vector<pll>; using setint = set<int32_t>; using qint = queue<int32_t>; using qpint = queue<pint>; constexpr std::int32_t INF = 1001001001; constexpr std::int64_t LINF = 1001001001001001001; class UnionFind { public: UnionFind(const int n) : par(n), rank(n, 0), sz(n, 1) { rep(i, n) par[i] = i; // 全てが根であるとして初期化 } // x が属する木の根を求める int find(const int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } // x と y を併合する void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; } else { par[y] = x; sz[x] += sz[y]; if (rank[x] == rank[y]) { ++rank[x]; } } } // x と y が同じ木に属するか bool same(const int x, const int y) { return find(x) == find(y); } int size(const int x) { return sz[find(x)]; } private: vint par; // 親 vint rank; // ランク(根からの距離) vint sz; // 木の要素数 }; void Main() { int n = in(); UnionFind uf(100005 * 2); vpint edges; rep(i, n) { int x = in(), y = in(); uf.unite(x, 100005 + y); edges.eb(x, y); } map<int, setint> mp1, mp2; map<int, int> edge_cnt; for (auto [x, y] : edges) { mp1[uf.find(x)].insert(x); mp2[uf.find(x)].insert(y); ++edge_cnt[uf.find(x)]; } ll ans = 0; auto itr1 = mp1.begin(), itr2 = mp2.begin(); auto itr3 = edge_cnt.begin(); rep(i, edge_cnt.size()) { ans += itr1->se.size() * itr2->se.size() - itr3->se; ++itr1; ++itr2; ++itr3; } out(ans); } signed main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "call.arguments.change" ]
808,684
808,685
u664394831
cpp
p02998
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <tuple> #include <utility> #include <vector> #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{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false) template<typename T> void PPPPP(T t) { cerr << t; } template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); } #else #define dump(...) do{ } while(false) #endif template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; } template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; } template<typename T> void print(T a) { cout << a << endl; } template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); } template<typename T> istream &operator,(istream &in, T &t) { return in >> t; } // clang-format on class UnionFind { public: vector<int> par; int N; UnionFind(int n) { par.resize(n, -1); N = n; } int Find(int n) { return par[n] < 0 ? n : par[n] = Find(par[n]); } bool Union(int x, int y) { x = Find(x); y = Find(y); if (x == y) return false; if (-par[x] > -par[y]) swap(x, y); par[y] += par[x]; par[x] = y; N--; return true; } bool Same(int x, int y) { return Find(x) == Find(y); } int size(int x) { return -par[Find(x)]; } int size() { return N; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin, n; int sz = 100010; vector<vector<int>> cnt(sz); REP(i, 0, n) { int x, y; cin, x, y; cnt[x].push_back(y); } UnionFind uf(sz); REP(i, 0, sz) { for (int j = 1; j < cnt[i].size(); j++) { uf.Union(cnt[i][0], cnt[i][j]); } } ll ans = 0; REP(i, 0, sz) { if (cnt[i].size()) { ans += uf.size(i) - cnt[i].size(); } } print(ans); return 0; }
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <tuple> #include <utility> #include <vector> #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{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false) template<typename T> void PPPPP(T t) { cerr << t; } template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); } #else #define dump(...) do{ } while(false) #endif template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; } template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; } template<typename T> void print(T a) { cout << a << endl; } template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); } template<typename T> istream &operator,(istream &in, T &t) { return in >> t; } // clang-format on class UnionFind { public: vector<int> par; int N; UnionFind(int n) { par.resize(n, -1); N = n; } int Find(int n) { return par[n] < 0 ? n : par[n] = Find(par[n]); } bool Union(int x, int y) { x = Find(x); y = Find(y); if (x == y) return false; if (-par[x] > -par[y]) swap(x, y); par[y] += par[x]; par[x] = y; N--; return true; } bool Same(int x, int y) { return Find(x) == Find(y); } int size(int x) { return -par[Find(x)]; } int size() { return N; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin, n; int sz = 100010; vector<vector<int>> cnt(sz); REP(i, 0, n) { int x, y; cin, x, y; cnt[x].push_back(y); } UnionFind uf(sz); REP(i, 0, sz) { for (int j = 1; j < cnt[i].size(); j++) { uf.Union(cnt[i][0], cnt[i][j]); } } ll ans = 0; REP(i, 0, sz) { if (cnt[i].size()) { ans += uf.size(cnt[i][0]) - cnt[i].size(); } } print(ans); return 0; }
[]
808,696
808,697
u451748673
cpp
p02998
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i, j, k) for (int(i) = (j); (i) < (int)(k); ++(i)) #define rep(i, j) FOR(i, 0, j) #define each(x, y) for (auto &(x) : (y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(), (x).end() #define debug(x) cout << #x << ": " << (x) << endl #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define MEM(x, y) memset((x), (y), sizeof(x)) #define sz(x) (int)(x).size() #define RT return using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; class UnionFind { int cnt; vector<int> par, rank, size; public: UnionFind() {} UnionFind(int _n) : cnt(_n), par(_n), rank(_n), size(_n, 1) { for (int i = 0; i < _n; ++i) par[i] = i; } int find(int k) { return (k == par[k]) ? k : (par[k] = find(par[k])); } int operator[](int k) { return find(k); } int getSize(int k) { return size[find(k)]; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; --cnt; if (rank[x] < rank[y]) { par[x] = y; size[y] += size[x]; } else { par[y] = x; size[x] += size[y]; if (rank[y] == rank[x]) ++rank[x]; } } int count() { return cnt; } }; void solve() { const int MA = (int)1e5 + 1; int N; cin >> N; vi X(N), Y(N); vector<vi> G(MA), H(MA); rep(i, N) { cin >> X[i] >> Y[i]; G[X[i]].push_back(Y[i]); H[Y[i]].push_back(X[i]); } UnionFind uf(MA * 2 + 10); rep(i, MA) { each(y, G[i]) uf.unite(y, G[i][0]); each(x, H[i]) uf.unite(x, H[i][0]); } ll ans = -N; vi vis(MA); rep(i, N) { int x = uf[X[i]]; if (vis[x]++) continue; ans += (ll)uf.getSize(X[i]) * uf.getSize(Y[i]); } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i, j, k) for (int(i) = (j); (i) < (int)(k); ++(i)) #define rep(i, j) FOR(i, 0, j) #define each(x, y) for (auto &(x) : (y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(), (x).end() #define debug(x) cout << #x << ": " << (x) << endl #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define MEM(x, y) memset((x), (y), sizeof(x)) #define sz(x) (int)(x).size() #define RT return using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; class UnionFind { int cnt; vector<int> par, rank, size; public: UnionFind() {} UnionFind(int _n) : cnt(_n), par(_n), rank(_n), size(_n, 1) { for (int i = 0; i < _n; ++i) par[i] = i; } int find(int k) { return (k == par[k]) ? k : (par[k] = find(par[k])); } int operator[](int k) { return find(k); } int getSize(int k) { return size[find(k)]; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; --cnt; if (rank[x] < rank[y]) { par[x] = y; size[y] += size[x]; } else { par[y] = x; size[x] += size[y]; if (rank[y] == rank[x]) ++rank[x]; } } int count() { return cnt; } }; void solve() { const int MA = (int)1e5 + 1; int N; cin >> N; vi X(N), Y(N); vector<vi> G(MA), H(MA); rep(i, N) { cin >> X[i] >> Y[i]; G[X[i]].push_back(Y[i]); H[Y[i]].push_back(X[i]); } UnionFind uf(MA * 2 + 10); rep(i, MA) { each(y, G[i]) uf.unite(MA + y, MA + G[i][0]); each(x, H[i]) uf.unite(x, H[i][0]); } ll ans = -N; vi vis(MA); rep(i, N) { int x = uf[X[i]]; if (vis[x]++) continue; ans += (ll)uf.getSize(X[i]) * uf.getSize(MA + Y[i]); } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }
[ "assignment.change" ]
808,902
808,903
u750436322
cpp
p02998
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const ll mo = 1000000007; const ll INF = 1LL << 60; // MAX 9223372036854775807 ll ans = 0; struct UnionFind { vector<ll> data; UnionFind(ll size) : data(size, -1) {} bool unionSet(ll x, ll y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(ll x, ll y) { return root(x) == root(y); } ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); } ll size(ll x) { return -data[root(x)]; } }; // UnionFind arr(n);で0~n-1バラバラが生成 // arr.findSet(x,y)同じ集合か // arr.size(x)xが属す要素の個数 // arr.unionSet(x,y)xが属す集合とyが属す集合をマージ int main() { ll n; cin >> n; UnionFind arr(2 * 100000); set<ll> xx, yy; rep(i, n) { ll x, y; cin >> x >> y; x--; y--; arr.unionSet(x, y + 100000); xx.insert(x); yy.insert(y); } map<ll, pair<ll, ll>> m{}; auto itr = xx.begin(); rep(i, xx.size()) { m[arr.root(*itr)].first += 1; itr++; } itr = yy.begin(); rep(i, yy.size()) { m[arr.root(*itr)].second += 1; itr++; } for (auto i = m.begin(); i != m.end(); ++i) { pair<ll, ll> pp; pp = i->second; ans += pp.first * pp.second; } cout << ans - n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const ll mo = 1000000007; const ll INF = 1LL << 60; // MAX 9223372036854775807 ll ans = 0; struct UnionFind { vector<ll> data; UnionFind(ll size) : data(size, -1) {} bool unionSet(ll x, ll y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(ll x, ll y) { return root(x) == root(y); } ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); } ll size(ll x) { return -data[root(x)]; } }; // UnionFind arr(n);で0~n-1バラバラが生成 // arr.findSet(x,y)同じ集合か // arr.size(x)xが属す要素の個数 // arr.unionSet(x,y)xが属す集合とyが属す集合をマージ int main() { ll n; cin >> n; UnionFind arr(200000); set<ll> xx, yy; rep(i, n) { ll x, y; cin >> x >> y; x--; y--; arr.unionSet(x, y + 100000); xx.insert(x); yy.insert(y); } map<ll, pair<ll, ll>> m{}; auto itr = xx.begin(); rep(i, xx.size()) { m[arr.root(*itr)].first += 1; itr++; } itr = yy.begin(); rep(i, yy.size()) { m[arr.root(*itr + 100000)].second += 1; itr++; } for (auto i = m.begin(); i != m.end(); ++i) { pair<ll, ll> pp; pp = i->second; ans += pp.first * pp.second; } cout << ans - n << endl; return 0; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove", "assignment.change" ]
808,910
808,911
u419307948
cpp
p02998
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; struct uftree { int par[100005]; int rank[100005]; int sz[100005]; uftree() {} void init(int n) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; sz[i] = 1; } } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; } else { if (rank[x] == rank[y]) rank[x]++; par[y] = x; sz[x] += sz[y]; } } bool same(int x, int y) { return find(x) == find(y); } }; uftree uf; int n; P p[100005]; int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &p[i].first, &p[i].second); swap(p[i].first, p[i].second); } uf.init(100001); sort(p, p + n); for (int i = 0; i + 1 < n; i++) { if (p[i].first == p[i + 1].first) { uf.unite(p[i].second, p[i].second + 1); } } int prev = -1; set<int> se; ll ans = 0; for (int i = 0; i < n; i++) { if (p[i].first != prev) { se.clear(); } int v = uf.sz[uf.find(p[i].second)]; if (v >= 2) { // printf("%d %d\n",v,ans); if (se.find(uf.find(p[i].second)) == se.end()) { ans += v - 1; se.insert(uf.find(p[i].second)); } else { ans--; } } prev = p[i].first; } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; struct uftree { int par[100005]; int rank[100005]; int sz[100005]; uftree() {} void init(int n) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; sz[i] = 1; } } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; } else { if (rank[x] == rank[y]) rank[x]++; par[y] = x; sz[x] += sz[y]; } } bool same(int x, int y) { return find(x) == find(y); } }; uftree uf; int n; P p[100005]; int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &p[i].first, &p[i].second); swap(p[i].first, p[i].second); } uf.init(100001); sort(p, p + n); for (int i = 0; i + 1 < n; i++) { if (p[i].first == p[i + 1].first) { uf.unite(p[i].second, p[i + 1].second); } } int prev = -1; set<int> se; ll ans = 0; for (int i = 0; i < n; i++) { if (p[i].first != prev) { se.clear(); } int v = uf.sz[uf.find(p[i].second)]; if (v >= 2) { // printf("%d %d\n",v,ans); if (se.find(uf.find(p[i].second)) == se.end()) { ans += v - 1; se.insert(uf.find(p[i].second)); } else { ans--; } } prev = p[i].first; } printf("%lld\n", ans); return 0; }
[ "expression.operation.binary.remove" ]
808,916
808,917
u854869949
cpp
p02998
// template version 1.12 using namespace std; #include <bits/stdc++.h> #include <iostream> // varibable settings #define infile "../test/sample-1.in" #define int long long //{{{ const int INF = 1e18; const int MOD = 1e9 + 7; //}}} // define basic macro {{{ #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define _rrep(i, n) rrepi(i, 0, n) #define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i) #define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__) #define each(i, a) for (auto &&i : a) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define pb(a) push_back(a) #define mp(a, b) make_pair(a, b) #define uni(x) \ sort(all(x)); \ x.erase(unique(all(x)), x.end()) #define ub upper_bound #define lb lower_bound #define posl(A, x) (lower_bound(all(A), x) - A.begin()) #define posu(A, x) (upper_bound(all(A), x) - A.begin()) template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); } template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); } typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; typedef pair<int, int> pii; typedef tuple<int, int, int> iii; template <typename T> using PQ = priority_queue<T, vector<T>, greater<T>>; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #if defined(PCM) || defined(LOCAL) #include "lib/dump.hpp" #else #define dump(...) 42 #define dump_1d(...) 42 #define dump_2d(...) 42 #endif //}}} struct UnionFind { /*{{{*/ vector<int> data; // size defined only for root node int count; UnionFind(int size) : data(size, -1), count(size) {} bool merge(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; count--; } return x != y; } int root(int x) { return (data[x] < 0 ? x : data[x] = root(data[x])); } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -data[root(x)]; } }; /*}}}*/ #define MAXN 30 struct kousi { int x, y, cnt; }; int solve() { int n; cin >> n; vi x(n), y(n); UnionFind uf(200001); vvi Y(MAXN + 1, vi()); vvi X(MAXN + 1, vi()); rep(i, n) { cin >> x[i] >> y[i]; uf.merge(x[i], y[i] + MAXN); Y[y[i]].pb(x[i]); X[x[i]].pb(y[i]); } each(el, Y) { rep(i, 1, sz(el)) { uf.merge(el[i - 1], el[i]); } } each(el, X) { rep(i, 1, sz(el)) { uf.merge(el[i - 1] + MAXN, el[i] + MAXN); } } map<int, kousi> roots; rep(i, 1, MAXN + 1) { roots[uf.root(i)].x += 1; } rep(i, 1, MAXN + 1) { roots[uf.root(i + MAXN)].y += 1; } rep(i, n) { roots[uf.root(x[i])].cnt++; } int res = 0; each(root, roots) { kousi k = root.second; // dump(p, k.x, k.y, k.cnt); res += k.x * k.y - k.cnt; } cout << res << endl; return 0; } signed main() { //{{{ #ifdef INPUT_FROM_FILE std::ifstream in(infile); std::cin.rdbuf(in.rdbuf()); #endif solve(); return 0; } //}}}
// template version 1.12 using namespace std; #include <bits/stdc++.h> #include <iostream> // varibable settings #define infile "../test/sample-1.in" #define int long long //{{{ const int INF = 1e18; const int MOD = 1e9 + 7; //}}} // define basic macro {{{ #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define _rrep(i, n) rrepi(i, 0, n) #define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i) #define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__) #define each(i, a) for (auto &&i : a) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define pb(a) push_back(a) #define mp(a, b) make_pair(a, b) #define uni(x) \ sort(all(x)); \ x.erase(unique(all(x)), x.end()) #define ub upper_bound #define lb lower_bound #define posl(A, x) (lower_bound(all(A), x) - A.begin()) #define posu(A, x) (upper_bound(all(A), x) - A.begin()) template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); } template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); } typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; typedef pair<int, int> pii; typedef tuple<int, int, int> iii; template <typename T> using PQ = priority_queue<T, vector<T>, greater<T>>; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #if defined(PCM) || defined(LOCAL) #include "lib/dump.hpp" #else #define dump(...) 42 #define dump_1d(...) 42 #define dump_2d(...) 42 #endif //}}} struct UnionFind { /*{{{*/ vector<int> data; // size defined only for root node int count; UnionFind(int size) : data(size, -1), count(size) {} bool merge(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; count--; } return x != y; } int root(int x) { return (data[x] < 0 ? x : data[x] = root(data[x])); } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -data[root(x)]; } }; /*}}}*/ #define MAXN 100000 struct kousi { int x, y, cnt; }; int solve() { int n; cin >> n; vi x(n), y(n); UnionFind uf(200001); vvi Y(MAXN + 1, vi()); vvi X(MAXN + 1, vi()); rep(i, n) { cin >> x[i] >> y[i]; uf.merge(x[i], y[i] + MAXN); Y[y[i]].pb(x[i]); X[x[i]].pb(y[i]); } each(el, Y) { rep(i, 1, sz(el)) { uf.merge(el[i - 1], el[i]); } } each(el, X) { rep(i, 1, sz(el)) { uf.merge(el[i - 1] + MAXN, el[i] + MAXN); } } map<int, kousi> roots; rep(i, 1, MAXN + 1) { roots[uf.root(i)].x += 1; } rep(i, 1, MAXN + 1) { roots[uf.root(i + MAXN)].y += 1; } rep(i, n) { roots[uf.root(x[i])].cnt++; } int res = 0; each(root, roots) { kousi k = root.second; // dump(p, k.x, k.y, k.cnt); res += k.x * k.y - k.cnt; } cout << res << endl; return 0; } signed main() { //{{{ #ifdef INPUT_FROM_FILE std::ifstream in(infile); std::cin.rdbuf(in.rdbuf()); #endif solve(); return 0; } //}}}
[ "preprocessor.define.value.change", "literal.integer.change" ]
808,920
808,921
u314057689
cpp
p02998
#include <algorithm> #include <cfloat> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define int long long #define ll long long #define eps LDBL_EPSILON #define mod 1000000007 #define int long long #define double long double #define INF LLONG_MAX / 1000 #define P pair<int, int> #define prique priority_queue using namespace std; int n, x[100010], y[100010]; bool used[2][100010]; vector<int> vec[2][100010]; int s, t; void func(int a, int b) { used[a][b] = true; if (!a) s++; else t++; for (int i : vec[!a][b]) { if (!used[!a][i]) func(!a, i); } } signed main() { cin >> n; rep(i, n) { cin >> x[i] >> y[i]; vec[0][x[i]].push_back(y[i]); vec[1][y[i]].push_back(x[i]); } int ans = 0; rep(i, n) { if (!used[0][x[i]]) { s = 0; t = 0; func(0, x[i]); ans += s * t; } } cout << ans - n << endl; return 0; }
#include <algorithm> #include <cfloat> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define int long long #define ll long long #define eps LDBL_EPSILON #define mod 1000000007 #define int long long #define double long double #define INF LLONG_MAX / 1000 #define P pair<int, int> #define prique priority_queue using namespace std; int n, x[100010], y[100010]; bool used[2][100010]; vector<int> vec[2][100010]; int s, t; void func(int a, int b) { used[a][b] = true; if (!a) s++; else t++; for (int i : vec[a][b]) { if (!used[!a][i]) func(!a, i); } } signed main() { cin >> n; rep(i, n) { cin >> x[i] >> y[i]; vec[0][x[i]].push_back(y[i]); vec[1][y[i]].push_back(x[i]); } int ans = 0; rep(i, n) { if (!used[0][x[i]]) { s = 0; t = 0; func(0, x[i]); ans += s * t; } } cout << ans - n << endl; return 0; }
[ "expression.operation.unary.logical.remove" ]
808,924
808,925
u379822620
cpp
p02998
#include <bits/stdc++.h> using namespace std; using ll = long long; class UnionFind { public: // parent node index if not root index // minus size of the tree if root index std::vector<int> data; UnionFind(int n) { data.resize(n, -1); } int find(int x) { if (data[x] < 0) { return x; } else { int r = find(data[x]); data[x] = r; return r; } } void unite(int x, int y) { int r = find(x); int s = find(y); if (r != s) { data[r] += data[s]; data[s] = r; } } int count(int x) { return -data[find(x)]; } }; template <typename T> int compress(vector<T> x) { int n = x.size(); vector<T> xs(n); for (int i = 0; i < n; i++) xs[i] = x[i]; sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for (int i = 0; i < n; i++) { x[i] = find(xs.begin(), xs.end(), x[i]) - xs.begin(); } return xs.size(); } int main() { int N; cin >> N; vector<int> X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; X[i]--, Y[i]--; } compress(X); compress(Y); UnionFind uf(2 * N); for (int i = 0; i < N; i++) { uf.unite(X[i], Y[i] + N); } map<int, int> nx, ny; for (int i = 0; i < 2 * N; i++) { int r = uf.find(i); int c = uf.count(r); if (c <= 1) continue; if (i < N) { nx[r]++; } else { ny[r]++; } } ll dots = 0; for (auto q : nx) { dots += (ll)q.second * ny[q.first]; } ll ans = dots - N; cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; class UnionFind { public: // parent node index if not root index // minus size of the tree if root index std::vector<int> data; UnionFind(int n) { data.resize(n, -1); } int find(int x) { if (data[x] < 0) { return x; } else { int r = find(data[x]); data[x] = r; return r; } } void unite(int x, int y) { int r = find(x); int s = find(y); if (r != s) { data[r] += data[s]; data[s] = r; } } int count(int x) { return -data[find(x)]; } }; template <typename T> int compress(vector<T> &x) { int n = x.size(); vector<T> xs(n); for (int i = 0; i < n; i++) xs[i] = x[i]; sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for (int i = 0; i < n; i++) { x[i] = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin(); } return xs.size(); } int main() { int N; cin >> N; vector<int> X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; X[i]--, Y[i]--; } compress(X); compress(Y); UnionFind uf(2 * N); for (int i = 0; i < N; i++) { uf.unite(X[i], Y[i] + N); } map<int, int> nx, ny; for (int i = 0; i < 2 * N; i++) { int r = uf.find(i); int c = uf.count(r); if (c <= 1) continue; if (i < N) { nx[r]++; } else { ny[r]++; } } ll dots = 0; for (auto q : nx) { dots += (ll)q.second * ny[q.first]; } ll ans = dots - N; cout << ans << '\n'; return 0; }
[ "assignment.value.change", "identifier.change", "call.function.change", "expression.operation.binary.change" ]
808,962
808,961
u930841425
cpp
p02998
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_set> #include <vector> using namespace std; using namespace std::chrono; typedef long long int llint; typedef double lldo; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase /*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/ const llint mod = 998244353; const llint big = 2.19e17 + 1; const long double pai = 3.141592653589793238462643383279502884197; const long double eps = 1e-15; template <class T, class U> bool mineq(T &a, U b) { if (a > b) { a = b; return true; } return false; } template <class T, class U> bool maxeq(T &a, U b) { if (a < b) { a = b; return true; } return false; } llint gcd(llint a, llint b) { if (a % b == 0) { return b; } else return gcd(b, a % b); } llint lcm(llint a, llint b) { if (a == 0) { return b; } return a / gcd(a, b) * b; } template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); } template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); } template <class T> llint LBI(vector<T> &ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); } template <class T> llint UBI(vector<T> &ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); } /// 2009~ int main(void) { int n, i, j; cin >> n; vector<vector<int>> tate(100001); vector<vector<int>> yoko(100001); vector<int> xz(n); vector<int> yz(n); for (i = 0; i < n; i++) { int x, y; cin >> x >> y; xz[i] = x; yz[i] = y; tate[x].pub(i); yoko[y].pub(i); } vector<vector<int>> go(n); for (int x = 1; x <= 100000; x++) { for (i = 1; i < tate[x].size(); i++) { go[tate[x][i]].pub(tate[x][i - 1]); go[tate[x][i - 1]].pub(tate[x][i]); } for (i = 1; i < tate[x].size(); i++) { go[yoko[x][i]].pub(yoko[x][i - 1]); go[yoko[x][i - 1]].pub(yoko[x][i]); } } vector<bool> mita(n); llint ans = -n; for (i = 0; i < n; i++) { // cerr<<"de"<<endl; if (mita[i]) { continue; } set<int> A, B; queue<int> que; que.push(i); while (que.size()) { int t = que.front(); que.pop(); if (mita[t]) { continue; } mita[t] = 1; A.ins(xz[t]); B.ins(yz[t]); for (auto it : go[t]) { que.push(it); } } ans += (llint)A.size() * B.size(); } cout << ans << endl; return 0; }
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_set> #include <vector> using namespace std; using namespace std::chrono; typedef long long int llint; typedef double lldo; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase /*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/ const llint mod = 998244353; const llint big = 2.19e17 + 1; const long double pai = 3.141592653589793238462643383279502884197; const long double eps = 1e-15; template <class T, class U> bool mineq(T &a, U b) { if (a > b) { a = b; return true; } return false; } template <class T, class U> bool maxeq(T &a, U b) { if (a < b) { a = b; return true; } return false; } llint gcd(llint a, llint b) { if (a % b == 0) { return b; } else return gcd(b, a % b); } llint lcm(llint a, llint b) { if (a == 0) { return b; } return a / gcd(a, b) * b; } template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); } template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); } template <class T> llint LBI(vector<T> &ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); } template <class T> llint UBI(vector<T> &ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); } /// 2009~ int main(void) { int n, i, j; cin >> n; vector<vector<int>> tate(100001); vector<vector<int>> yoko(100001); vector<int> xz(n); vector<int> yz(n); for (i = 0; i < n; i++) { int x, y; cin >> x >> y; xz[i] = x; yz[i] = y; tate[x].pub(i); yoko[y].pub(i); } vector<vector<int>> go(n); for (int x = 1; x <= 100000; x++) { for (i = 1; i < tate[x].size(); i++) { go[tate[x][i]].pub(tate[x][i - 1]); go[tate[x][i - 1]].pub(tate[x][i]); } for (i = 1; i < yoko[x].size(); i++) { go[yoko[x][i]].pub(yoko[x][i - 1]); go[yoko[x][i - 1]].pub(yoko[x][i]); } } vector<bool> mita(n); llint ans = -n; for (i = 0; i < n; i++) { // cerr<<"de"<<endl; if (mita[i]) { continue; } set<int> A, B; queue<int> que; que.push(i); while (que.size()) { int t = que.front(); que.pop(); if (mita[t]) { continue; } mita[t] = 1; A.ins(xz[t]); B.ins(yz[t]); for (auto it : go[t]) { que.push(it); } } ans += (llint)A.size() * B.size(); } cout << ans << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
808,974
808,975
u483814783
cpp
p02998
#include <bits/stdc++.h> #define err(args...) \ {} #ifdef DEBUG #include "_debug.cpp" #endif using namespace std; using ll = long long; template <typename T> using lim = numeric_limits<T>; const int N = 200'000; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> adj(N); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; x--, y--; adj[x].push_back(N / 2 + y); adj[N / 2 + y].push_back(x); } vector<bool> vis(N); int visL = 0, visR = 0, ecount = 0; function<void(int)> dfs = [&](int u) { vis[u] = true; (u < N / 2 ? visL : visR)++; ecount += adj[u].size(); for (int v : adj[u]) { if (not vis[v]) { dfs(v); } } }; ll ans = 0; for (int i = 0; i < N; i++) { if (not vis[i]) { visL = 0, visR = 0; dfs(i); if (visL >= 2 and visR >= 2) { ans += visL * visR - ecount / 2; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define err(args...) \ {} #ifdef DEBUG #include "_debug.cpp" #endif using namespace std; using ll = long long; template <typename T> using lim = numeric_limits<T>; const int N = 200'000; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> adj(N); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; x--, y--; adj[x].push_back(N / 2 + y); adj[N / 2 + y].push_back(x); } vector<bool> vis(N); ll visL = 0, visR = 0, ecount = 0; function<void(int)> dfs = [&](int u) { vis[u] = true; (u < N / 2 ? visL : visR)++; ecount += adj[u].size(); for (int v : adj[u]) { if (not vis[v]) { dfs(v); } } }; ll ans = 0; for (int i = 0; i < N; i++) { if (not vis[i]) { visL = 0, visR = 0, ecount = 0; dfs(i); if (visL >= 2 and visR >= 2) { ans += visL * visR - ecount / 2; } } } cout << ans << endl; return 0; }
[ "variable_declaration.type.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "control_flow.loop.for.initializer.change" ]
808,999
808,998
u957513998
cpp
p02998
#include <iostream> #include <set> #include <vector> using namespace std; typedef long long ll; ll N; vector<vector<int>> v(200010); int vis[200010] = {}; ll dfs(int n, set<int> &sx, set<int> &sy) { ll cnt = 0; vis[n] = 1; if (n <= 100000) sx.insert(n); else sy.insert(n); for (auto x : v[n]) { cnt++; if (vis[x] == 0) cnt += dfs(x, sx, sy); } return cnt; } int main() { cin >> N; int x, y; for (int i = 0; i < N; i++) { cin >> x >> y; v[x].push_back(y + 100000); v[y + 100000].push_back(x); } ll ans = 0; for (int i = 1; i <= 100000; i++) { if ((int)v[i].size() != 0 && vis[i] == 0) { set<int> sx, sy; ll n = dfs(1, sx, sy) / 2; ll cx = sx.size(), cy = sy.size(); ans += cx * cy - n; } } cout << ans << endl; }
#include <iostream> #include <set> #include <vector> using namespace std; typedef long long ll; ll N; vector<vector<int>> v(200010); int vis[200010] = {}; ll dfs(int n, set<int> &sx, set<int> &sy) { ll cnt = 0; vis[n] = 1; if (n <= 100000) sx.insert(n); else sy.insert(n); for (auto x : v[n]) { cnt++; if (vis[x] == 0) cnt += dfs(x, sx, sy); } return cnt; } int main() { cin >> N; int x, y; for (int i = 0; i < N; i++) { cin >> x >> y; v[x].push_back(y + 100000); v[y + 100000].push_back(x); } ll ans = 0; for (int i = 1; i <= 100000; i++) { if ((int)v[i].size() != 0 && vis[i] == 0) { set<int> sx, sy; ll n = dfs(i, sx, sy) / 2; ll cx = sx.size(), cy = sy.size(); ans += cx * cy - n; } } cout << ans << endl; }
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "expression.operation.binary.change" ]
809,000
809,001
u623954643
cpp
p02998
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define ll long long #define reg register #define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i) #define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i) template <typename _typer> inline _typer read() { _typer init = 0; char ch = getchar(), k = 0; for (; !isdigit(ch); ch = getchar()) k = (ch == '-'); for (; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48); return k ? -init : init; } const ll N = 100005, INF = 1e9; int n; int X[N], Y[N]; int fa[N << 1], totx[N << 1], toty[N << 1]; int mark[N << 1]; int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); } void Uni(int x, int y) { x = Find(x), y = Find(y); if (x == y) return; fa[x] = y; totx[y] += totx[x], toty[y] += toty[x]; } int main() { n = read<int>(); int deita = 100000; rep(i, 1, deita << 1) fa[i] = i, totx[i] = (i <= deita), toty[i] = (i > deita); rep(i, 1, n) { X[i] = read<int>(), Y[i] = read<int>(); Uni(X[i], Y[i] + deita); // cout << X[i] << " " << Y[i] + deita << endl; } ll Ans = 0; rep(i, 1, n) if (!mark[Find(X[i])]) Ans += 1ll * totx[fa[X[i]]] * toty[Find(Y[i])], mark[fa[X[i]]] = true; cout << Ans - n << endl; return 0; }
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define ll long long #define reg register #define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i) #define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i) template <typename _typer> inline _typer read() { _typer init = 0; char ch = getchar(), k = 0; for (; !isdigit(ch); ch = getchar()) k = (ch == '-'); for (; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48); return k ? -init : init; } const ll N = 100005, INF = 1e9; int n; int X[N], Y[N]; int fa[N << 1], totx[N << 1], toty[N << 1]; int mark[N << 1]; int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); } void Uni(int x, int y) { x = Find(x), y = Find(y); if (x == y) return; fa[x] = y; totx[y] += totx[x], toty[y] += toty[x]; } int main() { n = read<int>(); int deita = 100000; rep(i, 1, deita << 1) fa[i] = i, totx[i] = (i <= deita), toty[i] = (i > deita); rep(i, 1, n) { X[i] = read<int>(), Y[i] = read<int>(); Uni(X[i], Y[i] + deita); // cout << X[i] << " " << Y[i] + deita << endl; } ll Ans = 0; rep(i, 1, n) if (!mark[Find(X[i])]) Ans += 1ll * totx[fa[X[i]]] * toty[fa[X[i]]], mark[fa[X[i]]] = true; cout << Ans - n << endl; return 0; }
[ "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
809,012
809,013
u786191361
cpp
p02998
#include <bits/stdc++.h> #define N 100005 #define LL long long using namespace std; template <class T> inline void Rd(T &x) { x = 0; char c = getchar(); bool f = 0; while (c < '0' || c > '9') { if (c == '-') f ^= 1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar(); if (f) x = -x; } int n; int X[N], Y[N]; int fa[N << 1]; int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); } LL cnt[2][N]; int main() { Rd(n); for (register int i = 1; i < (N << 1); ++i) fa[i] = i; for (register int i = 1, x, y; i <= n; ++i) { Rd(x), Rd(y); fa[get(x)] = get(y + N); } for (register int i = 1; i <= N; ++i) ++cnt[0][get(i)]; for (register int i = 1 + N; i <= (N << 1); ++i) ++cnt[1][get(i)]; LL sum = 0; for (register int i = 1; i <= (N << 1); ++i) sum += cnt[0][i] * cnt[1][i]; cout << sum << endl; return 0; }
#include <bits/stdc++.h> #define N 100005 #define LL long long using namespace std; template <class T> inline void Rd(T &x) { x = 0; char c = getchar(); bool f = 0; while (c < '0' || c > '9') { if (c == '-') f ^= 1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar(); if (f) x = -x; } int n; int X[N], Y[N]; int fa[N << 1]; int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); } LL cnt[2][N << 1]; int main() { Rd(n); for (register int i = 1; i <= (N << 1); ++i) fa[i] = i; for (register int i = 1, x, y; i <= n; ++i) { Rd(x), Rd(y); fa[get(x)] = get(y + N); } for (register int i = 1; i <= N; ++i) ++cnt[0][get(i)]; for (register int i = 1 + N; i <= (N << 1); ++i) ++cnt[1][get(i)]; LL sum = 0; for (register int i = 1; i <= (N << 1); ++i) sum += cnt[0][i] * cnt[1][i]; cout << sum - n << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
809,064
809,063
u766592454
cpp
p02998
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } struct node { int x, y; } a[100010]; bool cmp(node a, node b) { if (a.y == b.y) return a.x < b.x; else return a.y < b.y; } int fa[100010], cnt[100010], num[100010]; inline int findfa(int x) { if (fa[x] != x) fa[x] = findfa(fa[x]); return fa[x]; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(); sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) { if (!cnt[a[i].x]) num[a[i].x] = 1, fa[a[i].x] = a[i].x; if (a[i].y == a[i - 1].y) { int fx = findfa(a[i].x), fy = findfa(a[i - 1].x); if (fx != fy) fa[fy] = fx, num[fx] += num[fy], cnt[fx] += cnt[fy]; } if (a[i].y != a[i + 1].y) { int f = findfa(a[i].x); cnt[f]++; } } long long ans = 0; for (int i = 1; i <= 100000; i++) if (findfa(i) == i) ans += 1LL * cnt[i] * num[i]; printf("%lld\n", ans - n); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } struct node { int x, y; } a[100010]; bool cmp(node a, node b) { if (a.y == b.y) return a.x < b.x; else return a.y < b.y; } int fa[100010], cnt[100010], num[100010]; inline int findfa(int x) { if (fa[x] != x) fa[x] = findfa(fa[x]); return fa[x]; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(); sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) { if (!num[a[i].x]) num[a[i].x] = 1, fa[a[i].x] = a[i].x; if (a[i].y == a[i - 1].y) { int fx = findfa(a[i].x), fy = findfa(a[i - 1].x); if (fx != fy) fa[fy] = fx, num[fx] += num[fy], cnt[fx] += cnt[fy]; } if (a[i].y != a[i + 1].y) { int f = findfa(a[i].x); cnt[f]++; } } long long ans = 0; for (int i = 1; i <= 100000; i++) if (findfa(i) == i) ans += 1LL * cnt[i] * num[i]; printf("%lld\n", ans - n); return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
809,065
809,066
u475221259
cpp
p02998
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } struct node { int x, y; } a[100010]; bool cmp(node a, node b) { if (a.y == b.y) return a.x < b.x; else return a.y < b.y; } int fa[100010], cnt[100010], num[100010]; inline int findfa(int x) { if (fa[x] != x) fa[x] = findfa(fa[x]); return fa[x]; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(); sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) { if (!cnt[a[i].x]) num[a[i].x] = 1, fa[a[i].x] = a[i].x; if (a[i].y == a[i - 1].y) { int fx = findfa(a[i].x), fy = findfa(a[i - 1].x); if (fx != fy) fa[fy] = fx, num[fx] += num[fy], cnt[fx] += cnt[fy]; } if (a[i].y != a[i + 1].y) { int f = findfa(a[i].y); cnt[f]++; } } long long ans = 0; for (int i = 1; i <= 100000; i++) if (findfa(i) == i) ans += 1LL * cnt[i] * num[i]; printf("%lld\n", ans - n); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } struct node { int x, y; } a[100010]; bool cmp(node a, node b) { if (a.y == b.y) return a.x < b.x; else return a.y < b.y; } int fa[100010], cnt[100010], num[100010]; inline int findfa(int x) { if (fa[x] != x) fa[x] = findfa(fa[x]); return fa[x]; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(); sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) { if (!num[a[i].x]) num[a[i].x] = 1, fa[a[i].x] = a[i].x; if (a[i].y == a[i - 1].y) { int fx = findfa(a[i].x), fy = findfa(a[i - 1].x); if (fx != fy) fa[fy] = fx, num[fx] += num[fy], cnt[fx] += cnt[fy]; } if (a[i].y != a[i + 1].y) { int f = findfa(a[i].x); cnt[f]++; } } long long ans = 0; for (int i = 1; i <= 100000; i++) if (findfa(i) == i) ans += 1LL * cnt[i] * num[i]; printf("%lld\n", ans - n); return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
809,067
809,066
u475221259
cpp
p02998
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; class U { public: int n; vector<int> p, s; U(int _) { n = _; p.resize(n); s.resize(n); for (int i = 0; i < n; i++) { p[i] = i; s[i] = 1; } } bool connect(int a, int b) { int ap, bp; for (ap = p[a]; ap != p[ap]; ap = p[ap]) ; for (bp = p[b]; bp != p[bp]; bp = p[bp]) ; if (ap == bp) return true; int mi = min(ap, bp), ma = max(ap, bp); p[ma] = mi; s[mi] += s[ma]; s[ma] = 0; for (int pp = a; pp != mi;) { int next = p[pp]; p[pp] = mi; pp = next; } for (int pp = b; pp != mi;) { int next = p[pp]; p[pp] = mi; pp = next; } return false; } int q(int a) { int ap; for (ap = a; ap != p[ap]; ap = p[ap]) ; return s[ap]; } int parent(int a) { int ap; for (ap = a; ap != p[ap]; ap = p[ap]) ; return p[ap]; } bool query(int a, int b) { return parent(a) == parent(b); } }; U u(101010); int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<pair<ll, ll>> ps(n); for (int i = 0; i < n; i++) cin >> ps[i].first >> ps[i].second; sort(ps.begin(), ps.end()); vector<int> buf; buf.push_back(ps[0].second); for (int i = 1; i < n; i++) { if (ps[i].first == ps[i - 1].first) { buf.push_back(ps[i].second); } else { int now = buf[0]; for (int j = 1; j < buf.size(); j++) { u.connect(now, buf[j]); } buf.clear(); buf.push_back(ps[i].second); } } int now = buf[0]; for (int j = 1; j < buf.size(); j++) { u.connect(now, buf[j]); } ll ans = 0; vector<set<int>> q(101010); for (int i = 0; i < n; i++) { q[u.parent(ps[i].first)].insert(ps[i].second); } for (int i = 0; i <= 100000; i++) { if (u.parent(i) == i) ans += q[i].size() * u.s[i]; } ans -= n; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; class U { public: int n; vector<int> p, s; U(int _) { n = _; p.resize(n); s.resize(n); for (int i = 0; i < n; i++) { p[i] = i; s[i] = 1; } } bool connect(int a, int b) { int ap, bp; for (ap = p[a]; ap != p[ap]; ap = p[ap]) ; for (bp = p[b]; bp != p[bp]; bp = p[bp]) ; if (ap == bp) return true; int mi = min(ap, bp), ma = max(ap, bp); p[ma] = mi; s[mi] += s[ma]; s[ma] = 0; for (int pp = a; pp != mi;) { int next = p[pp]; p[pp] = mi; pp = next; } for (int pp = b; pp != mi;) { int next = p[pp]; p[pp] = mi; pp = next; } return false; } int q(int a) { int ap; for (ap = a; ap != p[ap]; ap = p[ap]) ; return s[ap]; } int parent(int a) { int ap; for (ap = a; ap != p[ap]; ap = p[ap]) ; return p[ap]; } bool query(int a, int b) { return parent(a) == parent(b); } }; U u(101010); int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<pair<ll, ll>> ps(n); for (int i = 0; i < n; i++) cin >> ps[i].first >> ps[i].second; sort(ps.begin(), ps.end()); vector<int> buf; buf.push_back(ps[0].second); for (int i = 1; i < n; i++) { if (ps[i].first == ps[i - 1].first) { buf.push_back(ps[i].second); } else { int now = buf[0]; for (int j = 1; j < buf.size(); j++) { u.connect(now, buf[j]); } buf.clear(); buf.push_back(ps[i].second); } } int now = buf[0]; for (int j = 1; j < buf.size(); j++) { u.connect(now, buf[j]); } ll ans = 0; vector<set<int>> q(101010); for (int i = 0; i < n; i++) { q[u.parent(ps[i].second)].insert(ps[i].first); } for (int i = 0; i <= 100000; i++) { if (u.parent(i) == i) ans += q[i].size() * u.s[i]; } ans -= n; cout << ans << endl; return 0; }
[ "variable_access.subscript.index.change", "call.arguments.change" ]
809,074
809,075
u656572785
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << "0" << endl; } else if (x >= 10) { cout << "10" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << "0" << endl; } else if (x >= a) { cout << "10" << endl; } return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.branch.if.condition.change" ]
809,080
809,081
u497715246
cpp
p02999
#include <iostream> int main() { int X, A; std::cin >> X >> A; if (X <= A) std::cout << 0 << std::endl; else std::cout << 10 << std::endl; return 0; }
#include <iostream> int main() { int X, A; std::cin >> X >> A; if (X < A) std::cout << 0 << std::endl; else std::cout << 10 << std::endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
809,089
809,090
u913480647
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> a >> x; if (x < a) { cout << 0; } else { cout << 10; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << 0; } else { cout << 10; } return 0; }
[ "expression.operation.binary.remove" ]
809,119
809,120
u523119383
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> a >> x; if (x < a) { cout << 10; } else { cout << 0; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << 0; } else { cout << 10; } return 0; }
[ "expression.operation.binary.remove", "literal.number.change", "io.output.change" ]
809,121
809,120
u523119383
cpp
p02999
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // using ll=long long; //#define int long long #define _CRT_SECURE_NO_WARNINGS #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG const int MOD = 1e9 + 7; const int INF = 1e18 + 9; constexpr long double pi = 3.141592653589793238462643383279; //円周率 /*---------------------便利な関数--------------------------------------*/ int fact(int i) { //階乗 if (i == 0) return 1; return (fact(i - 1)) * i; } int gcd(int a, int b) { //最大公約数 if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { //最小公倍数 return a * b / gcd(a, b); } int keta(int n) { //桁数を求める if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } int ketasum(int n) { //各桁の和 int sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } //最小化問題(DP) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } //最大化問題(DP) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // dp注意点 //問題の種類 初期化する値 備考 //最小化問題 INF //最大化問題 -INF テーブル全体で 00 //以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 //でもいい場合もあります 数え上げ問題 00 確率問題 00 Yes/No 判定問題 // False /*-------------ここまで---------------------------------------------*/ /*signed*/ int main() { int x, a; cin >> x >> a; if (x >= a) cout << "0" << endl; else cout << "10" << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // using ll=long long; //#define int long long #define _CRT_SECURE_NO_WARNINGS #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG const int MOD = 1e9 + 7; const int INF = 1e18 + 9; constexpr long double pi = 3.141592653589793238462643383279; //円周率 /*---------------------便利な関数--------------------------------------*/ int fact(int i) { //階乗 if (i == 0) return 1; return (fact(i - 1)) * i; } int gcd(int a, int b) { //最大公約数 if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { //最小公倍数 return a * b / gcd(a, b); } int keta(int n) { //桁数を求める if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } int ketasum(int n) { //各桁の和 int sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } //最小化問題(DP) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } //最大化問題(DP) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // dp注意点 //問題の種類 初期化する値 備考 //最小化問題 INF //最大化問題 -INF テーブル全体で 00 //以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 //でもいい場合もあります 数え上げ問題 00 確率問題 00 Yes/No 判定問題 // False /*-------------ここまで---------------------------------------------*/ /*signed*/ int main() { int x, a; cin >> x >> a; if (x >= a) cout << "10" << endl; else cout << "0" << endl; return 0; }
[ "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
809,125
809,126
u605833494
cpp
p02999
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== using namespace std; using ll = long long; using vl = vector<long long>; using vll = vector<vector<long long>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; // =============================================================== ll gcd(ll a, ll b) //最大公約数 { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) //最小公倍数 { return a * b / gcd(a, b); } ll box(double a) // doubleの切り捨て { ll b = a; return b; } ll fff(double a) // doubleの四捨五入 { ll b = a + 0.5; return b; } ll sum(ll n) { //整数sまでの合計 if (n == 0) { return 0; } int s = sum(n - 1); return s + n; } bool prime(ll num) //素数判定、primeならtrue,違うならfalse { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } // 素数である return true; } // =============================================================== int main() { ll a, b; cin >> a >> b; if (b < a) { cout << 0 << endl; } else cout << 10 << endl; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== using namespace std; using ll = long long; using vl = vector<long long>; using vll = vector<vector<long long>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; // =============================================================== ll gcd(ll a, ll b) //最大公約数 { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) //最小公倍数 { return a * b / gcd(a, b); } ll box(double a) // doubleの切り捨て { ll b = a; return b; } ll fff(double a) // doubleの四捨五入 { ll b = a + 0.5; return b; } ll sum(ll n) { //整数sまでの合計 if (n == 0) { return 0; } int s = sum(n - 1); return s + n; } bool prime(ll num) //素数判定、primeならtrue,違うならfalse { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } // 素数である return true; } // =============================================================== int main() { ll a, b; cin >> a >> b; if (a < b) { cout << 0 << endl; } else cout << 10 << endl; }
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
809,131
809,132
u926006934
cpp
p02998
//#pragma once #include <algorithm> #include <bitset> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; #define modd 1000000007 typedef pair<long long, long long> pl; typedef string::const_iterator State; class ParseError {}; #define ll long long class UnionFind { public: vector<ll> par; vector<ll> siz; // Constructor UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); // resize だとなぜか初期化されなかった for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身 } // Member Function // Find ll root(ll x) { // 根の検索 while (par[x] != x) { x = par[x] = par[par[x]]; // x の親の親を x の親とする } return x; } // Union(Unite, Merge) bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; // merge technique(データ構造をマージするテク.小を大にくっつける) if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { // 連結判定 return root(x) == root(y); } ll size(ll x) { // 素集合のサイズ return siz[root(x)]; } }; long long N, M, K, a, b, c, d, e, H, W, L; ll A[2][200005] = {}; ll B[100005] = {}; ll C[300005] = {}; bool f, ff; string S, T; set<long long> sll; pl bufpl; vector<long long> vl[2][100005]; vector<long long> vll[100005]; vector<pl> vpl; vector<string> vs; set<ll> llset; multiset<ll> llmset; /* struct ST { long long Kati; int bangou; bool operator<(const ST& another) const { return Kati < another.Kati;//比較 }; }; /*vector <ST> vst; ST st[200005]; ST bufst; bitset<5000> bits;*/ long long modinv(long long aa, long long mm) { long long bb = mm, uu = 1, vv = 0; while (bb) { long long tt = aa / bb; aa -= tt * bb; swap(aa, bb); uu -= tt * vv; swap(uu, vv); } uu %= mm; if (uu < 0) uu += mm; return uu; } ll minn, maxx; double ansa; bool fl[30] = {}; string ss, sss; int main() { cin >> N; UnionFind uf(N); for (ll i = 0; i < N; i++) { cin >> A[0][i] >> A[1][i]; a = A[0][i]; b = A[1][i]; if (!vl[0][a].empty()) { uf.merge(i, vl[0][a][0]); } if (!vl[1][b].empty()) { uf.merge(i, vl[1][b][0]); } vl[0][a].push_back(i); vl[1][b].push_back(i); } for (ll i = 0; i < N; i++) { vll[uf.root(i)].push_back(i); } e = 0; for (ll i = 0; i < 100001; i++) { if (vll[i].size() >= 3) { a = 0; b = 0; bool fu[2][100001] = {}; for (int j = 0; j < vll[i].size(); j++) { c = A[0][vll[i][j]]; d = A[1][vll[i][j]]; if (fu[0][c] == false) { a++; fu[0][c] = true; } if (fu[1][c] == false) { b++; fu[1][c] = true; } } e += a * b - vll[i].size(); } } cout << e << endl; return 0; }
//#pragma once #include <algorithm> #include <bitset> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; #define modd 1000000007 typedef pair<long long, long long> pl; typedef string::const_iterator State; class ParseError {}; #define ll long long class UnionFind { public: vector<ll> par; vector<ll> siz; // Constructor UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); // resize だとなぜか初期化されなかった for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身 } // Member Function // Find ll root(ll x) { // 根の検索 while (par[x] != x) { x = par[x] = par[par[x]]; // x の親の親を x の親とする } return x; } // Union(Unite, Merge) bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; // merge technique(データ構造をマージするテク.小を大にくっつける) if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { // 連結判定 return root(x) == root(y); } ll size(ll x) { // 素集合のサイズ return siz[root(x)]; } }; long long N, M, K, a, b, c, d, e, H, W, L; ll A[2][200005] = {}; ll B[100005] = {}; ll C[300005] = {}; bool f, ff; string S, T; set<long long> sll; pl bufpl; vector<long long> vl[2][100005]; vector<long long> vll[100005]; vector<pl> vpl; vector<string> vs; set<ll> llset; multiset<ll> llmset; /* struct ST { long long Kati; int bangou; bool operator<(const ST& another) const { return Kati < another.Kati;//比較 }; }; /*vector <ST> vst; ST st[200005]; ST bufst; bitset<5000> bits;*/ long long modinv(long long aa, long long mm) { long long bb = mm, uu = 1, vv = 0; while (bb) { long long tt = aa / bb; aa -= tt * bb; swap(aa, bb); uu -= tt * vv; swap(uu, vv); } uu %= mm; if (uu < 0) uu += mm; return uu; } ll minn, maxx; double ansa; bool fl[30] = {}; string ss, sss; int main() { cin >> N; UnionFind uf(N); for (ll i = 0; i < N; i++) { cin >> A[0][i] >> A[1][i]; a = A[0][i]; b = A[1][i]; if (!vl[0][a].empty()) { uf.merge(i, vl[0][a][0]); } if (!vl[1][b].empty()) { uf.merge(i, vl[1][b][0]); } vl[0][a].push_back(i); vl[1][b].push_back(i); } for (ll i = 0; i < N; i++) { vll[uf.root(i)].push_back(i); } e = 0; for (ll i = 0; i < 100001; i++) { if (vll[i].size() >= 3) { a = 0; b = 0; bool fu[2][100001] = {}; for (int j = 0; j < vll[i].size(); j++) { c = A[0][vll[i][j]]; d = A[1][vll[i][j]]; if (fu[0][c] == false) { a++; fu[0][c] = true; } if (fu[1][d] == false) { b++; fu[1][d] = true; } } e += a * b - vll[i].size(); } } cout << e << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "assignment.variable.change" ]
809,150
809,151
u058317639
cpp
p02998
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; inline int read() { char c = getchar(); int t = 0, f = 1; while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { t = (t << 3) + (t << 1) + (c ^ 48); c = getchar(); } return t * f; } int n, f[maxn]; struct node { int x, y, id; } a[maxn]; bool cmp(node a, node b) { return a.x == b.x ? a.y < b.y : a.x < b.x; } bool cmp2(node a, node b) { return a.y == b.y ? a.x < b.x : a.y < b.y; } inline int find(int x) { return f[x] == x ? f[x] : f[x] = find(f[x]); } vector<node> alfa[maxn]; long long ans = 0; int cntx[maxn], cnty[maxn]; int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); a[i].id = i; f[i] = i; } sort(a + 1, a + 1 + n, cmp); for (int i = 1; i < n; i++) { if (a[i].x == a[i + 1].x) { int x = find(a[i].id), y = find(a[i + 1].id); if (x != y) { f[x] = y; } } } sort(a + 1, a + 1 + n, cmp2); for (int i = 1; i < n; i++) { if (a[i].y == a[i + 1].y) { int x = find(a[i].id), y = find(a[i + 1].id); if (x != y) { f[x] = y; } } } for (int i = 1; i <= n; i++) f[i] = find(f[i]); /* for(int i=1;i<=n;i++)printf("%d ",f[i]); puts("");*/ for (int i = 1; i <= n; i++) { alfa[f[i]].push_back(a[i]); } for (int i = 1; i <= n; i++) { int l = alfa[i].size(); if (l == 0) continue; int limx = 0, limy = 0; for (int j = 0; j < l; j++) { cntx[++limx] = alfa[i][j].x; cnty[++limy] = alfa[i][j].y; } sort(cntx + 1, cntx + 1 + limx); sort(cnty + 1, cnty + 1 + limy); limx = unique(cntx + 1, cntx + 1 + limx) - cntx - 1; limy = unique(cnty + 1, cnty + 1 + limy) - cnty - 1; ans = ans + 1ll * limx * limy; } printf("%lld\n", ans - n); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; inline int read() { char c = getchar(); int t = 0, f = 1; while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { t = (t << 3) + (t << 1) + (c ^ 48); c = getchar(); } return t * f; } int n, f[maxn]; struct node { int x, y, id; } a[maxn]; bool cmp(node a, node b) { return a.x == b.x ? a.y < b.y : a.x < b.x; } bool cmp2(node a, node b) { return a.y == b.y ? a.x < b.x : a.y < b.y; } inline int find(int x) { return f[x] == x ? f[x] : f[x] = find(f[x]); } vector<node> alfa[maxn]; long long ans = 0; int cntx[maxn], cnty[maxn]; int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); a[i].id = i; f[i] = i; } sort(a + 1, a + 1 + n, cmp); for (int i = 1; i < n; i++) { if (a[i].x == a[i + 1].x) { int x = find(a[i].id), y = find(a[i + 1].id); if (x != y) { f[x] = y; } } } sort(a + 1, a + 1 + n, cmp2); for (int i = 1; i < n; i++) { if (a[i].y == a[i + 1].y) { int x = find(a[i].id), y = find(a[i + 1].id); if (x != y) { f[x] = y; } } } for (int i = 1; i <= n; i++) f[i] = find(f[i]); /* for(int i=1;i<=n;i++)printf("%d ",f[i]); puts("");*/ for (int i = 1; i <= n; i++) { alfa[f[a[i].id]].push_back(a[i]); } for (int i = 1; i <= n; i++) { int l = alfa[i].size(); if (l == 0) continue; int limx = 0, limy = 0; for (int j = 0; j < l; j++) { cntx[++limx] = alfa[i][j].x; cnty[++limy] = alfa[i][j].y; } sort(cntx + 1, cntx + 1 + limx); sort(cnty + 1, cnty + 1 + limy); limx = unique(cntx + 1, cntx + 1 + limx) - cntx - 1; limy = unique(cnty + 1, cnty + 1 + limy) - cnty - 1; ans = ans + 1ll * limx * limy; } printf("%lld\n", ans - n); return 0; }
[]
809,156
809,157
u879660427
cpp
p02998
#include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 5; int xfa[maxn] = {0}, yfa[maxn] = {0}; int xsize[maxn] = {0}, ysize[maxn] = {0}; int vis[maxn] = {0}; struct point { int x; int y; } p[maxn]; list<int> xcolumn[maxn]; list<int> yrow[maxn]; int xfindrt(int p) { return (p == xfa[p] ? p : xfa[p] = xfindrt(xfa[p])); } int xmerge(int a, int b) { int fa = xfindrt(a), fb = xfindrt(b); if (fa == fb) return 1; xfa[fb] = fa; xsize[fa] += xsize[fb]; xsize[fb] = 0; return 0; } int yfindrt(int p) { return (p == yfa[p] ? p : yfa[p] = yfindrt(yfa[p])); } int ymerge(int a, int b) { int fa = yfindrt(a), fb = yfindrt(b); if (fa == fb) return 1; yfa[fa] = fb; ysize[fb] += ysize[fa]; ysize[fa] = 0; return 0; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; p[i] = {a, b}; xcolumn[a].push_back(b); yrow[b].push_back(a); xsize[a] = ysize[b] = 1; xfa[a] = a; yfa[b] = b; } for (int i = 1; i < maxn; i++) { if (xcolumn[i].size() <= 1) continue; int t = xcolumn[i].front(); for (int k : xcolumn[i]) { xmerge(t, k); } } for (int i = 1; i < maxn; i++) { if (yrow[i].size() <= 1) continue; int t = yrow[i].front(); for (int k : yrow[i]) { ymerge(t, k); } } ll ans = 0; for (int i = 0; i < n; i++) { int a = xfindrt(p[i].x), b = yfindrt(p[i].y); if (vis[a] == 0) { ans += xsize[a] * ysize[b]; vis[a] = 1; } } cout << ans - n; }
#include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 5; int xfa[maxn] = {0}, yfa[maxn] = {0}; ll xsize[maxn] = {0}, ysize[maxn] = {0}; int vis[maxn] = {0}; struct point { int x; int y; } p[maxn]; list<int> xcolumn[maxn]; list<int> yrow[maxn]; int xfindrt(int p) { return (p == xfa[p] ? p : xfa[p] = xfindrt(xfa[p])); } int xmerge(int a, int b) { int fa = xfindrt(a), fb = xfindrt(b); if (fa == fb) return 1; xfa[fb] = fa; xsize[fa] += xsize[fb]; xsize[fb] = 0; return 0; } int yfindrt(int p) { return (p == yfa[p] ? p : yfa[p] = yfindrt(yfa[p])); } int ymerge(int a, int b) { int fa = yfindrt(a), fb = yfindrt(b); if (fa == fb) return 1; yfa[fa] = fb; ysize[fb] += ysize[fa]; ysize[fa] = 0; return 0; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; p[i] = {a, b}; xcolumn[a].push_back(b); yrow[b].push_back(a); xsize[a] = ysize[b] = 1; xfa[a] = a; yfa[b] = b; } for (int i = 1; i < maxn; i++) { if (xcolumn[i].size() <= 1) continue; int t = xcolumn[i].front(); for (int k : xcolumn[i]) { ymerge(t, k); } } for (int i = 1; i < maxn; i++) { if (yrow[i].size() <= 1) continue; int t = yrow[i].front(); for (int k : yrow[i]) { xmerge(t, k); } } ll ans = 0; for (int i = 0; i < n; i++) { int a = xfindrt(p[i].x), b = yfindrt(p[i].y); if (vis[a] == 0) { ans += xsize[a] * ysize[b]; vis[a] = 1; } } cout << ans - n; }
[ "variable_declaration.type.change", "identifier.change", "call.function.change" ]
809,162
809,161
u219398458
cpp
p02998
#include <bits/stdc++.h> typedef long long LL; #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), &(Z)) #define DRI(X) \ int(X); \ scanf("%d", &X) #define DRII(X, Y) \ int X, Y; \ scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) \ int X, Y, Z; \ scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair<int, int> #define VI vector<int> #define VL vector<long long> #define VPII vector<pair<int, int>> #define PLL pair<long long, long long> #define VPLL vector<pair<long long, long long>> #define F first #define S second using namespace std; VI ps; int findp(int i) { if (ps[i] != i) ps[i] = findp(ps[i]); return ps[i]; } void merge(int i, int j) { ps[findp(i)] = ps[findp(j)]; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); DRI(n); VI cols(1e5 + 1, -1); VI rows(1e5 + 1, -1); ps = VI(n); REP(i, n) { ps[i] = i; } VPII points; REP(i, n) { DRII(x, y); points.PB({x, y}); if (cols[y] != -1) { merge(i, cols[y]); } if (rows[x] != -1) { merge(i, rows[x]); } cols[y] = i; rows[x] = i; } vector<set<int>> nbc(n); vector<set<int>> nbr(n); REP(i, n) { int p = findp(i); nbr[p].insert(points[i].F); nbc[p].insert(points[i].S); } LL rr = 0; REP(i, n) { int b = nbr[i].size(); int c = nbr[i].size(); rr += (LL)b * c; } printf("%lld\n", rr - n); }
#include <bits/stdc++.h> typedef long long LL; #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), &(Z)) #define DRI(X) \ int(X); \ scanf("%d", &X) #define DRII(X, Y) \ int X, Y; \ scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) \ int X, Y, Z; \ scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair<int, int> #define VI vector<int> #define VL vector<long long> #define VPII vector<pair<int, int>> #define PLL pair<long long, long long> #define VPLL vector<pair<long long, long long>> #define F first #define S second using namespace std; VI ps; int findp(int i) { if (ps[i] != i) ps[i] = findp(ps[i]); return ps[i]; } void merge(int i, int j) { ps[findp(i)] = ps[findp(j)]; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); DRI(n); VI cols(1e5 + 1, -1); VI rows(1e5 + 1, -1); ps = VI(n); REP(i, n) { ps[i] = i; } VPII points; REP(i, n) { DRII(x, y); points.PB({x, y}); if (cols[y] != -1) { merge(i, cols[y]); } if (rows[x] != -1) { merge(i, rows[x]); } cols[y] = i; rows[x] = i; } vector<set<int>> nbc(n); vector<set<int>> nbr(n); REP(i, n) { int p = findp(i); nbr[p].insert(points[i].F); nbc[p].insert(points[i].S); } LL rr = 0; REP(i, n) { int b = nbr[i].size(); int c = nbc[i].size(); rr += (LL)b * c; } printf("%lld\n", rr - n); }
[ "identifier.change" ]
809,166
809,167
u067899663
cpp
p02998
#include <bits/stdc++.h> typedef long long LL; #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), &(Z)) #define DRI(X) \ int(X); \ scanf("%d", &X) #define DRII(X, Y) \ int X, Y; \ scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) \ int X, Y, Z; \ scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair<int, int> #define VI vector<int> #define VL vector<long long> #define VPII vector<pair<int, int>> #define PLL pair<long long, long long> #define VPLL vector<pair<long long, long long>> #define F first #define S second using namespace std; VI ps; int findp(int i) { if (ps[i] != i) ps[i] = findp(ps[i]); return ps[i]; } void merge(int i, int j) { ps[findp(i)] = ps[findp(j)]; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); DRI(n); VI cols(1e5 + 1, -1); VI rows(1e5 + 1, -1); ps = VI(n); REP(i, n) { ps[i] = i; } VPII points; REP(i, n) { DRII(x, y); points.PB({x, y}); if (cols[y] != -1) { merge(i, cols[y]); } if (rows[x] != -1) { merge(i, rows[x]); } cols[y] = i; rows[x] = i; } vector<set<int>> nbc(n); vector<set<int>> nbr(n); REP(i, n) { int p = findp(i); nbr[p].insert(points[i].F); nbc[p].insert(points[i].S); } LL rr = 0; REP(i, n) { int b = nbr[i].size(); int c = nbr[i].size(); rr += (LL)b * c; } printf("%I64d\n", rr - n); }
#include <bits/stdc++.h> typedef long long LL; #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), &(Z)) #define DRI(X) \ int(X); \ scanf("%d", &X) #define DRII(X, Y) \ int X, Y; \ scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) \ int X, Y, Z; \ scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair<int, int> #define VI vector<int> #define VL vector<long long> #define VPII vector<pair<int, int>> #define PLL pair<long long, long long> #define VPLL vector<pair<long long, long long>> #define F first #define S second using namespace std; VI ps; int findp(int i) { if (ps[i] != i) ps[i] = findp(ps[i]); return ps[i]; } void merge(int i, int j) { ps[findp(i)] = ps[findp(j)]; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); DRI(n); VI cols(1e5 + 1, -1); VI rows(1e5 + 1, -1); ps = VI(n); REP(i, n) { ps[i] = i; } VPII points; REP(i, n) { DRII(x, y); points.PB({x, y}); if (cols[y] != -1) { merge(i, cols[y]); } if (rows[x] != -1) { merge(i, rows[x]); } cols[y] = i; rows[x] = i; } vector<set<int>> nbc(n); vector<set<int>> nbr(n); REP(i, n) { int p = findp(i); nbr[p].insert(points[i].F); nbc[p].insert(points[i].S); } LL rr = 0; REP(i, n) { int b = nbr[i].size(); int c = nbc[i].size(); rr += (LL)b * c; } printf("%lld\n", rr - n); }
[ "identifier.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
809,168
809,167
u067899663
cpp
p02998
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef long double ld; typedef vector<ld> vd; typedef bool bl; typedef vector<bl> vb; typedef unordered_map<ll, unordered_map<ll, ll>> graph; const ll e5 = 1 << 20; const ll mod = 1000000007; const ll e3 = 1 << 13; const ll INF = 1ll << 60; ll n; ll x[e5]; ll y[e5]; unordered_map<ll, vl> x_map, y_map; graph g; set<ll> x_set, y_set; ll cnt; ll vis[e5]; ll ans; void dfs(ll p) { vis[p] = 1; cnt++; x_set.insert(x[p]); y_set.insert(y[p]); for (auto y : g[p]) { if (vis[y.first] == 0) dfs(y.first); } } int main() { cin >> n; for (ll i = 0; i < n; i++) cin >> x[i] >> y[i]; for (ll i = 0; i < n; i++) { if (x_map[x[i]].size() > 0) { g[x_map[x[i]][0]][i] = 1; g[i][x_map[x[i]][0]] = 1; } else if (y_map[y[i]].size() > 0) { g[y_map[y[i]][0]][i] = 1; g[i][y_map[y[i]][0]] = 1; } x_map[x[i]].push_back(i); y_map[y[i]].push_back(i); } for (ll i = 0; i < n; i++) { if (vis[i] == 0) { x_set = set<ll>(); y_set = set<ll>(); cnt = 0; dfs(i); ans += x_set.size() * y_set.size() - cnt; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef long double ld; typedef vector<ld> vd; typedef bool bl; typedef vector<bl> vb; typedef unordered_map<ll, unordered_map<ll, ll>> graph; const ll e5 = 1 << 20; const ll mod = 1000000007; const ll e3 = 1 << 13; const ll INF = 1ll << 60; ll n; ll x[e5]; ll y[e5]; unordered_map<ll, vl> x_map, y_map; graph g; set<ll> x_set, y_set; ll cnt; ll vis[e5]; ll ans; void dfs(ll p) { vis[p] = 1; cnt++; x_set.insert(x[p]); y_set.insert(y[p]); for (auto q : g[p]) { if (vis[q.first] == 0) dfs(q.first); } } int main() { cin >> n; for (ll i = 0; i < n; i++) cin >> x[i] >> y[i]; for (ll i = 0; i < n; i++) { if (x_map[x[i]].size() > 0) { g[x_map[x[i]][0]][i] = 1; g[i][x_map[x[i]][0]] = 1; } if (y_map[y[i]].size() > 0) { g[y_map[y[i]][0]][i] = 1; g[i][y_map[y[i]][0]] = 1; } x_map[x[i]].push_back(i); y_map[y[i]].push_back(i); } for (ll i = 0; i < n; i++) { if (vis[i] == 0) { x_set = set<ll>(); y_set = set<ll>(); cnt = 0; dfs(i); ans += x_set.size() * y_set.size() - cnt; } } cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "call.arguments.change", "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove" ]
809,173
809,174
u842401785
cpp
p02998
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, x, n) for (int i = x; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define all(X) (X).begin(), (X).end() #define X first #define Y second #define pb push_back #define eb emplace_back using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; 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 (a > b) { a = b; return 1; } return 0; } template <class A, size_t N, class T> void Fill(A (&a)[N], const T &v) { fill((T *)a, (T *)(a + N), v); } template <class T> ostream &operator<<(ostream &os, const vector<T> &t) { os << "{"; rep(i, t.size()) { os << t[i] << ","; } os << "}"; return os; } template <class T, size_t n> ostream &operator<<(ostream &os, const array<T, n> &t) { os << "{"; rep(i, n) { os << t[i] << ","; } os << "}"; return os; } template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> &t) { return os << "(" << t.first << "," << t.second << ")"; } const ll INF = 1e9 + 7; struct UnionFind { std::vector<int> data; // dataの各要素について // 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。 // 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない //初期化 size:最大要素数 UnionFind(int size) : data(size, -1) {} // 集合を併合する // すでに同じ集合だった場合は、falseが返る bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { // 要素数の大きな方へ合併するためのswap if (data[y] < data[x]) std::swap(x, y); // 要素数を加算する data[x] += data[y]; // yの属する集合のルートをxに変更 data[y] = x; } return x != y; } // 同じ集合かどうか判定 bool find(int x, int y) { return root(x) == root(y); } // 集合の識別番号を返す int root(int x) { // 負の値を持つものがその集合のルート // 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く) return (data[x] < 0) ? x : data[x] = root(data[x]); } // 集合の要素数を返す int size(int x) { return -data[root(x)]; } }; int main() { ios_base::sync_with_stdio(false); ll N, ans = 0; map<int, vector<int>> mp; cin >> N; rep(i, N) { int x, y; cin >> x >> y; mp[x].push_back(y); } UnionFind uf(N); for (auto p : mp) { auto ys = p.Y; for (int y : ys) uf.unite(ys[0], y); } for (auto p : mp) { auto ys = p.Y; ans += uf.size(ys[0]) - ys.size(); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, x, n) for (int i = x; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define all(X) (X).begin(), (X).end() #define X first #define Y second #define pb push_back #define eb emplace_back using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; 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 (a > b) { a = b; return 1; } return 0; } template <class A, size_t N, class T> void Fill(A (&a)[N], const T &v) { fill((T *)a, (T *)(a + N), v); } template <class T> ostream &operator<<(ostream &os, const vector<T> &t) { os << "{"; rep(i, t.size()) { os << t[i] << ","; } os << "}"; return os; } template <class T, size_t n> ostream &operator<<(ostream &os, const array<T, n> &t) { os << "{"; rep(i, n) { os << t[i] << ","; } os << "}"; return os; } template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> &t) { return os << "(" << t.first << "," << t.second << ")"; } const ll INF = 1e9 + 7; struct UnionFind { std::vector<int> data; // dataの各要素について // 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。 // 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない //初期化 size:最大要素数 UnionFind(int size) : data(size, -1) {} // 集合を併合する // すでに同じ集合だった場合は、falseが返る bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { // 要素数の大きな方へ合併するためのswap if (data[y] < data[x]) std::swap(x, y); // 要素数を加算する data[x] += data[y]; // yの属する集合のルートをxに変更 data[y] = x; } return x != y; } // 同じ集合かどうか判定 bool find(int x, int y) { return root(x) == root(y); } // 集合の識別番号を返す int root(int x) { // 負の値を持つものがその集合のルート // 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く) return (data[x] < 0) ? x : data[x] = root(data[x]); } // 集合の要素数を返す int size(int x) { return -data[root(x)]; } }; int main() { ios_base::sync_with_stdio(false); ll N, ans = 0; map<int, vector<int>> mp; cin >> N; rep(i, N) { int x, y; cin >> x >> y; mp[x].push_back(y); } UnionFind uf(200005); for (auto p : mp) { auto ys = p.Y; for (int y : ys) uf.unite(ys[0], y); } for (auto p : mp) { auto ys = p.Y; ans += uf.size(ys[0]) - ys.size(); } cout << ans << endl; return 0; }
[]
809,181
809,182
u703805376
cpp
p02998
// Author: πα #include <bits/stdc++.h> using namespace std; #define long int64_t const int N = 1e5 + 5; vector<int> g[N]; bool vis[N]; int cl, cr, ce; void dfs(int u) { if (vis[u]) return; vis[u] = 1; if (u < N) cl++, ce += g[u].size(); else cr++; for (auto v : g[u]) dfs(v); } int main() { int n, u, v, i; long ans = 0; cin >> n; for (i = 0; i < n; ++i) { cin >> u >> v; v += N; g[u].push_back(v); g[v].push_back(u); } for (i = 1; i < N; ++i) if (not vis[i]) { cl = cr = ce = 0; dfs(i); ans += 1LL * cl * cr - ce; } cout << ans; return 0; }
// Author: πα #include <bits/stdc++.h> using namespace std; #define long int64_t const int N = 1e5 + 5; vector<int> g[N + N]; bool vis[N + N]; int cl, cr, ce; void dfs(int u) { if (vis[u]) return; vis[u] = 1; if (u < N) cl++, ce += g[u].size(); else cr++; for (auto v : g[u]) dfs(v); } int main() { int n, u, v, i; long ans = 0; cin >> n; for (i = 0; i < n; ++i) { cin >> u >> v; v += N; g[u].push_back(v); g[v].push_back(u); } for (i = 1; i < N; ++i) if (not vis[i]) { cl = cr = ce = 0; dfs(i); ans += 1LL * cl * cr - ce; } cout << ans; return 0; }
[ "variable_declaration.array_dimensions.change", "expression.operation.binary.add" ]
809,183
809,184
u518468154
cpp
p02998
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template <class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; class UnionFind { int n; vector<int> uni; public: explicit UnionFind(int n) : uni(static_cast<u32>(n), -1), n(n){}; int root(int a) { if (uni[a] < 0) return a; else return (uni[a] = root(uni[a])); } bool unite(int a, int b) { a = root(a); b = root(b); if (a == b) return false; if (uni[a] > uni[b]) swap(a, b); uni[a] += uni[b]; uni[b] = a; return true; } int size(int i) { return -uni[root(i)]; } bool same(int a, int b) { return root(a) == root(b); } }; int main() { int n; cin >> n; UnionFind uf(100001); vector<vector<int>> v(100001), u(100001); for (int i = 0; i < n; ++i) { int x, y; scanf("%d %d", &x, &y); v[x].emplace_back(y); u[y].emplace_back(x); } vector<int> dp(100001); for (int i = 0; i <= 100000; ++i) { for (int j = 0; j + 1 < u[i].size(); ++j) { uf.unite(u[i][j], u[i][j + 1]); } } for (int i = 0; i <= 100000; ++i) { int j = uf.root(i); if (i != j) { for (auto &&k : v[i]) { v[j].emplace_back(i); } } } ll ans = -n; for (int i = 0; i <= 100000; ++i) { if (i == uf.root(i)) { sort(v[i].begin(), v[i].end()); v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end()); ans += (ll)v[i].size() * uf.size(i); } } cout << ans << "\n"; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template <class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; class UnionFind { int n; vector<int> uni; public: explicit UnionFind(int n) : uni(static_cast<u32>(n), -1), n(n){}; int root(int a) { if (uni[a] < 0) return a; else return (uni[a] = root(uni[a])); } bool unite(int a, int b) { a = root(a); b = root(b); if (a == b) return false; if (uni[a] > uni[b]) swap(a, b); uni[a] += uni[b]; uni[b] = a; return true; } int size(int i) { return -uni[root(i)]; } bool same(int a, int b) { return root(a) == root(b); } }; int main() { int n; cin >> n; UnionFind uf(100001); vector<vector<int>> v(100001), u(100001); for (int i = 0; i < n; ++i) { int x, y; scanf("%d %d", &x, &y); v[x].emplace_back(y); u[y].emplace_back(x); } vector<int> dp(100001); for (int i = 1; i <= 100000; ++i) { for (int j = 0; j + 1 < u[i].size(); ++j) { uf.unite(u[i][j], u[i][j + 1]); } } for (int i = 1; i <= 100000; ++i) { int j = uf.root(i); if (i != j) { for (auto &&k : v[i]) { v[j].emplace_back(k); } } } ll ans = -n; for (int i = 1; i <= 100000; ++i) { if (i == uf.root(i)) { sort(v[i].begin(), v[i].end()); v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end()); ans += (ll)v[i].size() * uf.size(i); } } cout << ans << "\n"; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "identifier.change", "call.arguments.change" ]
809,193
809,194
u915020369
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int A, X; cin >> A >> X; if (X < A) { cout << "0"; } else if (X >= A) { cout << "10"; } }
#include <bits/stdc++.h> using namespace std; int main() { int A, X; cin >> X >> A; if (X < A) { cout << "0"; } else if (X >= A) { cout << "10"; } }
[ "expression.operation.binary.remove" ]
809,205
809,206
u946356400
cpp
p02999
#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 x, a; cin >> x >> a; if (x < a) cout << 0 << endl; else cout << 1 << endl; } // cout << fixed << setprecision(15) << << endl;
#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 x, a; cin >> x >> a; if (x < a) cout << 0 << endl; else cout << 10 << endl; } // cout << fixed << setprecision(15) << << endl;
[ "literal.number.change", "io.output.change" ]
809,211
809,212
u052656528
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; if (n << a) { cout << "0" << endl; } else { cout << "10" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; if (n < a) { cout << 0 << endl; } else { cout << 10 << endl; } }
[ "misc.typo", "control_flow.branch.if.condition.change" ]
809,213
809,214
u089230684
cpp
p02999
#include <stdio.h> int main() { int a, b; scanf("%d%d", &a, &b); if (a > b) printf("0"); else printf("10"); }
#include <stdio.h> int main() { int a, b; scanf("%d%d", &a, &b); if (a < b) printf("0"); else printf("10"); return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.return.add", "control_flow.return.0.add" ]
809,215
809,216
u018679195
cpp
p02999
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int A, X; cin >> A >> X; if (X < A) cout << 0; else cout << 10; cout << endl; }
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int A, X; cin >> X >> A; if (X < A) cout << 0; else cout << 10; cout << endl; }
[ "expression.operation.binary.remove" ]
809,217
809,218
u018679195
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a > b) { cout << "10"; } else { cout << "0"; } }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a >= b) { cout << "10"; } else { cout << "0"; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
809,219
809,220
u018679195
cpp
p02999
//#include<bits/stdc++.h> #include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> /* #include <boost/multiprecision/cpp_dec_float.hpp> #include<boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> namespace mp = boost::multiprecision; using Real = mp::number<mp::cpp_dec_float<1024>>; using Bint = mp::cpp_int; */ using namespace std; #define REP(i, s, e) for ((i) = (s); (i) < (e); (i)++) #define RREP(i, s, e) for ((i) = ((s)-1); (i) >= (e); (i)--) #define FOR(i, n) for ((i) = (0); (i) < (n); (i)++) #define RFOR(i, n) for ((i) = ((n)-1); (i) >= (0); (i)--) #define MOD 1000000007 signed main() { int X, A; cin >> X >> A; cout << (X >= A ? 10 : X) << endl; }
//#include<bits/stdc++.h> #include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> /* #include <boost/multiprecision/cpp_dec_float.hpp> #include<boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> namespace mp = boost::multiprecision; using Real = mp::number<mp::cpp_dec_float<1024>>; using Bint = mp::cpp_int; */ using namespace std; #define REP(i, s, e) for ((i) = (s); (i) < (e); (i)++) #define RREP(i, s, e) for ((i) = ((s)-1); (i) >= (e); (i)--) #define FOR(i, n) for ((i) = (0); (i) < (n); (i)++) #define RFOR(i, n) for ((i) = ((n)-1); (i) >= (0); (i)--) #define MOD 1000000007 signed main() { int X, A; cin >> X >> A; cout << (X >= A ? 10 : 0) << endl; }
[ "identifier.replace.remove", "literal.replace.add", "io.output.change" ]
809,233
809,234
u853817705
cpp
p02999
#include <algorithm> #include <bitset> #include <cstring> #include <ctype.h> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <deque> #define pi 3.141592653589793238 #include <chrono> #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f0 get<0> #define f1 get<1> #define f2 get<2> using namespace std; ll n; ll ncr(ll n, ll r) { ll i, ans = 1, k = 0; if (r == 0) return 1; else if (n < r) return 0; for (i = n; i >= n - r + 1; i--) { ans *= i; ans /= n - i + 1; } return ans; } void max_heapify(int a[100], int i) { int l, r, largest = i; l = 2 * i + 1; r = 2 * i + 2; if (l < n && a[l] > a[i]) largest = l; if (r < n && a[r] > a[l]) largest = r; if (largest != i) { int k; k = a[i]; a[i] = a[largest]; a[largest] = k; max_heapify(a, largest); } } int power(ll x, ll y, ll p) { int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bool square(ll n) { double x; x = sqrt(n); if (x == floor(x)) return true; else return false; } bool prime(ll n) { ll i; for (i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } ll modi(ll a, ll m) { return power(a, m - 2, m); } void kmp(string s, ll p[]) { int n = (int)s.length(); p[0] = 0; for (int i = 1; i < n; i++) { int j = p[i - 1]; while (j > 0 && s[i] != s[j]) j = p[j - 1]; if (s[i] == s[j]) j++; p[i] = j; } } void zfunc(string s, ll z[]) { ll n = (ll)s.length(); z[0] = 0; for (ll i = 1, l = 0, r = 0; i < n; ++i) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i]; if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1; } } struct pair_hash { size_t operator()(const pair<int, int> &p) const noexcept { return hash<ll>()((((ll)p.first) << 32) | ((ll)p.second)); } }; bool palin(string s) { ll i, n; n = s.length(); for (i = 0; i <= n / 2; i++) { if (s[i] != s[n - i - 1]) { return false; } } return true; } ll sum(ll n) { ll i; i = n; ll sum = 0; while (i > 0) { sum += i % 10; i = i / 10; } return sum; } ll nCr(ll n, ll r, ll p, ll fac[]) { if (r == 0) return 1; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; return (fac[n] * modi(fac[r], p) % p * modi(fac[n - r], p) % p) % p; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll mod(string num, ll a) { ll res = 0; for (ll i = 0; i < num.length(); i++) res = (res * 10 + (ll)num[i] - '0') % a; return res; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ll parent[1000], sizer[1000]; ll findset(ll a) { if (a == parent[a]) { return a; } parent[a] = findset(parent[a]); return parent[a]; } void unionset(ll a, ll b) { a = findset(a); b = findset(b); if (sizer[a] < sizer[b]) { swap(a, b); } sizer[b] += sizer[a]; parent[b] = a; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct fenwick { vector<ll> bit; ll n; fenwick(ll n, vector<ll> v) { this->n = n; bit.assign(n, 0); for (ll it = 0; it < n; it++) { add(it, v[it]); } } ll sum(ll idx) { if (idx < 0) return 0; ll ret = 0; for (; idx >= 0; idx = (idx & (idx + 1)) - 1) { ret += bit[idx]; } return ret; } void add(ll idx, ll x) { for (; idx < n; idx = idx | (idx + 1)) { bit[idx] += x; bit[idx] = max(0LL, bit[idx]); } } }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; // cin >> T; while (T--) { ll x, a; cin >> x >> a; if (x < a) { cout << 0; } else { cout << 1; } } return 0; }
#include <algorithm> #include <bitset> #include <cstring> #include <ctype.h> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <deque> #define pi 3.141592653589793238 #include <chrono> #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f0 get<0> #define f1 get<1> #define f2 get<2> using namespace std; ll n; ll ncr(ll n, ll r) { ll i, ans = 1, k = 0; if (r == 0) return 1; else if (n < r) return 0; for (i = n; i >= n - r + 1; i--) { ans *= i; ans /= n - i + 1; } return ans; } void max_heapify(int a[100], int i) { int l, r, largest = i; l = 2 * i + 1; r = 2 * i + 2; if (l < n && a[l] > a[i]) largest = l; if (r < n && a[r] > a[l]) largest = r; if (largest != i) { int k; k = a[i]; a[i] = a[largest]; a[largest] = k; max_heapify(a, largest); } } int power(ll x, ll y, ll p) { int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bool square(ll n) { double x; x = sqrt(n); if (x == floor(x)) return true; else return false; } bool prime(ll n) { ll i; for (i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } ll modi(ll a, ll m) { return power(a, m - 2, m); } void kmp(string s, ll p[]) { int n = (int)s.length(); p[0] = 0; for (int i = 1; i < n; i++) { int j = p[i - 1]; while (j > 0 && s[i] != s[j]) j = p[j - 1]; if (s[i] == s[j]) j++; p[i] = j; } } void zfunc(string s, ll z[]) { ll n = (ll)s.length(); z[0] = 0; for (ll i = 1, l = 0, r = 0; i < n; ++i) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i]; if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1; } } struct pair_hash { size_t operator()(const pair<int, int> &p) const noexcept { return hash<ll>()((((ll)p.first) << 32) | ((ll)p.second)); } }; bool palin(string s) { ll i, n; n = s.length(); for (i = 0; i <= n / 2; i++) { if (s[i] != s[n - i - 1]) { return false; } } return true; } ll sum(ll n) { ll i; i = n; ll sum = 0; while (i > 0) { sum += i % 10; i = i / 10; } return sum; } ll nCr(ll n, ll r, ll p, ll fac[]) { if (r == 0) return 1; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; return (fac[n] * modi(fac[r], p) % p * modi(fac[n - r], p) % p) % p; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll mod(string num, ll a) { ll res = 0; for (ll i = 0; i < num.length(); i++) res = (res * 10 + (ll)num[i] - '0') % a; return res; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ll parent[1000], sizer[1000]; ll findset(ll a) { if (a == parent[a]) { return a; } parent[a] = findset(parent[a]); return parent[a]; } void unionset(ll a, ll b) { a = findset(a); b = findset(b); if (sizer[a] < sizer[b]) { swap(a, b); } sizer[b] += sizer[a]; parent[b] = a; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct fenwick { vector<ll> bit; ll n; fenwick(ll n, vector<ll> v) { this->n = n; bit.assign(n, 0); for (ll it = 0; it < n; it++) { add(it, v[it]); } } ll sum(ll idx) { if (idx < 0) return 0; ll ret = 0; for (; idx >= 0; idx = (idx & (idx + 1)) - 1) { ret += bit[idx]; } return ret; } void add(ll idx, ll x) { for (; idx < n; idx = idx | (idx + 1)) { bit[idx] += x; bit[idx] = max(0LL, bit[idx]); } } }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; // cin >> T; while (T--) { ll x, a; cin >> x >> a; if (x < a) { cout << 0; } else { cout << 10; } } return 0; }
[ "literal.number.change", "io.output.change" ]
809,237
809,238
u734397606
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main(void) { int X, A; cin >> X >> A; if (X < A) cout << "0\n"; else "10\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int X, A; cin >> X >> A; if (X < A) cout << "0\n"; else cout << "10\n"; return 0; }
[ "io.output.change" ]
809,245
809,246
u346040900
cpp
p02999
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << '0' << endl; } else { cout << '10' << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x >> a; if (x < a) { cout << '0' << endl; } else { cout << "10" << endl; } }
[ "literal.string.change", "io.output.change" ]
809,251
809,252
u965418380
cpp